Skip to content

Commit

Permalink
Fill in Applicability from review comments by @flip1995
Browse files Browse the repository at this point in the history
  • Loading branch information
vi authored and flip1995 committed Sep 20, 2018
1 parent 3eccccb commit 5872934
Show file tree
Hide file tree
Showing 29 changed files with 52 additions and 48 deletions.
6 changes: 3 additions & 3 deletions clippy_lints/src/assign_ops.rs
Expand Up @@ -90,13 +90,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
long
),
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
Applicability::Unspecified,
Applicability::MachineApplicable,
);
db.span_suggestion_with_applicability(
expr.span,
"or",
long,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
}
},
Expand Down Expand Up @@ -183,7 +183,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
expr.span,
"replace it with",
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
Applicability::Unspecified,
Applicability::MachineApplicable,
);
}
},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/attrs.rs
Expand Up @@ -208,7 +208,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
line_span,
"if you just forgot a `!`, use",
sugg,
Applicability::Unspecified,
Applicability::MachineApplicable,
);
},
);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/bit_mask.rs
Expand Up @@ -143,7 +143,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
e.span,
"try",
format!("{}.trailing_zeros() >= {}", sugg, n.count_ones()),
Applicability::Unspecified,
Applicability::MaybeIncorrect,
);
});
}
Expand Down
4 changes: 4 additions & 0 deletions clippy_lints/src/booleans.rs
Expand Up @@ -395,6 +395,8 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
e.span,
"it would look like the following",
suggest(self.cx, suggestion, &h2q.terminals).0,
// nonminimal_bool can produce minimal but
// not human readable expressions (#3141)
Applicability::Unspecified,
);
},
Expand Down Expand Up @@ -423,6 +425,8 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
e.span,
"try",
suggestions,
// nonminimal_bool can produce minimal but
// not human readable expressions (#3141)
Applicability::Unspecified,
);
},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/collapsible_if.rs
Expand Up @@ -142,7 +142,7 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: &
lhs.and(&rhs),
snippet_block(cx, content.span, ".."),
),
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/const_static_lifetime.rs
Expand Up @@ -65,7 +65,7 @@ impl StaticConst {
ty.span,
"consider removing `'static`",
sugg,
Applicability::Unspecified,
Applicability::MachineApplicable, //snippet
);
},
);
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/entry.rs
Expand Up @@ -144,7 +144,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
self.span,
"consider using",
help,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
}
else {
Expand All @@ -156,7 +156,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
self.span,
"consider using",
help,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
}
});
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/eq_op.rs
Expand Up @@ -118,7 +118,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
left.span,
"use the left value directly",
lsnip,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
})
} else if !lcpy && rcpy && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty.into()]) {
Expand All @@ -133,7 +133,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
right.span,
"use the right value directly",
rsnip,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
},
)
Expand All @@ -150,7 +150,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
left.span,
"use the left value directly",
lsnip,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
})
}
Expand All @@ -166,7 +166,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
right.span,
"use the right value directly",
rsnip,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
})
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/eta_reduction.rs
Expand Up @@ -101,7 +101,7 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {
expr.span,
"remove closure as shown",
snippet,
Applicability::Unspecified,
Applicability::MachineApplicable,
);
}
});
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/format.rs
Expand Up @@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
expr.span,
"consider using .to_string()",
sugg,
Applicability::Unspecified,
Applicability::MachineApplicable,
);
});
}
Expand All @@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
span,
"consider using .to_string()",
sugg,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
});
}
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/identity_conversion.rs
Expand Up @@ -68,7 +68,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
e.span,
"consider removing `.into()`",
sugg,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
});
}
Expand All @@ -83,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
e.span,
"consider removing `.into_iter()`",
sugg,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
});
}
Expand All @@ -103,7 +103,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
e.span,
&sugg_msg,
sugg,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/if_let_redundant_pattern_matching.rs
Expand Up @@ -82,7 +82,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
span,
"try this",
format!("if {}.{}", snippet(cx, op.span, "_"), good_method),
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
},
);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/inline_fn_without_body.rs
Expand Up @@ -57,7 +57,7 @@ fn check_attrs(cx: &LateContext<'_, '_>, name: Name, attrs: &[Attribute]) {
attr.span,
&format!("use of `#[inline]` on trait method `{}` which has no body", name),
|db| {
db.suggest_remove_item(cx, attr.span, "remove", Applicability::Unspecified);
db.suggest_remove_item(cx, attr.span, "remove", Applicability::MachineApplicable);
},
);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/int_plus_one.rs
Expand Up @@ -157,7 +157,7 @@ impl IntPlusOne {
block.span,
"change `>= y + 1` to `> y` as shown",
recommendation,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/large_enum_variant.rs
Expand Up @@ -102,7 +102,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
"consider boxing the large fields to reduce the total size of the \
enum",
format!("Box<{}>", snip),
Applicability::Unspecified,
Applicability::MachineApplicable,
);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/let_if_seq.rs
Expand Up @@ -125,7 +125,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
span,
"it is more idiomatic to write",
sug,
Applicability::Unspecified,
Applicability::MaybeIncorrect,
);
if !mutability.is_empty() {
db.note("you might not need `mut` at all");
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops.rs
Expand Up @@ -1206,7 +1206,7 @@ fn check_for_loop_reverse_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arg: &'tcx
dots = dots,
start = start_snippet
),
Applicability::Unspecified,
Applicability::MaybeIncorrect,
);
},
);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/map_unit_fn.rs
Expand Up @@ -232,7 +232,7 @@ fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr
stmt.span,
"try this",
suggestion,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
} else {
let suggestion = format!("if let {0}({1}) = {2} {{ ... }}",
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches.rs
Expand Up @@ -344,7 +344,7 @@ fn check_match_bool(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Ex
expr.span,
"consider using an if/else expression",
sugg,
Applicability::Unspecified,
Applicability::MaybeIncorrect, // not sure
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/methods.rs
Expand Up @@ -1132,13 +1132,13 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
expr.span,
"try dereferencing it",
format!("{}({}{}).clone()", refs, derefs, snip.deref()),
Applicability::Unspecified,
Applicability::MaybeIncorrect,
);
db.span_suggestion_with_applicability(
expr.span,
"or try being explicit about what type to clone",
explicit,
Applicability::Unspecified,
Applicability::MaybeIncorrect,
);
},
);
Expand Down Expand Up @@ -1659,7 +1659,7 @@ fn lint_map_or_none<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr,
expr.span,
"try using and_then instead",
hint,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
});
}
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/misc.rs
Expand Up @@ -304,7 +304,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
tyopt=tyopt,
initref=initref,
),
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
}
);
Expand All @@ -331,7 +331,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
sugg,
&snippet(cx, b.span, ".."),
),
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
});
}
Expand Down Expand Up @@ -381,7 +381,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
expr.span,
"consider comparing them within some error",
format!("({}).abs() < error", lhs - rhs),
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
db.span_note(expr.span, "std::f32::EPSILON and std::f64::EPSILON are available.");
});
Expand Down Expand Up @@ -553,7 +553,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {
expr.span,
"try",
snip.to_string(),
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
},
);
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/misc_early.rs
Expand Up @@ -312,7 +312,7 @@ impl EarlyLintPass for MiscEarly {
expr.span,
"Try doing something like: ",
hint,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
},
);
Expand Down Expand Up @@ -402,13 +402,13 @@ impl MiscEarly {
lit.span,
"if you mean to use a decimal constant, remove the `0` to remove confusion",
src.trim_left_matches(|c| c == '_' || c == '0').to_string(),
Applicability::Unspecified,
Applicability::MaybeIncorrect,
);
db.span_suggestion_with_applicability(
lit.span,
"if you mean to use an octal constant, use `0o`",
format!("0o{}", src.trim_left_matches(|c| c == '_' || c == '0')),
Applicability::Unspecified,
Applicability::MaybeIncorrect,
);
});
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/needless_borrow.rs
Expand Up @@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
e.span,
"change this to",
snippet,
Applicability::Unspecified,
Applicability::MachineApplicable,
);
}
},
Expand Down Expand Up @@ -113,7 +113,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
pat.span,
"change this to",
snippet,
Applicability::Unspecified,
Applicability::MachineApplicable,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_borrowed_ref.rs
Expand Up @@ -82,7 +82,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrowedRef {
pat.span,
"try removing the `&ref` part and just keep",
hint,
Applicability::Unspecified,
Applicability::MachineApplicable, // snippet
);
});
}
Expand Down

0 comments on commit 5872934

Please sign in to comment.