Skip to content

Commit 0011fac

Browse files
committed
Auto merge of rust-lang#120017 - nnethercote:lint-api, r=oli-obk
Fix naming in the lint API Methods for emit lints are named very inconsistently. This PR fixes that up. r? `@compiler-errors`
2 parents d6b151f + 15a4c4f commit 0011fac

File tree

96 files changed

+353
-376
lines changed

Some content is hidden

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

96 files changed

+353
-376
lines changed

Diff for: compiler/rustc_borrowck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ fn do_mir_borrowck<'tcx>(
415415

416416
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
417417

418-
tcx.emit_spanned_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span })
418+
tcx.emit_node_span_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span })
419419
}
420420

421421
let tainted_by_errors = mbcx.emit_errors();

Diff for: compiler/rustc_codegen_ssa/src/codegen_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
563563
if codegen_fn_attrs.inline == InlineAttr::Always {
564564
if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) {
565565
let hir_id = tcx.local_def_id_to_hir_id(did);
566-
tcx.struct_span_lint_hir(
566+
tcx.node_span_lint(
567567
lint::builtin::INLINE_NO_SANITIZE,
568568
hir_id,
569569
no_sanitize_span,

Diff for: compiler/rustc_const_eval/src/const_eval/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub(super) fn lint<'tcx, 'mir, L>(
175175
{
176176
let (span, frames) = get_span_and_frames(tcx, machine);
177177

178-
tcx.emit_spanned_lint(
178+
tcx.emit_node_span_lint(
179179
lint,
180180
// We use the root frame for this so the crate that defines the const defines whether the
181181
// lint is emitted.

Diff for: compiler/rustc_const_eval/src/const_eval/machine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
611611
.0
612612
.is_error();
613613
let span = ecx.cur_span();
614-
ecx.tcx.emit_spanned_lint(
614+
ecx.tcx.emit_node_span_lint(
615615
rustc_session::lint::builtin::LONG_RUNNING_CONST_EVAL,
616616
hir_id,
617617
span,

Diff for: compiler/rustc_hir_analysis/src/astconv/generics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes(
656656
} else {
657657
let mut multispan = MultiSpan::from_span(span);
658658
multispan.push_span_label(span_late, note);
659-
tcx.struct_span_lint_hir(
659+
tcx.node_span_lint(
660660
LATE_BOUND_LIFETIME_ARGUMENTS,
661661
args.args[0].hir_id(),
662662
multispan,

Diff for: compiler/rustc_hir_analysis/src/astconv/lint.rs

+12-18
Original file line numberDiff line numberDiff line change
@@ -240,24 +240,18 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
240240
diag.stash(self_ty.span, StashKey::TraitMissingMethod);
241241
} else {
242242
let msg = "trait objects without an explicit `dyn` are deprecated";
243-
tcx.struct_span_lint_hir(
244-
BARE_TRAIT_OBJECTS,
245-
self_ty.hir_id,
246-
self_ty.span,
247-
msg,
248-
|lint| {
249-
if self_ty.span.can_be_used_for_suggestions()
250-
&& !self.maybe_lint_impl_trait(self_ty, lint)
251-
{
252-
lint.multipart_suggestion_verbose(
253-
"use `dyn`",
254-
sugg,
255-
Applicability::MachineApplicable,
256-
);
257-
}
258-
self.maybe_lint_blanket_trait_impl(self_ty, lint);
259-
},
260-
);
243+
tcx.node_span_lint(BARE_TRAIT_OBJECTS, self_ty.hir_id, self_ty.span, msg, |lint| {
244+
if self_ty.span.can_be_used_for_suggestions()
245+
&& !self.maybe_lint_impl_trait(self_ty, lint)
246+
{
247+
lint.multipart_suggestion_verbose(
248+
"use `dyn`",
249+
sugg,
250+
Applicability::MachineApplicable,
251+
);
252+
}
253+
self.maybe_lint_blanket_trait_impl(self_ty, lint);
254+
});
261255
}
262256
}
263257
}

Diff for: compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
13941394
let ty = self.projected_ty_from_poly_trait_ref(span, assoc_ty_did, assoc_segment, bound);
13951395

13961396
if let Some(variant_def_id) = variant_resolution {
1397-
tcx.struct_span_lint_hir(
1397+
tcx.node_span_lint(
13981398
AMBIGUOUS_ASSOCIATED_ITEMS,
13991399
hir_ref_id,
14001400
span,

Diff for: compiler/rustc_hir_analysis/src/astconv/object_safety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
220220
let def_id = projection_bound.projection_def_id();
221221
def_ids.remove(&def_id);
222222
if tcx.generics_require_sized_self(def_id) {
223-
tcx.emit_spanned_lint(
223+
tcx.emit_node_span_lint(
224224
UNUSED_ASSOCIATED_TYPE_BOUNDS,
225225
hir_id,
226226
*span,

Diff for: compiler/rustc_hir_analysis/src/check/check.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
4646
.emit();
4747
}
4848
None => {
49-
tcx.struct_span_lint_hir(
49+
tcx.node_span_lint(
5050
UNSUPPORTED_CALLING_CONVENTIONS,
5151
hir_id,
5252
span,
@@ -183,7 +183,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
183183
}
184184
};
185185
if layout.abi.is_uninhabited() {
186-
tcx.struct_span_lint_hir(
186+
tcx.node_span_lint(
187187
UNINHABITED_STATIC,
188188
tcx.local_def_id_to_hir_id(def_id),
189189
span,
@@ -1079,7 +1079,7 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
10791079
// If there are any non-trivial fields, then there can be no non-exhaustive 1-zsts.
10801080
// Otherwise, it's only an issue if there's >1 non-exhaustive 1-zst.
10811081
if non_trivial_count > 0 || prev_non_exhaustive_1zst {
1082-
tcx.struct_span_lint_hir(
1082+
tcx.node_span_lint(
10831083
REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS,
10841084
tcx.local_def_id_to_hir_id(adt.did().expect_local()),
10851085
span,

Diff for: compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ fn report_mismatched_rpitit_signature<'tcx>(
283283
});
284284

285285
let span = unmatched_bound.unwrap_or(span);
286-
tcx.emit_spanned_lint(
286+
tcx.emit_node_span_lint(
287287
REFINING_IMPL_TRAIT,
288288
tcx.local_def_id_to_hir_id(impl_m_def_id.expect_local()),
289289
span,

Diff for: compiler/rustc_hir_analysis/src/check/errs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn handle_static_mut_ref(
8888
"shared ",
8989
)
9090
};
91-
tcx.emit_spanned_lint(
91+
tcx.emit_node_span_lint(
9292
STATIC_MUT_REF,
9393
hir_id,
9494
span,

Diff for: compiler/rustc_hir_analysis/src/check/intrinsicck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
270270
if !spans.is_empty() {
271271
let (default_modifier, default_result) =
272272
reg_class.default_modifier(asm_arch).unwrap();
273-
self.tcx.struct_span_lint_hir(
273+
self.tcx.node_span_lint(
274274
lint::builtin::ASM_SUB_REGISTER,
275275
expr.hir_id,
276276
spans,

Diff for: compiler/rustc_hir_analysis/src/check_unused.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ fn check_unused_traits(tcx: TyCtxt<'_>, (): ()) {
4040
} else {
4141
"unused import".to_owned()
4242
};
43-
tcx.struct_span_lint_hir(
44-
lint::builtin::UNUSED_IMPORTS,
45-
item.hir_id(),
46-
path.span,
47-
msg,
48-
|_| {},
49-
);
43+
tcx.node_span_lint(lint::builtin::UNUSED_IMPORTS, item.hir_id(), path.span, msg, |_| {});
5044
}
5145
}

Diff for: compiler/rustc_hir_analysis/src/coherence/orphan.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ fn lint_auto_trait_impl<'tcx>(
495495
return;
496496
}
497497

498-
tcx.struct_span_lint_hir(
498+
tcx.node_span_lint(
499499
lint::builtin::SUSPICIOUS_AUTO_TRAIT_IMPLS,
500500
tcx.local_def_id_to_hir_id(impl_def_id),
501501
tcx.def_span(impl_def_id),

Diff for: compiler/rustc_hir_analysis/src/collect/generics_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
274274
Defaults::FutureCompatDisallowed
275275
if tcx.features().default_type_parameter_fallback => {}
276276
Defaults::FutureCompatDisallowed => {
277-
tcx.struct_span_lint_hir(
277+
tcx.node_span_lint(
278278
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,
279279
param.hir_id,
280280
param.span,

Diff for: compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
912912
continue;
913913
}
914914
self.insert_lifetime(lt, ResolvedArg::StaticLifetime);
915-
self.tcx.struct_span_lint_hir(
915+
self.tcx.node_span_lint(
916916
lint::builtin::UNUSED_LIFETIMES,
917917
lifetime.hir_id,
918918
lifetime.ident.span,

Diff for: compiler/rustc_hir_typeck/src/cast.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
587587
};
588588
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
589589
let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty);
590-
fcx.tcx.emit_spanned_lint(
590+
fcx.tcx.emit_node_span_lint(
591591
lint,
592592
self.expr.hir_id,
593593
self.span,
@@ -900,7 +900,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
900900
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
901901
let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty);
902902

903-
fcx.tcx.emit_spanned_lint(
903+
fcx.tcx.emit_node_span_lint(
904904
lint::builtin::CENUM_IMPL_DROP_CAST,
905905
self.expr.hir_id,
906906
self.span,
@@ -934,7 +934,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
934934
};
935935

936936
let lint = errors::LossyProvenancePtr2Int { expr_ty, cast_ty, sugg };
937-
fcx.tcx.emit_spanned_lint(
937+
fcx.tcx.emit_node_span_lint(
938938
lint::builtin::LOSSY_PROVENANCE_CASTS,
939939
self.expr.hir_id,
940940
self.span,
@@ -950,7 +950,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
950950
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
951951
let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty);
952952
let lint = errors::LossyProvenanceInt2Ptr { expr_ty, cast_ty, sugg };
953-
fcx.tcx.emit_spanned_lint(
953+
fcx.tcx.emit_node_span_lint(
954954
lint::builtin::FUZZY_PROVENANCE_CASTS,
955955
self.expr.hir_id,
956956
self.span,

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
6262
debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind);
6363

6464
let msg = format!("unreachable {kind}");
65-
self.tcx().struct_span_lint_hir(
65+
self.tcx().node_span_lint(
6666
lint::builtin::UNREACHABLE_CODE,
6767
id,
6868
span,

Diff for: compiler/rustc_hir_typeck/src/method/prelude2021.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7777

7878
// Inherent impls only require not relying on autoref and autoderef in order to
7979
// ensure that the trait implementation won't be used
80-
self.tcx.struct_span_lint_hir(
80+
self.tcx.node_span_lint(
8181
prelude_or_array_lint,
8282
self_expr.hir_id,
8383
self_expr.span,
@@ -127,7 +127,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
127127
} else {
128128
// trait implementations require full disambiguation to not clash with the new prelude
129129
// additions (i.e. convert from dot-call to fully-qualified call)
130-
self.tcx.struct_span_lint_hir(
130+
self.tcx.node_span_lint(
131131
prelude_or_array_lint,
132132
call_expr.hir_id,
133133
call_expr.span,
@@ -238,7 +238,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
238238
return;
239239
}
240240

241-
self.tcx.struct_span_lint_hir(
241+
self.tcx.node_span_lint(
242242
RUST_2021_PRELUDE_COLLISIONS,
243243
expr_id,
244244
span,

Diff for: compiler/rustc_hir_typeck/src/method/probe.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
440440
if self.tcx.sess.at_least_rust_2018() {
441441
self.dcx().emit_err(MethodCallOnUnknownRawPointee { span });
442442
} else {
443-
self.tcx.struct_span_lint_hir(
443+
self.tcx.node_span_lint(
444444
lint::builtin::TYVAR_BEHIND_RAW_POINTER,
445445
scope_expr_id,
446446
span,
@@ -1380,7 +1380,7 @@ impl<'tcx> Pick<'tcx> {
13801380
return;
13811381
}
13821382
let def_kind = self.item.kind.as_def_kind();
1383-
tcx.struct_span_lint_hir(
1383+
tcx.node_span_lint(
13841384
lint::builtin::UNSTABLE_NAME_COLLISIONS,
13851385
scope_expr_id,
13861386
span,

Diff for: compiler/rustc_hir_typeck/src/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18401840
&unmentioned_fields.iter().map(|(_, i)| i).collect::<Vec<_>>(),
18411841
);
18421842

1843-
self.tcx.struct_span_lint_hir(NON_EXHAUSTIVE_OMITTED_PATTERNS, pat.hir_id, pat.span, "some fields are not explicitly listed", |lint| {
1843+
self.tcx.node_span_lint(NON_EXHAUSTIVE_OMITTED_PATTERNS, pat.hir_id, pat.span, "some fields are not explicitly listed", |lint| {
18441844
lint.span_label(pat.span, format!("field{} {} not listed", rustc_errors::pluralize!(unmentioned_fields.len()), joined_patterns));
18451845
lint.help(
18461846
"ensure that all fields are mentioned explicitly by adding the suggested fields",

Diff for: compiler/rustc_hir_typeck/src/upvar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
754754

755755
let closure_hir_id = self.tcx.local_def_id_to_hir_id(closure_def_id);
756756
let closure_head_span = self.tcx.def_span(closure_def_id);
757-
self.tcx.struct_span_lint_hir(
757+
self.tcx.node_span_lint(
758758
lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
759759
closure_hir_id,
760760
closure_head_span,

Diff for: compiler/rustc_lint/src/array_into_iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
132132
} else {
133133
None
134134
};
135-
cx.emit_spanned_lint(
135+
cx.emit_span_lint(
136136
ARRAY_INTO_ITER,
137137
call.ident.span,
138138
ArrayIntoIterDiag { target, suggestion: call.ident.span, sub },

Diff for: compiler/rustc_lint/src/async_fn_in_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<'tcx> LateLintPass<'tcx> for AsyncFnInTrait {
116116
def.owner_id.def_id,
117117
" + Send",
118118
);
119-
cx.tcx.emit_spanned_lint(
119+
cx.tcx.emit_node_span_lint(
120120
ASYNC_FN_IN_TRAIT,
121121
item.hir_id(),
122122
async_span,

0 commit comments

Comments
 (0)