File tree 4 files changed +22
-0
lines changed
test/ui/non_modrs_mods_and_inline_mods
4 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -6426,6 +6426,17 @@ impl<'a> Parser<'a> {
6426
6426
self . directory . path . to_mut ( ) . push ( & path. as_str ( ) ) ;
6427
6427
self . directory . ownership = DirectoryOwnership :: Owned { relative : None } ;
6428
6428
} else {
6429
+ // We have to push on the current module name in the case of relative
6430
+ // paths in order to ensure that any additional module paths from inline
6431
+ // `mod x { ... }` come after the relative extension.
6432
+ //
6433
+ // For example, a `mod z { ... }` inside `x/y.rs` should set the current
6434
+ // directory path to `/x/y/z`, not `/x/z` with a relative offset of `y`.
6435
+ if let DirectoryOwnership :: Owned { relative } = & mut self . directory . ownership {
6436
+ if let Some ( ident) = relative. take ( ) { // remove the relative offset
6437
+ self . directory . path . to_mut ( ) . push ( ident. as_str ( ) ) ;
6438
+ }
6439
+ }
6429
6440
self . directory . path . to_mut ( ) . push ( & id. as_str ( ) ) ;
6430
6441
}
6431
6442
}
Original file line number Diff line number Diff line change
1
+ // compile-pass
2
+
3
+ mod x;
4
+
5
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ // ignore-test: not a test
2
+
3
+ pub mod y {
4
+ pub mod z;
5
+ }
Original file line number Diff line number Diff line change
1
+ // ignore-test: not a test
You can’t perform that action at this time.
0 commit comments