You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, rust-analyzer emits this diagnostic, with no code action available, and gives "no definition found for bar" when doing "Go to definition":
// rust-analyzer diagnostic
no method named `bar` found for struct `Foo<T>` in the current scope
the method was found for
- `Foo`rustc[Click for full compiler diagnostic](rust-analyzer-diagnostics-view:/diagnostic%20message%20%5B0%5D?0#file%3A%2F%2F%2Ftmp%2Fra-example-1%2Fsrc%2Flib.rs)
lib.rs(1,1): method `bar` not found for this struct
// rustc diagnostic
error[E0599]: no method named `bar` found for struct `Foo<T>` in the current scope
--> src/lib.rs:8:7
|
1 | struct Foo<T = u32>(T);
| ------------------- method `bar` not found for this struct
...
8 | x.bar();
| ^^^ method not found in `Foo<T>`
|
= note: the method was found for
- `Foo`
I think it would be useful if there was a way to "go to definition" of the method for the "the method was found for" type(s) (Foo::<u32>::bar above).
My experience with this diagnostic is that I am adding a generic to a widely-used type, and need to go around and fix the impls that did not previously have this generic but should now have it. Currently this mostly goes like:
add the generic to an impl
see what new errors that causes in that impl because code in it is calling methods that are in a not-yet-generic impl
Ideally, I could "go-to-defintion" on the red-underlined methods and add the generic to those methods' impls1, but currently I am just ctrl-Fing for fn method_name to find them that way.
Footnotes
or decide not to, and go back and refactor where it was called ↩
The text was updated successfully, but these errors were encountered:
The error comes from rustc, so we can't (at least easily) know that it is implemented for Foo<u32>. Of course it'll be good if rust-analyzer errors could also come with such detailed info, but we're further from that.
Consider the following code:
Currently, rust-analyzer emits this diagnostic, with no code action available, and gives "no definition found for
bar
" when doing "Go to definition":I think it would be useful if there was a way to "go to definition" of the method for the "the method was found for" type(s) (
Foo::<u32>::bar
above).My experience with this diagnostic is that I am adding a generic to a widely-used type, and need to go around and fix the
impl
s that did not previously have this generic but should now have it. Currently this mostly goes like:impl
impl
because code in it is calling methods that are in a not-yet-genericimpl
impl
s1, but currently I am justctrl-F
ing forfn method_name
to find them that way.Footnotes
or decide not to, and go back and refactor where it was called ↩
The text was updated successfully, but these errors were encountered: