-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve "associated type not found" diagnostics #115662
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
| ^^^^ associated type `Item` not found | ||
| ^^^^ | ||
| | ||
= help: `M` has no associated type, try removing `Item` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This suggestion doesn't make sense imo.
return err.emit(); | ||
} | ||
|
||
let msg = if all_candidate_names.len() > 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should suggest anything if there's >1 candidate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trait Qux {
type A;
type B;
}
fn quux<T>() where T: Qux<A = u32, ZZ = u32> {}
gives
error[E0220]: associated type `ZZ` not found for `Qux`
--> E0220.rs:14:36
|
14 | fn quux<T>() where T: Qux<A = u32, ZZ = u32> {}
| ^^
|
help: `Qux` has the following associated types
|
14 | fn quux<T>() where T: Qux<A = u32, A = u32> {}
| ~
14 | fn quux<T>() where T: Qux<A = u32, B = u32> {}
| ~
I think this is still helpful?
This comment has been minimized.
This comment has been minimized.
@bors r+ |
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#113807 (Tests crash from inappropriate use of common linkage) - rust-lang#115358 (debuginfo: add compiler option to allow compressed debuginfo sections) - rust-lang#115630 (Dont suggest use between `use` and cfg attr) - rust-lang#115662 (Improve "associated type not found" diagnostics) - rust-lang#115673 (Fix sanitize/cfg.rs test) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#115662 - ShE3py:E0220-note, r=compiler-errors Improve "associated type not found" diagnostics ```rs use core::ops::Deref; fn foo<T>() where T: Deref<Output = u32> {} ``` Before: ``` error[E0220]: associated type `Output` not found for `Deref` --> E0220.rs:5:28 | 5 | fn foo<T>() where T: Deref<Output = u32> {} | ^^^^^^ associated type `Output` not found ``` After: ``` error[E0220]: associated type `Output` not found for `Deref` --> E0220.rs:5:28 | 5 | fn foo<T>() where T: Deref<Output = u32> {} | ^^^^^^ help: `Deref` has the following associated type: `Target` ``` --- `@rustbot` label +A-diagnostics +D-papercut
Before:
After:
@rustbot label +A-diagnostics +D-papercut