-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemC-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
trait Foo { fn foo() {} }
trait Bar {}
impl<T: Bar> Foo for T {}
fn main() {
<i32 as Foo>::foo();
}
Reported error tries to be too smart:
error[E0277]: the trait bound `i32: Bar` is not satisfied
|
| <i32 as Foo>::foo();
| ^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `i32`
|
= note: required because of the requirements on the impl of `Foo` for `i32`
= note: required by `Foo::foo`
... but is misleading since the real error is that i32: Foo
is not satisfied; i32
may happen to implement Foo
and not implement Bar
, so the error message is actually just wrong.
jplatte
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemC-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.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
aldanor commentedon Feb 26, 2017
Hypothetical alternative error message:
estebank commentedon Jan 25, 2020
Current output:
It should be closer to
jplatte commentedon Jul 7, 2020
This should be tagged
A-traits
, no?estebank commentedon Jan 5, 2023
Current output:
estebank commentedon Oct 3, 2023
Current output:
estebank commentedon Oct 19, 2023
I believe the current output is good enough to explain what's going on, pointing at the blanket impl that matches but that introduces an unmet requirement.
jplatte commentedon Nov 21, 2023
I don't like that the current output still mentions
Bar
first, as if the user had written<i32 as Bar>
. IMHO the output should be something along the lines ofestebank commentedon Nov 21, 2023
Sure, we could potentially try to do that.
Provide more context on derived obligation error primary label
Provide more context on derived obligation error primary label
Rollup merge of rust-lang#120469 - estebank:issue-40120, r=TaKO8Ki
Rollup merge of rust-lang#120469 - estebank:issue-40120, r=TaKO8Ki
Unrolled build for rust-lang#120469