File tree Expand file tree Collapse file tree 4 files changed +22
-0
lines changed
test/ui/non_modrs_mods_and_inline_mods Expand file tree Collapse file tree 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> {
64266426 self . directory . path . to_mut ( ) . push ( & path. as_str ( ) ) ;
64276427 self . directory . ownership = DirectoryOwnership :: Owned { relative : None } ;
64286428 } 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+ }
64296440 self . directory . path . to_mut ( ) . push ( & id. as_str ( ) ) ;
64306441 }
64316442 }
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