1
Fork 0

Use local and remapped paths where appropriate

This commit is contained in:
Andy Wang 2021-04-19 23:27:02 +01:00
parent fb4f6439f6
commit 5417b45c26
No known key found for this signature in database
GPG key ID: 181B49F9F38F3374
28 changed files with 85 additions and 74 deletions

View file

@ -1080,7 +1080,10 @@ impl<'a> ExtCtxt<'a> {
other => {
return Err(self.struct_span_err(
span,
&format!("cannot resolve relative path in non-file source `{}`", other),
&format!(
"cannot resolve relative path in non-file source `{}`",
other.prefer_local()
),
));
}
};

View file

@ -365,7 +365,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
FileName::Real(name) => name
.into_local_path()
.expect("attempting to resolve a file path in an external file"),
other => PathBuf::from(other.to_string()),
other => PathBuf::from(other.prefer_local().to_string()),
};
let dir_path = file_path.parent().unwrap_or(&file_path).to_owned();
self.cx.root_path = dir_path.clone();

View file

@ -627,7 +627,7 @@ impl server::SourceFile for Rustc<'_> {
.to_str()
.expect("non-UTF8 file path in `proc_macro::SourceFile::path`")
.to_string(),
_ => file.name.to_string(),
_ => file.name.prefer_local().to_string(),
}
}
fn is_real(&mut self, file: &Self::SourceFile) -> bool {