Skip to content

Commit a179a53

Browse files
committed
Use Session::diagnostic in more places.
1 parent 6e95739 commit a179a53

File tree

21 files changed

+51
-66
lines changed

21 files changed

+51
-66
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl<'a> PostExpansionVisitor<'a> {
102102
}
103103
Err(abi::AbiDisabled::Unrecognized) => {
104104
if self.sess.opts.pretty.map_or(true, |ppm| ppm.needs_hir()) {
105-
self.sess.parse_sess.span_diagnostic.span_delayed_bug(
105+
self.sess.diagnostic().span_delayed_bug(
106106
span,
107107
format!(
108108
"unrecognized ABI not caught in lowering: {}",
@@ -628,7 +628,7 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate)
628628
if all_stable {
629629
err.sugg = Some(attr.span);
630630
}
631-
sess.parse_sess.span_diagnostic.emit_err(err);
631+
sess.diagnostic().emit_err(err);
632632
}
633633
}
634634
}

compiler/rustc_attr/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
945945
assert!(attr.has_name(sym::repr), "expected `#[repr(..)]`, found: {attr:?}");
946946
use ReprAttr::*;
947947
let mut acc = Vec::new();
948-
let diagnostic = &sess.parse_sess.span_diagnostic;
948+
let diagnostic = sess.diagnostic();
949949

950950
if let Some(items) = attr.meta_item_list() {
951951
for item in items {

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11351135
});
11361136
} else {
11371137
issued_spans.var_subdiag(
1138-
Some(&self.infcx.tcx.sess.parse_sess.span_diagnostic),
1138+
Some(self.infcx.tcx.sess.diagnostic()),
11391139
&mut err,
11401140
Some(issued_borrow.kind),
11411141
|kind, var_span| {
@@ -1152,7 +1152,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11521152
);
11531153

11541154
borrow_spans.var_subdiag(
1155-
Some(&self.infcx.tcx.sess.parse_sess.span_diagnostic),
1155+
Some(self.infcx.tcx.sess.diagnostic()),
11561156
&mut err,
11571157
Some(gen_borrow_kind),
11581158
|kind, var_span| {

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
124124
let did = did.expect_local();
125125
if let Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) {
126126
diag.eager_subdiagnostic(
127-
&self.infcx.tcx.sess.parse_sess.span_diagnostic,
127+
self.infcx.tcx.sess.diagnostic(),
128128
OnClosureNote::InvokedTwice {
129129
place_name: &ty::place_to_string_for_capture(
130130
self.infcx.tcx,
@@ -146,7 +146,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
146146
let did = did.expect_local();
147147
if let Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) {
148148
diag.eager_subdiagnostic(
149-
&self.infcx.tcx.sess.parse_sess.span_diagnostic,
149+
self.infcx.tcx.sess.diagnostic(),
150150
OnClosureNote::MovedTwice {
151151
place_name: &ty::place_to_string_for_capture(self.infcx.tcx, hir_place),
152152
span: *span,
@@ -1119,7 +1119,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11191119
&& self.infcx.can_eq(self.param_env, ty, self_ty)
11201120
{
11211121
err.eager_subdiagnostic(
1122-
&self.infcx.tcx.sess.parse_sess.span_diagnostic,
1122+
self.infcx.tcx.sess.diagnostic(),
11231123
CaptureReasonSuggest::FreshReborrow {
11241124
span: move_span.shrink_to_hi(),
11251125
},

compiler/rustc_builtin_macros/src/alloc_error_handler.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ pub fn expand(
3131
{
3232
(item, true, ecx.with_def_site_ctxt(fn_kind.sig.span))
3333
} else {
34-
ecx.sess
35-
.parse_sess
36-
.span_diagnostic
37-
.emit_err(errors::AllocErrorMustBeFn { span: item.span() });
34+
ecx.sess.diagnostic().emit_err(errors::AllocErrorMustBeFn { span: item.span() });
3835
return vec![orig_item];
3936
};
4037

compiler/rustc_builtin_macros/src/global_allocator.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ pub fn expand(
3434
{
3535
(item, true, ecx.with_def_site_ctxt(ty.span))
3636
} else {
37-
ecx.sess
38-
.parse_sess
39-
.span_diagnostic
40-
.emit_err(errors::AllocMustStatics { span: item.span() });
37+
ecx.sess.diagnostic().emit_err(errors::AllocMustStatics { span: item.span() });
4138
return vec![orig_item];
4239
};
4340

compiler/rustc_builtin_macros/src/test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ pub fn expand_test_or_bench(
389389
}
390390

391391
fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) {
392-
let diag = &cx.sess.parse_sess.span_diagnostic;
392+
let diag = cx.sess.diagnostic();
393393
let msg = "the `#[test]` attribute may only be used on a non-associated function";
394394
let mut err = match item.map(|i| &i.kind) {
395395
// 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<Symbol> {
466466
fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
467467
match attr::find_by_name(&i.attrs, sym::should_panic) {
468468
Some(attr) => {
469-
let sd = &cx.sess.parse_sess.span_diagnostic;
469+
let sd = cx.sess.diagnostic();
470470

471471
match attr.meta_item_list() {
472472
// Handle #[should_panic(expected = "foo")]
@@ -535,7 +535,7 @@ fn check_test_signature(
535535
f: &ast::Fn,
536536
) -> Result<(), ErrorGuaranteed> {
537537
let has_should_panic_attr = attr::contains_name(&i.attrs, sym::should_panic);
538-
let sd = &cx.sess.parse_sess.span_diagnostic;
538+
let sd = cx.sess.diagnostic();
539539

540540
if let ast::Unsafe::Yes(span) = f.sig.header.unsafety {
541541
return Err(sd.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "unsafe" }));
@@ -579,7 +579,7 @@ fn check_bench_signature(
579579
// N.B., inadequate check, but we're running
580580
// well before resolve, can't get too deep.
581581
if f.sig.decl.inputs.len() != 1 {
582-
return Err(cx.sess.parse_sess.span_diagnostic.emit_err(errors::BenchSig { span: i.span }));
582+
return Err(cx.sess.diagnostic().emit_err(errors::BenchSig { span: i.span }));
583583
}
584584
Ok(())
585585
}

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub fn link_binary<'a>(
143143
}
144144
}
145145
if sess.opts.json_artifact_notifications {
146-
sess.parse_sess.span_diagnostic.emit_artifact_notification(&out_filename, "link");
146+
sess.diagnostic().emit_artifact_notification(&out_filename, "link");
147147
}
148148

149149
if sess.prof.enabled() {

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ where
148148
let mut err = tcx.sess.create_err(err);
149149

150150
let msg = error.diagnostic_message();
151-
error.add_args(&tcx.sess.parse_sess.span_diagnostic, &mut err);
151+
error.add_args(tcx.sess.diagnostic(), &mut err);
152152

153153
// Use *our* span to label the interp error
154154
err.span_label(our_span, msg);

compiler/rustc_const_eval/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ pub trait ReportErrorExt {
437437
{
438438
ty::tls::with(move |tcx| {
439439
let mut builder = tcx.sess.struct_allow(DiagnosticMessage::Str(String::new().into()));
440-
let handler = &tcx.sess.parse_sess.span_diagnostic;
440+
let handler = tcx.sess.diagnostic();
441441
let message = self.diagnostic_message();
442442
self.add_args(handler, &mut builder);
443443
let s = handler.eagerly_translate_to_string(message, builder.args());

0 commit comments

Comments
 (0)