mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-13 17:35:21 +00:00
fix: unescape all occurrences of module name in module resolution
This commit is contained in:
parent
f02cd0a41d
commit
662ab0cd8e
2 changed files with 17 additions and 2 deletions
|
|
@ -65,6 +65,7 @@ impl ModDir {
|
||||||
name: &Name,
|
name: &Name,
|
||||||
attr_path: Option<&SmolStr>,
|
attr_path: Option<&SmolStr>,
|
||||||
) -> Result<(FileId, bool, ModDir), Box<[String]>> {
|
) -> Result<(FileId, bool, ModDir), Box<[String]>> {
|
||||||
|
let name = name.unescaped();
|
||||||
let orig_file_id = file_id.original_file(db.upcast());
|
let orig_file_id = file_id.original_file(db.upcast());
|
||||||
|
|
||||||
let mut candidate_files = ArrayVec::<_, 2>::new();
|
let mut candidate_files = ArrayVec::<_, 2>::new();
|
||||||
|
|
@ -73,12 +74,10 @@ impl ModDir {
|
||||||
candidate_files.push(self.dir_path.join_attr(attr_path, self.root_non_dir_owner))
|
candidate_files.push(self.dir_path.join_attr(attr_path, self.root_non_dir_owner))
|
||||||
}
|
}
|
||||||
None if file_id.is_include_macro(db.upcast()) => {
|
None if file_id.is_include_macro(db.upcast()) => {
|
||||||
let name = name.unescaped();
|
|
||||||
candidate_files.push(format!("{}.rs", name));
|
candidate_files.push(format!("{}.rs", name));
|
||||||
candidate_files.push(format!("{}/mod.rs", name));
|
candidate_files.push(format!("{}/mod.rs", name));
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let name = name.unescaped();
|
|
||||||
candidate_files.push(format!("{}{}.rs", self.dir_path.0, name));
|
candidate_files.push(format!("{}{}.rs", self.dir_path.0, name));
|
||||||
candidate_files.push(format!("{}{}/mod.rs", self.dir_path.0, name));
|
candidate_files.push(format!("{}{}/mod.rs", self.dir_path.0, name));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,15 @@ mod r#async;
|
||||||
use self::r#async::Bar;
|
use self::r#async::Bar;
|
||||||
|
|
||||||
//- /async.rs
|
//- /async.rs
|
||||||
|
mod foo;
|
||||||
|
mod r#async;
|
||||||
pub struct Bar;
|
pub struct Bar;
|
||||||
|
|
||||||
|
//- /async/foo.rs
|
||||||
|
pub struct Foo;
|
||||||
|
|
||||||
|
//- /async/async.rs
|
||||||
|
pub struct Baz;
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
crate
|
crate
|
||||||
|
|
@ -136,6 +144,14 @@ pub struct Bar;
|
||||||
|
|
||||||
crate::r#async
|
crate::r#async
|
||||||
Bar: t v
|
Bar: t v
|
||||||
|
foo: t
|
||||||
|
r#async: t
|
||||||
|
|
||||||
|
crate::r#async::foo
|
||||||
|
Foo: t v
|
||||||
|
|
||||||
|
crate::r#async::r#async
|
||||||
|
Baz: t v
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue