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
{{ message }}
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
Given the following code (where the trait Bar is not in scope):
#[derive(Clone,Debug)]// this is line 1 in this filepubstructService;pubstructResponse<T>whereT:Bar{pubitem:T}
Executing the "Add use foo::bar" quick fix will add the appropriate import but in the wrong location.
It will always pick to insert the line just above the Service struct declaration.
This is the case if the attribute line is commented out (understandable) and even if there are multiple empty lines between the struct decl and the attributes.
This isn't desired because I am now suddenly applying attributes to a use which is invalid.
I haven't been able to reduce this in a way that only reports a single fix (like what I described above).
The text was updated successfully, but these errors were encountered:
This is actually a rustc issue as that's the source of the suggestion. You can even see it in cargo check output.
error[E0405]: cannot find trait `Bar` in this scope
--> src/main.rs:4:33
|
4 | pub struct Response<T> where T: Bar { pub item: T }
| ^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
2 | use crate::foo::Bar;
The 2 | bit means rustc reckons this should be inserted on line 2.
I'd guess rustc has some pretty simple logic for import suggestion locations.
On top of the first use line.
If no use, at the top of the file, but under # lines.
The latter was probably to place imports under things like #![windows_subsystem = "windows"] where if placed above would cause compile error.
Given the following code (where the trait
Bar
is not in scope):Executing the "Add
use foo::bar
" quick fix will add the appropriate import but in the wrong location.It will always pick to insert the line just above the
Service
struct declaration.This is the case if the attribute line is commented out (understandable) and even if there are multiple empty lines between the struct decl and the attributes.
This isn't desired because I am now suddenly applying attributes to a
use
which is invalid.I haven't been able to reduce this in a way that only reports a single fix (like what I described above).
The text was updated successfully, but these errors were encountered: