Uh oh!
There was an error while loading. Please reload this page.
Suggest similarly named associated items in trait impls - #89248
Conversation
rust-highfive
commented
Sep 25, 2021
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
hkmatsumoto
commented
Sep 25, 2021
r? @estebank |
0512297 to
32f4d42Compare
This comment has been minimized.
This comment has been minimized.
32f4d42 to
dc9a931CompareThere was a problem hiding this comment.
I have no idea what it is ¯_(ツ)_/¯
We should skip this diagnostic in macros maybe.
There was a problem hiding this comment.
We should probably special case macros, but it's not needed right now :-/
estebank
left a comment
There was a problem hiding this comment.
I'm seeing the new output and it is an improvement, but I think we can get even better output if instead of the Option<Symbol> we kept an Option<DefId>, so that we could show a span_note with the span for the definition of the assoc item in a trait, instead of a span_label or span_suggestion. Part of why I'm saying that is because 1) the current span_suggestion, when applied will completely remove the underlined assoc item with the suggested identifier (not what we want) and 2) we are not making checks to see that the similar named assoc item matches (what if the method has a different number of arguments, for example?).
What do you think?
There was a problem hiding this comment.
We should probably special case macros, but it's not needed right now :-/
Uh oh!
There was an error while loading. Please reload this page.
dc9a931 to
a6eafcbComparePreviously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types and constants.
a6eafcb to
cef736fCompare| error[E0046]: not all trait items implemented, missing: `Type`, `foo`, `bar`, `qux` | ||
| --> $DIR/suggest-trait-items.rs:11:1 | ||
| | | ||
| LL | type Type; | ||
| | ---------- `Type` from trait | ||
| LL | | ||
| LL | fn foo(); | ||
| | --------- `foo` from trait | ||
| LL | fn bar(); | ||
| | --------- `bar` from trait | ||
| LL | fn qux(); | ||
| | --------- `qux` from trait | ||
| ... | ||
| LL | impl Foo for A { | ||
| | ^^^^^^^^^^^^^^ missing `Type`, `foo`, `bar`, `qux` in implementation |
There was a problem hiding this comment.
It'd be nice if we didn't error for missing elements that were suggested, but that's a nice to have, not a must have.
estebank
commented
Sep 28, 2021
@bors r+ |
bors
commented
Sep 28, 2021
📌 Commit cef736f has been approved by |
…-assoc-items, r=estebank Suggest similarly named associated items in trait impls Fixrust-lang#85942 Previously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types, and constants.
…-assoc-items, r=estebank Suggest similarly named associated items in trait impls Fixrust-lang#85942 Previously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types, and constants.
…arth Rollup of 8 pull requests Successful merges: - rust-lang#88782 (Fix ICE when `start` lang item has wrong generics) - rust-lang#89202 (Resolve infered types when complaining about unexpected call type ) - rust-lang#89248 (Suggest similarly named associated items in trait impls) - rust-lang#89303 (Add `#[must_not_suspend]` to some types in std) - rust-lang#89306 (thread: implements available_concurrency on haiku) - rust-lang#89314 (fix(lint): don't suggest refutable patterns to "fix" irrefutable bind) - rust-lang#89370 (CTFE: tweak aggregate rvalue handling) - rust-lang#89392 (bootstrap: Update comment in config.library.toml.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fix#85942
Previously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types, and constants.