Skip to content

Commit 5b3ffbc

Browse files
committed
Construct DiagCtxt a bit earlier in build_session
1 parent 5958825 commit 5b3ffbc

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

compiler/rustc_interface/src/interface.rs

-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
442442
locale_resources.push(codegen_backend.locale_resource());
443443

444444
let mut sess = rustc_session::build_session(
445-
early_dcx,
446445
config.opts,
447446
CompilerIO {
448447
input: config.input,

compiler/rustc_interface/src/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ where
6565
static USING_INTERNAL_FEATURES: AtomicBool = AtomicBool::new(false);
6666

6767
let sess = build_session(
68-
early_dcx,
6968
sessopts,
7069
io,
7170
None,

compiler/rustc_session/src/session.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,6 @@ fn default_emitter(
967967
#[allow(rustc::bad_opt_access)]
968968
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
969969
pub fn build_session(
970-
early_dcx: EarlyDiagCtxt,
971970
sopts: config::Options,
972971
io: CompilerIO,
973972
bundle: Option<Lrc<rustc_errors::FluentBundle>>,
@@ -992,14 +991,6 @@ pub fn build_session(
992991
let cap_lints_allow = sopts.lint_cap.is_some_and(|cap| cap == lint::Allow);
993992
let can_emit_warnings = !(warnings_allow || cap_lints_allow);
994993

995-
let host_triple = TargetTuple::from_tuple(config::host_tuple());
996-
let (host, target_warnings) = Target::search(&host_triple, &sysroot).unwrap_or_else(|e| {
997-
early_dcx.early_fatal(format!("Error loading host specification: {e}"))
998-
});
999-
for warning in target_warnings.warning_messages() {
1000-
early_dcx.early_warn(warning)
1001-
}
1002-
1003994
let fallback_bundle = fallback_fluent_bundle(
1004995
fluent_resources,
1005996
sopts.unstable_opts.translate_directionality_markers,
@@ -1014,9 +1005,12 @@ pub fn build_session(
10141005
dcx = dcx.with_ice_file(ice_file);
10151006
}
10161007

1017-
// Now that the proper handler has been constructed, drop early_dcx to
1018-
// prevent accidental use.
1019-
drop(early_dcx);
1008+
let host_triple = TargetTuple::from_tuple(config::host_tuple());
1009+
let (host, target_warnings) = Target::search(&host_triple, &sysroot)
1010+
.unwrap_or_else(|e| dcx.handle().fatal(format!("Error loading host specification: {e}")));
1011+
for warning in target_warnings.warning_messages() {
1012+
dcx.handle().warn(warning)
1013+
}
10201014

10211015
let self_profiler = if let SwitchWithOptPath::Enabled(ref d) = sopts.unstable_opts.self_profile
10221016
{

0 commit comments

Comments
 (0)