Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 48dc9c9

Browse files
committed
Update all lint diagnostics to store their span
1 parent 1f6b731 commit 48dc9c9

File tree

85 files changed

+1530
-1092
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1530
-1092
lines changed

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ fn do_mir_borrowck<'tcx>(
401401

402402
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
403403

404-
tcx.emit_node_span_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span })
404+
tcx.emit_node_lint(UNUSED_MUT, lint_root, VarNeedNotMut { span, mut_span })
405405
}
406406

407407
let tainted_by_errors = mbcx.emit_errors();

compiler/rustc_borrowck/src/session_diagnostics.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ pub(crate) struct GenericDoesNotLiveLongEnough {
5050
#[derive(LintDiagnostic)]
5151
#[diag(borrowck_var_does_not_need_mut)]
5252
pub(crate) struct VarNeedNotMut {
53-
#[suggestion(style = "short", applicability = "machine-applicable", code = "")]
53+
#[primary_span]
5454
pub span: Span,
55+
#[suggestion(style = "short", applicability = "machine-applicable", code = "")]
56+
pub mut_span: Span,
5557
}
5658
#[derive(Diagnostic)]
5759
#[diag(borrowck_var_cannot_escape_closure)]

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ pub(super) fn lint<'tcx, L>(
170170
tcx: TyCtxtAt<'tcx>,
171171
machine: &CompileTimeMachine<'tcx>,
172172
lint: &'static rustc_session::lint::Lint,
173-
decorator: impl FnOnce(Vec<errors::FrameNote>) -> L,
173+
decorator: impl FnOnce(Span, Vec<errors::FrameNote>) -> L,
174174
) where
175175
L: for<'a> rustc_errors::LintDiagnostic<'a, ()>,
176176
{
177177
let (span, frames) = get_span_and_frames(tcx, &machine.stack);
178178

179-
tcx.emit_node_span_lint(lint, machine.best_lint_scope(*tcx), span, decorator(frames));
179+
tcx.emit_node_lint(lint, machine.best_lint_scope(*tcx), decorator(span, frames));
180180
}

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,10 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
622622
.0
623623
.is_error();
624624
let span = ecx.cur_span();
625-
ecx.tcx.emit_node_span_lint(
625+
ecx.tcx.emit_node_lint(
626626
rustc_session::lint::builtin::LONG_RUNNING_CONST_EVAL,
627627
hir_id,
628-
span,
629-
LongRunning { item_span: ecx.tcx.span },
628+
LongRunning { span, item_span: ecx.tcx.span },
630629
);
631630
// If this was a hard error, don't bother continuing evaluation.
632631
if is_error {

compiler/rustc_const_eval/src/errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ pub(crate) struct InteriorMutableRefEscaping {
197197
#[diag(const_eval_long_running)]
198198
#[note]
199199
pub struct LongRunning {
200+
#[primary_span]
201+
pub span: Span,
200202
#[help]
201203
pub item_span: Span,
202204
}

compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,11 @@ fn report_mismatched_rpitit_signature<'tcx>(
297297
});
298298

299299
let span = unmatched_bound.unwrap_or(span);
300-
tcx.emit_node_span_lint(
300+
tcx.emit_node_lint(
301301
if is_internal { REFINING_IMPL_TRAIT_INTERNAL } else { REFINING_IMPL_TRAIT_REACHABLE },
302302
tcx.local_def_id_to_hir_id(impl_m_def_id.expect_local()),
303-
span,
304303
crate::errors::ReturnPositionImplTraitInTraitRefined {
304+
span,
305305
impl_return_span,
306306
trait_return_span,
307307
pre,

compiler/rustc_hir_analysis/src/check/errs.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ fn handle_static_mut_ref(
7979
} else {
8080
(errors::MutRefSugg::Shared { lo, hi }, "shared")
8181
};
82-
tcx.emit_node_span_lint(STATIC_MUT_REFS, hir_id, span, errors::RefOfMutStatic {
83-
span,
84-
sugg,
85-
shared,
86-
});
82+
tcx.emit_node_lint(STATIC_MUT_REFS, hir_id, errors::RefOfMutStatic { span, sugg, shared });
8783
}
8884
}

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,11 +2334,10 @@ fn lint_redundant_lifetimes<'tcx>(
23342334
&& outlives_env.free_region_map().sub_free_regions(tcx, victim, candidate)
23352335
{
23362336
shadowed.insert(victim);
2337-
tcx.emit_node_span_lint(
2337+
tcx.emit_node_lint(
23382338
rustc_lint_defs::builtin::REDUNDANT_LIFETIMES,
23392339
tcx.local_def_id_to_hir_id(def_id.expect_local()),
2340-
tcx.def_span(def_id),
2341-
RedundantLifetimeArgsLint { candidate, victim },
2340+
RedundantLifetimeArgsLint { span: tcx.def_span(def_id), candidate, victim },
23422341
);
23432342
}
23442343
}
@@ -2349,6 +2348,8 @@ fn lint_redundant_lifetimes<'tcx>(
23492348
#[diag(hir_analysis_redundant_lifetime_args)]
23502349
#[note]
23512350
struct RedundantLifetimeArgsLint<'tcx> {
2351+
#[primary_span]
2352+
pub span: Span,
23522353
/// The lifetime we have found to be redundant.
23532354
victim: ty::Region<'tcx>,
23542355
// The lifetime we can replace the victim with.

compiler/rustc_hir_analysis/src/coherence/orphan.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -494,18 +494,18 @@ fn lint_uncovered_ty_params<'tcx>(
494494
let name = tcx.item_name(param_def_id);
495495

496496
match local_ty {
497-
Some(local_type) => tcx.emit_node_span_lint(
497+
Some(local_type) => tcx.emit_node_lint(
498498
UNCOVERED_PARAM_IN_PROJECTION,
499499
hir_id,
500-
span,
501500
errors::TyParamFirstLocalLint { span, note: (), param: name, local_type },
502501
),
503-
None => tcx.emit_node_span_lint(
504-
UNCOVERED_PARAM_IN_PROJECTION,
505-
hir_id,
506-
span,
507-
errors::TyParamSomeLint { span, note: (), param: name },
508-
),
502+
None => {
503+
tcx.emit_node_lint(UNCOVERED_PARAM_IN_PROJECTION, hir_id, errors::TyParamSomeLint {
504+
span,
505+
note: (),
506+
param: name,
507+
})
508+
}
509509
};
510510
}
511511
}

compiler/rustc_hir_analysis/src/errors.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,7 @@ pub(crate) enum LateBoundInApit {
11321132
#[diag(hir_analysis_unused_associated_type_bounds)]
11331133
#[note]
11341134
pub(crate) struct UnusedAssociatedTypeBounds {
1135+
#[primary_span]
11351136
#[suggestion(code = "")]
11361137
pub span: Span,
11371138
}
@@ -1141,6 +1142,8 @@ pub(crate) struct UnusedAssociatedTypeBounds {
11411142
#[note]
11421143
#[note(hir_analysis_feedback_note)]
11431144
pub(crate) struct ReturnPositionImplTraitInTraitRefined<'tcx> {
1145+
#[primary_span]
1146+
pub span: Span,
11441147
#[suggestion(applicability = "maybe-incorrect", code = "{pre}{return_ty}{post}")]
11451148
pub impl_return_span: Span,
11461149
#[label]
@@ -1398,6 +1401,7 @@ pub(crate) struct TyParamFirstLocal<'tcx> {
13981401
#[diag(hir_analysis_ty_param_first_local, code = E0210)]
13991402
#[note]
14001403
pub(crate) struct TyParamFirstLocalLint<'tcx> {
1404+
#[primary_span]
14011405
#[label]
14021406
pub span: Span,
14031407
#[note(hir_analysis_case_note)]
@@ -1422,6 +1426,7 @@ pub(crate) struct TyParamSome {
14221426
#[diag(hir_analysis_ty_param_some, code = E0210)]
14231427
#[note]
14241428
pub(crate) struct TyParamSomeLint {
1429+
#[primary_span]
14251430
#[label]
14261431
pub span: Span,
14271432
#[note(hir_analysis_only_note)]

0 commit comments

Comments
 (0)