diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-04-16 21:41:23 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-16 21:41:23 +0200 |
| commit | 14496d561e19d480733f079725c08f170b3eb34b (patch) | |
| tree | 6db29e5c0786c6a14b97a01dfe1b7f56ba086a2d /compiler/rustc_session/src | |
| parent | 468f1156843c35af624304c44b0ea0cf0a7777d4 (diff) | |
| parent | 9b0ced000a7e9db6bed97046974adfa9bf3bc165 (diff) | |
| download | rust-14496d561e19d480733f079725c08f170b3eb34b.tar.gz rust-14496d561e19d480733f079725c08f170b3eb34b.zip | |
Rollup merge of #122811 - nnethercote:mv-SourceMap-init, r=WaffleLapkin
Move `SourceMap` initialization So it happens at the same time as `SessionGlobals` initialization, rather than shortly afterward. r? `@WaffleLapkin`
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 34 |
2 files changed, 18 insertions, 28 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index d9fc43625ef..2a7b5650fc2 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1125,7 +1125,7 @@ impl Options { || self.unstable_opts.query_dep_graph } - pub(crate) fn file_path_mapping(&self) -> FilePathMapping { + pub fn file_path_mapping(&self) -> FilePathMapping { file_path_mapping(self.remap_path_prefix.clone(), &self.unstable_opts) } @@ -1162,6 +1162,16 @@ impl UnstableOptions { track_diagnostics: self.track_diagnostics, } } + + pub fn src_hash_algorithm(&self, target: &Target) -> SourceFileHashAlgorithm { + self.src_hash_algorithm.unwrap_or_else(|| { + if target.is_like_msvc { + SourceFileHashAlgorithm::Sha256 + } else { + SourceFileHashAlgorithm::Md5 + } + }) + } } // The type of entry function, so users can have their own entry functions diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 38642efadbd..b63c119eee0 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -28,9 +28,9 @@ use rustc_errors::{ use rustc_macros::HashStable_Generic; pub use rustc_span::def_id::StableCrateId; use rustc_span::edition::Edition; -use rustc_span::source_map::{FileLoader, FilePathMapping, RealFileLoader, SourceMap}; +use rustc_span::source_map::{FilePathMapping, SourceMap}; use rustc_span::{FileNameDisplayPreference, RealFileName}; -use rustc_span::{SourceFileHashAlgorithm, Span, Symbol}; +use rustc_span::{Span, Symbol}; use rustc_target::asm::InlineAsmArch; use rustc_target::spec::{CodeModel, PanicStrategy, RelocModel, RelroLevel}; use rustc_target::spec::{ @@ -988,7 +988,6 @@ pub fn build_session( registry: rustc_errors::registry::Registry, fluent_resources: Vec<&'static str>, driver_lint_caps: FxHashMap<lint::LintId, lint::Level>, - file_loader: Option<Box<dyn FileLoader + Send + Sync + 'static>>, target: Target, sysroot: PathBuf, cfg_version: &'static str, @@ -1015,24 +1014,11 @@ pub fn build_session( early_dcx.early_warn(warning) } - let loader = file_loader.unwrap_or_else(|| Box::new(RealFileLoader)); - let hash_kind = sopts.unstable_opts.src_hash_algorithm.unwrap_or_else(|| { - if target.is_like_msvc { - SourceFileHashAlgorithm::Sha256 - } else { - SourceFileHashAlgorithm::Md5 - } - }); - let source_map = Lrc::new(SourceMap::with_file_loader_and_hash_kind( - loader, - sopts.file_path_mapping(), - hash_kind, - )); - let fallback_bundle = fallback_fluent_bundle( fluent_resources, sopts.unstable_opts.translate_directionality_markers, ); + let source_map = rustc_span::source_map::get_source_map().unwrap(); let emitter = default_emitter(&sopts, registry, source_map.clone(), bundle, fallback_bundle); let mut dcx = @@ -1411,16 +1397,10 @@ impl EarlyDiagCtxt { self.dcx.warn(msg) } - pub fn initialize_checked_jobserver(&self) { - // initialize jobserver before getting `jobserver::client` and `build_session`. - jobserver::initialize_checked(|err| { - #[allow(rustc::untranslatable_diagnostic)] - #[allow(rustc::diagnostic_outside_of_impl)] - self.dcx - .struct_warn(err) - .with_note("the build environment is likely misconfigured") - .emit() - }); + #[allow(rustc::untranslatable_diagnostic)] + #[allow(rustc::diagnostic_outside_of_impl)] + pub fn early_struct_warn(&self, msg: impl Into<DiagMessage>) -> Diag<'_, ()> { + self.dcx.struct_warn(msg) } } |
