Open homchom opened 2 months ago
If the PathSegmentKind
of first segment is Name
(which it is for the imports in example), it either tag the import group as Std
or ExternalCrate
.
Seems like we may need to have list of local modules as arguments for this function and tag local modules ThisCrate
or ThisModule
.
I do not believe this is a regression, but it is exacerbated by #17277.
rust-analyzer version: 0.3.1975-standalone (71a816a90 2024-05-26)
rustc version: 1.78.0 (9b00956e5 2024-04-29)
editor or extension: VSCode
relevant settings:
rust-analyzer.imports.prefix
to reproduce:
serde
(including featurederive
) as a dependency; any external crate would work, but I chose serde for this report.src
directoryand the following files.
mod foo;
[derive(Serialize)]
struct Example;
impl Example { fn a() { } }
It is important that the module is named
foo
, so it is alphabetically beforeserde
.rust-analyzer.imports.prefix
toself
.Example::a()
, typeb
and use auto-import. Observe thatself::foo::b
is correctly imported in a group belowserde::Serialize
. Remove the function call and import, so it once again resembles Step 2.rust-analyzer.imports.prefix
toplain
(the default).Example::a()
, typeb
and use auto-import. Observe thatfoo::c
is incorrectly imported. It should be belowserde::Serialize
, as it is a current module import, but it is instead aboveserde::Serialize
in the same group, as if it was an external crate.