mirror of https://github.com/rust-lang/rust.git
Use RealFileName for Session::working_dir as it may also be remapped
This commit is contained in:
parent
9e0426d784
commit
0407919083
|
@ -64,7 +64,7 @@ impl<'tcx> DebugContext<'tcx> {
|
||||||
// FIXME: how to get version when building out of tree?
|
// FIXME: how to get version when building out of tree?
|
||||||
// Normally this would use option_env!("CFG_VERSION").
|
// Normally this would use option_env!("CFG_VERSION").
|
||||||
let producer = format!("cg_clif (rustc {})", "unknown version");
|
let producer = format!("cg_clif (rustc {})", "unknown version");
|
||||||
let comp_dir = tcx.sess.working_dir.0.to_string_lossy().into_owned();
|
let comp_dir = tcx.sess.working_dir.stable_name().to_string_lossy().into_owned();
|
||||||
let (name, file_info) = match tcx.sess.local_crate_source_file.clone() {
|
let (name, file_info) = match tcx.sess.local_crate_source_file.clone() {
|
||||||
Some(path) => {
|
Some(path) => {
|
||||||
let name = path.to_string_lossy().into_owned();
|
let name = path.to_string_lossy().into_owned();
|
||||||
|
|
|
@ -764,7 +764,7 @@ pub fn file_metadata(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) -> &'ll
|
||||||
let hash = Some(&source_file.src_hash);
|
let hash = Some(&source_file.src_hash);
|
||||||
let file_name = Some(source_file.name.to_string());
|
let file_name = Some(source_file.name.to_string());
|
||||||
let directory = if source_file.is_real_file() && !source_file.is_imported() {
|
let directory = if source_file.is_real_file() && !source_file.is_imported() {
|
||||||
Some(cx.sess().working_dir.0.to_string_lossy().to_string())
|
Some(cx.sess().working_dir.stable_name().to_string_lossy().to_string())
|
||||||
} else {
|
} else {
|
||||||
// If the path comes from an upstream crate we assume it has been made
|
// If the path comes from an upstream crate we assume it has been made
|
||||||
// independent of the compiler's working directory one way or another.
|
// independent of the compiler's working directory one way or another.
|
||||||
|
@ -992,7 +992,7 @@ pub fn compile_unit_metadata(
|
||||||
let producer = format!("clang LLVM ({})", rustc_producer);
|
let producer = format!("clang LLVM ({})", rustc_producer);
|
||||||
|
|
||||||
let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
|
let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
|
||||||
let work_dir = tcx.sess.working_dir.0.to_string_lossy();
|
let work_dir = tcx.sess.working_dir.stable_name().to_string_lossy();
|
||||||
let flags = "\0";
|
let flags = "\0";
|
||||||
let out_dir = &tcx.output_filenames(LOCAL_CRATE).out_directory;
|
let out_dir = &tcx.output_filenames(LOCAL_CRATE).out_directory;
|
||||||
let split_name = if tcx.sess.target_can_use_split_dwarf() {
|
let split_name = if tcx.sess.target_can_use_split_dwarf() {
|
||||||
|
|
|
@ -469,7 +469,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
let source_map = self.tcx.sess.source_map();
|
let source_map = self.tcx.sess.source_map();
|
||||||
let all_source_files = source_map.files();
|
let all_source_files = source_map.files();
|
||||||
|
|
||||||
let (working_dir, _cwd_remapped) = self.tcx.sess.working_dir.clone();
|
let working_dir = self.tcx.sess.working_dir.stable_name();
|
||||||
// By replacing the `Option` with `None`, we ensure that we can't
|
// By replacing the `Option` with `None`, we ensure that we can't
|
||||||
// accidentally serialize any more `Span`s after the source map encoding
|
// accidentally serialize any more `Span`s after the source map encoding
|
||||||
// is done.
|
// is done.
|
||||||
|
|
|
@ -190,7 +190,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let data = CompilationOptions {
|
let data = CompilationOptions {
|
||||||
directory: self.tcx.sess.working_dir.0.clone(),
|
directory: self.tcx.sess.working_dir.stable_name().into(),
|
||||||
program,
|
program,
|
||||||
arguments,
|
arguments,
|
||||||
output: self.save_ctxt.compilation_output(crate_name),
|
output: self.save_ctxt.compilation_output(crate_name),
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl<'a> SpanUtils<'a> {
|
||||||
.display()
|
.display()
|
||||||
.to_string()
|
.to_string()
|
||||||
} else {
|
} else {
|
||||||
self.sess.working_dir.0.join(&path).display().to_string()
|
self.sess.working_dir.stable_name().join(&path).display().to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the file name was remapped, we assume the user
|
// If the file name was remapped, we assume the user
|
||||||
|
|
|
@ -23,8 +23,8 @@ use rustc_errors::registry::Registry;
|
||||||
use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorReported};
|
use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorReported};
|
||||||
use rustc_lint_defs::FutureBreakage;
|
use rustc_lint_defs::FutureBreakage;
|
||||||
pub use rustc_span::crate_disambiguator::CrateDisambiguator;
|
pub use rustc_span::crate_disambiguator::CrateDisambiguator;
|
||||||
use rustc_span::edition::Edition;
|
|
||||||
use rustc_span::source_map::{FileLoader, MultiSpan, RealFileLoader, SourceMap, Span};
|
use rustc_span::source_map::{FileLoader, MultiSpan, RealFileLoader, SourceMap, Span};
|
||||||
|
use rustc_span::{edition::Edition, RealFileName};
|
||||||
use rustc_span::{sym, SourceFileHashAlgorithm, Symbol};
|
use rustc_span::{sym, SourceFileHashAlgorithm, Symbol};
|
||||||
use rustc_target::asm::InlineAsmArch;
|
use rustc_target::asm::InlineAsmArch;
|
||||||
use rustc_target::spec::{CodeModel, PanicStrategy, RelocModel, RelroLevel};
|
use rustc_target::spec::{CodeModel, PanicStrategy, RelocModel, RelroLevel};
|
||||||
|
@ -125,9 +125,8 @@ pub struct Session {
|
||||||
/// The name of the root source file of the crate, in the local file system.
|
/// The name of the root source file of the crate, in the local file system.
|
||||||
/// `None` means that there is no source file.
|
/// `None` means that there is no source file.
|
||||||
pub local_crate_source_file: Option<PathBuf>,
|
pub local_crate_source_file: Option<PathBuf>,
|
||||||
/// The directory the compiler has been executed in plus a flag indicating
|
/// The directory the compiler has been executed in
|
||||||
/// if the value stored here has been affected by path remapping.
|
pub working_dir: RealFileName,
|
||||||
pub working_dir: (PathBuf, bool),
|
|
||||||
|
|
||||||
/// Set of `(DiagnosticId, Option<Span>, message)` tuples tracking
|
/// Set of `(DiagnosticId, Option<Span>, message)` tuples tracking
|
||||||
/// (sub)diagnostics that have been set once, but should not be set again,
|
/// (sub)diagnostics that have been set once, but should not be set again,
|
||||||
|
@ -1361,7 +1360,12 @@ pub fn build_session(
|
||||||
let working_dir = env::current_dir().unwrap_or_else(|e| {
|
let working_dir = env::current_dir().unwrap_or_else(|e| {
|
||||||
parse_sess.span_diagnostic.fatal(&format!("Current directory is invalid: {}", e)).raise()
|
parse_sess.span_diagnostic.fatal(&format!("Current directory is invalid: {}", e)).raise()
|
||||||
});
|
});
|
||||||
let working_dir = file_path_mapping.map_prefix(working_dir);
|
let (path, remapped) = file_path_mapping.map_prefix(working_dir.clone());
|
||||||
|
let working_dir = if remapped {
|
||||||
|
RealFileName::Remapped { local_path: Some(working_dir), virtual_name: path }
|
||||||
|
} else {
|
||||||
|
RealFileName::LocalPath(path)
|
||||||
|
};
|
||||||
|
|
||||||
let cgu_reuse_tracker = if sopts.debugging_opts.query_dep_graph {
|
let cgu_reuse_tracker = if sopts.debugging_opts.query_dep_graph {
|
||||||
CguReuseTracker::new()
|
CguReuseTracker::new()
|
||||||
|
|
Loading…
Reference in New Issue