Skip to content

Commit 8a9db25

Browse files
committed
Remove more Session methods that duplicate DiagCtxt methods.
1 parent 8af3d8d commit 8a9db25

File tree

36 files changed

+62
-74
lines changed

36 files changed

+62
-74
lines changed

compiler/rustc_builtin_macros/src/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ fn make_format_args(
529529

530530
// Only check for unused named argument names if there are no other errors to avoid causing
531531
// too much noise in output errors, such as when a named argument is entirely unused.
532-
if invalid_refs.is_empty() && ecx.sess.err_count() == 0 {
532+
if invalid_refs.is_empty() && ecx.dcx().err_count() == 0 {
533533
for &(index, span, used_as) in &numeric_refences_to_named_arg {
534534
let (position_sp_to_replace, position_sp_for_msg) = match used_as {
535535
Placeholder(pspan) => (span, pspan),

compiler/rustc_codegen_cranelift/src/driver/aot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl OngoingCodegen {
108108

109109
self.concurrency_limiter.finished();
110110

111-
sess.abort_if_errors();
111+
sess.dcx().abort_if_errors();
112112

113113
(
114114
CodegenResults {

compiler/rustc_codegen_cranelift/src/driver/jit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
151151
tcx.dcx().fatal("Inline asm is not supported in JIT mode");
152152
}
153153

154-
tcx.sess.abort_if_errors();
154+
tcx.dcx().abort_if_errors();
155155

156156
jit_module.finalize_definitions().unwrap();
157157
unsafe { cx.unwind_context.register_jit(&jit_module) };
@@ -338,7 +338,7 @@ fn dep_symbol_lookup_fn(
338338
.collect::<Box<[_]>>(),
339339
);
340340

341-
sess.abort_if_errors();
341+
sess.dcx().abort_if_errors();
342342

343343
Box::new(move |sym_name| {
344344
for dylib in &*imported_dylibs {

compiler/rustc_codegen_cranelift/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
204204
metadata: EncodedMetadata,
205205
need_metadata_module: bool,
206206
) -> Box<dyn Any> {
207-
tcx.sess.abort_if_errors();
207+
tcx.dcx().abort_if_errors();
208208
let config = self.config.borrow().clone().unwrap();
209209
match config.codegen_mode {
210210
CodegenMode::Aot => driver::aot::run_aot(tcx, config, metadata, need_metadata_module),

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ fn link_dwarf_object<'a>(
716716
Ok(()) => {}
717717
Err(e) => {
718718
sess.dcx().emit_err(errors::ThorinErrorWrapper(e));
719-
sess.abort_if_errors();
719+
sess.dcx().abort_if_errors();
720720
}
721721
}
722722
}
@@ -765,7 +765,7 @@ fn link_natively<'a>(
765765
}
766766

767767
// May have not found libraries in the right formats.
768-
sess.abort_if_errors();
768+
sess.dcx().abort_if_errors();
769769

770770
// Invoke the system linker
771771
info!("{:?}", &cmd);
@@ -970,7 +970,7 @@ fn link_natively<'a>(
970970
}
971971
}
972972

973-
sess.abort_if_errors();
973+
sess.dcx().abort_if_errors();
974974
}
975975
info!("linker stderr:\n{}", escape_string(&prog.stderr));
976976
info!("linker stdout:\n{}", escape_string(&prog.stdout));
@@ -993,7 +993,7 @@ fn link_natively<'a>(
993993
sess.dcx().emit_note(errors::CheckInstalledVisualStudio);
994994
sess.dcx().emit_note(errors::InsufficientVSCodeProduct);
995995
}
996-
sess.abort_if_errors();
996+
sess.dcx().abort_if_errors();
997997
}
998998
}
999999

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,7 @@ impl SharedEmitterMain {
18831883
err.emit();
18841884
}
18851885
Ok(SharedEmitterMessage::AbortIfErrors) => {
1886-
sess.abort_if_errors();
1886+
sess.dcx().abort_if_errors();
18871887
}
18881888
Ok(SharedEmitterMessage::Fatal(msg)) => {
18891889
sess.dcx().fatal(msg);
@@ -1939,15 +1939,15 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
19391939
let compiled_modules = sess.time("join_worker_thread", || match self.coordinator.join() {
19401940
Ok(Ok(compiled_modules)) => compiled_modules,
19411941
Ok(Err(())) => {
1942-
sess.abort_if_errors();
1942+
sess.dcx().abort_if_errors();
19431943
panic!("expected abort due to worker thread errors")
19441944
}
19451945
Err(_) => {
19461946
bug!("panic during codegen/LLVM phase");
19471947
}
19481948
});
19491949

1950-
sess.abort_if_errors();
1950+
sess.dcx().abort_if_errors();
19511951

19521952
let work_products =
19531953
copy_all_cgu_workproducts_to_incr_comp_cache_dir(sess, &compiled_modules);

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,9 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
448448
let Some(llfn) = cx.declare_c_main(llfty) else {
449449
// FIXME: We should be smart and show a better diagnostic here.
450450
let span = cx.tcx().def_span(rust_main_def_id);
451-
cx.sess().dcx().emit_err(errors::MultipleMainFunctions { span });
452-
cx.sess().abort_if_errors();
451+
let dcx = cx.tcx().dcx();
452+
dcx.emit_err(errors::MultipleMainFunctions { span });
453+
dcx.abort_if_errors();
453454
bug!();
454455
};
455456

@@ -752,7 +753,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
752753
// This will unwind if there are errors, which triggers our `AbortCodegenOnDrop`
753754
// guard. Unfortunately, just skipping the `submit_codegened_module_to_llvm` makes
754755
// compilation hang on post-monomorphization errors.
755-
tcx.sess.abort_if_errors();
756+
tcx.dcx().abort_if_errors();
756757

757758
submit_codegened_module_to_llvm(
758759
&backend,

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
279279
self.tcx.dcx().emit_diagnostic(error);
280280
}
281281
} else {
282-
assert!(self.tcx.sess.has_errors().is_some());
282+
assert!(self.tcx.dcx().has_errors().is_some());
283283
}
284284
}
285285

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub const DEFAULT_BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust/issu
150150
pub fn abort_on_err<T>(result: Result<T, ErrorGuaranteed>, sess: &Session) -> T {
151151
match result {
152152
Err(..) => {
153-
sess.abort_if_errors();
153+
sess.dcx().abort_if_errors();
154154
panic!("error reported but abort_if_errors didn't abort???");
155155
}
156156
Ok(x) => x,

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ pub(super) fn check_type_params_are_used<'tcx>(
12841284
if ty.references_error() {
12851285
// If there is already another error, do not emit
12861286
// an error for not using a type parameter.
1287-
assert!(tcx.sess.has_errors().is_some());
1287+
assert!(tcx.dcx().has_errors().is_some());
12881288
return;
12891289
}
12901290

0 commit comments

Comments
 (0)