File tree Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -98,13 +98,15 @@ pub(crate) trait AsName {
98
98
99
99
impl AsName for ast:: NameRef {
100
100
fn as_name ( & self ) -> Name {
101
- Name :: new ( self . text ( ) . clone ( ) )
101
+ let name = resolve_name ( self . text ( ) ) ;
102
+ Name :: new ( name)
102
103
}
103
104
}
104
105
105
106
impl AsName for ast:: Name {
106
107
fn as_name ( & self ) -> Name {
107
- Name :: new ( self . text ( ) . clone ( ) )
108
+ let name = resolve_name ( self . text ( ) ) ;
109
+ Name :: new ( name)
108
110
}
109
111
}
110
112
@@ -184,3 +186,12 @@ impl AsName for KnownName {
184
186
Name :: new ( s. into ( ) )
185
187
}
186
188
}
189
+
190
+ fn resolve_name ( text : & SmolStr ) -> SmolStr {
191
+ let raw_start = "r#" ;
192
+ if text. as_str ( ) . starts_with ( raw_start) {
193
+ SmolStr :: new ( & text[ raw_start. len ( ) ..] )
194
+ } else {
195
+ text. clone ( )
196
+ }
197
+ }
Original file line number Diff line number Diff line change @@ -338,6 +338,32 @@ fn module_resolution_works_for_non_standard_filenames() {
338
338
"### ) ;
339
339
}
340
340
341
+ #[ test]
342
+ fn module_resolution_works_for_raw_modules ( ) {
343
+ let map = def_map_with_crate_graph (
344
+ "
345
+ //- /library.rs
346
+ mod r#async;
347
+ use self::r#async::Bar;
348
+
349
+ //- /async.rs
350
+ pub struct Bar;
351
+ " ,
352
+ crate_graph ! {
353
+ "library" : ( "/library.rs" , [ ] ) ,
354
+ } ,
355
+ ) ;
356
+
357
+ assert_snapshot_matches ! ( map, @r###"
358
+ ⋮crate
359
+ ⋮Bar: t v
360
+ ⋮async: t
361
+ ⋮
362
+ ⋮crate::async
363
+ ⋮Bar: t v
364
+ "### ) ;
365
+ }
366
+
341
367
#[ test]
342
368
fn name_res_works_for_broken_modules ( ) {
343
369
covers ! ( name_res_works_for_broken_modules) ;
You can’t perform that action at this time.
0 commit comments