Replace emit_span_lint with emit_span_diag_lint in rustc_lint

This commit is contained in:
Guillaume Gomez
2026-02-25 15:46:34 +01:00
parent bca1cb4c2f
commit b409cb16ae
38 changed files with 141 additions and 182 deletions
+1 -1
View File
@@ -109,7 +109,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
}
&& method_did.map(|did| find_attr!(cx.tcx, did, RustcNoImplicitAutorefs)).unwrap_or(true)
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
DANGEROUS_IMPLICIT_AUTOREFS,
expr.span.source_callsite(),
ImplicitUnsafeAutorefsDiag {
+31 -35
View File
@@ -99,7 +99,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
"{}loop",
label.map_or_else(String::new, |label| format!("{}: ", label.ident,))
);
cx.emit_span_diag_lint(
cx.emit_span_lint(
WHILE_TRUE,
condition_span,
BuiltinWhileTrue { suggestion: condition_span, replace },
@@ -172,7 +172,7 @@ fn check_pat(&mut self, cx: &LateContext<'_>, pat: &hir::Pat<'_>) {
if cx.tcx.find_field_index(ident, variant)
== Some(cx.typeck_results().field_index(fieldpat.hir_id))
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
NON_SHORTHAND_FIELD_PATTERNS,
fieldpat.span,
BuiltinNonShorthandFieldPatterns {
@@ -242,7 +242,7 @@ fn report_unsafe(
return;
}
cx.emit_span_diag_lint(UNSAFE_CODE, span, decorate);
cx.emit_span_lint(UNSAFE_CODE, span, decorate);
}
}
@@ -423,7 +423,7 @@ fn check_missing_docs_attrs(
let attrs = cx.tcx.hir_attrs(cx.tcx.local_def_id_to_hir_id(def_id));
let has_doc = attrs.iter().any(has_doc);
if !has_doc {
cx.emit_span_diag_lint(
cx.emit_span_lint(
MISSING_DOCS,
cx.tcx.def_span(def_id),
BuiltinMissingDoc { article, desc },
@@ -624,7 +624,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
)
.is_ok()
{
cx.emit_span_diag_lint(MISSING_COPY_IMPLEMENTATIONS, item.span, BuiltinMissingCopyImpl);
cx.emit_span_lint(MISSING_COPY_IMPLEMENTATIONS, item.span, BuiltinMissingCopyImpl);
}
}
}
@@ -711,7 +711,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
.next()
.is_some();
if !has_impl {
cx.emit_span_diag_lint(
cx.emit_span_lint(
MISSING_DEBUG_IMPLEMENTATIONS,
item.span,
BuiltinMissingDebugImpl { tcx: cx.tcx, def_id: debug },
@@ -788,7 +788,7 @@ fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::AssocItem) {
} else {
("<type>", Applicability::HasPlaceholders)
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
ANONYMOUS_PARAMETERS,
arg.pat.span,
BuiltinAnonymousParams { suggestion: (arg.pat.span, appl), ty_snip },
@@ -833,7 +833,7 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &
BuiltinUnusedDocCommentSub::BlockHelp
}
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNUSED_DOC_COMMENTS,
span,
BuiltinUnusedDocComment { kind: node_kind, label: node_span, sub },
@@ -965,7 +965,7 @@ fn check_no_mangle_on_generic_fn(
) {
let generics = cx.tcx.generics_of(def_id);
if generics.requires_monomorphization(cx.tcx) {
cx.emit_span_diag_lint(
cx.emit_span_lint(
NO_MANGLE_GENERIC_ITEMS,
cx.tcx.def_span(def_id),
BuiltinNoMangleGeneric { suggestion: attr_span },
@@ -997,7 +997,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
// Const items do not refer to a particular location in memory, and therefore
// don't have anything to attach a symbol to
cx.emit_span_diag_lint(
cx.emit_span_lint(
NO_MANGLE_CONST_ITEMS,
it.span,
BuiltinConstNoMangle { suggestion },
@@ -1058,7 +1058,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &hir::Expr<'_>) {
get_transmute_from_to(cx, expr).map(|(ty1, ty2)| (ty1.kind(), ty2.kind()))
{
if from_mutbl < to_mutbl {
cx.emit_span_diag_lint(MUTABLE_TRANSMUTES, expr.span, BuiltinMutablesTransmutes);
cx.emit_span_lint(MUTABLE_TRANSMUTES, expr.span, BuiltinMutablesTransmutes);
}
}
@@ -1122,7 +1122,7 @@ impl<'tcx> LateLintPass<'tcx> for UnstableFeatures {
fn check_attributes(&mut self, cx: &LateContext<'_>, attrs: &[hir::Attribute]) {
if let Some(features) = find_attr!(attrs, Feature(features, _) => features) {
for feature in features {
cx.emit_span_diag_lint(UNSTABLE_FEATURES, feature.span, BuiltinUnstableFeatures);
cx.emit_span_lint(UNSTABLE_FEATURES, feature.span, BuiltinUnstableFeatures);
}
}
}
@@ -1175,7 +1175,7 @@ fn check_fn(
// Now, check if the function has the `#[track_caller]` attribute
&& let Some(attr_span) = find_attr!(cx.tcx, def_id, TrackCaller(span) => *span)
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNGATED_ASYNC_FN_TRACK_CALLER,
attr_span,
BuiltinUngatedAsyncFnTrackCaller { label: span, session: &cx.tcx.sess },
@@ -1260,7 +1260,7 @@ fn perform_lint(
applicability = Applicability::MaybeIncorrect;
}
let def_span = cx.tcx.def_span(def_id);
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNREACHABLE_PUB,
def_span,
BuiltinUnreachablePub {
@@ -1412,7 +1412,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
let enable_feat_help = cx.tcx.sess.is_nightly_build();
if let [.., label_sp] = *where_spans {
cx.emit_span_diag_lint(
cx.emit_span_lint(
TYPE_ALIAS_BOUNDS,
where_spans,
BuiltinTypeAliasBounds {
@@ -1426,7 +1426,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
);
}
if let [.., label_sp] = *inline_spans {
cx.emit_span_diag_lint(
cx.emit_span_lint(
TYPE_ALIAS_BOUNDS,
inline_spans,
BuiltinTypeAliasBounds {
@@ -1526,7 +1526,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
| ty::ClauseKind::HostEffect(..) => continue,
};
if predicate.is_global() {
cx.emit_span_diag_lint(
cx.emit_span_lint(
TRIVIAL_BOUNDS,
span,
BuiltinTrivialBounds { predicate_kind_name, predicate },
@@ -1581,7 +1581,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
// Don't lint if this jumps macro expansion boundary (Issue #143980)
&& expr.span.eq_ctxt(inner.span)
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
DOUBLE_NEGATIONS,
expr.span,
BuiltinDoubleNegations {
@@ -1702,7 +1702,7 @@ fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(Option<&Expr>, &Expr, Span)>
replace,
});
} else {
cx.emit_span_diag_lint(
cx.emit_span_lint(
ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
pat.span,
BuiltinEllipsisInclusiveRangePatternsLint::Parenthesise {
@@ -1720,7 +1720,7 @@ fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(Option<&Expr>, &Expr, Span)>
replace: replace.to_string(),
});
} else {
cx.emit_span_diag_lint(
cx.emit_span_lint(
ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
join,
BuiltinEllipsisInclusiveRangePatternsLint::NonParenthesise {
@@ -1902,7 +1902,7 @@ fn check_ident_token(
return;
}
cx.emit_span_diag_lint(
cx.emit_span_lint(
lint,
ident.span,
BuiltinKeywordIdents { kw: ident, next: edition, suggestion: ident.span, prefix },
@@ -2238,7 +2238,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
lint_spans.sort_unstable();
lint_spans.dedup();
cx.emit_span_diag_lint(
cx.emit_span_lint(
EXPLICIT_OUTLIVES_REQUIREMENTS,
lint_spans.clone(),
BuiltinExplicitOutlives {
@@ -2323,17 +2323,13 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
let help =
HAS_MIN_FEATURES.contains(&name).then_some(BuiltinIncompleteFeaturesHelp);
cx.emit_span_diag_lint(
cx.emit_span_lint(
INCOMPLETE_FEATURES,
span,
BuiltinIncompleteFeatures { name, note, help },
);
} else {
cx.emit_span_diag_lint(
INTERNAL_FEATURES,
span,
BuiltinInternalFeatures { name },
);
cx.emit_span_lint(INTERNAL_FEATURES, span, BuiltinInternalFeatures { name });
}
});
}
@@ -2659,7 +2655,7 @@ fn ty_find_init_error<'tcx>(
}
};
let sub = BuiltinUnpermittedTypeInitSub { err };
cx.emit_span_diag_lint(
cx.emit_span_lint(
INVALID_VALUE,
expr.span,
BuiltinUnpermittedTypeInit {
@@ -2765,7 +2761,7 @@ fn is_zero(expr: &hir::Expr<'_>) -> bool {
{
// `&raw *NULL` is ok.
} else {
cx.emit_span_diag_lint(
cx.emit_span_lint(
DEREF_NULLPTR,
expr.span,
BuiltinDerefNullptr { label: expr.span },
@@ -3074,14 +3070,14 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
let span = span.unwrap_or(*template_span);
match label_kind {
AsmLabelKind::Named => {
cx.emit_span_diag_lint(
cx.emit_span_lint(
NAMED_ASM_LABELS,
span,
InvalidAsmLabel::Named { missing_precise_span },
);
}
AsmLabelKind::FormatArg => {
cx.emit_span_diag_lint(
cx.emit_span_lint(
NAMED_ASM_LABELS,
span,
InvalidAsmLabel::FormatArg { missing_precise_span },
@@ -3095,7 +3091,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
Some(InlineAsmArch::X86 | InlineAsmArch::X86_64) | None
) =>
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
BINARY_ASM_LABELS,
span,
InvalidAsmLabel::Binary { missing_precise_span, span },
@@ -3171,12 +3167,12 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, krate: &ast::Crate) {
}
match ident.name.as_str() {
"lib" => cx.emit_span_diag_lint(
"lib" => cx.emit_span_lint(
SPECIAL_MODULE_NAME,
item.span,
BuiltinSpecialModuleNameUsed::Lib,
),
"main" => cx.emit_span_diag_lint(
"main" => cx.emit_span_lint(
SPECIAL_MODULE_NAME,
item.span,
BuiltinSpecialModuleNameUsed::Main,
-13
View File
@@ -538,19 +538,6 @@ fn opt_span_diag_lint<S: Into<MultiSpan>>(
/// Emit a lint at `span` from a lint struct (some type that implements `LintDiagnostic`,
/// typically generated by `#[derive(LintDiagnostic)]`).
fn emit_span_lint<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: S,
decorator: impl for<'a> LintDiagnostic<'a, ()>,
) {
self.opt_span_lint(lint, Some(span), |lint| {
decorator.decorate_lint(lint);
});
}
/// Emit a lint at `span` from a lint struct (some type that implements `LintDiagnostic`,
/// typically generated by `#[derive(LintDiagnostic)]`).
fn emit_span_diag_lint<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: S,
@@ -89,7 +89,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
)
.map(|label| SupertraitAsDerefTargetLabel { label: tcx.def_span(label.def_id) });
let span = tcx.def_span(item.owner_id.def_id);
cx.emit_span_diag_lint(
cx.emit_span_lint(
DEREF_INTO_DYN_SUPERTRAIT,
span,
SupertraitAsDerefTarget {
@@ -27,7 +27,7 @@ fn check_ty(&mut self, cx: &LateContext<'_>, ty: &'tcx hir::Ty<'tcx, AmbigArg>)
return;
}
if let Some(t) = path_for_pass_by_value(cx, inner_ty) {
cx.emit_span_diag_lint(
cx.emit_span_lint(
DISALLOWED_PASS_BY_REF,
ty.span,
DisallowedPassByRefDiag { ty: t, suggestion: ty.span },
@@ -163,14 +163,14 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
};
match fn_name {
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => {
cx.emit_span_diag_lint(
cx.emit_span_lint(
DROPPING_REFERENCES,
expr.span,
DropRefDiag { arg_ty, label: arg.span, sugg: let_underscore_ignore_sugg() },
);
}
sym::mem_forget if arg_ty.is_ref() => {
cx.emit_span_diag_lint(
cx.emit_span_lint(
FORGETTING_REFERENCES,
expr.span,
ForgetRefDiag {
@@ -181,7 +181,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
);
}
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => {
cx.emit_span_diag_lint(
cx.emit_span_lint(
DROPPING_COPY_TYPES,
expr.span,
DropCopyDiag {
@@ -192,7 +192,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
);
}
sym::mem_forget if is_copy => {
cx.emit_span_diag_lint(
cx.emit_span_lint(
FORGETTING_COPY_TYPES,
expr.span,
ForgetCopyDiag {
@@ -206,7 +206,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
if let ty::Adt(adt, _) = arg_ty.kind()
&& adt.is_manually_drop() =>
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNDROPPED_MANUALLY_DROPS,
expr.span,
UndroppedManuallyDropsDiag {
@@ -53,7 +53,7 @@ fn enforce_mem_discriminant(
) {
let ty_param = cx.typeck_results().node_args(func_expr.hir_id).type_at(0);
if is_non_enum(ty_param) {
cx.emit_span_diag_lint(
cx.emit_span_lint(
ENUM_INTRINSICS_NON_ENUMS,
expr_span,
EnumIntrinsicsMemDiscriminate { ty_param, note: args_span },
@@ -64,11 +64,7 @@ fn enforce_mem_discriminant(
fn enforce_mem_variant_count(cx: &LateContext<'_>, func_expr: &hir::Expr<'_>, span: Span) {
let ty_param = cx.typeck_results().node_args(func_expr.hir_id).type_at(0);
if is_non_enum(ty_param) {
cx.emit_span_diag_lint(
ENUM_INTRINSICS_NON_ENUMS,
span,
EnumIntrinsicsMemVariant { ty_param },
);
cx.emit_span_lint(ENUM_INTRINSICS_NON_ENUMS, span, EnumIntrinsicsMemVariant { ty_param });
}
}
@@ -98,7 +98,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
end_span: pat.span.between(arg_span),
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
FOR_LOOPS_OVER_FALLIBLES,
arg_span,
ForLoopsOverFalliblesDiag { article, ref_prefix, ty, sub, question_mark, suggestion },
+1 -5
View File
@@ -184,11 +184,7 @@ fn check_fn(
// Check for no_mangle/export_name, so the kernel can be found when querying the compiled object for the kernel function by name
if !find_attr!(cx.tcx, id, NoMangle(..) | ExportName { .. }) {
cx.emit_span_diag_lint(
MISSING_GPU_KERNEL_EXPORT_NAME,
span,
MissingGpuKernelExportName,
);
cx.emit_span_lint(MISSING_GPU_KERNEL_EXPORT_NAME, span, MissingGpuKernelExportName);
}
}
}
@@ -113,7 +113,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
None
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
CONST_ITEM_INTERIOR_MUTATIONS,
expr.span,
ConstItemInteriorMutationsDiag {
+19 -19
View File
@@ -48,7 +48,7 @@ fn check_path(&mut self, cx: &LateContext<'_>, path: &hir::Path<'_>, hir_id: Hir
Some(sym::HashSet) => "FxHashSet",
_ => return,
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
DEFAULT_HASH_TYPES,
path.span,
DefaultHashTypesDiag { preferred, used: cx.tcx.item_name(def_id) },
@@ -91,14 +91,14 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
{
let def_id = instance.def_id();
if find_attr!(cx.tcx, def_id, RustcLintQueryInstability) {
cx.emit_span_diag_lint(
cx.emit_span_lint(
POTENTIAL_QUERY_INSTABILITY,
span,
QueryInstability { query: cx.tcx.item_name(def_id) },
);
} else if has_unstable_into_iter_predicate(cx, callee_def_id, generic_args) {
let call_span = span.with_hi(expr.span.hi());
cx.emit_span_diag_lint(
cx.emit_span_lint(
POTENTIAL_QUERY_INSTABILITY,
call_span,
QueryInstability { query: sym::into_iter },
@@ -106,7 +106,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
}
if find_attr!(cx.tcx, def_id, RustcLintUntrackedQueryInformation) {
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNTRACKED_QUERY_INFORMATION,
span,
QueryUntracked { method: cx.tcx.item_name(def_id) },
@@ -214,7 +214,7 @@ fn check_path(
{
let span =
path.span.with_hi(segment.args.map_or(segment.ident.span, |a| a.span_ext).hi());
cx.emit_span_diag_lint(USAGE_OF_TY_TYKIND, path.span, TykindKind { suggestion: span });
cx.emit_span_lint(USAGE_OF_TY_TYKIND, path.span, TykindKind { suggestion: span });
}
}
@@ -249,19 +249,19 @@ fn check_ty(&mut self, cx: &LateContext<'_>, ty: &'tcx hir::Ty<'tcx, hir::AmbigA
match span {
Some(span) => {
cx.emit_span_diag_lint(
cx.emit_span_lint(
USAGE_OF_TY_TYKIND,
path.span,
TykindKind { suggestion: span },
);
}
None => cx.emit_span_diag_lint(USAGE_OF_TY_TYKIND, path.span, TykindDiag),
None => cx.emit_span_lint(USAGE_OF_TY_TYKIND, path.span, TykindDiag),
}
} else if !ty.span.from_expansion()
&& path.segments.len() > 1
&& let Some(ty) = is_ty_or_ty_ctxt(cx, path)
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
USAGE_OF_QUALIFIED_TY,
path.span,
TyQualified { ty, suggestion: path.span },
@@ -385,7 +385,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
&& (cx.tcx.is_diagnostic_item(sym::type_ir_interner, trait_def_id)
| cx.tcx.is_diagnostic_item(sym::type_ir_infer_ctxt_like, trait_def_id))
{
cx.emit_span_diag_lint(USAGE_OF_TYPE_IR_TRAITS, expr.span, TypeIrTraitUsage);
cx.emit_span_lint(USAGE_OF_TYPE_IR_TRAITS, expr.span, TypeIrTraitUsage);
}
}
@@ -399,13 +399,13 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
// Path segments except for the final.
if let Some(seg) = path.segments.iter().find(|seg| is_mod_inherent(seg.res)) {
cx.emit_span_diag_lint(USAGE_OF_TYPE_IR_INHERENT, seg.ident.span, TypeIrInherentUsage);
cx.emit_span_lint(USAGE_OF_TYPE_IR_INHERENT, seg.ident.span, TypeIrInherentUsage);
}
// Final path resolutions, like `use rustc_type_ir::inherent`
else if let Some(type_ns) = path.res.type_ns
&& is_mod_inherent(type_ns)
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
USAGE_OF_TYPE_IR_INHERENT,
path.segments.last().unwrap().ident.span,
TypeIrInherentUsage,
@@ -430,7 +430,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
}
_ => return,
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT,
path.span,
NonGlobImportTypeIrInherent { suggestion: lo.eq_ctxt(hi).then(|| lo.to(hi)), snippet },
@@ -448,7 +448,7 @@ fn check_path(
.opt_def_id()
.is_some_and(|def_id| cx.tcx.is_diagnostic_item(sym::type_ir, def_id))
}) {
cx.emit_span_diag_lint(DIRECT_USE_OF_RUSTC_TYPE_IR, seg.ident.span, TypeIrDirectUse);
cx.emit_span_lint(DIRECT_USE_OF_RUSTC_TYPE_IR, seg.ident.span, TypeIrDirectUse);
}
}
}
@@ -475,7 +475,7 @@ fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
&& call_site.ctxt().outer_expn_data().kind
!= ExpnKind::Macro(MacroKind::Bang, sym::declare_lint_pass)
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
LINT_PASS_IMPL_WITHOUT_MACRO,
of_trait.trait_ref.path.span,
LintPassByHand,
@@ -510,7 +510,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &hir::Expr<'_>) {
if field.name == target.name
&& let Some(lint_message) = find_attr!(cx.tcx, field.did, RustcLintOptDenyFieldAccess { lint_message, } => lint_message)
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
BAD_OPT_ACCESS,
expr.span,
BadOptAccessDiag { msg: lint_message.as_str() },
@@ -538,7 +538,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &hir::Expr<'_>) {
) = expr.kind
{
if is_span_ctxt_call(cx, lhs) && is_span_ctxt_call(cx, rhs) {
cx.emit_span_diag_lint(SPAN_USE_EQ_CTXT, expr.span, SpanUseEqCtxtDiag);
cx.emit_span_lint(SPAN_USE_EQ_CTXT, expr.span, SpanUseEqCtxtDiag);
}
}
}
@@ -576,7 +576,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx rustc_hir::Expr<'tc
&& let hir::ExprKind::Lit(kind) = arg.kind
&& let rustc_ast::LitKind::Str(_, _) = kind.node
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
SYMBOL_INTERN_STRING_LITERAL,
kind.span,
SymbolInternStringLiteralDiag,
@@ -612,7 +612,7 @@ fn is_whitelisted(crate_name: &str) -> bool {
let name = original_name.as_ref().unwrap_or(&imported_name.name).as_str();
let externs = &cx.builder.sess().opts.externs;
if externs.get(name).is_none() && !is_whitelisted(name) {
cx.emit_span_diag_lint(
cx.emit_span_lint(
IMPLICIT_SYSROOT_CRATE_IMPORT,
item.span,
ImplicitSysrootCrateImportDiag { name },
@@ -635,7 +635,7 @@ fn check_arm(&mut self, cx: &EarlyContext<'_>, arm: &rustc_ast::Arm) {
fn path_contains_attribute_kind(cx: &EarlyContext<'_>, path: &Path) {
for segment in &path.segments {
if segment.ident.as_str() == "AttributeKind" {
cx.emit_span_diag_lint(
cx.emit_span_lint(
BAD_USE_OF_FIND_ATTR,
segment.span(),
AttributeKindInFindAttr,
+1 -1
View File
@@ -87,7 +87,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
let valid_up_to = utf8_error.valid_up_to();
let is_unchecked_variant = diag_item.as_str().contains("unchecked");
cx.emit_span_diag_lint(
cx.emit_span_lint(
if is_unchecked_variant {
INVALID_FROM_UTF8_UNCHECKED
} else {
+2 -6
View File
@@ -156,18 +156,14 @@ fn check_local(&mut self, cx: &LateContext<'_>, local: &hir::LetStmt<'_>) {
};
if is_sync_lock {
let span = MultiSpan::from_span(pat.span);
cx.emit_span_diag_lint(
cx.emit_span_lint(
LET_UNDERSCORE_LOCK,
span,
NonBindingLet::SyncLock { sub, pat: pat.span },
);
// Only emit let_underscore_drop for top-level `_` patterns.
} else if can_use_init.is_some() {
cx.emit_span_diag_lint(
LET_UNDERSCORE_DROP,
local.span,
NonBindingLet::DropType { sub },
);
cx.emit_span_lint(LET_UNDERSCORE_DROP, local.span, NonBindingLet::DropType { sub });
}
});
}
+7 -7
View File
@@ -593,7 +593,7 @@ fn insert_spec(&mut self, id: LintId, LevelAndSource { level, lint_id, src }: Le
sub,
});
} else {
self.emit_span_diag_lint(
self.emit_span_lint(
FORBIDDEN_LINT_GROUPS,
src.span().into(),
OverruledAttributeLint {
@@ -783,7 +783,7 @@ fn add(
Symbol::intern(complete_name)
}
Some(new_lint_name) => {
self.emit_span_diag_lint(
self.emit_span_lint(
builtin::RENAMED_AND_REMOVED_LINTS,
sp.into(),
DeprecatedLintName {
@@ -822,7 +822,7 @@ fn add(
RenamedLintSuggestion::WithSpan { suggestion: sp, replace };
let name =
tool_ident.map(|tool| format!("{tool}::{name}")).unwrap_or(name);
self.emit_span_diag_lint(
self.emit_span_lint(
RENAMED_AND_REMOVED_LINTS,
sp.into(),
RenamedLint { name: name.as_str(), replace, suggestion },
@@ -847,7 +847,7 @@ fn add(
if self.lint_added_lints {
let name =
tool_ident.map(|tool| format!("{tool}::{name}")).unwrap_or(name);
self.emit_span_diag_lint(
self.emit_span_lint(
RENAMED_AND_REMOVED_LINTS,
sp.into(),
RemovedLint { name: name.as_str(), reason },
@@ -867,7 +867,7 @@ fn add(
from_rustc,
}
});
self.emit_span_diag_lint(
self.emit_span_lint(
UNKNOWN_LINTS,
sp.into(),
UnknownLint { name, suggestion },
@@ -921,7 +921,7 @@ fn add(
continue;
};
self.emit_span_diag_lint(
self.emit_span_lint(
UNUSED_ATTRIBUTES,
lint_attr_span.into(),
IgnoredUnlessCrateSpecified { level: level.as_str(), name: lint_attr_name },
@@ -1001,7 +1001,7 @@ pub(crate) fn opt_span_diag_lint(
}
#[track_caller]
pub fn emit_span_diag_lint(
pub fn emit_span_lint(
&self,
lint: &'static Lint,
span: MultiSpan,
+1 -1
View File
@@ -470,7 +470,7 @@ fn emit_mismatch_diagnostic<'tcx>(
suggestions.extend(implicit_suggestion);
suggestions.extend(explicit_anonymous_suggestion);
cx.emit_span_diag_lint(
cx.emit_span_lint(
MISMATCHED_LIFETIME_SYNTAXES,
inputs.iter_unnamed().chain(outputs.iter_unnamed()).copied().collect::<Vec<_>>(),
lints::MismatchedLifetimeSyntaxes { inputs, outputs, suggestions },
@@ -133,7 +133,7 @@ fn check_ident_token(&mut self, cx: &crate::EarlyContext<'_>, token: &Token) {
}
debug!("emitting lint");
cx.builder.emit_span_diag_lint(
cx.builder.emit_span_lint(
&EDITION_2024_EXPR_FRAGMENT_SPECIFIER,
token.span.into(),
MacroExprFragment2024 { suggestion: token.span },
+1 -1
View File
@@ -67,7 +67,7 @@ fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &Stmt<'_>) {
if !(ret_ty.is_unit() || ret_ty.is_never()) {
return;
}
cx.emit_span_diag_lint(
cx.emit_span_lint(
MAP_UNIT_FN,
span,
MappingToUnit {
@@ -50,7 +50,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
.filter(|pred| !cx.tcx.is_lang_item(pred.def_id(), hir::LangItem::MetaSized))
.filter(|pred| !cx.tcx.is_default_trait(pred.def_id()));
if direct_super_traits_iter.count() > 1 {
cx.emit_span_diag_lint(
cx.emit_span_lint(
MULTIPLE_SUPERTRAIT_UPCASTABLE,
cx.tcx.def_span(def_id),
crate::lints::MultipleSupertraitUpcastable { ident },
+5 -5
View File
@@ -190,7 +190,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
continue;
}
has_non_ascii_idents = true;
cx.emit_span_diag_lint(NON_ASCII_IDENTS, sp, IdentifierNonAsciiChar);
cx.emit_span_lint(NON_ASCII_IDENTS, sp, IdentifierNonAsciiChar);
if check_uncommon_codepoints
&& !symbol_str.chars().all(GeneralSecurityProfile::identifier_allowed)
{
@@ -210,7 +210,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
if codepoints.is_empty() {
continue;
}
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNCOMMON_CODEPOINTS,
sp,
IdentifierUncommonCodepoints {
@@ -225,7 +225,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
.extract_if(.., |(c, _)| !GeneralSecurityProfile::identifier_allowed(*c))
.collect::<Vec<_>>();
if !remaining.is_empty() {
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNCOMMON_CODEPOINTS,
sp,
IdentifierUncommonCodepoints {
@@ -262,7 +262,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
.entry(skeleton_sym)
.and_modify(|(existing_symbol, existing_span, existing_is_ascii)| {
if !*existing_is_ascii || !is_ascii {
cx.emit_span_diag_lint(
cx.emit_span_lint(
CONFUSABLE_IDENTS,
sp,
ConfusableIdentifierPair {
@@ -383,7 +383,7 @@ enum ScriptSetUsage {
let char_info = format!("'{}' (U+{:04X})", ch, ch as u32);
includes += &char_info;
}
cx.emit_span_diag_lint(
cx.emit_span_lint(
MIXED_SCRIPT_CONFUSABLES,
sp,
MixedScriptConfusables { set: script_set.to_string(), includes },
+2 -2
View File
@@ -259,7 +259,7 @@ fn check_panic_str<'tcx>(
.map(|span| fmt_span.from_inner(InnerSpan::new(span.start, span.end)))
.collect(),
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
NON_FMT_PANICS,
arg_spans,
NonFmtPanicUnused {
@@ -276,7 +276,7 @@ fn check_panic_str<'tcx>(
.collect()
});
let count = brace_spans.as_ref().map(|v| v.len()).unwrap_or(/* any number >1 */ 2);
cx.emit_span_diag_lint(
cx.emit_span_lint(
NON_FMT_PANICS,
brace_spans.unwrap_or_else(|| vec![span]),
NonFmtPanicBraces {
+2 -2
View File
@@ -225,7 +225,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
None
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
NON_LOCAL_DEFINITIONS,
ms,
NonLocalDefinitionsDiag::Impl {
@@ -244,7 +244,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
ItemKind::Macro(_, _macro, _kinds)
if find_attr!(cx.tcx, item.owner_id.def_id, MacroExport { .. }) =>
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
NON_LOCAL_DEFINITIONS,
item.span,
NonLocalDefinitionsDiag::MacroRules {
+2 -2
View File
@@ -132,7 +132,7 @@ fn check_case(&self, cx: &EarlyContext<'_>, sort: &str, ident: &Ident) {
} else {
NonCamelCaseTypeSub::Label { span: ident.span }
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
NON_CAMEL_CASE_TYPES,
ident.span,
NonCamelCaseType { sort, name, sub },
@@ -301,7 +301,7 @@ fn is_snake_case(ident: &str) -> bool {
} else {
NonSnakeCaseDiagSub::Label { span }
};
cx.emit_span_diag_lint(NON_SNAKE_CASE, span, NonSnakeCaseDiag { sort, name, sc, sub });
cx.emit_span_lint(NON_SNAKE_CASE, span, NonSnakeCaseDiag { sort, name, sc, sub });
}
}
}
+3 -3
View File
@@ -131,7 +131,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
ty::Adt(def, _) => Some(cx.tcx.def_span(def.did()).shrink_to_lo()),
_ => None,
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
NOOP_METHOD_CALL,
span,
NoopMethodCallDiag {
@@ -147,12 +147,12 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
// If `type_of(x) == T` and `x.borrow()` is used to get `&T`,
// then that should be allowed
sym::noop_method_borrow => return,
sym::noop_method_clone => cx.emit_span_diag_lint(
sym::noop_method_clone => cx.emit_span_lint(
SUSPICIOUS_DOUBLE_REF_OP,
span,
SuspiciousDoubleRefCloneDiag { ty: expr_ty },
),
sym::noop_method_deref => cx.emit_span_diag_lint(
sym::noop_method_deref => cx.emit_span_lint(
SUSPICIOUS_DOUBLE_REF_OP,
span,
SuspiciousDoubleRefDerefDiag { ty: expr_ty },
@@ -180,7 +180,7 @@ fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx hir::Ty<'tcx, AmbigArg>
_ => None,
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
OPAQUE_HIDDEN_INFERRED_BOUND,
pred_span,
OpaqueHiddenInferredBoundLint {
+1 -1
View File
@@ -52,7 +52,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
&& let ExprKind::Lit(lit) = &arg.kind
&& let LitKind::Integer | LitKind::Float = &lit.kind
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
AMBIGUOUS_NEGATIVE_LITERALS,
expr.span,
AmbiguousNegativeLiteralsDiag {
+5 -5
View File
@@ -143,7 +143,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
)
&& let Some(diag) = useless_check(cx, arg) =>
{
cx.emit_span_diag_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
cx.emit_span_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
}
// Catching:
@@ -195,7 +195,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
InvalidNullArgumentsDiag::NullPtrThroughBinding { null_span }
};
cx.emit_span_diag_lint(INVALID_NULL_ARGUMENTS, expr.span, diag)
cx.emit_span_lint(INVALID_NULL_ARGUMENTS, expr.span, diag)
}
}
}
@@ -210,7 +210,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
)
&& let Some(diag) = useless_check(cx, receiver) =>
{
cx.emit_span_diag_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
cx.emit_span_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
}
ExprKind::Binary(op, left, right) if matches!(op.node, BinOpKind::Eq) => {
@@ -234,7 +234,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
&& let LitKind::Int(v, _) = spanned.node
&& v == 0 =>
{
cx.emit_span_diag_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
cx.emit_span_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
}
// Catching:
@@ -245,7 +245,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
&& let Some(diag_item) = cx.tcx.get_diagnostic_name(def_id)
&& (diag_item == sym::ptr_null || diag_item == sym::ptr_null_mut) =>
{
cx.emit_span_diag_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
cx.emit_span_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
}
_ => {}
@@ -55,7 +55,7 @@ fn maybe_lint_redundant_semis(cx: &EarlyContext<'_>, seq: &mut Option<(Span, boo
Some(RedundantSemicolonsSuggestion { multiple_semicolons: multiple, span })
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
REDUNDANT_SEMICOLONS,
span,
RedundantSemicolonsDiag { multiple, suggestion },
+2 -2
View File
@@ -55,7 +55,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
&& let Some(ty_has_interior_mutability) =
is_cast_from_ref_to_mut_ptr(cx, init, &mut peel_casts)
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
INVALID_REFERENCE_CASTING,
expr.span,
if pat == PatternKind::Assign {
@@ -75,7 +75,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
if let Some((from_ty_layout, to_ty_layout, e_alloc)) =
is_cast_to_bigger_memory_layout(cx, init, &mut peel_casts)
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
INVALID_REFERENCE_CASTING,
expr.span,
InvalidReferenceCastingDiag::BiggerLayout {
@@ -150,7 +150,7 @@ fn is_ref_to_boxed_slice(ty: Ty<'_>) -> bool {
None
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
lint,
call.ident.span,
ShadowedIntoIterDiag { target, edition, suggestion: call.ident.span, sub },
+1 -1
View File
@@ -155,7 +155,7 @@ fn emit_static_mut_refs(
}
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
STATIC_MUT_REFS,
span,
RefOfMutStatic { span, sugg, shared_label, shared_note, mut_note },
+2 -2
View File
@@ -101,7 +101,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
continue;
}
let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { return };
cx.emit_span_diag_lint(
cx.emit_span_lint(
DROP_BOUNDS,
span,
DropTraitConstraintsDiag { predicate, tcx: cx.tcx, def_id },
@@ -118,7 +118,7 @@ fn check_ty(&mut self, cx: &LateContext<'_>, ty: &'tcx hir::Ty<'tcx, AmbigArg>)
let def_id = bound.trait_ref.trait_def_id();
if def_id.is_some_and(|def_id| cx.tcx.is_lang_item(def_id, LangItem::Drop)) {
let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { return };
cx.emit_span_diag_lint(DYN_DROP, bound.span, DropGlue { tcx: cx.tcx, def_id });
cx.emit_span_lint(DYN_DROP, bound.span, DropGlue { tcx: cx.tcx, def_id });
}
}
}
+13 -21
View File
@@ -278,7 +278,7 @@ fn eq_ne(
_ => return,
};
cx.emit_span_diag_lint(INVALID_NAN_COMPARISONS, e.span, lint);
cx.emit_span_lint(INVALID_NAN_COMPARISONS, e.span, lint);
}
#[derive(Debug, PartialEq, Copy, Clone)]
@@ -343,7 +343,7 @@ fn lint_wide_pointer<'tcx>(
let (Some(l_span), Some(r_span)) =
(l.span.find_ancestor_inside(e.span), r.span.find_ancestor_inside(e.span))
else {
return cx.emit_span_diag_lint(
return cx.emit_span_lint(
AMBIGUOUS_WIDE_POINTER_COMPARISONS,
e.span,
AmbiguousWidePointerComparisons::Spanless,
@@ -365,7 +365,7 @@ fn lint_wide_pointer<'tcx>(
let l_modifiers = &*l_modifiers;
let r_modifiers = &*r_modifiers;
cx.emit_span_diag_lint(
cx.emit_span_lint(
AMBIGUOUS_WIDE_POINTER_COMPARISONS,
e.span,
if is_eq_ne {
@@ -460,7 +460,7 @@ fn lint_fn_pointer<'tcx>(
&& r_some_arg.expect_ty().is_fn()
{
// both operands are `Option<{function ptr}>`
return cx.emit_span_diag_lint(
return cx.emit_span_lint(
UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS,
e.span,
UnpredictableFunctionPointerComparisons::Warn,
@@ -476,7 +476,7 @@ fn lint_fn_pointer<'tcx>(
if !is_eq_ne {
// Neither `==` nor `!=`, we can't suggest `ptr::fn_addr_eq`, just show the warning.
return cx.emit_span_diag_lint(
return cx.emit_span_lint(
UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS,
e.span,
UnpredictableFunctionPointerComparisons::Warn,
@@ -487,7 +487,7 @@ fn lint_fn_pointer<'tcx>(
(l.span.find_ancestor_inside(e.span), r.span.find_ancestor_inside(e.span))
else {
// No appropriate spans for the left and right operands, just show the warning.
return cx.emit_span_diag_lint(
return cx.emit_span_lint(
UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS,
e.span,
UnpredictableFunctionPointerComparisons::Warn,
@@ -530,7 +530,7 @@ fn lint_fn_pointer<'tcx>(
}
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS,
e.span,
UnpredictableFunctionPointerComparisons::Suggestion { sugg },
@@ -558,7 +558,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx hir::Expr<'tcx>) {
hir::ExprKind::Binary(binop, ref l, ref r) => {
if is_comparison(binop.node) {
if !check_limits(cx, binop.node, l, r) {
cx.emit_span_diag_lint(UNUSED_COMPARISONS, e.span, UnusedComparisons);
cx.emit_span_lint(UNUSED_COMPARISONS, e.span, UnusedComparisons);
} else {
lint_nan(cx, e, binop.node, l, r);
let cmpop = ComparisonOp::BinOp(binop.node);
@@ -975,7 +975,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
// We only warn if the largest variant is at least thrice as large as
// the second-largest.
if largest > slargest * 3 && slargest > 0 {
cx.emit_span_diag_lint(
cx.emit_span_lint(
VARIANT_SIZE_DIFFERENCES,
enum_definition.variants[largest_index].span,
VariantSizeDifferencesDiag { largest },
@@ -1096,17 +1096,9 @@ fn check_atomic_load_store(cx: &LateContext<'_>, expr: &Expr<'_>) {
&& (ordering == invalid_ordering || ordering == sym::AcqRel)
{
if method == sym::load {
cx.emit_span_diag_lint(
INVALID_ATOMIC_ORDERING,
ordering_arg.span,
AtomicOrderingLoad,
);
cx.emit_span_lint(INVALID_ATOMIC_ORDERING, ordering_arg.span, AtomicOrderingLoad);
} else {
cx.emit_span_diag_lint(
INVALID_ATOMIC_ORDERING,
ordering_arg.span,
AtomicOrderingStore,
);
cx.emit_span_lint(INVALID_ATOMIC_ORDERING, ordering_arg.span, AtomicOrderingStore);
};
}
}
@@ -1118,7 +1110,7 @@ fn check_memory_fence(cx: &LateContext<'_>, expr: &Expr<'_>) {
&& matches!(cx.tcx.get_diagnostic_name(def_id), Some(sym::fence | sym::compiler_fence))
&& Self::match_ordering(cx, &args[0]) == Some(sym::Relaxed)
{
cx.emit_span_diag_lint(INVALID_ATOMIC_ORDERING, args[0].span, AtomicOrderingFence);
cx.emit_span_lint(INVALID_ATOMIC_ORDERING, args[0].span, AtomicOrderingFence);
}
}
@@ -1146,7 +1138,7 @@ fn check_atomic_compare_exchange(cx: &LateContext<'_>, expr: &Expr<'_>) {
let Some(fail_ordering) = Self::match_ordering(cx, fail_order_arg) else { return };
if matches!(fail_ordering, sym::Release | sym::AcqRel) {
cx.emit_span_diag_lint(
cx.emit_span_lint(
INVALID_ATOMIC_ORDERING,
fail_order_arg.span,
InvalidAtomicOrderingDiag { method, fail_order_arg_span: fail_order_arg.span },
@@ -237,7 +237,7 @@ fn check_struct_for_power_alignment<'tcx>(
// to be the fields that are misaligned.
let ty = tcx.type_of(field_def.def_id).instantiate_identity();
if check_arg_for_power_alignment(cx, ty) {
cx.emit_span_diag_lint(USES_POWER_ALIGNMENT, field_def.span, UsesPowerAlignment);
cx.emit_span_lint(USES_POWER_ALIGNMENT, field_def.span, UsesPowerAlignment);
}
}
}
@@ -959,11 +959,7 @@ fn emit_ffi_unsafe_type_lint(
} else {
None
};
cx.emit_span_diag_lint(
lint,
sp,
ImproperCTypes { ty, desc, label: sp, help, note, span_note },
);
cx.emit_span_lint(lint, sp, ImproperCTypes { ty, desc, label: sp, help, note, span_note });
}
}
+8 -8
View File
@@ -87,7 +87,7 @@ fn lint_overflowing_range_endpoint<'tcx>(
}
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
OVERFLOWING_LITERALS,
range_span,
RangeEndpointOutOfRange { ty, sub: sub_sugg },
@@ -201,7 +201,7 @@ fn report_bin_hex_error(
})
.flatten();
cx.emit_span_diag_lint(
cx.emit_span_lint(
OVERFLOWING_LITERALS,
span,
OverflowingBinHex {
@@ -297,7 +297,7 @@ fn lint_int_literal<'tcx>(
let help = get_type_suggestion(cx.typeck_results().node_type(hir_id), v, negative)
.map(|suggestion_ty| OverflowingIntHelp { suggestion_ty });
cx.emit_span_diag_lint(
cx.emit_span_lint(
OVERFLOWING_LITERALS,
span,
OverflowingInt { ty: t.name_str(), lit, min, max, help },
@@ -327,19 +327,19 @@ fn lint_uint_literal<'tcx>(
hir::ExprKind::Cast(..) => {
if let ty::Char = cx.typeck_results().expr_ty(par_e).kind() {
if lit_val > 0x10FFFF {
cx.emit_span_diag_lint(
cx.emit_span_lint(
OVERFLOWING_LITERALS,
par_e.span,
TooLargeCharCast { literal: lit_val },
);
} else if (0xD800..=0xDFFF).contains(&lit_val) {
cx.emit_span_diag_lint(
cx.emit_span_lint(
OVERFLOWING_LITERALS,
par_e.span,
SurrogateCharCast { literal: lit_val },
);
} else {
cx.emit_span_diag_lint(
cx.emit_span_lint(
OVERFLOWING_LITERALS,
par_e.span,
OnlyCastu8ToChar { span: par_e.span, literal: lit_val },
@@ -368,7 +368,7 @@ fn lint_uint_literal<'tcx>(
);
return;
}
cx.emit_span_diag_lint(
cx.emit_span_lint(
OVERFLOWING_LITERALS,
span,
OverflowingUInt {
@@ -426,7 +426,7 @@ pub(crate) fn lint_literal<'tcx>(
};
if is_infinite == Some(true) {
cx.emit_span_diag_lint(
cx.emit_span_lint(
OVERFLOWING_LITERALS,
span,
OverflowingLiteral {
+1 -1
View File
@@ -63,7 +63,7 @@ fn check_local(&mut self, cx: &crate::LateContext<'tcx>, local: &'tcx hir::LetSt
&& !matches!(init.kind, hir::ExprKind::Tup([]))
&& !matches!(local.pat.kind, hir::PatKind::Tuple([], ..))
{
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNIT_BINDINGS,
local.span,
UnitBindingsDiag { label: local.pat.span },
@@ -74,7 +74,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
}
// This `use` qualifies for our lint!
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNQUALIFIED_LOCAL_IMPORTS,
first_seg.ident.span,
lints::UnqualifiedLocalImportsDiag,
+6 -6
View File
@@ -51,9 +51,9 @@ fn check_stmt(&mut self, cx: &LateContext<'_>, s: &hir::Stmt<'_>) {
} else {
PathStatementDropSub::Help { span: s.span }
};
cx.emit_span_diag_lint(PATH_STATEMENTS, s.span, PathStatementDrop { sub })
cx.emit_span_lint(PATH_STATEMENTS, s.span, PathStatementDrop { sub })
} else {
cx.emit_span_diag_lint(PATH_STATEMENTS, s.span, PathStatementNoEffect);
cx.emit_span_lint(PATH_STATEMENTS, s.span, PathStatementNoEffect);
}
}
}
@@ -352,7 +352,7 @@ fn emit_unused_delims(
end_replace: hi_replace,
}
});
cx.emit_span_diag_lint(
cx.emit_span_lint(
self.lint(),
primary_span,
UnusedDelim { delim: Self::DELIM_STR, item: msg, suggestion },
@@ -1181,7 +1181,7 @@ fn check_use_tree(&self, cx: &EarlyContext<'_>, use_tree: &ast::UseTree, item: &
ast::UseTreeKind::Nested { .. } => return,
};
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNUSED_IMPORT_BRACES,
item.span,
UnusedImportBracesDiag { node: node_name },
@@ -1244,10 +1244,10 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &hir::Expr<'_>) {
}
match m {
adjustment::AutoBorrowMutability::Not => {
cx.emit_span_diag_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationDiag);
cx.emit_span_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationDiag);
}
adjustment::AutoBorrowMutability::Mut { .. } => {
cx.emit_span_diag_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationMutDiag);
cx.emit_span_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationMutDiag);
}
};
}
+5 -5
View File
@@ -400,7 +400,7 @@ fn check_stmt(&mut self, cx: &LateContext<'_>, s: &hir::Stmt<'_>) {
let op_warned = match must_use_op {
Some(must_use_op) => {
let span = expr.span.find_ancestor_not_from_macro().unwrap_or(expr.span);
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNUSED_MUST_USE,
expr.span,
UnusedOp {
@@ -423,7 +423,7 @@ fn check_stmt(&mut self, cx: &LateContext<'_>, s: &hir::Stmt<'_>) {
// Only emit unused results lint if we haven't emitted any of the more specific lints and the expression type is non trivial.
if !(type_lint_emitted_or_trivial || fn_warned || op_warned) {
cx.emit_span_diag_lint(UNUSED_RESULTS, s.span, UnusedResult { ty });
cx.emit_span_lint(UNUSED_RESULTS, s.span, UnusedResult { ty });
}
}
}
@@ -598,14 +598,14 @@ fn emit_must_use_untranslated(
);
}
MustUsePath::Closure(span) => {
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNUSED_MUST_USE,
*span,
UnusedClosure { count: plural_len, pre: descr_pre, post: descr_post },
);
}
MustUsePath::Coroutine(span) => {
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNUSED_MUST_USE,
*span,
UnusedCoroutine { count: plural_len, pre: descr_pre, post: descr_post },
@@ -621,7 +621,7 @@ fn emit_must_use_untranslated(
.map(|prev| prev.trim_end().ends_with("let _ ="))
.unwrap_or(false);
let suggestion_span = if is_redundant_let_ignore { *span } else { ancenstor_span };
cx.emit_span_diag_lint(
cx.emit_span_lint(
UNUSED_MUST_USE,
ancenstor_span,
UnusedDef {