Reformat using the new identifier sorting from rustfmt
This commit is contained in:
parent
1173204b36
commit
c682aa162b
1455 changed files with 7152 additions and 8384 deletions
|
@ -28,10 +28,10 @@ use rustc_ast::visit::{FnCtxt, FnKind};
|
|||
use rustc_ast::{self as ast, *};
|
||||
use rustc_ast_pretty::pprust::{self, expr_to_string};
|
||||
use rustc_errors::{Applicability, LintDiagnostic};
|
||||
use rustc_feature::{deprecated_attributes, AttributeGate, BuiltinAttribute, GateIssue, Stability};
|
||||
use rustc_feature::{AttributeGate, BuiltinAttribute, GateIssue, Stability, deprecated_attributes};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
|
||||
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
|
||||
use rustc_hir::intravisit::FnKind as HirFnKind;
|
||||
use rustc_hir::{Body, FnDecl, GenericParamKind, PatKind, PredicateOrigin};
|
||||
use rustc_middle::bug;
|
||||
|
@ -39,13 +39,13 @@ use rustc_middle::lint::in_external_macro;
|
|||
use rustc_middle::ty::layout::LayoutOf;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, Upcast, VariantDef};
|
||||
use rustc_session::lint::FutureIncompatibilityReason;
|
||||
// hardwired lints from rustc_lint_defs
|
||||
pub use rustc_session::lint::builtin::*;
|
||||
use rustc_session::lint::FutureIncompatibilityReason;
|
||||
use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::symbol::{Ident, Symbol, kw, sym};
|
||||
use rustc_span::{BytePos, InnerSpan, Span};
|
||||
use rustc_target::abi::Abi;
|
||||
use rustc_target::asm::InlineAsmArch;
|
||||
|
@ -68,10 +68,10 @@ use crate::lints::{
|
|||
BuiltinUnsafe, BuiltinUnstableFeatures, BuiltinUnusedDocComment, BuiltinUnusedDocCommentSub,
|
||||
BuiltinWhileTrue, InvalidAsmLabel,
|
||||
};
|
||||
use crate::nonstandard_style::{method_context, MethodLateContext};
|
||||
use crate::nonstandard_style::{MethodLateContext, method_context};
|
||||
use crate::{
|
||||
fluent_generated as fluent, EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level,
|
||||
LintContext,
|
||||
EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level, LintContext,
|
||||
fluent_generated as fluent,
|
||||
};
|
||||
|
||||
declare_lint! {
|
||||
|
@ -120,11 +120,10 @@ impl EarlyLintPass for WhileTrue {
|
|||
"{}loop",
|
||||
label.map_or_else(String::new, |label| format!("{}: ", label.ident,))
|
||||
);
|
||||
cx.emit_span_lint(
|
||||
WHILE_TRUE,
|
||||
condition_span,
|
||||
BuiltinWhileTrue { suggestion: condition_span, replace },
|
||||
);
|
||||
cx.emit_span_lint(WHILE_TRUE, condition_span, BuiltinWhileTrue {
|
||||
suggestion: condition_span,
|
||||
replace,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -436,11 +435,10 @@ impl MissingDoc {
|
|||
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_lint(
|
||||
MISSING_DOCS,
|
||||
cx.tcx.def_span(def_id),
|
||||
BuiltinMissingDoc { article, desc },
|
||||
);
|
||||
cx.emit_span_lint(MISSING_DOCS, cx.tcx.def_span(def_id), BuiltinMissingDoc {
|
||||
article,
|
||||
desc,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -721,11 +719,10 @@ impl<'tcx> LateLintPass<'tcx> for MissingDebugImplementations {
|
|||
.next()
|
||||
.is_some();
|
||||
if !has_impl {
|
||||
cx.emit_span_lint(
|
||||
MISSING_DEBUG_IMPLEMENTATIONS,
|
||||
item.span,
|
||||
BuiltinMissingDebugImpl { tcx: cx.tcx, def_id: debug },
|
||||
);
|
||||
cx.emit_span_lint(MISSING_DEBUG_IMPLEMENTATIONS, item.span, BuiltinMissingDebugImpl {
|
||||
tcx: cx.tcx,
|
||||
def_id: debug,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -847,24 +844,21 @@ impl EarlyLintPass for DeprecatedAttr {
|
|||
BuiltinDeprecatedAttrLinkSuggestion::Default { suggestion: attr.span }
|
||||
}
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
DEPRECATED,
|
||||
attr.span,
|
||||
BuiltinDeprecatedAttrLink { name, reason, link, suggestion },
|
||||
);
|
||||
cx.emit_span_lint(DEPRECATED, attr.span, BuiltinDeprecatedAttrLink {
|
||||
name,
|
||||
reason,
|
||||
link,
|
||||
suggestion,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if attr.has_name(sym::no_start) || attr.has_name(sym::crate_id) {
|
||||
cx.emit_span_lint(
|
||||
DEPRECATED,
|
||||
attr.span,
|
||||
BuiltinDeprecatedAttrUsed {
|
||||
name: pprust::path_to_string(&attr.get_normal_item().path),
|
||||
suggestion: attr.span,
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(DEPRECATED, attr.span, BuiltinDeprecatedAttrUsed {
|
||||
name: pprust::path_to_string(&attr.get_normal_item().path),
|
||||
suggestion: attr.span,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -899,11 +893,11 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &
|
|||
BuiltinUnusedDocCommentSub::BlockHelp
|
||||
}
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
UNUSED_DOC_COMMENTS,
|
||||
span,
|
||||
BuiltinUnusedDocComment { kind: node_kind, label: node_span, sub },
|
||||
);
|
||||
cx.emit_span_lint(UNUSED_DOC_COMMENTS, span, BuiltinUnusedDocComment {
|
||||
kind: node_kind,
|
||||
label: node_span,
|
||||
sub,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1033,11 +1027,9 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
|
|||
match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => {}
|
||||
GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => {
|
||||
cx.emit_span_lint(
|
||||
NO_MANGLE_GENERIC_ITEMS,
|
||||
span,
|
||||
BuiltinNoMangleGeneric { suggestion: no_mangle_attr.span },
|
||||
);
|
||||
cx.emit_span_lint(NO_MANGLE_GENERIC_ITEMS, span, BuiltinNoMangleGeneric {
|
||||
suggestion: no_mangle_attr.span,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1064,11 +1056,9 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
|
|||
|
||||
// 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_lint(
|
||||
NO_MANGLE_CONST_ITEMS,
|
||||
it.span,
|
||||
BuiltinConstNoMangle { suggestion },
|
||||
);
|
||||
cx.emit_span_lint(NO_MANGLE_CONST_ITEMS, it.span, BuiltinConstNoMangle {
|
||||
suggestion,
|
||||
});
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Impl(hir::Impl { generics, items, .. }) => {
|
||||
|
@ -1316,15 +1306,11 @@ impl UnreachablePub {
|
|||
applicability = Applicability::MaybeIncorrect;
|
||||
}
|
||||
let def_span = cx.tcx.def_span(def_id);
|
||||
cx.emit_span_lint(
|
||||
UNREACHABLE_PUB,
|
||||
def_span,
|
||||
BuiltinUnreachablePub {
|
||||
what,
|
||||
suggestion: (vis_span, applicability),
|
||||
help: exportable,
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(UNREACHABLE_PUB, def_span, BuiltinUnreachablePub {
|
||||
what,
|
||||
suggestion: (vis_span, applicability),
|
||||
help: exportable,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1468,32 +1454,24 @@ impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds {
|
|||
let enable_feat_help = cx.tcx.sess.is_nightly_build();
|
||||
|
||||
if let [.., label_sp] = *where_spans {
|
||||
cx.emit_span_lint(
|
||||
TYPE_ALIAS_BOUNDS,
|
||||
where_spans,
|
||||
BuiltinTypeAliasBounds {
|
||||
in_where_clause: true,
|
||||
label: label_sp,
|
||||
enable_feat_help,
|
||||
suggestions: vec![(generics.where_clause_span, String::new())],
|
||||
preds: generics.predicates,
|
||||
ty: ty.take(),
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(TYPE_ALIAS_BOUNDS, where_spans, BuiltinTypeAliasBounds {
|
||||
in_where_clause: true,
|
||||
label: label_sp,
|
||||
enable_feat_help,
|
||||
suggestions: vec![(generics.where_clause_span, String::new())],
|
||||
preds: generics.predicates,
|
||||
ty: ty.take(),
|
||||
});
|
||||
}
|
||||
if let [.., label_sp] = *inline_spans {
|
||||
cx.emit_span_lint(
|
||||
TYPE_ALIAS_BOUNDS,
|
||||
inline_spans,
|
||||
BuiltinTypeAliasBounds {
|
||||
in_where_clause: false,
|
||||
label: label_sp,
|
||||
enable_feat_help,
|
||||
suggestions: inline_sugg,
|
||||
preds: generics.predicates,
|
||||
ty,
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(TYPE_ALIAS_BOUNDS, inline_spans, BuiltinTypeAliasBounds {
|
||||
in_where_clause: false,
|
||||
label: label_sp,
|
||||
enable_feat_help,
|
||||
suggestions: inline_sugg,
|
||||
preds: generics.predicates,
|
||||
ty,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1579,11 +1557,10 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
|
|||
| ClauseKind::ConstEvaluatable(..) => continue,
|
||||
};
|
||||
if predicate.is_global() {
|
||||
cx.emit_span_lint(
|
||||
TRIVIAL_BOUNDS,
|
||||
span,
|
||||
BuiltinTrivialBounds { predicate_kind_name, predicate },
|
||||
);
|
||||
cx.emit_span_lint(TRIVIAL_BOUNDS, span, BuiltinTrivialBounds {
|
||||
predicate_kind_name,
|
||||
predicate,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1899,11 +1876,12 @@ impl KeywordIdents {
|
|||
return;
|
||||
}
|
||||
|
||||
cx.emit_span_lint(
|
||||
lint,
|
||||
ident.span,
|
||||
BuiltinKeywordIdents { kw: ident, next: edition, suggestion: ident.span, prefix },
|
||||
);
|
||||
cx.emit_span_lint(lint, ident.span, BuiltinKeywordIdents {
|
||||
kw: ident,
|
||||
next: edition,
|
||||
suggestion: ident.span,
|
||||
prefix,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2322,11 +2300,11 @@ impl EarlyLintPass for IncompleteInternalFeatures {
|
|||
let help =
|
||||
HAS_MIN_FEATURES.contains(&name).then_some(BuiltinIncompleteFeaturesHelp);
|
||||
|
||||
cx.emit_span_lint(
|
||||
INCOMPLETE_FEATURES,
|
||||
span,
|
||||
BuiltinIncompleteFeatures { name, note, help },
|
||||
);
|
||||
cx.emit_span_lint(INCOMPLETE_FEATURES, span, BuiltinIncompleteFeatures {
|
||||
name,
|
||||
note,
|
||||
help,
|
||||
});
|
||||
} else {
|
||||
cx.emit_span_lint(INTERNAL_FEATURES, span, BuiltinInternalFeatures { name });
|
||||
}
|
||||
|
@ -2647,17 +2625,13 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
|
|||
InitKind::Uninit => fluent::lint_builtin_unpermitted_type_init_uninit,
|
||||
};
|
||||
let sub = BuiltinUnpermittedTypeInitSub { err };
|
||||
cx.emit_span_lint(
|
||||
INVALID_VALUE,
|
||||
expr.span,
|
||||
BuiltinUnpermittedTypeInit {
|
||||
msg,
|
||||
ty: conjured_ty,
|
||||
label: expr.span,
|
||||
sub,
|
||||
tcx: cx.tcx,
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(INVALID_VALUE, expr.span, BuiltinUnpermittedTypeInit {
|
||||
msg,
|
||||
ty: conjured_ty,
|
||||
label: expr.span,
|
||||
sub,
|
||||
tcx: cx.tcx,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2735,11 +2709,9 @@ impl<'tcx> LateLintPass<'tcx> for DerefNullPtr {
|
|||
|
||||
if let rustc_hir::ExprKind::Unary(rustc_hir::UnOp::Deref, expr_deref) = expr.kind {
|
||||
if is_null_ptr(cx, expr_deref) {
|
||||
cx.emit_span_lint(
|
||||
DEREF_NULLPTR,
|
||||
expr.span,
|
||||
BuiltinDerefNullptr { label: expr.span },
|
||||
);
|
||||
cx.emit_span_lint(DEREF_NULLPTR, expr.span, BuiltinDerefNullptr {
|
||||
label: expr.span,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2956,18 +2928,14 @@ impl<'tcx> LateLintPass<'tcx> for AsmLabels {
|
|||
let span = span.unwrap_or(*template_span);
|
||||
match label_kind {
|
||||
AsmLabelKind::Named => {
|
||||
cx.emit_span_lint(
|
||||
NAMED_ASM_LABELS,
|
||||
span,
|
||||
InvalidAsmLabel::Named { missing_precise_span },
|
||||
);
|
||||
cx.emit_span_lint(NAMED_ASM_LABELS, span, InvalidAsmLabel::Named {
|
||||
missing_precise_span,
|
||||
});
|
||||
}
|
||||
AsmLabelKind::FormatArg => {
|
||||
cx.emit_span_lint(
|
||||
NAMED_ASM_LABELS,
|
||||
span,
|
||||
InvalidAsmLabel::FormatArg { missing_precise_span },
|
||||
);
|
||||
cx.emit_span_lint(NAMED_ASM_LABELS, span, InvalidAsmLabel::FormatArg {
|
||||
missing_precise_span,
|
||||
});
|
||||
}
|
||||
// the binary asm issue only occurs when using intel syntax on x86 targets
|
||||
AsmLabelKind::Binary
|
||||
|
@ -2977,11 +2945,10 @@ impl<'tcx> LateLintPass<'tcx> for AsmLabels {
|
|||
Some(InlineAsmArch::X86 | InlineAsmArch::X86_64) | None
|
||||
) =>
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
BINARY_ASM_LABELS,
|
||||
cx.emit_span_lint(BINARY_ASM_LABELS, span, InvalidAsmLabel::Binary {
|
||||
missing_precise_span,
|
||||
span,
|
||||
InvalidAsmLabel::Binary { missing_precise_span, span },
|
||||
)
|
||||
})
|
||||
}
|
||||
// No lint on anything other than x86
|
||||
AsmLabelKind::Binary => (),
|
||||
|
|
|
@ -29,15 +29,15 @@ use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
|||
use rustc_middle::bug;
|
||||
use rustc_middle::middle::privacy::EffectiveVisibilities;
|
||||
use rustc_middle::ty::layout::{LayoutError, LayoutOfHelpers, TyAndLayout};
|
||||
use rustc_middle::ty::print::{with_no_trimmed_paths, PrintError, PrintTraitRefExt as _, Printer};
|
||||
use rustc_middle::ty::print::{PrintError, PrintTraitRefExt as _, Printer, with_no_trimmed_paths};
|
||||
use rustc_middle::ty::{self, GenericArg, RegisteredTools, Ty, TyCtxt};
|
||||
use rustc_session::lint::{
|
||||
BuiltinLintDiag, FutureIncompatibleInfo, Level, Lint, LintBuffer, LintExpectationId, LintId,
|
||||
};
|
||||
use rustc_session::{LintStoreMarker, Session};
|
||||
use rustc_span::edit_distance::find_best_match_for_names;
|
||||
use rustc_span::symbol::{sym, Ident, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::edit_distance::find_best_match_for_names;
|
||||
use rustc_span::symbol::{Ident, Symbol, sym};
|
||||
use rustc_target::abi;
|
||||
use tracing::debug;
|
||||
|
||||
|
@ -251,14 +251,11 @@ impl LintStore {
|
|||
}
|
||||
|
||||
pub fn register_group_alias(&mut self, lint_name: &'static str, alias: &'static str) {
|
||||
self.lint_groups.insert(
|
||||
alias,
|
||||
LintGroup {
|
||||
lint_ids: vec![],
|
||||
is_externally_loaded: false,
|
||||
depr: Some(LintAlias { name: lint_name, silent: true }),
|
||||
},
|
||||
);
|
||||
self.lint_groups.insert(alias, LintGroup {
|
||||
lint_ids: vec![],
|
||||
is_externally_loaded: false,
|
||||
depr: Some(LintAlias { name: lint_name, silent: true }),
|
||||
});
|
||||
}
|
||||
|
||||
pub fn register_group(
|
||||
|
@ -273,14 +270,11 @@ impl LintStore {
|
|||
.insert(name, LintGroup { lint_ids: to, is_externally_loaded, depr: None })
|
||||
.is_none();
|
||||
if let Some(deprecated) = deprecated_name {
|
||||
self.lint_groups.insert(
|
||||
deprecated,
|
||||
LintGroup {
|
||||
lint_ids: vec![],
|
||||
is_externally_loaded,
|
||||
depr: Some(LintAlias { name, silent: false }),
|
||||
},
|
||||
);
|
||||
self.lint_groups.insert(deprecated, LintGroup {
|
||||
lint_ids: vec![],
|
||||
is_externally_loaded,
|
||||
depr: Some(LintAlias { name, silent: false }),
|
||||
});
|
||||
}
|
||||
|
||||
if !new {
|
||||
|
|
|
@ -5,13 +5,13 @@ use std::borrow::Cow;
|
|||
|
||||
use rustc_ast::util::unicode::TEXT_FLOW_CONTROL_CHARS;
|
||||
use rustc_errors::{
|
||||
elided_lifetime_in_path_suggestion, Applicability, Diag, DiagArgValue, LintDiagnostic,
|
||||
Applicability, Diag, DiagArgValue, LintDiagnostic, elided_lifetime_in_path_suggestion,
|
||||
};
|
||||
use rustc_middle::middle::stability;
|
||||
use rustc_session::lint::{BuiltinLintDiag, ElidedLifetimeResolution};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::kw;
|
||||
use rustc_session::lint::{BuiltinLintDiag, ElidedLifetimeResolution};
|
||||
use rustc_span::BytePos;
|
||||
use rustc_span::symbol::kw;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::lints::{self, ElidedNamedLifetime};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use rustc_middle::bug;
|
||||
use rustc_session::config::ExpectedValues;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::config::ExpectedValues;
|
||||
use rustc_span::edit_distance::find_best_match_for_name;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::{sym, Span, Symbol};
|
||||
use rustc_span::{Span, Symbol, sym};
|
||||
|
||||
use crate::lints;
|
||||
|
||||
|
|
|
@ -86,19 +86,14 @@ impl<'tcx> LateLintPass<'tcx> for DerefIntoDynSupertrait {
|
|||
.find_map(|i| (i.ident.name == sym::Target).then_some(i.span))
|
||||
.map(|label| SupertraitAsDerefTargetLabel { label });
|
||||
let span = tcx.def_span(item.owner_id.def_id);
|
||||
cx.emit_span_lint(
|
||||
DEREF_INTO_DYN_SUPERTRAIT,
|
||||
span,
|
||||
SupertraitAsDerefTarget {
|
||||
self_ty,
|
||||
supertrait_principal: supertrait_principal.map_bound(|trait_ref| {
|
||||
ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)
|
||||
}),
|
||||
target_principal,
|
||||
label: span,
|
||||
label2,
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(DEREF_INTO_DYN_SUPERTRAIT, span, SupertraitAsDerefTarget {
|
||||
self_ty,
|
||||
supertrait_principal: supertrait_principal
|
||||
.map_bound(|trait_ref| ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)),
|
||||
target_principal,
|
||||
label: span,
|
||||
label2,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,44 +163,32 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
|
|||
};
|
||||
match fn_name {
|
||||
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => {
|
||||
cx.emit_span_lint(
|
||||
DROPPING_REFERENCES,
|
||||
expr.span,
|
||||
DropRefDiag { arg_ty, label: arg.span, sugg: let_underscore_ignore_sugg() },
|
||||
);
|
||||
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_lint(
|
||||
FORGETTING_REFERENCES,
|
||||
expr.span,
|
||||
ForgetRefDiag {
|
||||
arg_ty,
|
||||
label: arg.span,
|
||||
sugg: let_underscore_ignore_sugg(),
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(FORGETTING_REFERENCES, expr.span, ForgetRefDiag {
|
||||
arg_ty,
|
||||
label: arg.span,
|
||||
sugg: let_underscore_ignore_sugg(),
|
||||
});
|
||||
}
|
||||
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => {
|
||||
cx.emit_span_lint(
|
||||
DROPPING_COPY_TYPES,
|
||||
expr.span,
|
||||
DropCopyDiag {
|
||||
arg_ty,
|
||||
label: arg.span,
|
||||
sugg: let_underscore_ignore_sugg(),
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(DROPPING_COPY_TYPES, expr.span, DropCopyDiag {
|
||||
arg_ty,
|
||||
label: arg.span,
|
||||
sugg: let_underscore_ignore_sugg(),
|
||||
});
|
||||
}
|
||||
sym::mem_forget if is_copy => {
|
||||
cx.emit_span_lint(
|
||||
FORGETTING_COPY_TYPES,
|
||||
expr.span,
|
||||
ForgetCopyDiag {
|
||||
arg_ty,
|
||||
label: arg.span,
|
||||
sugg: let_underscore_ignore_sugg(),
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(FORGETTING_COPY_TYPES, expr.span, ForgetCopyDiag {
|
||||
arg_ty,
|
||||
label: arg.span,
|
||||
sugg: let_underscore_ignore_sugg(),
|
||||
});
|
||||
}
|
||||
sym::mem_drop
|
||||
if let ty::Adt(adt, _) = arg_ty.kind()
|
||||
|
|
|
@ -15,15 +15,15 @@
|
|||
//! for all lint attributes.
|
||||
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::visit::{self as ast_visit, walk_list, Visitor};
|
||||
use rustc_ast::visit::{self as ast_visit, Visitor, walk_list};
|
||||
use rustc_ast::{self as ast, HasAttrs};
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_feature::Features;
|
||||
use rustc_middle::ty::RegisteredTools;
|
||||
use rustc_session::lint::{BufferedEarlyLint, LintBuffer, LintPass};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_session::lint::{BufferedEarlyLint, LintBuffer, LintPass};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::Ident;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::context::{EarlyContext, LintStore};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use rustc_hir as hir;
|
||||
use rustc_middle::ty::visit::TypeVisitableExt;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_middle::ty::visit::TypeVisitableExt;
|
||||
use rustc_session::{declare_lint, declare_lint_pass};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
use crate::context::LintContext;
|
||||
use crate::lints::{EnumIntrinsicsMemDiscriminate, EnumIntrinsicsMemVariant};
|
||||
|
@ -55,11 +55,10 @@ 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_lint(
|
||||
ENUM_INTRINSICS_NON_ENUMS,
|
||||
expr_span,
|
||||
EnumIntrinsicsMemDiscriminate { ty_param, note: args_span },
|
||||
);
|
||||
cx.emit_span_lint(ENUM_INTRINSICS_NON_ENUMS, expr_span, EnumIntrinsicsMemDiscriminate {
|
||||
ty_param,
|
||||
note: args_span,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ use rustc_hir::CRATE_OWNER_ID;
|
|||
use rustc_middle::lint::LintExpectation;
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::lint::builtin::UNFULFILLED_LINT_EXPECTATIONS;
|
||||
use rustc_session::lint::LintExpectationId;
|
||||
use rustc_session::lint::builtin::UNFULFILLED_LINT_EXPECTATIONS;
|
||||
use rustc_span::Symbol;
|
||||
|
||||
use crate::lints::{Expectation, ExpectationNote};
|
||||
|
|
|
@ -4,7 +4,7 @@ use rustc_infer::infer::TyCtxtInferExt;
|
|||
use rustc_infer::traits::ObligationCause;
|
||||
use rustc_middle::ty;
|
||||
use rustc_session::{declare_lint, declare_lint_pass};
|
||||
use rustc_span::{sym, Span};
|
||||
use rustc_span::{Span, sym};
|
||||
use rustc_trait_selection::traits::ObligationCtxt;
|
||||
|
||||
use crate::lints::{
|
||||
|
@ -96,11 +96,14 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
|
|||
end_span: pat.span.between(arg.span),
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
FOR_LOOPS_OVER_FALLIBLES,
|
||||
arg.span,
|
||||
ForLoopsOverFalliblesDiag { article, ref_prefix, ty, sub, question_mark, suggestion },
|
||||
);
|
||||
cx.emit_span_lint(FOR_LOOPS_OVER_FALLIBLES, arg.span, ForLoopsOverFalliblesDiag {
|
||||
article,
|
||||
ref_prefix,
|
||||
ty,
|
||||
sub,
|
||||
question_mark,
|
||||
suggestion,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@ use rustc_hir::def::DefKind;
|
|||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::{self, AdtDef, Instance, Ty, TyCtxt};
|
||||
use rustc_session::declare_lint;
|
||||
use rustc_span::{sym, Span, Symbol};
|
||||
use rustc_span::{Span, Symbol, sym};
|
||||
use rustc_target::abi::FIRST_VARIANT;
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
use crate::lints::{BuiltinClashingExtern, BuiltinClashingExternSub};
|
||||
use crate::{types, LintVec};
|
||||
use crate::{LintVec, types};
|
||||
|
||||
pub(crate) fn provide(providers: &mut Providers) {
|
||||
*providers = Providers { clashing_extern_declarations, ..*providers };
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use ast::util::unicode::{contains_text_flow_control_chars, TEXT_FLOW_CONTROL_CHARS};
|
||||
use ast::util::unicode::{TEXT_FLOW_CONTROL_CHARS, contains_text_flow_control_chars};
|
||||
use rustc_ast as ast;
|
||||
use rustc_session::{declare_lint, declare_lint_pass};
|
||||
use rustc_span::{BytePos, Span, Symbol};
|
||||
|
@ -73,11 +73,13 @@ impl HiddenUnicodeCodepoints {
|
|||
HiddenUnicodeCodepointsDiagSub::NoEscape { spans }
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
TEXT_DIRECTION_CODEPOINT_IN_LITERAL,
|
||||
span,
|
||||
HiddenUnicodeCodepointsDiag { label, count, span_label: span, labels, sub },
|
||||
);
|
||||
cx.emit_span_lint(TEXT_DIRECTION_CODEPOINT_IN_LITERAL, span, HiddenUnicodeCodepointsDiag {
|
||||
label,
|
||||
count,
|
||||
span_label: span,
|
||||
labels,
|
||||
sub,
|
||||
});
|
||||
}
|
||||
}
|
||||
impl EarlyLintPass for HiddenUnicodeCodepoints {
|
||||
|
|
|
@ -11,8 +11,8 @@ use rustc_macros::LintDiagnostic;
|
|||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::lint::{FutureIncompatibilityReason, Level};
|
||||
use rustc_session::{declare_lint, impl_lint_pass};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::edition::Edition;
|
||||
|
||||
use crate::{LateContext, LateLintPass};
|
||||
|
||||
|
@ -210,25 +210,20 @@ impl IfLetRescope {
|
|||
}
|
||||
}
|
||||
if let Some((span, hir_id)) = first_if_to_lint {
|
||||
tcx.emit_node_span_lint(
|
||||
IF_LET_RESCOPE,
|
||||
hir_id,
|
||||
span,
|
||||
IfLetRescopeLint {
|
||||
significant_droppers,
|
||||
lifetime_ends,
|
||||
rewrite: first_if_to_rewrite.then_some(IfLetRescopeRewrite {
|
||||
match_heads,
|
||||
consequent_heads,
|
||||
closing_brackets: ClosingBrackets {
|
||||
span: expr_end,
|
||||
count: closing_brackets,
|
||||
empty_alt,
|
||||
},
|
||||
alt_heads,
|
||||
}),
|
||||
},
|
||||
);
|
||||
tcx.emit_node_span_lint(IF_LET_RESCOPE, hir_id, span, IfLetRescopeLint {
|
||||
significant_droppers,
|
||||
lifetime_ends,
|
||||
rewrite: first_if_to_rewrite.then_some(IfLetRescopeRewrite {
|
||||
match_heads,
|
||||
consequent_heads,
|
||||
closing_brackets: ClosingBrackets {
|
||||
span: expr_end,
|
||||
count: closing_brackets,
|
||||
empty_alt,
|
||||
},
|
||||
alt_heads,
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@ use rustc_errors::{Applicability, LintDiagnostic};
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
|
||||
use rustc_macros::LintDiagnostic;
|
||||
use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
|
||||
use rustc_middle::ty::relate::{
|
||||
structurally_relate_consts, structurally_relate_tys, Relate, RelateResult, TypeRelation,
|
||||
Relate, RelateResult, TypeRelation, structurally_relate_consts, structurally_relate_tys,
|
||||
};
|
||||
use rustc_middle::ty::{
|
||||
self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
|
||||
|
@ -22,10 +22,10 @@ use rustc_session::lint::FutureIncompatibilityReason;
|
|||
use rustc_session::{declare_lint, declare_lint_pass};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::{Span, Symbol};
|
||||
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt;
|
||||
use rustc_trait_selection::traits::ObligationCtxt;
|
||||
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt;
|
||||
|
||||
use crate::{fluent_generated as fluent, LateContext, LateLintPass};
|
||||
use crate::{LateContext, LateLintPass, fluent_generated as fluent};
|
||||
|
||||
declare_lint! {
|
||||
/// The `impl_trait_overcaptures` lint warns against cases where lifetime
|
||||
|
@ -309,10 +309,12 @@ where
|
|||
// We only computed variance of lifetimes...
|
||||
debug_assert_matches!(self.tcx.def_kind(def_id), DefKind::LifetimeParam);
|
||||
let uncaptured = match *kind {
|
||||
ParamKind::Early(name, index) => ty::Region::new_early_param(
|
||||
self.tcx,
|
||||
ty::EarlyParamRegion { name, index },
|
||||
),
|
||||
ParamKind::Early(name, index) => {
|
||||
ty::Region::new_early_param(self.tcx, ty::EarlyParamRegion {
|
||||
name,
|
||||
index,
|
||||
})
|
||||
}
|
||||
ParamKind::Free(def_id, name) => ty::Region::new_late_param(
|
||||
self.tcx,
|
||||
self.parent_def_id.to_def_id(),
|
||||
|
|
|
@ -10,9 +10,9 @@ use rustc_hir::{
|
|||
};
|
||||
use rustc_middle::ty::{self, GenericArgsRef, Ty as MiddleTy};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::hygiene::{ExpnKind, MacroKind};
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::hygiene::{ExpnKind, MacroKind};
|
||||
use rustc_span::symbol::{Symbol, kw, sym};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::lints::{
|
||||
|
@ -48,11 +48,10 @@ impl LateLintPass<'_> for DefaultHashTypes {
|
|||
Some(sym::HashSet) => "FxHashSet",
|
||||
_ => return,
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
DEFAULT_HASH_TYPES,
|
||||
path.span,
|
||||
DefaultHashTypesDiag { preferred, used: cx.tcx.item_name(def_id) },
|
||||
);
|
||||
cx.emit_span_lint(DEFAULT_HASH_TYPES, path.span, DefaultHashTypesDiag {
|
||||
preferred,
|
||||
used: cx.tcx.item_name(def_id),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,18 +106,14 @@ impl LateLintPass<'_> for QueryStability {
|
|||
if let Ok(Some(instance)) = ty::Instance::try_resolve(cx.tcx, cx.param_env, def_id, args) {
|
||||
let def_id = instance.def_id();
|
||||
if cx.tcx.has_attr(def_id, sym::rustc_lint_query_instability) {
|
||||
cx.emit_span_lint(
|
||||
POTENTIAL_QUERY_INSTABILITY,
|
||||
span,
|
||||
QueryInstability { query: cx.tcx.item_name(def_id) },
|
||||
);
|
||||
cx.emit_span_lint(POTENTIAL_QUERY_INSTABILITY, span, QueryInstability {
|
||||
query: cx.tcx.item_name(def_id),
|
||||
});
|
||||
}
|
||||
if cx.tcx.has_attr(def_id, sym::rustc_lint_untracked_query_information) {
|
||||
cx.emit_span_lint(
|
||||
UNTRACKED_QUERY_INFORMATION,
|
||||
span,
|
||||
QueryUntracked { method: cx.tcx.item_name(def_id) },
|
||||
);
|
||||
cx.emit_span_lint(UNTRACKED_QUERY_INFORMATION, span, QueryUntracked {
|
||||
method: cx.tcx.item_name(def_id),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -208,11 +203,9 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
|
|||
|
||||
match span {
|
||||
Some(span) => {
|
||||
cx.emit_span_lint(
|
||||
USAGE_OF_TY_TYKIND,
|
||||
path.span,
|
||||
TykindKind { suggestion: span },
|
||||
);
|
||||
cx.emit_span_lint(USAGE_OF_TY_TYKIND, path.span, TykindKind {
|
||||
suggestion: span,
|
||||
});
|
||||
}
|
||||
None => cx.emit_span_lint(USAGE_OF_TY_TYKIND, path.span, TykindDiag),
|
||||
}
|
||||
|
@ -220,11 +213,10 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
|
|||
&& path.segments.len() > 1
|
||||
&& let Some(ty) = is_ty_or_ty_ctxt(cx, path)
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
USAGE_OF_QUALIFIED_TY,
|
||||
path.span,
|
||||
TyQualified { ty, suggestion: path.span },
|
||||
);
|
||||
cx.emit_span_lint(USAGE_OF_QUALIFIED_TY, path.span, TyQualified {
|
||||
ty,
|
||||
suggestion: path.span,
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
@ -418,11 +410,9 @@ impl<'tcx> LateLintPass<'tcx> for ExistingDocKeyword {
|
|||
if is_doc_keyword(keyword) {
|
||||
return;
|
||||
}
|
||||
cx.emit_span_lint(
|
||||
EXISTING_DOC_KEYWORD,
|
||||
attr.span,
|
||||
NonExistentDocKeyword { keyword },
|
||||
);
|
||||
cx.emit_span_lint(EXISTING_DOC_KEYWORD, attr.span, NonExistentDocKeyword {
|
||||
keyword,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -625,11 +615,9 @@ impl LateLintPass<'_> for BadOptAccess {
|
|||
&& let Some(lit) = item.lit()
|
||||
&& let ast::LitKind::Str(val, _) = lit.kind
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
BAD_OPT_ACCESS,
|
||||
expr.span,
|
||||
BadOptAccessDiag { msg: val.as_str() },
|
||||
);
|
||||
cx.emit_span_lint(BAD_OPT_ACCESS, expr.span, BadOptAccessDiag {
|
||||
msg: val.as_str(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,14 +18,14 @@ use std::any::Any;
|
|||
use std::cell::Cell;
|
||||
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_data_structures::sync::{join, Lrc};
|
||||
use rustc_data_structures::sync::{Lrc, join};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{LocalDefId, LocalModDefId};
|
||||
use rustc_hir::{intravisit as hir_visit, HirId};
|
||||
use rustc_hir::{HirId, intravisit as hir_visit};
|
||||
use rustc_middle::hir::nested_filter;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_session::lint::LintPass;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::lint::LintPass;
|
||||
use rustc_span::Span;
|
||||
use tracing::debug;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use rustc_errors::MultiSpan;
|
|||
use rustc_hir as hir;
|
||||
use rustc_middle::ty;
|
||||
use rustc_session::{declare_lint, declare_lint_pass};
|
||||
use rustc_span::{sym, Symbol};
|
||||
use rustc_span::{Symbol, sym};
|
||||
|
||||
use crate::lints::{NonBindingLet, NonBindingLetSub};
|
||||
use crate::{LateContext, LateLintPass, LintContext};
|
||||
|
@ -156,11 +156,10 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
|
|||
};
|
||||
if is_sync_lock {
|
||||
let span = MultiSpan::from_span(pat.span);
|
||||
cx.emit_span_lint(
|
||||
LET_UNDERSCORE_LOCK,
|
||||
span,
|
||||
NonBindingLet::SyncLock { sub, pat: pat.span },
|
||||
);
|
||||
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_lint(LET_UNDERSCORE_DROP, local.span, NonBindingLet::DropType { sub });
|
||||
|
|
|
@ -2,25 +2,25 @@ use rustc_ast_pretty::pprust;
|
|||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_errors::{Diag, LintDiagnostic, MultiSpan};
|
||||
use rustc_feature::{Features, GateIssue};
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::HirId;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
use rustc_middle::lint::{
|
||||
lint_level, reveal_actual_level, LevelAndSource, LintExpectation, LintLevelSource,
|
||||
ShallowLintLevelMap,
|
||||
LevelAndSource, LintExpectation, LintLevelSource, ShallowLintLevelMap, lint_level,
|
||||
reveal_actual_level,
|
||||
};
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::{RegisteredTools, TyCtxt};
|
||||
use rustc_session::Session;
|
||||
use rustc_session::lint::builtin::{
|
||||
self, FORBIDDEN_LINT_GROUPS, RENAMED_AND_REMOVED_LINTS, SINGLE_USE_LIFETIMES,
|
||||
UNFULFILLED_LINT_EXPECTATIONS, UNKNOWN_LINTS, UNUSED_ATTRIBUTES,
|
||||
};
|
||||
use rustc_session::lint::{Level, Lint, LintExpectationId, LintId};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::symbol::{Symbol, sym};
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
use tracing::{debug, instrument};
|
||||
use {rustc_ast as ast, rustc_hir as hir};
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ pub use builtin::{MissingDoc, SoftLints};
|
|||
pub use context::{
|
||||
CheckLintNameResult, EarlyContext, FindLintError, LateContext, LintContext, LintStore,
|
||||
};
|
||||
pub use early::{check_ast_node, EarlyCheckNode};
|
||||
pub use early::{EarlyCheckNode, check_ast_node};
|
||||
pub use late::{check_crate, late_lint_mod, unerased_lint_store};
|
||||
pub use passes::{EarlyLintPass, LateLintPass};
|
||||
pub use rustc_session::lint::Level::{self, *};
|
||||
|
@ -618,24 +618,19 @@ fn register_internals(store: &mut LintStore) {
|
|||
// `DIAGNOSTIC_OUTSIDE_OF_IMPL` here because `-Wrustc::internal` is provided to every crate and
|
||||
// these lints will trigger all of the time - change this once migration to diagnostic structs
|
||||
// and translation is completed
|
||||
store.register_group(
|
||||
false,
|
||||
"rustc::internal",
|
||||
None,
|
||||
vec![
|
||||
LintId::of(DEFAULT_HASH_TYPES),
|
||||
LintId::of(POTENTIAL_QUERY_INSTABILITY),
|
||||
LintId::of(UNTRACKED_QUERY_INFORMATION),
|
||||
LintId::of(USAGE_OF_TY_TYKIND),
|
||||
LintId::of(PASS_BY_VALUE),
|
||||
LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO),
|
||||
LintId::of(USAGE_OF_QUALIFIED_TY),
|
||||
LintId::of(NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT),
|
||||
LintId::of(EXISTING_DOC_KEYWORD),
|
||||
LintId::of(BAD_OPT_ACCESS),
|
||||
LintId::of(SPAN_USE_EQ_CTXT),
|
||||
],
|
||||
);
|
||||
store.register_group(false, "rustc::internal", None, vec![
|
||||
LintId::of(DEFAULT_HASH_TYPES),
|
||||
LintId::of(POTENTIAL_QUERY_INSTABILITY),
|
||||
LintId::of(UNTRACKED_QUERY_INFORMATION),
|
||||
LintId::of(USAGE_OF_TY_TYKIND),
|
||||
LintId::of(PASS_BY_VALUE),
|
||||
LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO),
|
||||
LintId::of(USAGE_OF_QUALIFIED_TY),
|
||||
LintId::of(NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT),
|
||||
LintId::of(EXISTING_DOC_KEYWORD),
|
||||
LintId::of(BAD_OPT_ACCESS),
|
||||
LintId::of(SPAN_USE_EQ_CTXT),
|
||||
]);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -13,15 +13,15 @@ use rustc_hir::{self as hir, MissingLifetimeKind};
|
|||
use rustc_macros::{LintDiagnostic, Subdiagnostic};
|
||||
use rustc_middle::ty::inhabitedness::InhabitedPredicate;
|
||||
use rustc_middle::ty::{Clause, PolyExistentialTraitRef, Ty, TyCtxt};
|
||||
use rustc_session::lint::AmbiguityErrorDiag;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::lint::AmbiguityErrorDiag;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent};
|
||||
use rustc_span::{sym, Span, Symbol};
|
||||
use rustc_span::{Span, Symbol, sym};
|
||||
|
||||
use crate::builtin::{InitError, ShorthandAssocTyCollector, TypeAliasBounds};
|
||||
use crate::errors::{OverruledAttributeSub, RequestedLevel};
|
||||
use crate::{fluent_generated as fluent, LateContext};
|
||||
use crate::{LateContext, fluent_generated as fluent};
|
||||
|
||||
// array_into_iter.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
|
|
|
@ -8,8 +8,8 @@ use rustc_span::edition::Edition;
|
|||
use rustc_span::sym;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::lints::MacroExprFragment2024;
|
||||
use crate::EarlyLintPass;
|
||||
use crate::lints::MacroExprFragment2024;
|
||||
|
||||
declare_lint! {
|
||||
/// The `edition_2024_expr_fragment_specifier` lint detects the use of
|
||||
|
|
|
@ -60,39 +60,25 @@ impl<'tcx> LateLintPass<'tcx> for MapUnitFn {
|
|||
let fn_ty = cx.tcx.fn_sig(id).skip_binder();
|
||||
let ret_ty = fn_ty.output().skip_binder();
|
||||
if is_unit_type(ret_ty) {
|
||||
cx.emit_span_lint(
|
||||
MAP_UNIT_FN,
|
||||
span,
|
||||
MappingToUnit {
|
||||
function_label: cx
|
||||
.tcx
|
||||
.span_of_impl(*id)
|
||||
.unwrap_or(default_span),
|
||||
argument_label: args[0].span,
|
||||
map_label: arg_ty.default_span(cx.tcx),
|
||||
suggestion: path.ident.span,
|
||||
replace: "for_each".to_string(),
|
||||
},
|
||||
)
|
||||
cx.emit_span_lint(MAP_UNIT_FN, span, MappingToUnit {
|
||||
function_label: cx.tcx.span_of_impl(*id).unwrap_or(default_span),
|
||||
argument_label: args[0].span,
|
||||
map_label: arg_ty.default_span(cx.tcx),
|
||||
suggestion: path.ident.span,
|
||||
replace: "for_each".to_string(),
|
||||
})
|
||||
}
|
||||
} else if let ty::Closure(id, subs) = arg_ty.kind() {
|
||||
let cl_ty = subs.as_closure().sig();
|
||||
let ret_ty = cl_ty.output().skip_binder();
|
||||
if is_unit_type(ret_ty) {
|
||||
cx.emit_span_lint(
|
||||
MAP_UNIT_FN,
|
||||
span,
|
||||
MappingToUnit {
|
||||
function_label: cx
|
||||
.tcx
|
||||
.span_of_impl(*id)
|
||||
.unwrap_or(default_span),
|
||||
argument_label: args[0].span,
|
||||
map_label: arg_ty.default_span(cx.tcx),
|
||||
suggestion: path.ident.span,
|
||||
replace: "for_each".to_string(),
|
||||
},
|
||||
)
|
||||
cx.emit_span_lint(MAP_UNIT_FN, span, MappingToUnit {
|
||||
function_label: cx.tcx.span_of_impl(*id).unwrap_or(default_span),
|
||||
argument_label: args[0].span,
|
||||
map_label: arg_ty.default_span(cx.tcx),
|
||||
suggestion: path.ident.span,
|
||||
replace: "for_each".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use rustc_hir::{Expr, ExprKind};
|
||||
use rustc_middle::ty;
|
||||
use rustc_session::{declare_lint, declare_lint_pass};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
use crate::lints::CStringPtr;
|
||||
use crate::{LateContext, LateLintPass, LintContext};
|
||||
|
@ -58,11 +58,10 @@ fn lint_cstring_as_ptr(
|
|||
if cx.tcx.is_diagnostic_item(sym::Result, def.did()) {
|
||||
if let ty::Adt(adt, _) = args.type_at(0).kind() {
|
||||
if cx.tcx.is_diagnostic_item(sym::cstring_type, adt.did()) {
|
||||
cx.emit_span_lint(
|
||||
TEMPORARY_CSTRING_AS_PTR,
|
||||
as_ptr_span,
|
||||
CStringPtr { as_ptr: as_ptr_span, unwrap: unwrap.span },
|
||||
);
|
||||
cx.emit_span_lint(TEMPORARY_CSTRING_AS_PTR, as_ptr_span, CStringPtr {
|
||||
as_ptr: as_ptr_span,
|
||||
unwrap: unwrap.span,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,30 +209,22 @@ impl EarlyLintPass for NonAsciiIdents {
|
|||
if codepoints.is_empty() {
|
||||
continue;
|
||||
}
|
||||
cx.emit_span_lint(
|
||||
UNCOMMON_CODEPOINTS,
|
||||
sp,
|
||||
IdentifierUncommonCodepoints {
|
||||
codepoints_len: codepoints.len(),
|
||||
codepoints: codepoints.into_iter().map(|(c, _)| c).collect(),
|
||||
identifier_type: id_ty_descr,
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(UNCOMMON_CODEPOINTS, sp, IdentifierUncommonCodepoints {
|
||||
codepoints_len: codepoints.len(),
|
||||
codepoints: codepoints.into_iter().map(|(c, _)| c).collect(),
|
||||
identifier_type: id_ty_descr,
|
||||
});
|
||||
}
|
||||
|
||||
let remaining = chars
|
||||
.extract_if(|(c, _)| !GeneralSecurityProfile::identifier_allowed(*c))
|
||||
.collect::<Vec<_>>();
|
||||
if !remaining.is_empty() {
|
||||
cx.emit_span_lint(
|
||||
UNCOMMON_CODEPOINTS,
|
||||
sp,
|
||||
IdentifierUncommonCodepoints {
|
||||
codepoints_len: remaining.len(),
|
||||
codepoints: remaining.into_iter().map(|(c, _)| c).collect(),
|
||||
identifier_type: "Restricted",
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(UNCOMMON_CODEPOINTS, sp, IdentifierUncommonCodepoints {
|
||||
codepoints_len: remaining.len(),
|
||||
codepoints: remaining.into_iter().map(|(c, _)| c).collect(),
|
||||
identifier_type: "Restricted",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -261,16 +253,12 @@ impl EarlyLintPass for NonAsciiIdents {
|
|||
.entry(skeleton_sym)
|
||||
.and_modify(|(existing_symbol, existing_span, existing_is_ascii)| {
|
||||
if !*existing_is_ascii || !is_ascii {
|
||||
cx.emit_span_lint(
|
||||
CONFUSABLE_IDENTS,
|
||||
sp,
|
||||
ConfusableIdentifierPair {
|
||||
existing_sym: *existing_symbol,
|
||||
sym: symbol,
|
||||
label: *existing_span,
|
||||
main_label: sp,
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(CONFUSABLE_IDENTS, sp, ConfusableIdentifierPair {
|
||||
existing_sym: *existing_symbol,
|
||||
sym: symbol,
|
||||
label: *existing_span,
|
||||
main_label: sp,
|
||||
});
|
||||
}
|
||||
if *existing_is_ascii && !is_ascii {
|
||||
*existing_symbol = symbol;
|
||||
|
@ -382,11 +370,10 @@ impl EarlyLintPass for NonAsciiIdents {
|
|||
let char_info = format!("'{}' (U+{:04X})", ch, ch as u32);
|
||||
includes += &char_info;
|
||||
}
|
||||
cx.emit_span_lint(
|
||||
MIXED_SCRIPT_CONFUSABLES,
|
||||
sp,
|
||||
MixedScriptConfusables { set: script_set.to_string(), includes },
|
||||
);
|
||||
cx.emit_span_lint(MIXED_SCRIPT_CONFUSABLES, sp, MixedScriptConfusables {
|
||||
set: script_set.to_string(),
|
||||
includes,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@ use rustc_session::lint::FutureIncompatibilityReason;
|
|||
use rustc_session::{declare_lint, declare_lint_pass};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::symbol::kw;
|
||||
use rustc_span::{hygiene, sym, InnerSpan, Span, Symbol};
|
||||
use rustc_span::{InnerSpan, Span, Symbol, hygiene, sym};
|
||||
use rustc_trait_selection::infer::InferCtxtExt;
|
||||
|
||||
use crate::lints::{NonFmtPanicBraces, NonFmtPanicUnused};
|
||||
use crate::{fluent_generated as fluent, LateContext, LateLintPass, LintContext};
|
||||
use crate::{LateContext, LateLintPass, LintContext, fluent_generated as fluent};
|
||||
|
||||
declare_lint! {
|
||||
/// The `non_fmt_panics` lint detects `panic!(..)` invocations where the first
|
||||
|
@ -255,14 +255,10 @@ fn check_panic_str<'tcx>(
|
|||
.map(|span| fmt_span.from_inner(InnerSpan::new(span.start, span.end)))
|
||||
.collect(),
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
NON_FMT_PANICS,
|
||||
arg_spans,
|
||||
NonFmtPanicUnused {
|
||||
count: n_arguments,
|
||||
suggestion: is_arg_inside_call(arg.span, span).then_some(arg.span),
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(NON_FMT_PANICS, arg_spans, NonFmtPanicUnused {
|
||||
count: n_arguments,
|
||||
suggestion: is_arg_inside_call(arg.span, span).then_some(arg.span),
|
||||
});
|
||||
} else {
|
||||
let brace_spans: Option<Vec<_>> =
|
||||
snippet.filter(|s| s.starts_with('"') || s.starts_with("r#")).map(|s| {
|
||||
|
|
|
@ -10,14 +10,14 @@ use rustc_middle::ty::{
|
|||
use rustc_session::{declare_lint, impl_lint_pass};
|
||||
use rustc_span::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_span::symbol::kw;
|
||||
use rustc_span::{sym, ExpnKind, MacroKind, Span, Symbol};
|
||||
use rustc_span::{ExpnKind, MacroKind, Span, Symbol, sym};
|
||||
use rustc_trait_selection::error_reporting::traits::ambiguity::{
|
||||
compute_applicable_impls_for_diagnostics, CandidateSource,
|
||||
CandidateSource, compute_applicable_impls_for_diagnostics,
|
||||
};
|
||||
use rustc_trait_selection::infer::TyCtxtInferExt;
|
||||
|
||||
use crate::lints::{NonLocalDefinitionsCargoUpdateNote, NonLocalDefinitionsDiag};
|
||||
use crate::{fluent_generated as fluent, LateContext, LateLintPass, LintContext};
|
||||
use crate::{LateContext, LateLintPass, LintContext, fluent_generated as fluent};
|
||||
|
||||
declare_lint! {
|
||||
/// The `non_local_definitions` lint checks for `impl` blocks and `#[macro_export]`
|
||||
|
@ -277,26 +277,22 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
|
|||
None
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
NON_LOCAL_DEFINITIONS,
|
||||
ms,
|
||||
NonLocalDefinitionsDiag::Impl {
|
||||
depth: self.body_depth,
|
||||
body_kind_descr: cx.tcx.def_kind_descr(parent_def_kind, parent),
|
||||
body_name: parent_opt_item_name
|
||||
.map(|s| s.to_ident_string())
|
||||
.unwrap_or_else(|| "<unnameable>".to_string()),
|
||||
cargo_update: cargo_update(),
|
||||
const_anon,
|
||||
self_ty_str,
|
||||
of_trait_str,
|
||||
move_to,
|
||||
doctest,
|
||||
may_remove,
|
||||
has_trait: impl_.of_trait.is_some(),
|
||||
macro_to_change,
|
||||
},
|
||||
)
|
||||
cx.emit_span_lint(NON_LOCAL_DEFINITIONS, ms, NonLocalDefinitionsDiag::Impl {
|
||||
depth: self.body_depth,
|
||||
body_kind_descr: cx.tcx.def_kind_descr(parent_def_kind, parent),
|
||||
body_name: parent_opt_item_name
|
||||
.map(|s| s.to_ident_string())
|
||||
.unwrap_or_else(|| "<unnameable>".to_string()),
|
||||
cargo_update: cargo_update(),
|
||||
const_anon,
|
||||
self_ty_str,
|
||||
of_trait_str,
|
||||
move_to,
|
||||
doctest,
|
||||
may_remove,
|
||||
has_trait: impl_.of_trait.is_some(),
|
||||
macro_to_change,
|
||||
})
|
||||
}
|
||||
ItemKind::Macro(_macro, MacroKind::Bang)
|
||||
if cx.tcx.has_attr(item.owner_id.def_id, sym::macro_export) =>
|
||||
|
|
|
@ -5,7 +5,7 @@ use rustc_middle::ty;
|
|||
use rustc_session::config::CrateType;
|
||||
use rustc_session::{declare_lint, declare_lint_pass};
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::symbol::{sym, Ident};
|
||||
use rustc_span::symbol::{Ident, sym};
|
||||
use rustc_span::{BytePos, Span};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir};
|
||||
|
@ -151,11 +151,11 @@ impl NonCamelCaseTypes {
|
|||
} else {
|
||||
NonCamelCaseTypeSub::Label { span: ident.span }
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
NON_CAMEL_CASE_TYPES,
|
||||
ident.span,
|
||||
NonCamelCaseType { sort, name, sub },
|
||||
);
|
||||
cx.emit_span_lint(NON_CAMEL_CASE_TYPES, ident.span, NonCamelCaseType {
|
||||
sort,
|
||||
name,
|
||||
sub,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -489,11 +489,11 @@ impl NonUpperCaseGlobals {
|
|||
} else {
|
||||
NonUpperCaseGlobalSub::Label { span: ident.span }
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
NON_UPPER_CASE_GLOBALS,
|
||||
ident.span,
|
||||
NonUpperCaseGlobal { sort, name, sub },
|
||||
);
|
||||
cx.emit_span_lint(NON_UPPER_CASE_GLOBALS, ident.span, NonUpperCaseGlobal {
|
||||
sort,
|
||||
name,
|
||||
sub,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,17 +128,13 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
|
|||
ty::Adt(def, _) => Some(cx.tcx.def_span(def.did()).shrink_to_lo()),
|
||||
_ => None,
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
NOOP_METHOD_CALL,
|
||||
span,
|
||||
NoopMethodCallDiag {
|
||||
method: call.ident.name,
|
||||
orig_ty,
|
||||
trait_,
|
||||
label: span,
|
||||
suggest_derive,
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(NOOP_METHOD_CALL, span, NoopMethodCallDiag {
|
||||
method: call.ident.name,
|
||||
orig_ty,
|
||||
trait_,
|
||||
label: span,
|
||||
suggest_derive,
|
||||
});
|
||||
} else {
|
||||
match name {
|
||||
// If `type_of(x) == T` and `x.borrow()` is used to get `&T`,
|
||||
|
|
|
@ -5,8 +5,8 @@ use rustc_middle::ty::fold::BottomUpFolder;
|
|||
use rustc_middle::ty::print::{PrintTraitPredicateExt as _, TraitPredPrintModifiersAndPath};
|
||||
use rustc_middle::ty::{self, Ty, TypeFoldable};
|
||||
use rustc_session::{declare_lint, declare_lint_pass};
|
||||
use rustc_span::symbol::kw;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::kw;
|
||||
use rustc_trait_selection::traits::{self, ObligationCtxt};
|
||||
|
||||
use crate::{LateContext, LateLintPass, LintContext};
|
||||
|
|
|
@ -31,11 +31,10 @@ impl<'tcx> LateLintPass<'tcx> for PassByValue {
|
|||
}
|
||||
}
|
||||
if let Some(t) = path_for_pass_by_value(cx, inner_ty) {
|
||||
cx.emit_span_lint(
|
||||
PASS_BY_VALUE,
|
||||
ty.span,
|
||||
PassByValueDiag { ty: t, suggestion: ty.span },
|
||||
);
|
||||
cx.emit_span_lint(PASS_BY_VALUE, ty.span, PassByValueDiag {
|
||||
ty: t,
|
||||
suggestion: ty.span,
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use rustc_session::lint::builtin::HardwiredLints;
|
||||
use rustc_session::lint::LintPass;
|
||||
use rustc_session::lint::builtin::HardwiredLints;
|
||||
|
||||
use crate::context::{EarlyContext, LateContext};
|
||||
|
||||
|
|
|
@ -50,10 +50,9 @@ fn maybe_lint_redundant_semis(cx: &EarlyContext<'_>, seq: &mut Option<(Span, boo
|
|||
return;
|
||||
}
|
||||
|
||||
cx.emit_span_lint(
|
||||
REDUNDANT_SEMICOLONS,
|
||||
span,
|
||||
RedundantSemicolonsDiag { multiple, suggestion: span },
|
||||
);
|
||||
cx.emit_span_lint(REDUNDANT_SEMICOLONS, span, RedundantSemicolonsDiag {
|
||||
multiple,
|
||||
suggestion: span,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,10 +146,11 @@ impl<'tcx> LateLintPass<'tcx> for ShadowedIntoIter {
|
|||
None
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
lint,
|
||||
call.ident.span,
|
||||
ShadowedIntoIterDiag { target, edition, suggestion: call.ident.span, sub },
|
||||
);
|
||||
cx.emit_span_lint(lint, call.ident.span, ShadowedIntoIterDiag {
|
||||
target,
|
||||
edition,
|
||||
suggestion: call.ident.span,
|
||||
sub,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ use rustc_hir::{Expr, Stmt};
|
|||
use rustc_middle::ty::{Mutability, TyKind};
|
||||
use rustc_session::lint::FutureIncompatibilityReason;
|
||||
use rustc_session::{declare_lint, declare_lint_pass};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::edition::Edition;
|
||||
|
||||
use crate::lints::{MutRefSugg, RefOfMutStatic};
|
||||
use crate::{LateContext, LateLintPass, LintContext};
|
||||
|
@ -146,9 +146,11 @@ fn emit_static_mut_refs(
|
|||
}
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
STATIC_MUT_REFS,
|
||||
cx.emit_span_lint(STATIC_MUT_REFS, span, RefOfMutStatic {
|
||||
span,
|
||||
RefOfMutStatic { span, sugg, shared_label, shared_note, mut_note },
|
||||
);
|
||||
sugg,
|
||||
shared_label,
|
||||
shared_note,
|
||||
mut_note,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ use rustc_macros::LintDiagnostic;
|
|||
use rustc_middle::ty;
|
||||
use rustc_session::lint::FutureIncompatibilityReason;
|
||||
use rustc_session::{declare_lint, declare_lint_pass};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::edition::Edition;
|
||||
|
||||
use crate::{LateContext, LateLintPass};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustc_span::{create_default_session_globals_then, Symbol};
|
||||
use rustc_span::{Symbol, create_default_session_globals_then};
|
||||
|
||||
use crate::levels::parse_lint_and_tool_name;
|
||||
|
||||
|
|
|
@ -101,11 +101,11 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
|
|||
continue;
|
||||
}
|
||||
let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { return };
|
||||
cx.emit_span_lint(
|
||||
DROP_BOUNDS,
|
||||
span,
|
||||
DropTraitConstraintsDiag { predicate, tcx: cx.tcx, def_id },
|
||||
);
|
||||
cx.emit_span_lint(DROP_BOUNDS, span, DropTraitConstraintsDiag {
|
||||
predicate,
|
||||
tcx: cx.tcx,
|
||||
def_id,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use rustc_middle::ty::{
|
|||
use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass};
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::{source_map, Span, Symbol};
|
||||
use rustc_span::{Span, Symbol, source_map};
|
||||
use rustc_target::abi::{Abi, TagEncoding, Variants, WrappingRange};
|
||||
use rustc_target::spec::abi::Abi as SpecAbi;
|
||||
use tracing::debug;
|
||||
|
@ -24,7 +24,7 @@ use crate::lints::{
|
|||
AtomicOrderingStore, ImproperCTypes, InvalidAtomicOrderingDiag, InvalidNanComparisons,
|
||||
InvalidNanComparisonsSuggestion, UnusedComparisons, VariantSizeDifferencesDiag,
|
||||
};
|
||||
use crate::{fluent_generated as fluent, LateContext, LateLintPass, LintContext};
|
||||
use crate::{LateContext, LateLintPass, LintContext, fluent_generated as fluent};
|
||||
|
||||
mod literal;
|
||||
|
||||
|
@ -434,16 +434,13 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits {
|
|||
}
|
||||
|
||||
fn rev_binop(binop: hir::BinOp) -> hir::BinOp {
|
||||
source_map::respan(
|
||||
binop.span,
|
||||
match binop.node {
|
||||
hir::BinOpKind::Lt => hir::BinOpKind::Gt,
|
||||
hir::BinOpKind::Le => hir::BinOpKind::Ge,
|
||||
hir::BinOpKind::Gt => hir::BinOpKind::Lt,
|
||||
hir::BinOpKind::Ge => hir::BinOpKind::Le,
|
||||
_ => return binop,
|
||||
},
|
||||
)
|
||||
source_map::respan(binop.span, match binop.node {
|
||||
hir::BinOpKind::Lt => hir::BinOpKind::Gt,
|
||||
hir::BinOpKind::Le => hir::BinOpKind::Ge,
|
||||
hir::BinOpKind::Gt => hir::BinOpKind::Lt,
|
||||
hir::BinOpKind::Ge => hir::BinOpKind::Le,
|
||||
_ => return binop,
|
||||
})
|
||||
}
|
||||
|
||||
fn check_limits(
|
||||
|
@ -1193,11 +1190,14 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
self.cx.emit_span_lint(
|
||||
lint,
|
||||
sp,
|
||||
ImproperCTypes { ty, desc, label: sp, help, note, span_note },
|
||||
);
|
||||
self.cx.emit_span_lint(lint, sp, ImproperCTypes {
|
||||
ty,
|
||||
desc,
|
||||
label: sp,
|
||||
help,
|
||||
note,
|
||||
span_note,
|
||||
});
|
||||
}
|
||||
|
||||
fn check_for_opaque_ty(&mut self, sp: Span, ty: Ty<'tcx>) -> bool {
|
||||
|
@ -1666,11 +1666,11 @@ impl InvalidAtomicOrdering {
|
|||
}
|
||||
|
||||
fn check_atomic_compare_exchange(cx: &LateContext<'_>, expr: &Expr<'_>) {
|
||||
let Some((method, args)) = Self::inherent_atomic_method_call(
|
||||
cx,
|
||||
expr,
|
||||
&[sym::fetch_update, sym::compare_exchange, sym::compare_exchange_weak],
|
||||
) else {
|
||||
let Some((method, args)) = Self::inherent_atomic_method_call(cx, expr, &[
|
||||
sym::fetch_update,
|
||||
sym::compare_exchange,
|
||||
sym::compare_exchange_weak,
|
||||
]) else {
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
use hir::{is_range_literal, ExprKind, Node};
|
||||
use rustc_middle::ty::layout::IntegerExt;
|
||||
use hir::{ExprKind, Node, is_range_literal};
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_middle::ty::layout::IntegerExt;
|
||||
use rustc_middle::{bug, ty};
|
||||
use rustc_target::abi::{Integer, Size};
|
||||
use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir};
|
||||
|
||||
use crate::LateContext;
|
||||
use crate::context::LintContext;
|
||||
use crate::lints::{
|
||||
OnlyCastu8ToChar, OverflowingBinHex, OverflowingBinHexSign, OverflowingBinHexSignBitSub,
|
||||
OverflowingBinHexSub, OverflowingInt, OverflowingIntHelp, OverflowingLiteral, OverflowingUInt,
|
||||
RangeEndpointOutOfRange, UseInclusiveRange,
|
||||
};
|
||||
use crate::types::{TypeLimits, OVERFLOWING_LITERALS};
|
||||
use crate::LateContext;
|
||||
use crate::types::{OVERFLOWING_LITERALS, TypeLimits};
|
||||
|
||||
/// Attempts to special-case the overflowing literal lint when it occurs as a range endpoint (`expr..MAX+1`).
|
||||
/// Returns `true` iff the lint was emitted.
|
||||
|
@ -74,11 +74,10 @@ fn lint_overflowing_range_endpoint<'tcx>(
|
|||
}
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
struct_expr.span,
|
||||
RangeEndpointOutOfRange { ty, sub: sub_sugg },
|
||||
);
|
||||
cx.emit_span_lint(OVERFLOWING_LITERALS, struct_expr.span, RangeEndpointOutOfRange {
|
||||
ty,
|
||||
sub: sub_sugg,
|
||||
});
|
||||
|
||||
// We've just emitted a lint, special cased for `(...)..MAX+1` ranges,
|
||||
// return `true` so the callers don't also emit a lint
|
||||
|
@ -187,19 +186,15 @@ fn report_bin_hex_error(
|
|||
})
|
||||
.flatten();
|
||||
|
||||
cx.emit_span_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
expr.span,
|
||||
OverflowingBinHex {
|
||||
ty: t,
|
||||
lit: repr_str.clone(),
|
||||
dec: val,
|
||||
actually,
|
||||
sign,
|
||||
sub,
|
||||
sign_bit_sub,
|
||||
},
|
||||
)
|
||||
cx.emit_span_lint(OVERFLOWING_LITERALS, expr.span, OverflowingBinHex {
|
||||
ty: t,
|
||||
lit: repr_str.clone(),
|
||||
dec: val,
|
||||
actually,
|
||||
sign,
|
||||
sub,
|
||||
sign_bit_sub,
|
||||
})
|
||||
}
|
||||
|
||||
// Find the "next" fitting integer and return a suggestion string
|
||||
|
@ -266,11 +261,13 @@ fn lint_int_literal<'tcx>(
|
|||
let help = get_type_suggestion(cx.typeck_results().node_type(e.hir_id), v, negative)
|
||||
.map(|suggestion_ty| OverflowingIntHelp { suggestion_ty });
|
||||
|
||||
cx.emit_span_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
span,
|
||||
OverflowingInt { ty: t.name_str(), lit, min, max, help },
|
||||
);
|
||||
cx.emit_span_lint(OVERFLOWING_LITERALS, span, OverflowingInt {
|
||||
ty: t.name_str(),
|
||||
lit,
|
||||
min,
|
||||
max,
|
||||
help,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,11 +291,10 @@ fn lint_uint_literal<'tcx>(
|
|||
match par_e.kind {
|
||||
hir::ExprKind::Cast(..) => {
|
||||
if let ty::Char = cx.typeck_results().expr_ty(par_e).kind() {
|
||||
cx.emit_span_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
par_e.span,
|
||||
OnlyCastu8ToChar { span: par_e.span, literal: lit_val },
|
||||
);
|
||||
cx.emit_span_lint(OVERFLOWING_LITERALS, par_e.span, OnlyCastu8ToChar {
|
||||
span: par_e.span,
|
||||
literal: lit_val,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -321,20 +317,16 @@ fn lint_uint_literal<'tcx>(
|
|||
);
|
||||
return;
|
||||
}
|
||||
cx.emit_span_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
e.span,
|
||||
OverflowingUInt {
|
||||
ty: t.name_str(),
|
||||
lit: cx
|
||||
.sess()
|
||||
.source_map()
|
||||
.span_to_snippet(lit.span)
|
||||
.unwrap_or_else(|_| lit_val.to_string()),
|
||||
min,
|
||||
max,
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(OVERFLOWING_LITERALS, e.span, OverflowingUInt {
|
||||
ty: t.name_str(),
|
||||
lit: cx
|
||||
.sess()
|
||||
.source_map()
|
||||
.span_to_snippet(lit.span)
|
||||
.unwrap_or_else(|_| lit_val.to_string()),
|
||||
min,
|
||||
max,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,18 +359,14 @@ pub(crate) fn lint_literal<'tcx>(
|
|||
_ => bug!(),
|
||||
};
|
||||
if is_infinite == Ok(true) {
|
||||
cx.emit_span_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
e.span,
|
||||
OverflowingLiteral {
|
||||
ty: t.name_str(),
|
||||
lit: cx
|
||||
.sess()
|
||||
.source_map()
|
||||
.span_to_snippet(lit.span)
|
||||
.unwrap_or_else(|_| sym.to_string()),
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(OVERFLOWING_LITERALS, e.span, OverflowingLiteral {
|
||||
ty: t.name_str(),
|
||||
lit: cx
|
||||
.sess()
|
||||
.source_map()
|
||||
.span_to_snippet(lit.span)
|
||||
.unwrap_or_else(|_| sym.to_string()),
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -63,11 +63,9 @@ impl<'tcx> LateLintPass<'tcx> for UnitBindings {
|
|||
&& !matches!(init.kind, hir::ExprKind::Tup([]))
|
||||
&& !matches!(local.pat.kind, hir::PatKind::Tuple([], ..))
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
UNIT_BINDINGS,
|
||||
local.span,
|
||||
UnitBindingsDiag { label: local.pat.span },
|
||||
);
|
||||
cx.emit_span_lint(UNIT_BINDINGS, local.span, UnitBindingsDiag {
|
||||
label: local.pat.span,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,14 +4,14 @@ use std::ops::ControlFlow;
|
|||
use rustc_ast as ast;
|
||||
use rustc_ast::util::{classify, parser};
|
||||
use rustc_ast::{ExprKind, StmtKind};
|
||||
use rustc_errors::{pluralize, MultiSpan};
|
||||
use rustc_errors::{MultiSpan, pluralize};
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{self as hir, LangItem};
|
||||
use rustc_infer::traits::util::elaborate;
|
||||
use rustc_middle::ty::{self, adjustment, Ty};
|
||||
use rustc_middle::ty::{self, Ty, adjustment};
|
||||
use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass};
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::symbol::{Symbol, kw, sym};
|
||||
use rustc_span::{BytePos, Span};
|
||||
use tracing::instrument;
|
||||
|
||||
|
@ -185,22 +185,18 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
|||
let mut op_warned = false;
|
||||
|
||||
if let Some(must_use_op) = must_use_op {
|
||||
cx.emit_span_lint(
|
||||
UNUSED_MUST_USE,
|
||||
expr.span,
|
||||
UnusedOp {
|
||||
op: must_use_op,
|
||||
label: expr.span,
|
||||
suggestion: if expr_is_from_block {
|
||||
UnusedOpSuggestion::BlockTailExpr {
|
||||
before_span: expr.span.shrink_to_lo(),
|
||||
after_span: expr.span.shrink_to_hi(),
|
||||
}
|
||||
} else {
|
||||
UnusedOpSuggestion::NormalExpr { span: expr.span.shrink_to_lo() }
|
||||
},
|
||||
cx.emit_span_lint(UNUSED_MUST_USE, expr.span, UnusedOp {
|
||||
op: must_use_op,
|
||||
label: expr.span,
|
||||
suggestion: if expr_is_from_block {
|
||||
UnusedOpSuggestion::BlockTailExpr {
|
||||
before_span: expr.span.shrink_to_lo(),
|
||||
after_span: expr.span.shrink_to_hi(),
|
||||
}
|
||||
} else {
|
||||
UnusedOpSuggestion::NormalExpr { span: expr.span.shrink_to_lo() }
|
||||
},
|
||||
);
|
||||
});
|
||||
op_warned = true;
|
||||
}
|
||||
|
||||
|
@ -497,39 +493,35 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
|||
);
|
||||
}
|
||||
MustUsePath::Closure(span) => {
|
||||
cx.emit_span_lint(
|
||||
UNUSED_MUST_USE,
|
||||
*span,
|
||||
UnusedClosure { count: plural_len, pre: descr_pre, post: descr_post },
|
||||
);
|
||||
cx.emit_span_lint(UNUSED_MUST_USE, *span, UnusedClosure {
|
||||
count: plural_len,
|
||||
pre: descr_pre,
|
||||
post: descr_post,
|
||||
});
|
||||
}
|
||||
MustUsePath::Coroutine(span) => {
|
||||
cx.emit_span_lint(
|
||||
UNUSED_MUST_USE,
|
||||
*span,
|
||||
UnusedCoroutine { count: plural_len, pre: descr_pre, post: descr_post },
|
||||
);
|
||||
cx.emit_span_lint(UNUSED_MUST_USE, *span, UnusedCoroutine {
|
||||
count: plural_len,
|
||||
pre: descr_pre,
|
||||
post: descr_post,
|
||||
});
|
||||
}
|
||||
MustUsePath::Def(span, def_id, reason) => {
|
||||
cx.emit_span_lint(
|
||||
UNUSED_MUST_USE,
|
||||
*span,
|
||||
UnusedDef {
|
||||
pre: descr_pre,
|
||||
post: descr_post,
|
||||
cx,
|
||||
def_id: *def_id,
|
||||
note: *reason,
|
||||
suggestion: (!is_inner).then_some(if expr_is_from_block {
|
||||
UnusedDefSuggestion::BlockTailExpr {
|
||||
before_span: span.shrink_to_lo(),
|
||||
after_span: span.shrink_to_hi(),
|
||||
}
|
||||
} else {
|
||||
UnusedDefSuggestion::NormalExpr { span: span.shrink_to_lo() }
|
||||
}),
|
||||
},
|
||||
);
|
||||
cx.emit_span_lint(UNUSED_MUST_USE, *span, UnusedDef {
|
||||
pre: descr_pre,
|
||||
post: descr_post,
|
||||
cx,
|
||||
def_id: *def_id,
|
||||
note: *reason,
|
||||
suggestion: (!is_inner).then_some(if expr_is_from_block {
|
||||
UnusedDefSuggestion::BlockTailExpr {
|
||||
before_span: span.shrink_to_lo(),
|
||||
after_span: span.shrink_to_hi(),
|
||||
}
|
||||
} else {
|
||||
UnusedDefSuggestion::NormalExpr { span: span.shrink_to_lo() }
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -791,7 +783,7 @@ trait UnusedDelimLint {
|
|||
// ```
|
||||
// fn f(){(print!(á
|
||||
// ```
|
||||
use rustc_ast::visit::{walk_expr, Visitor};
|
||||
use rustc_ast::visit::{Visitor, walk_expr};
|
||||
struct ErrExprVisitor;
|
||||
impl<'ast> Visitor<'ast> for ErrExprVisitor {
|
||||
type Result = ControlFlow<()>;
|
||||
|
@ -869,11 +861,11 @@ trait UnusedDelimLint {
|
|||
end_replace: hi_replace,
|
||||
}
|
||||
});
|
||||
cx.emit_span_lint(
|
||||
self.lint(),
|
||||
primary_span,
|
||||
UnusedDelim { delim: Self::DELIM_STR, item: msg, suggestion },
|
||||
);
|
||||
cx.emit_span_lint(self.lint(), primary_span, UnusedDelim {
|
||||
delim: Self::DELIM_STR,
|
||||
item: msg,
|
||||
suggestion,
|
||||
});
|
||||
}
|
||||
|
||||
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
|
||||
|
@ -1558,11 +1550,9 @@ impl UnusedImportBraces {
|
|||
ast::UseTreeKind::Nested { .. } => return,
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
UNUSED_IMPORT_BRACES,
|
||||
item.span,
|
||||
UnusedImportBracesDiag { node: node_name },
|
||||
);
|
||||
cx.emit_span_lint(UNUSED_IMPORT_BRACES, item.span, UnusedImportBracesDiag {
|
||||
node: node_name,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue