-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The following code came up on IRC. It cannot ever work, but the error message is completely wrong (playground):
pub trait Foo { fn foo() -> usize; }
struct Bar();
impl Foo for Bar { fn foo() -> usize { 3 } }
fn baz<F: Foo>() {
let _x = [0_u32; <F as Foo>::foo()];
}
fn main() {
baz::<Bar>();
}
outputs:
error[E0277]: the trait bound `F: Foo` is not satisfied
--> src/main.rs:7:22
|
7 | let _x = [0_u32; <F as Foo>::foo()];
| ^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `F`
|
= help: consider adding a `where F: Foo` bound
= note: required by `Foo::foo`
This error messages is 100% wrong: F
does implement the trait Foo
since the function signature does require it.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.