Skip to content

Commit e125bee

Browse files
committed
Auto merge of #13890 - lowr:fix/unescape-inline-mod-name, r=Veykril
fix: unescape inline module names in module resolution Fixes #13884
2 parents ba204ef + 21ea004 commit e125bee

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl ModDir {
3434
let path = match attr_path.map(SmolStr::as_str) {
3535
None => {
3636
let mut path = self.dir_path.clone();
37-
path.push(&name.to_smol_str());
37+
path.push(&name.unescaped().to_smol_str());
3838
path
3939
}
4040
Some(attr_path) => {

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,43 @@ pub struct Baz;
156156
);
157157
}
158158

159+
#[test]
160+
fn module_resolution_works_for_inline_raw_modules() {
161+
check(
162+
r#"
163+
//- /lib.rs
164+
mod r#async {
165+
pub mod a;
166+
pub mod r#async;
167+
}
168+
use self::r#async::a::Foo;
169+
use self::r#async::r#async::Bar;
170+
171+
//- /async/a.rs
172+
pub struct Foo;
173+
174+
//- /async/async.rs
175+
pub struct Bar;
176+
"#,
177+
expect![[r#"
178+
crate
179+
Bar: t v
180+
Foo: t v
181+
r#async: t
182+
183+
crate::r#async
184+
a: t
185+
r#async: t
186+
187+
crate::r#async::a
188+
Foo: t v
189+
190+
crate::r#async::r#async
191+
Bar: t v
192+
"#]],
193+
);
194+
}
195+
159196
#[test]
160197
fn module_resolution_decl_path() {
161198
check(

0 commit comments

Comments
 (0)