expand: Move module file path stack from global session to expansion data
Also don't push the paths on the stack directly in `fn parse_external_mod`, return them instead.
This commit is contained in:
parent
bc18eb4717
commit
39052c55bb
7 changed files with 80 additions and 70 deletions
|
@ -101,7 +101,7 @@ pub fn expand_include<'cx>(
|
|||
None => return DummyResult::any(sp),
|
||||
};
|
||||
// The file will be added to the code map by the parser
|
||||
let mut file = match cx.resolve_path(file, sp) {
|
||||
let file = match cx.resolve_path(file, sp) {
|
||||
Ok(f) => f,
|
||||
Err(mut err) => {
|
||||
err.emit();
|
||||
|
@ -114,10 +114,9 @@ pub fn expand_include<'cx>(
|
|||
// then the path of `bar.rs` should be relative to the directory of `file`.
|
||||
// See https://github.com/rust-lang/rust/pull/69838/files#r395217057 for a discussion.
|
||||
// `MacroExpander::fully_expand_fragment` later restores, so "stack discipline" is maintained.
|
||||
file.pop();
|
||||
let dir_path = file.parent().unwrap_or(&file).to_owned();
|
||||
cx.current_expansion.module = Rc::new(cx.current_expansion.module.with_dir_path(dir_path));
|
||||
cx.current_expansion.directory_ownership = DirectoryOwnership::Owned { relative: None };
|
||||
let mod_path = cx.current_expansion.module.mod_path.clone();
|
||||
cx.current_expansion.module = Rc::new(ModuleData { mod_path, directory: file });
|
||||
|
||||
struct ExpandResult<'a> {
|
||||
p: Parser<'a>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue