Skip to content

Commit b613896

Browse files
committed
Auto merge of #13149 - lowr:fix/unescape-raw-ident-module-path, r=Veykril
fix: unescape all occurrences of module name in module resolution Fixes #13141
2 parents ef27641 + 662ab0c commit b613896

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

crates/hir-def/src/nameres/mod_resolution.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ impl ModDir {
6565
name: &Name,
6666
attr_path: Option<&SmolStr>,
6767
) -> Result<(FileId, bool, ModDir), Box<[String]>> {
68+
let name = name.unescaped();
6869
let orig_file_id = file_id.original_file(db.upcast());
6970

7071
let mut candidate_files = ArrayVec::<_, 2>::new();
@@ -73,12 +74,10 @@ impl ModDir {
7374
candidate_files.push(self.dir_path.join_attr(attr_path, self.root_non_dir_owner))
7475
}
7576
None if file_id.is_include_macro(db.upcast()) => {
76-
let name = name.unescaped();
7777
candidate_files.push(format!("{}.rs", name));
7878
candidate_files.push(format!("{}/mod.rs", name));
7979
}
8080
None => {
81-
let name = name.unescaped();
8281
candidate_files.push(format!("{}{}.rs", self.dir_path.0, name));
8382
candidate_files.push(format!("{}{}/mod.rs", self.dir_path.0, name));
8483
}

crates/hir-def/src/nameres/tests/mod_resolution.rs

+16
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,15 @@ mod r#async;
127127
use self::r#async::Bar;
128128
129129
//- /async.rs
130+
mod foo;
131+
mod r#async;
130132
pub struct Bar;
133+
134+
//- /async/foo.rs
135+
pub struct Foo;
136+
137+
//- /async/async.rs
138+
pub struct Baz;
131139
"#,
132140
expect![[r#"
133141
crate
@@ -136,6 +144,14 @@ pub struct Bar;
136144
137145
crate::r#async
138146
Bar: t v
147+
foo: t
148+
r#async: t
149+
150+
crate::r#async::foo
151+
Foo: t v
152+
153+
crate::r#async::r#async
154+
Baz: t v
139155
"#]],
140156
);
141157
}

0 commit comments

Comments
 (0)