1
Fork 0

Construct DiagCtxt a bit earlier in build_session

This commit is contained in:
bjorn3 2025-02-05 15:01:17 +00:00
parent 79f82ad5e8
commit 9a833de62a
3 changed files with 6 additions and 14 deletions

View file

@ -442,7 +442,6 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
locale_resources.push(codegen_backend.locale_resource()); locale_resources.push(codegen_backend.locale_resource());
let mut sess = rustc_session::build_session( let mut sess = rustc_session::build_session(
early_dcx,
config.opts, config.opts,
CompilerIO { CompilerIO {
input: config.input, input: config.input,

View file

@ -65,7 +65,6 @@ where
static USING_INTERNAL_FEATURES: AtomicBool = AtomicBool::new(false); static USING_INTERNAL_FEATURES: AtomicBool = AtomicBool::new(false);
let sess = build_session( let sess = build_session(
early_dcx,
sessopts, sessopts,
io, io,
None, None,

View file

@ -965,7 +965,6 @@ fn default_emitter(
#[allow(rustc::bad_opt_access)] #[allow(rustc::bad_opt_access)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
pub fn build_session( pub fn build_session(
early_dcx: EarlyDiagCtxt,
sopts: config::Options, sopts: config::Options,
io: CompilerIO, io: CompilerIO,
bundle: Option<Arc<rustc_errors::FluentBundle>>, bundle: Option<Arc<rustc_errors::FluentBundle>>,
@ -990,14 +989,6 @@ pub fn build_session(
let cap_lints_allow = sopts.lint_cap.is_some_and(|cap| cap == lint::Allow); let cap_lints_allow = sopts.lint_cap.is_some_and(|cap| cap == lint::Allow);
let can_emit_warnings = !(warnings_allow || cap_lints_allow); let can_emit_warnings = !(warnings_allow || cap_lints_allow);
let host_triple = TargetTuple::from_tuple(config::host_tuple());
let (host, target_warnings) = Target::search(&host_triple, &sysroot).unwrap_or_else(|e| {
early_dcx.early_fatal(format!("Error loading host specification: {e}"))
});
for warning in target_warnings.warning_messages() {
early_dcx.early_warn(warning)
}
let fallback_bundle = fallback_fluent_bundle( let fallback_bundle = fallback_fluent_bundle(
fluent_resources, fluent_resources,
sopts.unstable_opts.translate_directionality_markers, sopts.unstable_opts.translate_directionality_markers,
@ -1012,9 +1003,12 @@ pub fn build_session(
dcx = dcx.with_ice_file(ice_file); dcx = dcx.with_ice_file(ice_file);
} }
// Now that the proper handler has been constructed, drop early_dcx to let host_triple = TargetTuple::from_tuple(config::host_tuple());
// prevent accidental use. let (host, target_warnings) = Target::search(&host_triple, &sysroot)
drop(early_dcx); .unwrap_or_else(|e| dcx.handle().fatal(format!("Error loading host specification: {e}")));
for warning in target_warnings.warning_messages() {
dcx.handle().warn(warning)
}
let self_profiler = if let SwitchWithOptPath::Enabled(ref d) = sopts.unstable_opts.self_profile let self_profiler = if let SwitchWithOptPath::Enabled(ref d) = sopts.unstable_opts.self_profile
{ {