From a179a53565b63b7499c3199bae5eff810341b41f Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 1 Dec 2023 13:35:19 +1100 Subject: [PATCH] Use `Session::diagnostic` in more places. --- compiler/rustc_ast_passes/src/feature_gate.rs | 4 ++-- compiler/rustc_attr/src/builtin.rs | 2 +- .../src/diagnostics/conflict_errors.rs | 4 ++-- compiler/rustc_borrowck/src/diagnostics/mod.rs | 6 +++--- .../src/alloc_error_handler.rs | 5 +---- .../src/global_allocator.rs | 5 +---- compiler/rustc_builtin_macros/src/test.rs | 8 ++++---- compiler/rustc_codegen_ssa/src/back/link.rs | 2 +- .../rustc_const_eval/src/const_eval/error.rs | 2 +- compiler/rustc_const_eval/src/errors.rs | 2 +- .../src/interpret/eval_context.rs | 2 +- compiler/rustc_expand/src/base.rs | 15 +++++++-------- compiler/rustc_expand/src/mbe/macro_rules.rs | 17 +++++++---------- compiler/rustc_expand/src/proc_macro.rs | 4 ++-- .../src/infer/error_reporting/need_type_info.rs | 12 ++++++------ .../src/infer/error_reporting/note.rs | 12 ++++++------ compiler/rustc_interface/src/passes.rs | 4 +--- compiler/rustc_metadata/src/creader.rs | 2 +- compiler/rustc_metadata/src/fs.rs | 5 +---- compiler/rustc_query_system/src/query/job.rs | 2 +- compiler/rustc_session/src/session.rs | 2 +- 21 files changed, 51 insertions(+), 66 deletions(-) diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 80b18b0e775..1cffe22ced8 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -102,7 +102,7 @@ impl<'a> PostExpansionVisitor<'a> { } Err(abi::AbiDisabled::Unrecognized) => { if self.sess.opts.pretty.map_or(true, |ppm| ppm.needs_hir()) { - self.sess.parse_sess.span_diagnostic.span_delayed_bug( + self.sess.diagnostic().span_delayed_bug( span, format!( "unrecognized ABI not caught in lowering: {}", @@ -628,7 +628,7 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate) if all_stable { err.sugg = Some(attr.span); } - sess.parse_sess.span_diagnostic.emit_err(err); + sess.diagnostic().emit_err(err); } } } diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 9fd5c91f554..a6930fe0a17 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -945,7 +945,7 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec { assert!(attr.has_name(sym::repr), "expected `#[repr(..)]`, found: {attr:?}"); use ReprAttr::*; let mut acc = Vec::new(); - let diagnostic = &sess.parse_sess.span_diagnostic; + let diagnostic = sess.diagnostic(); if let Some(items) = attr.meta_item_list() { for item in items { diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index ef4bf543454..7bcad92ff33 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -1135,7 +1135,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }); } else { issued_spans.var_subdiag( - Some(&self.infcx.tcx.sess.parse_sess.span_diagnostic), + Some(self.infcx.tcx.sess.diagnostic()), &mut err, Some(issued_borrow.kind), |kind, var_span| { @@ -1152,7 +1152,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ); borrow_spans.var_subdiag( - Some(&self.infcx.tcx.sess.parse_sess.span_diagnostic), + Some(self.infcx.tcx.sess.diagnostic()), &mut err, Some(gen_borrow_kind), |kind, var_span| { diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index e37457f48df..4deed98d002 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -124,7 +124,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let did = did.expect_local(); if let Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) { diag.eager_subdiagnostic( - &self.infcx.tcx.sess.parse_sess.span_diagnostic, + self.infcx.tcx.sess.diagnostic(), OnClosureNote::InvokedTwice { place_name: &ty::place_to_string_for_capture( self.infcx.tcx, @@ -146,7 +146,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let did = did.expect_local(); if let Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) { diag.eager_subdiagnostic( - &self.infcx.tcx.sess.parse_sess.span_diagnostic, + self.infcx.tcx.sess.diagnostic(), OnClosureNote::MovedTwice { place_name: &ty::place_to_string_for_capture(self.infcx.tcx, hir_place), span: *span, @@ -1119,7 +1119,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { && self.infcx.can_eq(self.param_env, ty, self_ty) { err.eager_subdiagnostic( - &self.infcx.tcx.sess.parse_sess.span_diagnostic, + self.infcx.tcx.sess.diagnostic(), CaptureReasonSuggest::FreshReborrow { span: move_span.shrink_to_hi(), }, diff --git a/compiler/rustc_builtin_macros/src/alloc_error_handler.rs b/compiler/rustc_builtin_macros/src/alloc_error_handler.rs index 070d50708ff..e13d217ef01 100644 --- a/compiler/rustc_builtin_macros/src/alloc_error_handler.rs +++ b/compiler/rustc_builtin_macros/src/alloc_error_handler.rs @@ -31,10 +31,7 @@ pub fn expand( { (item, true, ecx.with_def_site_ctxt(fn_kind.sig.span)) } else { - ecx.sess - .parse_sess - .span_diagnostic - .emit_err(errors::AllocErrorMustBeFn { span: item.span() }); + ecx.sess.diagnostic().emit_err(errors::AllocErrorMustBeFn { span: item.span() }); return vec![orig_item]; }; diff --git a/compiler/rustc_builtin_macros/src/global_allocator.rs b/compiler/rustc_builtin_macros/src/global_allocator.rs index 33392edf060..6dc75e3ba4c 100644 --- a/compiler/rustc_builtin_macros/src/global_allocator.rs +++ b/compiler/rustc_builtin_macros/src/global_allocator.rs @@ -34,10 +34,7 @@ pub fn expand( { (item, true, ecx.with_def_site_ctxt(ty.span)) } else { - ecx.sess - .parse_sess - .span_diagnostic - .emit_err(errors::AllocMustStatics { span: item.span() }); + ecx.sess.diagnostic().emit_err(errors::AllocMustStatics { span: item.span() }); return vec![orig_item]; }; diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index c0055380c25..bf1e1ebf5dd 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -389,7 +389,7 @@ pub fn expand_test_or_bench( } fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) { - let diag = &cx.sess.parse_sess.span_diagnostic; + let diag = cx.sess.diagnostic(); let msg = "the `#[test]` attribute may only be used on a non-associated function"; let mut err = match item.map(|i| &i.kind) { // These were a warning before #92959 and need to continue being that to avoid breaking @@ -466,7 +466,7 @@ fn should_ignore_message(i: &ast::Item) -> Option { fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic { match attr::find_by_name(&i.attrs, sym::should_panic) { Some(attr) => { - let sd = &cx.sess.parse_sess.span_diagnostic; + let sd = cx.sess.diagnostic(); match attr.meta_item_list() { // Handle #[should_panic(expected = "foo")] @@ -535,7 +535,7 @@ fn check_test_signature( f: &ast::Fn, ) -> Result<(), ErrorGuaranteed> { let has_should_panic_attr = attr::contains_name(&i.attrs, sym::should_panic); - let sd = &cx.sess.parse_sess.span_diagnostic; + let sd = cx.sess.diagnostic(); if let ast::Unsafe::Yes(span) = f.sig.header.unsafety { return Err(sd.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "unsafe" })); @@ -579,7 +579,7 @@ fn check_bench_signature( // N.B., inadequate check, but we're running // well before resolve, can't get too deep. if f.sig.decl.inputs.len() != 1 { - return Err(cx.sess.parse_sess.span_diagnostic.emit_err(errors::BenchSig { span: i.span })); + return Err(cx.sess.diagnostic().emit_err(errors::BenchSig { span: i.span })); } Ok(()) } diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 5dfa10261bb..f5cb7ad4ff3 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -143,7 +143,7 @@ pub fn link_binary<'a>( } } if sess.opts.json_artifact_notifications { - sess.parse_sess.span_diagnostic.emit_artifact_notification(&out_filename, "link"); + sess.diagnostic().emit_artifact_notification(&out_filename, "link"); } if sess.prof.enabled() { diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index bf1e0a37073..4934fcc75ec 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -148,7 +148,7 @@ where let mut err = tcx.sess.create_err(err); let msg = error.diagnostic_message(); - error.add_args(&tcx.sess.parse_sess.span_diagnostic, &mut err); + error.add_args(tcx.sess.diagnostic(), &mut err); // Use *our* span to label the interp error err.span_label(our_span, msg); diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs index cc8f3387238..8343dc2dd35 100644 --- a/compiler/rustc_const_eval/src/errors.rs +++ b/compiler/rustc_const_eval/src/errors.rs @@ -437,7 +437,7 @@ pub trait ReportErrorExt { { ty::tls::with(move |tcx| { let mut builder = tcx.sess.struct_allow(DiagnosticMessage::Str(String::new().into())); - let handler = &tcx.sess.parse_sess.span_diagnostic; + let handler = tcx.sess.diagnostic(); let message = self.diagnostic_message(); self.add_args(handler, &mut builder); let s = handler.eagerly_translate_to_string(message, builder.args()); diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index dd8f06df6d7..cbece374c76 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -470,7 +470,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { backtrace.print_backtrace(); // FIXME(fee1-dead), HACK: we want to use the error as title therefore we can just extract the // label and arguments from the InterpError. - let handler = &self.tcx.sess.parse_sess.span_diagnostic; + let handler = self.tcx.sess.diagnostic(); #[allow(rustc::untranslatable_diagnostic)] let mut diag = self.tcx.sess.struct_allow(""); let msg = e.diagnostic_message(); diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 88e90a3b3d1..91f3ca1d115 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -1119,7 +1119,7 @@ impl<'a> ExtCtxt<'a> { sp: S, msg: impl Into, ) -> DiagnosticBuilder<'a, ErrorGuaranteed> { - self.sess.parse_sess.span_diagnostic.struct_span_err(sp, msg) + self.sess.diagnostic().struct_span_err(sp, msg) } #[track_caller] @@ -1143,15 +1143,15 @@ impl<'a> ExtCtxt<'a> { #[rustc_lint_diagnostics] #[track_caller] pub fn span_err>(&self, sp: S, msg: impl Into) { - self.sess.parse_sess.span_diagnostic.span_err(sp, msg); + self.sess.diagnostic().span_err(sp, msg); } #[rustc_lint_diagnostics] #[track_caller] pub fn span_warn>(&self, sp: S, msg: impl Into) { - self.sess.parse_sess.span_diagnostic.span_warn(sp, msg); + self.sess.diagnostic().span_warn(sp, msg); } pub fn span_bug>(&self, sp: S, msg: impl Into) -> ! { - self.sess.parse_sess.span_diagnostic.span_bug(sp, msg); + self.sess.diagnostic().span_bug(sp, msg); } pub fn trace_macros_diag(&mut self) { for (span, notes) in self.expansions.iter() { @@ -1165,7 +1165,7 @@ impl<'a> ExtCtxt<'a> { self.expansions.clear(); } pub fn bug(&self, msg: &'static str) -> ! { - self.sess.parse_sess.span_diagnostic.bug(msg); + self.sess.diagnostic().bug(msg); } pub fn trace_macros(&self) -> bool { self.ecfg.trace_mac @@ -1286,9 +1286,8 @@ pub fn expr_to_string( /// Non-fatally assert that `tts` is empty. Note that this function /// returns even when `tts` is non-empty, macros that *need* to stop -/// compilation should call -/// `cx.parse_sess.span_diagnostic.abort_if_errors()` (this should be -/// done as rarely as possible). +/// compilation should call `cx.diagnostic().abort_if_errors()` +/// (this should be done as rarely as possible). pub fn check_zero_tts(cx: &ExtCtxt<'_>, span: Span, tts: TokenStream, name: &str) { if !tts.is_empty() { cx.emit_err(errors::TakesNoArguments { span, name }); diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 1aa4e461e1b..19734394382 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -475,17 +475,14 @@ pub fn compile_declarative_macro( let s = parse_failure_msg(&token); let sp = token.span.substitute_dummy(def.span); - let mut err = sess.parse_sess.span_diagnostic.struct_span_err(sp, s); + let mut err = sess.diagnostic().struct_span_err(sp, s); err.span_label(sp, msg); annotate_doc_comment(&mut err, sess.source_map(), sp); err.emit(); return dummy_syn_ext(); } Error(sp, msg) => { - sess.parse_sess - .span_diagnostic - .struct_span_err(sp.substitute_dummy(def.span), msg) - .emit(); + sess.diagnostic().struct_span_err(sp.substitute_dummy(def.span), msg).emit(); return dummy_syn_ext(); } ErrorReported(_) => { @@ -514,10 +511,10 @@ pub fn compile_declarative_macro( valid &= check_lhs_nt_follows(&sess.parse_sess, def, &tt); return tt; } - sess.parse_sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs") + sess.diagnostic().span_bug(def.span, "wrong-structured lhs") }) .collect::>(), - _ => sess.parse_sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs"), + _ => sess.diagnostic().span_bug(def.span, "wrong-structured lhs"), }; let rhses = match &argument_map[&MacroRulesNormalizedIdent::new(rhs_nm)] { @@ -536,10 +533,10 @@ pub fn compile_declarative_macro( .pop() .unwrap(); } - sess.parse_sess.span_diagnostic.span_bug(def.span, "wrong-structured rhs") + sess.diagnostic().span_bug(def.span, "wrong-structured rhs") }) .collect::>(), - _ => sess.parse_sess.span_diagnostic.span_bug(def.span, "wrong-structured rhs"), + _ => sess.diagnostic().span_bug(def.span, "wrong-structured rhs"), }; for rhs in &rhses { @@ -595,7 +592,7 @@ pub fn compile_declarative_macro( mbe::TokenTree::Delimited(_, delimited) => { mbe::macro_parser::compute_locs(&delimited.tts) } - _ => sess.parse_sess.span_diagnostic.span_bug(def.span, "malformed macro lhs"), + _ => sess.diagnostic().span_bug(def.span, "malformed macro lhs"), } }) .collect() diff --git a/compiler/rustc_expand/src/proc_macro.rs b/compiler/rustc_expand/src/proc_macro.rs index 39a16259fa6..d08026b9c14 100644 --- a/compiler/rustc_expand/src/proc_macro.rs +++ b/compiler/rustc_expand/src/proc_macro.rs @@ -156,7 +156,7 @@ impl MultiItemModifier for DeriveProcMacro { } }; - let error_count_before = ecx.sess.parse_sess.span_diagnostic.err_count(); + let error_count_before = ecx.sess.diagnostic().err_count(); let mut parser = rustc_parse::stream_to_parser(&ecx.sess.parse_sess, stream, Some("proc-macro derive")); let mut items = vec![]; @@ -179,7 +179,7 @@ impl MultiItemModifier for DeriveProcMacro { } // fail if there have been errors emitted - if ecx.sess.parse_sess.span_diagnostic.err_count() > error_count_before { + if ecx.sess.diagnostic().err_count() > error_count_before { ecx.sess.emit_err(errors::ProcMacroDeriveTokens { span }); } diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index 7dd19c8e15f..8fe6c1b0d86 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -374,7 +374,7 @@ impl<'tcx> InferCtxt<'tcx> { multi_suggestions, bad_label, } - .into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic), + .into_diagnostic(self.tcx.sess.diagnostic()), TypeAnnotationNeeded::E0283 => AmbiguousImpl { span, source_kind, @@ -384,7 +384,7 @@ impl<'tcx> InferCtxt<'tcx> { multi_suggestions, bad_label, } - .into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic), + .into_diagnostic(self.tcx.sess.diagnostic()), TypeAnnotationNeeded::E0284 => AmbiguousReturn { span, source_kind, @@ -394,7 +394,7 @@ impl<'tcx> InferCtxt<'tcx> { multi_suggestions, bad_label, } - .into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic), + .into_diagnostic(self.tcx.sess.diagnostic()), } } } @@ -581,7 +581,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { multi_suggestions, bad_label: None, } - .into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic), + .into_diagnostic(self.tcx.sess.diagnostic()), TypeAnnotationNeeded::E0283 => AmbiguousImpl { span, source_kind, @@ -591,7 +591,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { multi_suggestions, bad_label: None, } - .into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic), + .into_diagnostic(self.tcx.sess.diagnostic()), TypeAnnotationNeeded::E0284 => AmbiguousReturn { span, source_kind, @@ -601,7 +601,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { multi_suggestions, bad_label: None, } - .into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic), + .into_diagnostic(self.tcx.sess.diagnostic()), } } } diff --git a/compiler/rustc_infer/src/infer/error_reporting/note.rs b/compiler/rustc_infer/src/infer/error_reporting/note.rs index 781cc192ae5..fed76cd65cf 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note.rs @@ -140,7 +140,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { span, notes: reference_valid.into_iter().chain(content_valid).collect(), } - .into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic) + .into_diagnostic(self.tcx.sess.diagnostic()) } infer::RelateObjectBound(span) => { let object_valid = note_and_explain::RegionExplanation::new( @@ -161,7 +161,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { span, notes: object_valid.into_iter().chain(pointer_valid).collect(), } - .into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic) + .into_diagnostic(self.tcx.sess.diagnostic()) } infer::RelateParamBound(span, ty, opt_span) => { let prefix = match *sub { @@ -177,7 +177,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { self.tcx, sub, opt_span, prefix, suffix, ); FulfillReqLifetime { span, ty: self.resolve_vars_if_possible(ty), note } - .into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic) + .into_diagnostic(self.tcx.sess.diagnostic()) } infer::RelateRegionParamBound(span) => { let param_instantiated = note_and_explain::RegionExplanation::new( @@ -198,7 +198,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { span, notes: param_instantiated.into_iter().chain(param_must_outlive).collect(), } - .into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic) + .into_diagnostic(self.tcx.sess.diagnostic()) } infer::ReferenceOutlivesReferent(ty, span) => { let pointer_valid = note_and_explain::RegionExplanation::new( @@ -220,7 +220,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ty: self.resolve_vars_if_possible(ty), notes: pointer_valid.into_iter().chain(data_valid).collect(), } - .into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic) + .into_diagnostic(self.tcx.sess.diagnostic()) } infer::CompareImplItemObligation { span, impl_item_def_id, trait_item_def_id } => { let mut err = self.report_extra_impl_obligation( @@ -281,7 +281,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { span, notes: instantiated.into_iter().chain(must_outlive).collect(), } - .into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic) + .into_diagnostic(self.tcx.sess.diagnostic()) } }; if sub.is_error() || sup.is_error() { diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 88212d164bc..fab8a18f2dc 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -519,9 +519,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P match result { Ok(_) => { if sess.opts.json_artifact_notifications { - sess.parse_sess - .span_diagnostic - .emit_artifact_notification(deps_filename, "dep-info"); + sess.diagnostic().emit_artifact_notification(deps_filename, "dep-info"); } } Err(error) => { diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index a616dbf929e..301e3f2620d 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -267,7 +267,7 @@ impl CStore { let unused_externs = self.unused_externs.iter().map(|ident| ident.to_ident_string()).collect::>(); let unused_externs = unused_externs.iter().map(String::as_str).collect::>(); - tcx.sess.parse_sess.span_diagnostic.emit_unused_externs( + tcx.sess.diagnostic().emit_unused_externs( level, json_unused_externs.is_loud(), &unused_externs, diff --git a/compiler/rustc_metadata/src/fs.rs b/compiler/rustc_metadata/src/fs.rs index 4b451253f2b..c95ef01faa7 100644 --- a/compiler/rustc_metadata/src/fs.rs +++ b/compiler/rustc_metadata/src/fs.rs @@ -91,10 +91,7 @@ pub fn encode_and_write_metadata(tcx: TyCtxt<'_>) -> (EncodedMetadata, bool) { } }; if tcx.sess.opts.json_artifact_notifications { - tcx.sess - .parse_sess - .span_diagnostic - .emit_artifact_notification(out_filename.as_path(), "metadata"); + tcx.sess.diagnostic().emit_artifact_notification(out_filename.as_path(), "metadata"); } (filename, None) } else { diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs index 2a55ec72c5f..d933f897833 100644 --- a/compiler/rustc_query_system/src/query/job.rs +++ b/compiler/rustc_query_system/src/query/job.rs @@ -605,7 +605,7 @@ pub(crate) fn report_cycle<'a>( note_span: (), }; - cycle_diag.into_diagnostic(&sess.parse_sess.span_diagnostic) + cycle_diag.into_diagnostic(sess.diagnostic()) } pub fn print_query_stack( diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 60139f5d18b..ce94a3a72ea 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -302,7 +302,7 @@ impl Session { if diags.is_empty() { return; } - self.parse_sess.span_diagnostic.emit_future_breakage_report(diags); + self.diagnostic().emit_future_breakage_report(diags); } /// Returns true if the crate is a testing one.