Rename TyCtxt::struct_span_lint_hir as TyCtxt::node_span_lint.
This commit is contained in:
@@ -563,7 +563,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
if codegen_fn_attrs.inline == InlineAttr::Always {
|
||||
if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) {
|
||||
let hir_id = tcx.local_def_id_to_hir_id(did);
|
||||
tcx.struct_span_lint_hir(
|
||||
tcx.node_span_lint(
|
||||
lint::builtin::INLINE_NO_SANITIZE,
|
||||
hir_id,
|
||||
no_sanitize_span,
|
||||
|
||||
@@ -656,7 +656,7 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes(
|
||||
} else {
|
||||
let mut multispan = MultiSpan::from_span(span);
|
||||
multispan.push_span_label(span_late, note);
|
||||
tcx.struct_span_lint_hir(
|
||||
tcx.node_span_lint(
|
||||
LATE_BOUND_LIFETIME_ARGUMENTS,
|
||||
args.args[0].hir_id(),
|
||||
multispan,
|
||||
|
||||
@@ -240,24 +240,18 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
diag.stash(self_ty.span, StashKey::TraitMissingMethod);
|
||||
} else {
|
||||
let msg = "trait objects without an explicit `dyn` are deprecated";
|
||||
tcx.struct_span_lint_hir(
|
||||
BARE_TRAIT_OBJECTS,
|
||||
self_ty.hir_id,
|
||||
self_ty.span,
|
||||
msg,
|
||||
|lint| {
|
||||
if self_ty.span.can_be_used_for_suggestions()
|
||||
&& !self.maybe_lint_impl_trait(self_ty, lint)
|
||||
{
|
||||
lint.multipart_suggestion_verbose(
|
||||
"use `dyn`",
|
||||
sugg,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
self.maybe_lint_blanket_trait_impl(self_ty, lint);
|
||||
},
|
||||
);
|
||||
tcx.node_span_lint(BARE_TRAIT_OBJECTS, self_ty.hir_id, self_ty.span, msg, |lint| {
|
||||
if self_ty.span.can_be_used_for_suggestions()
|
||||
&& !self.maybe_lint_impl_trait(self_ty, lint)
|
||||
{
|
||||
lint.multipart_suggestion_verbose(
|
||||
"use `dyn`",
|
||||
sugg,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
self.maybe_lint_blanket_trait_impl(self_ty, lint);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1394,7 +1394,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
let ty = self.projected_ty_from_poly_trait_ref(span, assoc_ty_did, assoc_segment, bound);
|
||||
|
||||
if let Some(variant_def_id) = variant_resolution {
|
||||
tcx.struct_span_lint_hir(
|
||||
tcx.node_span_lint(
|
||||
AMBIGUOUS_ASSOCIATED_ITEMS,
|
||||
hir_ref_id,
|
||||
span,
|
||||
|
||||
@@ -46,7 +46,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
|
||||
.emit();
|
||||
}
|
||||
None => {
|
||||
tcx.struct_span_lint_hir(
|
||||
tcx.node_span_lint(
|
||||
UNSUPPORTED_CALLING_CONVENTIONS,
|
||||
hir_id,
|
||||
span,
|
||||
@@ -183,7 +183,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
}
|
||||
};
|
||||
if layout.abi.is_uninhabited() {
|
||||
tcx.struct_span_lint_hir(
|
||||
tcx.node_span_lint(
|
||||
UNINHABITED_STATIC,
|
||||
tcx.local_def_id_to_hir_id(def_id),
|
||||
span,
|
||||
@@ -1079,7 +1079,7 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
|
||||
// If there are any non-trivial fields, then there can be no non-exhaustive 1-zsts.
|
||||
// Otherwise, it's only an issue if there's >1 non-exhaustive 1-zst.
|
||||
if non_trivial_count > 0 || prev_non_exhaustive_1zst {
|
||||
tcx.struct_span_lint_hir(
|
||||
tcx.node_span_lint(
|
||||
REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS,
|
||||
tcx.local_def_id_to_hir_id(adt.did().expect_local()),
|
||||
span,
|
||||
|
||||
@@ -270,7 +270,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||
if !spans.is_empty() {
|
||||
let (default_modifier, default_result) =
|
||||
reg_class.default_modifier(asm_arch).unwrap();
|
||||
self.tcx.struct_span_lint_hir(
|
||||
self.tcx.node_span_lint(
|
||||
lint::builtin::ASM_SUB_REGISTER,
|
||||
expr.hir_id,
|
||||
spans,
|
||||
|
||||
@@ -40,12 +40,6 @@ fn check_unused_traits(tcx: TyCtxt<'_>, (): ()) {
|
||||
} else {
|
||||
"unused import".to_owned()
|
||||
};
|
||||
tcx.struct_span_lint_hir(
|
||||
lint::builtin::UNUSED_IMPORTS,
|
||||
item.hir_id(),
|
||||
path.span,
|
||||
msg,
|
||||
|_| {},
|
||||
);
|
||||
tcx.node_span_lint(lint::builtin::UNUSED_IMPORTS, item.hir_id(), path.span, msg, |_| {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,7 +495,7 @@ fn lint_auto_trait_impl<'tcx>(
|
||||
return;
|
||||
}
|
||||
|
||||
tcx.struct_span_lint_hir(
|
||||
tcx.node_span_lint(
|
||||
lint::builtin::SUSPICIOUS_AUTO_TRAIT_IMPLS,
|
||||
tcx.local_def_id_to_hir_id(impl_def_id),
|
||||
tcx.def_span(impl_def_id),
|
||||
|
||||
@@ -274,7 +274,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
||||
Defaults::FutureCompatDisallowed
|
||||
if tcx.features().default_type_parameter_fallback => {}
|
||||
Defaults::FutureCompatDisallowed => {
|
||||
tcx.struct_span_lint_hir(
|
||||
tcx.node_span_lint(
|
||||
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,
|
||||
param.hir_id,
|
||||
param.span,
|
||||
|
||||
@@ -912,7 +912,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||
continue;
|
||||
}
|
||||
self.insert_lifetime(lt, ResolvedArg::StaticLifetime);
|
||||
self.tcx.struct_span_lint_hir(
|
||||
self.tcx.node_span_lint(
|
||||
lint::builtin::UNUSED_LIFETIMES,
|
||||
lifetime.hir_id,
|
||||
lifetime.ident.span,
|
||||
|
||||
@@ -62,7 +62,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind);
|
||||
|
||||
let msg = format!("unreachable {kind}");
|
||||
self.tcx().struct_span_lint_hir(
|
||||
self.tcx().node_span_lint(
|
||||
lint::builtin::UNREACHABLE_CODE,
|
||||
id,
|
||||
span,
|
||||
|
||||
@@ -77,7 +77,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
// Inherent impls only require not relying on autoref and autoderef in order to
|
||||
// ensure that the trait implementation won't be used
|
||||
self.tcx.struct_span_lint_hir(
|
||||
self.tcx.node_span_lint(
|
||||
prelude_or_array_lint,
|
||||
self_expr.hir_id,
|
||||
self_expr.span,
|
||||
@@ -127,7 +127,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
} else {
|
||||
// trait implementations require full disambiguation to not clash with the new prelude
|
||||
// additions (i.e. convert from dot-call to fully-qualified call)
|
||||
self.tcx.struct_span_lint_hir(
|
||||
self.tcx.node_span_lint(
|
||||
prelude_or_array_lint,
|
||||
call_expr.hir_id,
|
||||
call_expr.span,
|
||||
@@ -238,7 +238,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
self.tcx.struct_span_lint_hir(
|
||||
self.tcx.node_span_lint(
|
||||
RUST_2021_PRELUDE_COLLISIONS,
|
||||
expr_id,
|
||||
span,
|
||||
|
||||
@@ -440,7 +440,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
if self.tcx.sess.at_least_rust_2018() {
|
||||
self.dcx().emit_err(MethodCallOnUnknownRawPointee { span });
|
||||
} else {
|
||||
self.tcx.struct_span_lint_hir(
|
||||
self.tcx.node_span_lint(
|
||||
lint::builtin::TYVAR_BEHIND_RAW_POINTER,
|
||||
scope_expr_id,
|
||||
span,
|
||||
@@ -1380,7 +1380,7 @@ impl<'tcx> Pick<'tcx> {
|
||||
return;
|
||||
}
|
||||
let def_kind = self.item.kind.as_def_kind();
|
||||
tcx.struct_span_lint_hir(
|
||||
tcx.node_span_lint(
|
||||
lint::builtin::UNSTABLE_NAME_COLLISIONS,
|
||||
scope_expr_id,
|
||||
span,
|
||||
|
||||
@@ -1840,7 +1840,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
&unmentioned_fields.iter().map(|(_, i)| i).collect::<Vec<_>>(),
|
||||
);
|
||||
|
||||
self.tcx.struct_span_lint_hir(NON_EXHAUSTIVE_OMITTED_PATTERNS, pat.hir_id, pat.span, "some fields are not explicitly listed", |lint| {
|
||||
self.tcx.node_span_lint(NON_EXHAUSTIVE_OMITTED_PATTERNS, pat.hir_id, pat.span, "some fields are not explicitly listed", |lint| {
|
||||
lint.span_label(pat.span, format!("field{} {} not listed", rustc_errors::pluralize!(unmentioned_fields.len()), joined_patterns));
|
||||
lint.help(
|
||||
"ensure that all fields are mentioned explicitly by adding the suggested fields",
|
||||
|
||||
@@ -754,7 +754,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
let closure_hir_id = self.tcx.local_def_id_to_hir_id(closure_def_id);
|
||||
let closure_head_span = self.tcx.def_span(closure_def_id);
|
||||
self.tcx.struct_span_lint_hir(
|
||||
self.tcx.node_span_lint(
|
||||
lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
|
||||
closure_hir_id,
|
||||
closure_head_span,
|
||||
|
||||
@@ -676,7 +676,7 @@ impl<'tcx> LintContext for LateContext<'tcx> {
|
||||
let hir_id = self.last_node_with_lint_attrs;
|
||||
|
||||
match span {
|
||||
Some(s) => self.tcx.struct_span_lint_hir(lint, hir_id, s, msg, decorate),
|
||||
Some(s) => self.tcx.node_span_lint(lint, hir_id, s, msg, decorate),
|
||||
None => self.tcx.node_lint(lint, hir_id, msg, decorate),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ pub fn explain_lint_level_source(
|
||||
/// If you are looking to implement a lint, look for higher level functions,
|
||||
/// for example:
|
||||
/// - [`TyCtxt::emit_spanned_lint`]
|
||||
/// - [`TyCtxt::struct_span_lint_hir`]
|
||||
/// - [`TyCtxt::node_span_lint`]
|
||||
/// - [`TyCtxt::emit_lint`]
|
||||
/// - [`TyCtxt::node_lint`]
|
||||
/// - `LintContext::opt_span_lint`
|
||||
|
||||
@@ -217,7 +217,7 @@ fn late_report_deprecation(
|
||||
return;
|
||||
}
|
||||
let method_span = method_span.unwrap_or(span);
|
||||
tcx.struct_span_lint_hir(lint, hir_id, method_span, message, |diag| {
|
||||
tcx.node_span_lint(lint, hir_id, method_span, message, |diag| {
|
||||
if let hir::Node::Expr(_) = tcx.hir_node(hir_id) {
|
||||
let kind = tcx.def_descr(def_id);
|
||||
deprecation_suggestion(diag, kind, suggestion, method_span);
|
||||
@@ -585,7 +585,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
unmarked: impl FnOnce(Span, DefId),
|
||||
) -> bool {
|
||||
let soft_handler = |lint, span, msg: String| {
|
||||
self.struct_span_lint_hir(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, msg, |_| {})
|
||||
self.node_span_lint(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, msg, |_| {})
|
||||
};
|
||||
let eval_result =
|
||||
self.eval_stability_allow_unstable(def_id, id, span, method_span, allow_unstable);
|
||||
|
||||
@@ -108,7 +108,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
let mir_body = self.mir_for_ctfe(instance.def_id());
|
||||
if mir_body.is_polymorphic {
|
||||
let Some(local_def_id) = ct.def.as_local() else { return };
|
||||
self.struct_span_lint_hir(
|
||||
self.node_span_lint(
|
||||
lint::builtin::CONST_EVALUATABLE_UNCHECKED,
|
||||
self.local_def_id_to_hir_id(local_def_id),
|
||||
self.def_span(ct.def),
|
||||
|
||||
@@ -2096,7 +2096,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_span_lint_hir(
|
||||
pub fn node_span_lint(
|
||||
self,
|
||||
lint: &'static Lint,
|
||||
hir_id: HirId,
|
||||
|
||||
@@ -161,7 +161,7 @@ fn lint_object_unsafe_trait(
|
||||
) {
|
||||
// Using `CRATE_NODE_ID` is wrong, but it's hard to get a more precise id.
|
||||
// It's also hard to get a use site span, so we use the method definition span.
|
||||
tcx.struct_span_lint_hir(
|
||||
tcx.node_span_lint(
|
||||
WHERE_CLAUSES_OBJECT_SAFETY,
|
||||
hir::CRATE_HIR_ID,
|
||||
span,
|
||||
|
||||
@@ -462,7 +462,7 @@ fn report_conflicting_impls<'tcx>(
|
||||
FutureCompatOverlapErrorKind::Issue33140 => ORDER_DEPENDENT_TRAIT_OBJECTS,
|
||||
FutureCompatOverlapErrorKind::LeakCheck => COHERENCE_LEAK_CHECK,
|
||||
};
|
||||
tcx.struct_span_lint_hir(
|
||||
tcx.node_span_lint(
|
||||
lint,
|
||||
tcx.local_def_id_to_hir_id(impl_def_id),
|
||||
impl_span,
|
||||
|
||||
Reference in New Issue
Block a user