Auto merge of #3705 - matthiaskrgr:rustup, r=phansch

rustup

rustup https://github.com/rust-lang/rust/pull/57907/ and https://github.com/rust-lang/rust/pull/57726
Fixes #3708
This commit is contained in:
bors 2019-01-27 13:14:37 +00:00
commit 13421e3945
133 changed files with 696 additions and 109 deletions

View File

@ -60,6 +60,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(APPROX_CONSTANT)
}
fn name(&self) -> &'static str {
"ApproxConstant"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -52,6 +52,10 @@ impl LintPass for Arithmetic {
fn get_lints(&self) -> LintArray {
lint_array!(INTEGER_ARITHMETIC, FLOAT_ARITHMETIC)
}
fn name(&self) -> &'static str {
"Arithmetic"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {

View File

@ -34,6 +34,10 @@ impl LintPass for AssertionsOnConstants {
fn get_lints(&self) -> LintArray {
lint_array![ASSERTIONS_ON_CONSTANTS]
}
fn name(&self) -> &'static str {
"AssertionsOnConstants"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {

View File

@ -57,6 +57,10 @@ impl LintPass for AssignOps {
fn get_lints(&self) -> LintArray {
lint_array!(ASSIGN_OP_PATTERN, MISREFACTORED_ASSIGN_OP)
}
fn name(&self) -> &'static str {
"AssignOps"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
@ -79,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
let r = &sugg::Sugg::hir(cx, rhs, "..");
let long =
format!("{} = {}", snip_a, sugg::make_binop(higher::binop(op.node), a, r));
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
&format!(
"Did you mean {} = {} {} {} or {}? Consider replacing it with",
@ -92,7 +96,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
Applicability::MachineApplicable,
);
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"or",
long,
@ -179,7 +183,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
if let (Some(snip_a), Some(snip_r)) =
(snippet_opt(cx, assignee.span), snippet_opt(cx, rhs.span))
{
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"replace it with",
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),

View File

@ -199,6 +199,10 @@ impl LintPass for AttrPass {
UNKNOWN_CLIPPY_LINTS,
)
}
fn name(&self) -> &'static str {
"Attributes"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
@ -269,7 +273,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
"useless lint attribute",
|db| {
sugg = sugg.replacen("#[", "#![", 1);
db.span_suggestion_with_applicability(
db.span_suggestion(
line_span,
"if you just forgot a `!`, use",
sugg,
@ -332,7 +336,7 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) {
// https://github.com/rust-lang/rust/pull/56992
CheckLintNameResult::NoLint(None) => (),
_ => {
db.span_suggestion_with_applicability(
db.span_suggestion(
lint.span,
"lowercase the lint name",
name_lower,
@ -500,6 +504,10 @@ impl LintPass for CfgAttrPass {
fn get_lints(&self) -> LintArray {
lint_array!(DEPRECATED_CFG_ATTR,)
}
fn name(&self) -> &'static str {
"DeprecatedCfgAttribute"
}
}
impl EarlyLintPass for CfgAttrPass {

View File

@ -108,6 +108,9 @@ impl LintPass for BitMask {
fn get_lints(&self) -> LintArray {
lint_array!(BAD_BIT_MASK, INEFFECTIVE_BIT_MASK, VERBOSE_BIT_MASK)
}
fn name(&self) -> &'static str {
"BitMask"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
@ -139,7 +142,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
"bit mask could be simplified with a call to `trailing_zeros`",
|db| {
let sugg = Sugg::hir(cx, left1, "...").maybe_par();
db.span_suggestion_with_applicability(
db.span_suggestion(
e.span,
"try",
format!("{}.trailing_zeros() >= {}", sugg, n.count_ones()),

View File

@ -37,6 +37,9 @@ impl LintPass for BlackListedName {
fn get_lints(&self) -> LintArray {
lint_array!(BLACKLISTED_NAME)
}
fn name(&self) -> &'static str {
"BlacklistedName"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlackListedName {

View File

@ -49,6 +49,10 @@ impl LintPass for BlockInIfCondition {
fn get_lints(&self) -> LintArray {
lint_array!(BLOCK_IN_IF_CONDITION_EXPR, BLOCK_IN_IF_CONDITION_STMT)
}
fn name(&self) -> &'static str {
"BlockInIfCondition"
}
}
struct ExVisitor<'a, 'tcx: 'a> {

View File

@ -58,6 +58,10 @@ impl LintPass for NonminimalBool {
fn get_lints(&self) -> LintArray {
lint_array!(NONMINIMAL_BOOL, LOGIC_BUG)
}
fn name(&self) -> &'static str {
"NonminimalBool"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonminimalBool {
@ -389,7 +393,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
"this expression can be optimized out by applying boolean operations to the \
outer expression",
);
db.span_suggestion_with_applicability(
db.span_suggestion(
e.span,
"it would look like the following",
suggest(self.cx, suggestion, &h2q.terminals).0,
@ -419,7 +423,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
e.span,
"this boolean expression can be simplified",
|db| {
db.span_suggestions_with_applicability(
db.span_suggestions(
e.span,
"try",
suggestions.into_iter(),

View File

@ -38,6 +38,10 @@ impl LintPass for ByteCount {
fn get_lints(&self) -> LintArray {
lint_array!(NAIVE_BYTECOUNT)
}
fn name(&self) -> &'static str {
"ByteCount"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {

View File

@ -62,6 +62,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(CARGO_COMMON_METADATA)
}
fn name(&self) -> &'static str {
"CargoCommonMetadata"
}
}
impl EarlyLintPass for Pass {

View File

@ -78,6 +78,10 @@ impl LintPass for CollapsibleIf {
fn get_lints(&self) -> LintArray {
lint_array!(COLLAPSIBLE_IF)
}
fn name(&self) -> &'static str {
"CollapsibleIf"
}
}
impl EarlyLintPass for CollapsibleIf {
@ -150,7 +154,7 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: &
span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this if statement can be collapsed", |db| {
let lhs = Sugg::ast(cx, check, "..");
let rhs = Sugg::ast(cx, check_inner, "..");
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"try",
format!(

View File

@ -32,6 +32,10 @@ impl LintPass for StaticConst {
fn get_lints(&self) -> LintArray {
lint_array!(CONST_STATIC_LIFETIME)
}
fn name(&self) -> &'static str {
"StaticConst"
}
}
impl StaticConst {
@ -62,7 +66,7 @@ impl StaticConst {
lifetime.ident.span,
"Constants have by default a `'static` lifetime",
|db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
ty.span,
"consider removing `'static`",
sugg,

View File

@ -110,6 +110,10 @@ impl LintPass for CopyAndPaste {
fn get_lints(&self) -> LintArray {
lint_array![IFS_SAME_COND, IF_SAME_THEN_ELSE, MATCH_SAME_ARMS]
}
fn name(&self) -> &'static str {
"CopyAndPaste"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyAndPaste {
@ -203,7 +207,7 @@ fn lint_match_arms(cx: &LateContext<'_, '_>, expr: &Expr) {
|db| {
db.span_note(i.body.span, "same as this");
// Note: this does not use `span_suggestion_with_applicability` on purpose:
// Note: this does not use `span_suggestion` on purpose:
// there is no clean way
// to remove the other arm. Building a span and suggest to replace it to ""
// makes an even more confusing error message. Also in order not to make up a

View File

@ -35,6 +35,10 @@ impl LintPass for CopyIterator {
fn get_lints(&self) -> LintArray {
lint_array![COPY_ITERATOR]
}
fn name(&self) -> &'static str {
"CopyIterator"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyIterator {

View File

@ -42,6 +42,10 @@ impl LintPass for CyclomaticComplexity {
fn get_lints(&self) -> LintArray {
lint_array!(CYCLOMATIC_COMPLEXITY)
}
fn name(&self) -> &'static str {
"CyclomaticComplexity"
}
}
impl CyclomaticComplexity {

View File

@ -35,6 +35,10 @@ impl LintPass for DefaultTraitAccess {
fn get_lints(&self) -> LintArray {
lint_array!(DEFAULT_TRAIT_ACCESS)
}
fn name(&self) -> &'static str {
"DefaultTraitAccess"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess {

View File

@ -68,6 +68,10 @@ impl LintPass for Derive {
fn get_lints(&self) -> LintArray {
lint_array!(EXPL_IMPL_CLONE_ON_COPY, DERIVE_HASH_XOR_EQ)
}
fn name(&self) -> &'static str {
"Derive"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {

View File

@ -48,6 +48,10 @@ impl LintPass for Doc {
fn get_lints(&self) -> LintArray {
lint_array![DOC_MARKDOWN]
}
fn name(&self) -> &'static str {
"DocMarkdown"
}
}
impl EarlyLintPass for Doc {

View File

@ -37,6 +37,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(DOUBLE_COMPARISONS)
}
fn name(&self) -> &'static str {
"DoubleComparisons"
}
}
impl<'a, 'tcx> Pass {

View File

@ -29,6 +29,10 @@ impl LintPass for DoubleParens {
fn get_lints(&self) -> LintArray {
lint_array!(DOUBLE_PARENS)
}
fn name(&self) -> &'static str {
"DoubleParens"
}
}
impl EarlyLintPass for DoubleParens {

View File

@ -112,6 +112,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(DROP_REF, FORGET_REF, DROP_COPY, FORGET_COPY)
}
fn name(&self) -> &'static str {
"DropForgetRef"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -36,6 +36,10 @@ impl LintPass for DurationSubsec {
fn get_lints(&self) -> LintArray {
lint_array!(DURATION_SUBSEC)
}
fn name(&self) -> &'static str {
"DurationSubsec"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DurationSubsec {

View File

@ -46,6 +46,10 @@ impl LintPass for ElseIfWithoutElse {
fn get_lints(&self) -> LintArray {
lint_array!(ELSE_IF_WITHOUT_ELSE)
}
fn name(&self) -> &'static str {
"ElseIfWithoutElse"
}
}
impl EarlyLintPass for ElseIfWithoutElse {

View File

@ -30,6 +30,10 @@ impl LintPass for EmptyEnum {
fn get_lints(&self) -> LintArray {
lint_array!(EMPTY_ENUM)
}
fn name(&self) -> &'static str {
"EmptyEnum"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {

View File

@ -44,6 +44,10 @@ impl LintPass for HashMapLint {
fn get_lints(&self) -> LintArray {
lint_array!(MAP_ENTRY)
}
fn name(&self) -> &'static str {
"HashMap"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HashMapLint {
@ -145,7 +149,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
snippet(self.cx, params[1].span, ".."),
snippet(self.cx, params[2].span, ".."));
db.span_suggestion_with_applicability(
db.span_suggestion(
self.span,
"consider using",
help,
@ -157,7 +161,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
snippet(self.cx, self.map.span, "map"),
snippet(self.cx, params[1].span, ".."));
db.span_suggestion_with_applicability(
db.span_suggestion(
self.span,
"consider using",
help,

View File

@ -40,6 +40,10 @@ impl LintPass for UnportableVariant {
fn get_lints(&self) -> LintArray {
lint_array!(ENUM_CLIKE_UNPORTABLE_VARIANT)
}
fn name(&self) -> &'static str {
"UnportableVariant"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {

View File

@ -32,6 +32,10 @@ impl LintPass for EnumGlobUse {
fn get_lints(&self) -> LintArray {
lint_array!(ENUM_GLOB_USE)
}
fn name(&self) -> &'static str {
"EnumGlobUse"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EnumGlobUse {

View File

@ -124,6 +124,10 @@ impl LintPass for EnumVariantNames {
MODULE_INCEPTION
)
}
fn name(&self) -> &'static str {
"EnumVariantNames"
}
}
fn var2str(var: &Variant) -> LocalInternedString {

View File

@ -52,6 +52,10 @@ impl LintPass for EqOp {
fn get_lints(&self) -> LintArray {
lint_array!(EQ_OP, OP_REF)
}
fn name(&self) -> &'static str {
"EqOp"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
@ -122,7 +126,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
{
span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| {
let lsnip = snippet(cx, l.span, "...").to_string();
db.span_suggestion_with_applicability(
db.span_suggestion(
left.span,
"use the left value directly",
lsnip,
@ -140,7 +144,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
"needlessly taken reference of right operand",
|db| {
let rsnip = snippet(cx, r.span, "...").to_string();
db.span_suggestion_with_applicability(
db.span_suggestion(
right.span,
"use the right value directly",
rsnip,
@ -159,7 +163,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
{
span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| {
let lsnip = snippet(cx, l.span, "...").to_string();
db.span_suggestion_with_applicability(
db.span_suggestion(
left.span,
"use the left value directly",
lsnip,
@ -177,7 +181,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
{
span_lint_and_then(cx, OP_REF, e.span, "taken reference of right operand", |db| {
let rsnip = snippet(cx, r.span, "...").to_string();
db.span_suggestion_with_applicability(
db.span_suggestion(
right.span,
"use the right value directly",
rsnip,

View File

@ -32,6 +32,10 @@ impl LintPass for ErasingOp {
fn get_lints(&self) -> LintArray {
lint_array!(ERASING_OP)
}
fn name(&self) -> &'static str {
"ErasingOp"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ErasingOp {

View File

@ -52,6 +52,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(BOXED_LOCAL)
}
fn name(&self) -> &'static str {
"BoxedLocal"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -36,6 +36,10 @@ impl LintPass for EtaPass {
fn get_lints(&self) -> LintArray {
lint_array!(REDUNDANT_CLOSURE)
}
fn name(&self) -> &'static str {
"EtaReduction"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EtaPass {
@ -97,7 +101,7 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {
}
span_lint_and_then(cx, REDUNDANT_CLOSURE, expr.span, "redundant closure found", |db| {
if let Some(snippet) = snippet_opt(cx, caller.span) {
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"remove closure as shown",
snippet,

View File

@ -61,6 +61,10 @@ impl LintPass for EvalOrderDependence {
fn get_lints(&self) -> LintArray {
lint_array!(EVAL_ORDER_DEPENDENCE, DIVERGING_SUB_EXPRESSION)
}
fn name(&self) -> &'static str {
"EvalOrderDependence"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence {

View File

@ -41,6 +41,10 @@ impl LintPass for ExcessivePrecision {
fn get_lints(&self) -> LintArray {
lint_array!(EXCESSIVE_PRECISION)
}
fn name(&self) -> &'static str {
"ExcessivePrecision"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision {

View File

@ -31,6 +31,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(EXPLICIT_WRITE)
}
fn name(&self) -> &'static str {
"ExplicitWrite"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -34,6 +34,10 @@ impl LintPass for FallibleImplFrom {
fn get_lints(&self) -> LintArray {
lint_array!(FALLIBLE_IMPL_FROM)
}
fn name(&self) -> &'static str {
"FallibleImpleFrom"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom {

View File

@ -40,6 +40,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array![USELESS_FORMAT]
}
fn name(&self) -> &'static str {
"UselessFormat"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
@ -79,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
};
span_lint_and_then(cx, USELESS_FORMAT, span, "useless use of `format!`", |db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
message,
sugg,
@ -95,7 +99,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
if tup.is_empty() {
let sugg = format!("{}.to_string()", snippet(cx, expr.span, "<expr>").into_owned());
span_lint_and_then(cx, USELESS_FORMAT, span, "useless use of `format!`", |db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
span,
"consider using .to_string()",
sugg,

View File

@ -89,6 +89,10 @@ impl LintPass for Formatting {
POSSIBLE_MISSING_COMMA
)
}
fn name(&self) -> &'static str {
"Formatting"
}
}
impl EarlyLintPass for Formatting {

View File

@ -74,6 +74,10 @@ impl LintPass for Functions {
fn get_lints(&self) -> LintArray {
lint_array!(TOO_MANY_ARGUMENTS, NOT_UNSAFE_PTR_ARG_DEREF)
}
fn name(&self) -> &'static str {
"Functions"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {

View File

@ -34,6 +34,10 @@ impl LintPass for IdentityConversion {
fn get_lints(&self) -> LintArray {
lint_array!(IDENTITY_CONVERSION)
}
fn name(&self) -> &'static str {
"IdentityConversion"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
@ -67,7 +71,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
let sugg = snippet_with_macro_callsite(cx, args[0].span, "<expr>").to_string();
span_lint_and_then(cx, IDENTITY_CONVERSION, e.span, "identical conversion", |db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
e.span,
"consider removing `.into()`",
sugg,
@ -82,7 +86,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
if same_tys(cx, a, b) {
let sugg = snippet(cx, args[0].span, "<expr>").into_owned();
span_lint_and_then(cx, IDENTITY_CONVERSION, e.span, "identical conversion", |db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
e.span,
"consider removing `.into_iter()`",
sugg,
@ -104,7 +108,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
let sugg_msg =
format!("consider removing `{}()`", snippet(cx, path.span, "From::from"));
span_lint_and_then(cx, IDENTITY_CONVERSION, e.span, "identical conversion", |db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
e.span,
&sugg_msg,
sugg,

View File

@ -30,6 +30,10 @@ impl LintPass for IdentityOp {
fn get_lints(&self) -> LintArray {
lint_array!(IDENTITY_OP)
}
fn name(&self) -> &'static str {
"IdentityOp"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityOp {

View File

@ -44,6 +44,10 @@ impl LintPass for IfNotElse {
fn get_lints(&self) -> LintArray {
lint_array!(IF_NOT_ELSE)
}
fn name(&self) -> &'static str {
"IfNotElse"
}
}
impl EarlyLintPass for IfNotElse {

View File

@ -39,7 +39,7 @@ impl Pass {
fn lint(cx: &LateContext<'_, '_>, outer_span: syntax_pos::Span, inner_span: syntax_pos::Span, msg: &str) {
span_lint_and_then(cx, IMPLICIT_RETURN, outer_span, "missing return statement", |db| {
if let Some(snippet) = snippet_opt(cx, inner_span) {
db.span_suggestion_with_applicability(
db.span_suggestion(
outer_span,
msg,
format!("return {}", snippet),
@ -114,6 +114,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(IMPLICIT_RETURN)
}
fn name(&self) -> &'static str {
"ImplicitReturn"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -91,6 +91,10 @@ impl LintPass for IndexingSlicing {
fn get_lints(&self) -> LintArray {
lint_array!(INDEXING_SLICING, OUT_OF_BOUNDS_INDEXING)
}
fn name(&self) -> &'static str {
"IndexSlicing"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {

View File

@ -47,6 +47,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(INFALLIBLE_DESTRUCTURING_MATCH)
}
fn name(&self) -> &'static str {
"InfallibleDestructingMatch"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -45,6 +45,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(INFINITE_ITER, MAYBE_INFINITE_ITER)
}
fn name(&self) -> &'static str {
"InfiniteIter"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -56,6 +56,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(MULTIPLE_INHERENT_IMPL)
}
fn name(&self) -> &'static str {
"MultipleInherientImpl"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -35,6 +35,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(INLINE_FN_WITHOUT_BODY)
}
fn name(&self) -> &'static str {
"InlineFnWithoutBody"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -36,6 +36,10 @@ impl LintPass for IntPlusOne {
fn get_lints(&self) -> LintArray {
lint_array!(INT_PLUS_ONE)
}
fn name(&self) -> &'static str {
"IntPlusOne"
}
}
// cases:
@ -158,7 +162,7 @@ impl IntPlusOne {
block.span,
"Unnecessary `>= y + 1` or `x - 1 >=`",
|db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
block.span,
"change `>= y + 1` to `> y` as shown",
recommendation,

View File

@ -32,6 +32,10 @@ impl LintPass for InvalidRef {
fn get_lints(&self) -> LintArray {
lint_array!(INVALID_REF)
}
fn name(&self) -> &'static str {
"InvalidRef"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidRef {

View File

@ -40,6 +40,10 @@ impl LintPass for ItemsAfterStatements {
fn get_lints(&self) -> LintArray {
lint_array!(ITEMS_AFTER_STATEMENTS)
}
fn name(&self) -> &'static str {
"ItemsAfterStatements"
}
}
impl EarlyLintPass for ItemsAfterStatements {

View File

@ -46,6 +46,10 @@ impl LintPass for LargeEnumVariant {
fn get_lints(&self) -> LintArray {
lint_array!(LARGE_ENUM_VARIANT)
}
fn name(&self) -> &'static str {
"LargeEnumVariant"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
@ -96,7 +100,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
VariantData::Unit(_) => unreachable!(),
};
if let Some(snip) = snippet_opt(cx, span) {
db.span_suggestion_with_applicability(
db.span_suggestion(
span,
"consider boxing the large fields to reduce the total size of the \
enum",

View File

@ -77,6 +77,10 @@ impl LintPass for LenZero {
fn get_lints(&self) -> LintArray {
lint_array!(LEN_ZERO, LEN_WITHOUT_IS_EMPTY)
}
fn name(&self) -> &'static str {
"LenZero"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {

View File

@ -60,6 +60,10 @@ impl LintPass for LetIfSeq {
fn get_lints(&self) -> LintArray {
lint_array!(USELESS_LET_IF_SEQ)
}
fn name(&self) -> &'static str {
"LetIfSeq"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
@ -120,7 +124,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
span,
"`if _ { .. } else { .. }` is an expression",
|db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
span,
"it is more idiomatic to write",
sug,

View File

@ -212,15 +212,22 @@ pub fn register_pre_expansion_lints(
store: &mut rustc::lint::LintStore,
conf: &Conf,
) {
store.register_pre_expansion_pass(Some(session), box write::Pass);
store.register_pre_expansion_pass(Some(session), box redundant_field_names::RedundantFieldNames);
store.register_pre_expansion_pass(Some(session), true, false, box write::Pass);
store.register_pre_expansion_pass(
Some(session),
true,
false,
box redundant_field_names::RedundantFieldNames,
);
store.register_pre_expansion_pass(
Some(session),
true,
false,
box non_expressive_names::NonExpressiveNames {
single_char_binding_names_threshold: conf.single_char_binding_names_threshold,
},
);
store.register_pre_expansion_pass(Some(session), box attrs::CfgAttrPass);
store.register_pre_expansion_pass(Some(session), true, false, box attrs::CfgAttrPass);
}
pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf {

View File

@ -61,6 +61,10 @@ impl LintPass for LifetimePass {
fn get_lints(&self) -> LintArray {
lint_array!(NEEDLESS_LIFETIMES, EXTRA_UNUSED_LIFETIMES)
}
fn name(&self) -> &'static str {
"LifeTimes"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LifetimePass {

View File

@ -346,6 +346,10 @@ impl LintPass for LiteralDigitGrouping {
MISTYPED_LITERAL_SUFFIXES,
)
}
fn name(&self) -> &'static str {
"LiteralDigitGrouping"
}
}
impl EarlyLintPass for LiteralDigitGrouping {
@ -493,6 +497,10 @@ impl LintPass for LiteralRepresentation {
fn get_lints(&self) -> LintArray {
lint_array!(DECIMAL_LITERAL_REPRESENTATION)
}
fn name(&self) -> &'static str {
"DecimalLiteralRepresentation"
}
}
impl EarlyLintPass for LiteralRepresentation {

View File

@ -465,6 +465,10 @@ impl LintPass for Pass {
WHILE_IMMUTABLE_CONDITION,
)
}
fn name(&self) -> &'static str {
"Loops"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
@ -1300,7 +1304,7 @@ fn check_for_loop_reverse_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arg: &'tcx
expr.span,
"this range is empty so this for loop will never run",
|db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
arg.span,
"consider using the following if you are attempting to iterate over this \
range in reverse",
@ -2404,7 +2408,7 @@ fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr, cx: &LateContext<'a, 'tcx>
if method.ident.name == "len" {
let span = shorten_needless_collect_span(expr);
span_lint_and_then(cx, NEEDLESS_COLLECT, span, NEEDLESS_COLLECT_MSG, |db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
span,
"replace with",
".count()".to_string(),
@ -2415,7 +2419,7 @@ fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr, cx: &LateContext<'a, 'tcx>
if method.ident.name == "is_empty" {
let span = shorten_needless_collect_span(expr);
span_lint_and_then(cx, NEEDLESS_COLLECT, span, NEEDLESS_COLLECT_MSG, |db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
span,
"replace with",
".next().is_none()".to_string(),
@ -2427,7 +2431,7 @@ fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr, cx: &LateContext<'a, 'tcx>
let contains_arg = snippet(cx, args[1].span, "??");
let span = shorten_needless_collect_span(expr);
span_lint_and_then(cx, NEEDLESS_COLLECT, span, NEEDLESS_COLLECT_MSG, |db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
span,
"replace with",
format!(

View File

@ -46,6 +46,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(MAP_CLONE)
}
fn name(&self) -> &'static str {
"MapClone"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -81,6 +81,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(OPTION_MAP_UNIT_FN, RESULT_MAP_UNIT_FN)
}
fn name(&self) -> &'static str {
"MapUnit"
}
}
fn is_unit_type(ty: ty::Ty<'_>) -> bool {
@ -212,7 +216,7 @@ fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr
);
span_lint_and_then(cx, lint, expr.span, &msg, |db| {
db.span_suggestion_with_applicability(stmt.span, "try this", suggestion, Applicability::Unspecified);
db.span_suggestion(stmt.span, "try this", suggestion, Applicability::Unspecified);
});
} else if let Some((binding, closure_expr)) = unit_closure(cx, fn_arg) {
let msg = suggestion_msg("closure", map_type);
@ -226,7 +230,7 @@ fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr
snippet(cx, var_arg.span, "_"),
snippet(cx, reduced_expr_span, "_")
);
db.span_suggestion_with_applicability(
db.span_suggestion(
stmt.span,
"try this",
suggestion,
@ -239,7 +243,7 @@ fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr
snippet(cx, binding.pat.span, "_"),
snippet(cx, var_arg.span, "_")
);
db.span_suggestion_with_applicability(stmt.span, "try this", suggestion, Applicability::Unspecified);
db.span_suggestion(stmt.span, "try this", suggestion, Applicability::Unspecified);
}
});
}

View File

@ -202,6 +202,10 @@ impl LintPass for MatchPass {
MATCH_AS_REF
)
}
fn name(&self) -> &'static str {
"Matches"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MatchPass {
@ -371,7 +375,7 @@ fn check_match_bool(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Ex
};
if let Some(sugg) = sugg {
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"consider using an if/else expression",
sugg,

View File

@ -31,6 +31,10 @@ impl LintPass for MemDiscriminant {
fn get_lints(&self) -> LintArray {
lint_array![MEM_DISCRIMINANT_NON_ENUM]
}
fn name(&self) -> &'static str {
"MemDiscriminant"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemDiscriminant {
@ -70,7 +74,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemDiscriminant {
}
let derefs: String = iter::repeat('*').take(derefs_needed).collect();
db.span_suggestion_with_applicability(
db.span_suggestion(
param.span,
"try dereferencing",
format!("{}{}", derefs, snippet(cx, cur_expr.span, "<param>")),

View File

@ -27,6 +27,10 @@ impl LintPass for MemForget {
fn get_lints(&self) -> LintArray {
lint_array![MEM_FORGET]
}
fn name(&self) -> &'static str {
"MemForget"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemForget {

View File

@ -36,6 +36,10 @@ impl LintPass for MemReplace {
fn get_lints(&self) -> LintArray {
lint_array![MEM_REPLACE_OPTION_WITH_NONE]
}
fn name(&self) -> &'static str {
"MemReplace"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemReplace {

View File

@ -814,6 +814,10 @@ impl LintPass for Pass {
INTO_ITER_ON_REF,
)
}
fn name(&self) -> &'static str {
"Methods"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
@ -1309,13 +1313,13 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
let refs: String = iter::repeat('&').take(n + 1).collect();
let derefs: String = iter::repeat('*').take(n).collect();
let explicit = format!("{}{}::clone({})", refs, ty, snip);
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"try dereferencing it",
format!("{}({}{}).clone()", refs, derefs, snip.deref()),
Applicability::MaybeIncorrect,
);
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"or try being explicit about what type to clone",
explicit,
@ -1375,7 +1379,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
}
span_lint_and_then(cx, CLONE_ON_COPY, expr.span, "using `clone` on a `Copy` type", |db| {
if let Some((text, snip)) = snip {
db.span_suggestion_with_applicability(expr.span, text, snip, Applicability::Unspecified);
db.span_suggestion(expr.span, text, snip, Applicability::Unspecified);
}
});
}
@ -1806,7 +1810,7 @@ fn lint_map_flatten<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr,
let func_snippet = snippet(cx, map_args[1].span, "..");
let hint = format!("{0}.flat_map({1})", self_snippet, func_snippet);
span_lint_and_then(cx, MAP_FLATTEN, expr.span, msg, |db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"try using flat_map instead",
hint,
@ -1893,7 +1897,7 @@ fn lint_map_or_none<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr,
let map_or_func_snippet = snippet(cx, map_or_args[2].span, "..");
let hint = format!("{0}.and_then({1})", map_or_self_snippet, map_or_func_snippet);
span_lint_and_then(cx, OPTION_MAP_OR_NONE, expr.span, msg, |db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"try using and_then instead",
hint,

View File

@ -31,6 +31,10 @@ impl LintPass for MinMaxPass {
fn get_lints(&self) -> LintArray {
lint_array!(MIN_MAX)
}
fn name(&self) -> &'static str {
"MinMax"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MinMaxPass {

View File

@ -242,6 +242,10 @@ impl LintPass for Pass {
FLOAT_CMP_CONST
)
}
fn name(&self) -> &'static str {
"MiscLints"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
@ -298,7 +302,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
l.pat.span,
"`ref` on an entire `let` pattern is discouraged, take a reference with `&` instead",
|db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
s.span,
"try",
format!(
@ -326,7 +330,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
"boolean short circuit operator in statement may be clearer using an explicit test",
|db| {
let sugg = if binop.node == BinOpKind::Or { !sugg } else { sugg };
db.span_suggestion_with_applicability(
db.span_suggestion(
s.span,
"replace it with",
format!(
@ -383,7 +387,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
let lhs = Sugg::hir(cx, left, "..");
let rhs = Sugg::hir(cx, right, "..");
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"consider comparing them within some error",
format!("({}).abs() < error", lhs - rhs),
@ -564,7 +568,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {
snip.to_string()
};
db.span_suggestion_with_applicability(
db.span_suggestion(
lint_span,
"try",
try_hint,

View File

@ -187,6 +187,10 @@ impl LintPass for MiscEarly {
BUILTIN_TYPE_SHADOW
)
}
fn name(&self) -> &'static str {
"MiscEarlyLints"
}
}
// Used to find `return` statements or equivalents e.g. `?`
@ -339,7 +343,7 @@ impl EarlyLintPass for MiscEarly {
|db| {
if decl.inputs.is_empty() {
let hint = snippet(cx, block.span, "..").into_owned();
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"Try doing something like: ",
hint,
@ -434,13 +438,13 @@ impl MiscEarly {
lit.span,
"this is a decimal constant",
|db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
lit.span,
"if you mean to use a decimal constant, remove the `0` to remove confusion",
src.trim_start_matches(|c| c == '_' || c == '0').to_string(),
Applicability::MaybeIncorrect,
);
db.span_suggestion_with_applicability(
db.span_suggestion(
lit.span,
"if you mean to use an octal constant, use `0o`",
format!("0o{}", src.trim_start_matches(|c| c == '_' || c == '0')),

View File

@ -90,6 +90,10 @@ impl LintPass for MissingDoc {
fn get_lints(&self) -> LintArray {
lint_array![MISSING_DOCS_IN_PRIVATE_ITEMS]
}
fn name(&self) -> &'static str {
"MissingDoc"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {

View File

@ -83,6 +83,10 @@ impl LintPass for MissingInline {
fn get_lints(&self) -> LintArray {
lint_array![MISSING_INLINE_IN_PUBLIC_ITEMS]
}
fn name(&self) -> &'static str {
"MissingInline"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {

View File

@ -37,6 +37,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(MULTIPLE_CRATE_VERSIONS)
}
fn name(&self) -> &'static str {
"MultipleCrateVersions"
}
}
impl EarlyLintPass for Pass {

View File

@ -30,6 +30,10 @@ impl LintPass for MutMut {
fn get_lints(&self) -> LintArray {
lint_array!(MUT_MUT)
}
fn name(&self) -> &'static str {
"MutMut"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutMut {

View File

@ -30,6 +30,10 @@ impl LintPass for UnnecessaryMutPassed {
fn get_lints(&self) -> LintArray {
lint_array!(UNNECESSARY_MUT_PASSED)
}
fn name(&self) -> &'static str {
"UnneccessaryMutPassed"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {

View File

@ -53,6 +53,10 @@ impl LintPass for MutexAtomic {
fn get_lints(&self) -> LintArray {
lint_array!(MUTEX_ATOMIC, MUTEX_INTEGER)
}
fn name(&self) -> &'static str {
"Mutex"
}
}
pub struct MutexAtomic;

View File

@ -61,6 +61,10 @@ impl LintPass for NeedlessBool {
fn get_lints(&self) -> LintArray {
lint_array!(NEEDLESS_BOOL)
}
fn name(&self) -> &'static str {
"NeedlessBool"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool {
@ -141,6 +145,10 @@ impl LintPass for BoolComparison {
fn get_lints(&self) -> LintArray {
lint_array!(BOOL_COMPARISON)
}
fn name(&self) -> &'static str {
"BoolComparison"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {

View File

@ -39,6 +39,10 @@ impl LintPass for NeedlessBorrow {
fn get_lints(&self) -> LintArray {
lint_array!(NEEDLESS_BORROW)
}
fn name(&self) -> &'static str {
"NeedlessBorrow"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
@ -66,7 +70,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
by the compiler",
|db| {
if let Some(snippet) = snippet_opt(cx, inner.span) {
db.span_suggestion_with_applicability(
db.span_suggestion(
e.span,
"change this to",
snippet,
@ -99,7 +103,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
"this pattern creates a reference to a reference",
|db| {
if let Some(snippet) = snippet_opt(cx, name.span) {
db.span_suggestion_with_applicability(
db.span_suggestion(
pat.span,
"change this to",
snippet,

View File

@ -58,6 +58,10 @@ impl LintPass for NeedlessBorrowedRef {
fn get_lints(&self) -> LintArray {
lint_array!(NEEDLESS_BORROWED_REFERENCE)
}
fn name(&self) -> &'static str {
"NeedlessBorrowedRef"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrowedRef {
@ -78,7 +82,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrowedRef {
"this pattern takes a reference on something that is being de-referenced",
|db| {
let hint = snippet(cx, spanned_name.span, "..").into_owned();
db.span_suggestion_with_applicability(
db.span_suggestion(
pat.span,
"try removing the `&ref` part and just keep",
hint,

View File

@ -107,6 +107,10 @@ impl LintPass for NeedlessContinue {
fn get_lints(&self) -> LintArray {
lint_array!(NEEDLESS_CONTINUE)
}
fn name(&self) -> &'static str {
"NeedlessContinue"
}
}
impl EarlyLintPass for NeedlessContinue {

View File

@ -56,6 +56,10 @@ impl LintPass for NeedlessPassByValue {
fn get_lints(&self) -> LintArray {
lint_array![NEEDLESS_PASS_BY_VALUE]
}
fn name(&self) -> &'static str {
"NeedlessPassByValue"
}
}
macro_rules! need {
@ -233,7 +237,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
}).unwrap());
then {
let slice_ty = format!("&[{}]", snippet(cx, elem_ty.span, "_"));
db.span_suggestion_with_applicability(
db.span_suggestion(
input.span,
"consider changing the type to",
slice_ty,
@ -241,7 +245,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
);
for (span, suggestion) in clone_spans {
db.span_suggestion_with_applicability(
db.span_suggestion(
span,
&snippet_opt(cx, span)
.map_or(
@ -262,7 +266,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
if match_type(cx, ty, &paths::STRING) {
if let Some(clone_spans) =
get_spans(cx, Some(body.id()), idx, &[("clone", ".to_string()"), ("as_str", "")]) {
db.span_suggestion_with_applicability(
db.span_suggestion(
input.span,
"consider changing the type to",
"&str".to_string(),
@ -270,7 +274,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
);
for (span, suggestion) in clone_spans {
db.span_suggestion_with_applicability(
db.span_suggestion(
span,
&snippet_opt(cx, span)
.map_or(

View File

@ -33,6 +33,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(NEEDLESS_UPDATE)
}
fn name(&self) -> &'static str {
"NeedUpdate"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -48,6 +48,10 @@ impl LintPass for NoNegCompOpForPartialOrd {
fn get_lints(&self) -> LintArray {
lint_array!(NEG_CMP_OP_ON_PARTIAL_ORD)
}
fn name(&self) -> &'static str {
"NoNegCompOpForPartialOrd"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NoNegCompOpForPartialOrd {

View File

@ -30,6 +30,10 @@ impl LintPass for NegMultiply {
fn get_lints(&self) -> LintArray {
lint_array!(NEG_MULTIPLY)
}
fn name(&self) -> &'static str {
"NegMultiply"
}
}
#[allow(clippy::match_same_arms)]

View File

@ -93,6 +93,10 @@ impl LintPass for NewWithoutDefault {
fn get_lints(&self) -> LintArray {
lint_array!(NEW_WITHOUT_DEFAULT)
}
fn name(&self) -> &'static str {
"NewWithoutDefault"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {

View File

@ -100,6 +100,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(NO_EFFECT, UNNECESSARY_OPERATION)
}
fn name(&self) -> &'static str {
"NoEffect"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -122,7 +122,7 @@ fn verify_ty_bound<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>, sourc
match source {
Source::Item { .. } => {
let const_kw_span = span.from_inner_byte_pos(0, 5);
db.span_suggestion_with_applicability(
db.span_suggestion(
const_kw_span,
"make this a static item",
"static".to_string(),
@ -147,6 +147,10 @@ impl LintPass for NonCopyConst {
fn get_lints(&self) -> LintArray {
lint_array!(DECLARE_INTERIOR_MUTABLE_CONST, BORROW_INTERIOR_MUTABLE_CONST)
}
fn name(&self) -> &'static str {
"NonCopyConst"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst {

View File

@ -71,6 +71,10 @@ impl LintPass for NonExpressiveNames {
fn get_lints(&self) -> LintArray {
lint_array!(SIMILAR_NAMES, MANY_SINGLE_CHAR_NAMES, JUST_UNDERSCORES_AND_DIGITS)
}
fn name(&self) -> &'static str {
"NoneExpressiveNames"
}
}
struct ExistingName {

View File

@ -41,6 +41,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(IF_LET_SOME_RESULT)
}
fn name(&self) -> &'static str {
"OkIfLet"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -30,6 +30,10 @@ impl LintPass for NonSensical {
fn get_lints(&self) -> LintArray {
lint_array!(NONSENSICAL_OPEN_OPTIONS)
}
fn name(&self) -> &'static str {
"OpenOptions"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSensical {

View File

@ -28,6 +28,10 @@ impl LintPass for OverflowCheckConditional {
fn get_lints(&self) -> LintArray {
lint_array!(OVERFLOW_CHECK_CONDITIONAL)
}
fn name(&self) -> &'static str {
"OverflowCheckConditional"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OverflowCheckConditional {

View File

@ -48,6 +48,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(PANIC_PARAMS, UNIMPLEMENTED)
}
fn name(&self) -> &'static str {
"PanicUnimplemented"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -35,6 +35,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(PARTIALEQ_NE_IMPL)
}
fn name(&self) -> &'static str {
"PartialEqNeImpl"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {

View File

@ -35,6 +35,10 @@ impl LintPass for Precedence {
fn get_lints(&self) -> LintArray {
lint_array!(PRECEDENCE)
}
fn name(&self) -> &'static str {
"Precedence"
}
}
impl EarlyLintPass for Precedence {

View File

@ -102,6 +102,10 @@ impl LintPass for PointerPass {
fn get_lints(&self) -> LintArray {
lint_array!(PTR_ARG, CMP_NULL, MUT_FROM_REF)
}
fn name(&self) -> &'static str {
"Ptr"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass {
@ -178,7 +182,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id:
with non-Vec-based slices.",
|db| {
if let Some(ref snippet) = ty_snippet {
db.span_suggestion_with_applicability(
db.span_suggestion(
arg.span,
"change this to",
format!("&[{}]", snippet),
@ -186,7 +190,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id:
);
}
for (clonespan, suggestion) in spans {
db.span_suggestion_with_applicability(
db.span_suggestion(
clonespan,
&snippet_opt(cx, clonespan).map_or("change the call to".into(), |x| {
Cow::Owned(format!("change `{}` to", x))
@ -206,14 +210,9 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id:
arg.span,
"writing `&String` instead of `&str` involves a new object where a slice will do.",
|db| {
db.span_suggestion_with_applicability(
arg.span,
"change this to",
"&str".into(),
Applicability::Unspecified,
);
db.span_suggestion(arg.span, "change this to", "&str".into(), Applicability::Unspecified);
for (clonespan, suggestion) in spans {
db.span_suggestion_short_with_applicability(
db.span_suggestion_short(
clonespan,
&snippet_opt(cx, clonespan).map_or("change the call to".into(), |x| {
Cow::Owned(format!("change `{}` to", x))
@ -246,7 +245,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id:
arg.span,
"using a reference to `Cow` is not recommended.",
|db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
arg.span,
"change this to",
"&".to_owned() + &r,

View File

@ -46,6 +46,10 @@ impl lint::LintPass for Pass {
fn get_lints(&self) -> lint::LintArray {
lint_array!(PTR_OFFSET_WITH_CAST)
}
fn name(&self) -> &'static str {
"PtrOffsetWithCast"
}
}
impl<'a, 'tcx> lint::LateLintPass<'a, 'tcx> for Pass {

View File

@ -41,6 +41,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(QUESTION_MARK)
}
fn name(&self) -> &'static str {
"QuestionMark"
}
}
impl Pass {
@ -88,7 +92,7 @@ impl Pass {
expr.span,
"this block may be rewritten with the `?` operator",
|db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"replace_it_with",
replacement_str,

View File

@ -97,6 +97,10 @@ impl LintPass for Pass {
RANGE_MINUS_ONE
)
}
fn name(&self) -> &'static str {
"Ranges"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
@ -162,14 +166,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
let end = Sugg::hir(cx, y, "y");
if let Some(is_wrapped) = &snippet_opt(cx, expr.span) {
if is_wrapped.starts_with('(') && is_wrapped.ends_with(')') {
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"use",
format!("({}..={})", start, end),
Applicability::MaybeIncorrect,
);
} else {
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"use",
format!("{}..={}", start, end),
@ -195,7 +199,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|db| {
let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").to_string());
let end = Sugg::hir(cx, y, "y");
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"use",
format!("{}..{}", start, end),

View File

@ -73,6 +73,10 @@ impl LintPass for RedundantClone {
fn get_lints(&self) -> LintArray {
lint_array!(REDUNDANT_CLONE)
}
fn name(&self) -> &'static str {
"RedundantClone"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
@ -198,7 +202,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
);
span_lint_node_and_then(cx, REDUNDANT_CLONE, node, sugg_span, "redundant clone", |db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
sugg_span,
"remove this",
String::new(),

View File

@ -38,6 +38,10 @@ impl LintPass for RedundantFieldNames {
fn get_lints(&self) -> LintArray {
lint_array!(REDUNDANT_FIELD_NAMES)
}
fn name(&self) -> &'static str {
"RedundantFieldNames"
}
}
impl EarlyLintPass for RedundantFieldNames {

View File

@ -49,6 +49,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(REDUNDANT_PATTERN_MATCHING)
}
fn name(&self) -> &'static str {
"RedundantPatternMatching"
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
@ -94,7 +98,7 @@ fn find_sugg_for_if_let<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr,
&format!("redundant pattern matching, consider using `{}`", good_method),
|db| {
let span = expr.span.to(op.span);
db.span_suggestion_with_applicability(
db.span_suggestion(
span,
"try this",
format!("if {}.{}", snippet(cx, op.span, "_"), good_method),
@ -159,7 +163,7 @@ fn find_sugg_for_match<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, o
&format!("redundant pattern matching, consider using `{}`", good_method),
|db| {
let span = expr.span.to(op.span);
db.span_suggestion_with_applicability(
db.span_suggestion(
span,
"try this",
format!("{}.{}", snippet(cx, op.span, "_"), good_method),

Some files were not shown because too many files have changed in this diff Show More