Skip to content

Commit

Permalink
submodules: update clippy from 6651c1b to 891e1a8
Browse files Browse the repository at this point in the history
Changes:
````
Polished lint and tests
Added final lint and tests
Added basic lint and tests
fix redundant_pattern_matching lint
add lint futures_not_send
Integrate more idiomatic rust changes.
Fix issue rust-lang#4892.
cargo dev fmt
Cleanup: Rename 'db' variable to 'diag'
question_mark: don't add `as_ref()` for a call expression
unit_arg suggestion may be incorrect
readme: update to cargo clippy --fix command
CI: performing system upgrade fixes broken apt deps on ubuntu 32bit
Do not lint in macros for match lints
[fix] Minor typo in GH Actions 'clippy_dev'
Reenable rustfmt integration test
Add test to map_flatten with an Option
Lint map_flatten if caller is an Option
Apply suggestions from code review
manually fixing formatting at this point lol
fmt
rename field
revert the damn fmt changes
add some tests
split it up for testing but the merge broke tests
dogfood tasted bad
fix rustfmt issue
boycott manish
check for unstable options
Start work on clippy-fix as subcommand
````
  • Loading branch information
matthiaskrgr committed Apr 18, 2020
1 parent d918cd9 commit 6b96dd1
Show file tree
Hide file tree
Showing 89 changed files with 1,976 additions and 451 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/clippy_bors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ jobs:
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
# perform system upgrade to work around https://github.com/rust-lang/rust-clippy/issues/5477 , revert as soon as that is fixed
sudo apt-get -y upgrade
sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386
if: matrix.host == 'i686-unknown-linux-gnu'

Expand Down Expand Up @@ -234,8 +236,7 @@ jobs:
- 'rust-lang/cargo'
- 'rust-lang/rls'
- 'rust-lang/chalk'
# FIXME: Disabled until https://github.com/rust-lang/rust/issues/71077 is fixed
# - 'rust-lang/rustfmt'
- 'rust-lang/rustfmt'
- 'Marwes/combine'
- 'Geal/nom'
- 'rust-lang/stdarch'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clippy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request:
# Only run on paths, that get checked by the clippy_dev tool
paths:
- 'CAHNGELOG.md'
- 'CHANGELOG.md'
- 'README.md'
- '**.stderr'
- '**.rs'
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,7 @@ Released 2018-09-13
[`for_loop_over_result`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loop_over_result
[`forget_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_copy
[`forget_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_ref
[`future_not_send`]: https://rust-lang.github.io/rust-clippy/master/index.html#future_not_send
[`get_last_with_len`]: https://rust-lang.github.io/rust-clippy/master/index.html#get_last_with_len
[`get_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#get_unwrap
[`identity_conversion`]: https://rust-lang.github.io/rust-clippy/master/index.html#identity_conversion
Expand All @@ -1292,6 +1293,7 @@ Released 2018-09-13
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
[`implicit_hasher`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_hasher
[`implicit_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_return
[`implicit_saturating_sub`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_saturating_sub
[`imprecise_flops`]: https://rust-lang.github.io/rust-clippy/master/index.html#imprecise_flops
[`inconsistent_digit_grouping`]: https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_digit_grouping
[`indexing_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ cargo clippy

#### Automatically applying Clippy suggestions

Some Clippy lint suggestions can be automatically applied by `cargo fix`.
Clippy can automatically apply some lint suggestions.
Note that this is still experimental and only supported on the nightly channel:

```terminal
cargo fix -Z unstable-options --clippy
cargo clippy --fix -Z unstable-options
```

### Running Clippy from the command line without installing it
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/assign_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
ASSIGN_OP_PATTERN,
expr.span,
"manual implementation of an assign operation",
|db| {
|diag| {
if let (Some(snip_a), Some(snip_r)) =
(snippet_opt(cx, assignee.span), snippet_opt(cx, rhs.span))
{
db.span_suggestion(
diag.span_suggestion(
expr.span,
"replace it with",
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
Expand Down Expand Up @@ -199,12 +199,12 @@ fn lint_misrefactored_assign_op(
MISREFACTORED_ASSIGN_OP,
expr.span,
"variable appears on both sides of an assignment operation",
|db| {
|diag| {
if let (Some(snip_a), Some(snip_r)) = (snippet_opt(cx, assignee.span), snippet_opt(cx, rhs_other.span)) {
let a = &sugg::Sugg::hir(cx, assignee, "..");
let r = &sugg::Sugg::hir(cx, rhs, "..");
let long = format!("{} = {}", snip_a, sugg::make_binop(higher::binop(op.node), a, r));
db.span_suggestion(
diag.span_suggestion(
expr.span,
&format!(
"Did you mean `{} = {} {} {}` or `{}`? Consider replacing it with",
Expand All @@ -217,7 +217,7 @@ fn lint_misrefactored_assign_op(
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
Applicability::MaybeIncorrect,
);
db.span_suggestion(
diag.span_suggestion(
expr.span,
"or",
long,
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes {
USELESS_ATTRIBUTE,
line_span,
"useless lint attribute",
|db| {
|diag| {
sugg = sugg.replacen("#[", "#![", 1);
db.span_suggestion(
diag.span_suggestion(
line_span,
"if you just forgot a `!`, use",
sugg,
Expand Down Expand Up @@ -329,7 +329,7 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) {
UNKNOWN_CLIPPY_LINTS,
lint.span(),
&format!("unknown clippy lint: clippy::{}", name),
|db| {
|diag| {
let name_lower = name.as_str().to_lowercase();
let symbols = lint_store.get_lints().iter().map(
|l| Symbol::intern(&l.name_lower())
Expand All @@ -341,14 +341,14 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) {
);
if name.as_str().chars().any(char::is_uppercase)
&& lint_store.find_lints(&format!("clippy::{}", name_lower)).is_ok() {
db.span_suggestion(
diag.span_suggestion(
lint.span(),
"lowercase the lint name",
format!("clippy::{}", name_lower),
Applicability::MachineApplicable,
);
} else if let Some(sugg) = sugg {
db.span_suggestion(
diag.span_suggestion(
lint.span(),
"did you mean",
sugg.to_string(),
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/bit_mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
VERBOSE_BIT_MASK,
e.span,
"bit mask could be simplified with a call to `trailing_zeros`",
|db| {
|diag| {
let sugg = Sugg::hir(cx, left1, "...").maybe_par();
db.span_suggestion(
diag.span_suggestion(
e.span,
"try",
format!("{}.trailing_zeros() >= {}", sugg, n.count_ones()),
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,13 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
LOGIC_BUG,
e.span,
"this boolean expression contains a logic bug",
|db| {
db.span_help(
|diag| {
diag.span_help(
h2q.terminals[i].span,
"this expression can be optimized out by applying boolean operations to the \
outer expression",
);
db.span_suggestion(
diag.span_suggestion(
e.span,
"it would look like the following",
suggest(self.cx, suggestion, &h2q.terminals),
Expand Down Expand Up @@ -411,8 +411,8 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
NONMINIMAL_BOOL,
e.span,
"this boolean expression can be simplified",
|db| {
db.span_suggestions(
|diag| {
diag.span_suggestions(
e.span,
"try",
suggestions.into_iter(),
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/collapsible_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: &
if expr.span.ctxt() != inner.span.ctxt() {
return;
}
span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this `if` statement can be collapsed", |db| {
span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this `if` statement can be collapsed", |diag| {
let lhs = Sugg::ast(cx, check, "..");
let rhs = Sugg::ast(cx, check_inner, "..");
db.span_suggestion(
diag.span_suggestion(
expr.span,
"try",
format!(
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/copies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ fn lint_match_arms<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr<'_>) {
MATCH_SAME_ARMS,
j.body.span,
"this `match` has identical arm bodies",
|db| {
db.span_note(i.body.span, "same as this");
|diag| {
diag.span_note(i.body.span, "same as this");

// Note: this does not use `span_suggestion` on purpose:
// there is no clean way
Expand All @@ -296,15 +296,15 @@ fn lint_match_arms<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr<'_>) {
// if the last arm is _, then i could be integrated into _
// note that i.pat cannot be _, because that would mean that we're
// hiding all the subsequent arms, and rust won't compile
db.span_note(
diag.span_note(
i.body.span,
&format!(
"`{}` has the same arm body as the `_` wildcard, consider removing it",
lhs
),
);
} else {
db.span_help(i.pat.span, &format!("consider refactoring into `{} | {}`", lhs, rhs));
diag.span_help(i.pat.span, &format!("consider refactoring into `{} | {}`", lhs, rhs));
}
},
);
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ fn check_hash_peq<'a, 'tcx>(
span_lint_and_then(
cx, DERIVE_HASH_XOR_EQ, span,
mess,
|db| {
|diag| {
if let Some(node_id) = cx.tcx.hir().as_local_hir_id(impl_id) {
db.span_note(
diag.span_note(
cx.tcx.hir().span(node_id),
"`PartialEq` implemented here"
);
Expand Down Expand Up @@ -168,8 +168,8 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item<'_>, trait
EXPL_IMPL_CLONE_ON_COPY,
item.span,
"you are implementing `Clone` explicitly on a `Copy` type",
|db| {
db.span_note(item.span, "consider deriving `Clone` or removing `Copy`");
|diag| {
diag.span_note(item.span, "consider deriving `Clone` or removing `Copy`");
},
);
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/empty_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
let ty = cx.tcx.type_of(did);
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
if adt.variants.is_empty() {
span_lint_and_then(cx, EMPTY_ENUM, item.span, "enum with no variants", |db| {
db.span_help(
span_lint_and_then(cx, EMPTY_ENUM, item.span, "enum with no variants", |diag| {
diag.span_help(
item.span,
"consider using the uninhabited type `!` (never type) or a wrapper \
around it to introduce a type which can't be instantiated",
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
if snippet_opt(self.cx, self.map.span) == snippet_opt(self.cx, params[0].span);
then {
span_lint_and_then(self.cx, MAP_ENTRY, self.span,
&format!("usage of `contains_key` followed by `insert` on a `{}`", self.ty), |db| {
&format!("usage of `contains_key` followed by `insert` on a `{}`", self.ty), |diag| {
if self.sole_expr {
let mut app = Applicability::MachineApplicable;
let help = format!("{}.entry({}).or_insert({});",
snippet_with_applicability(self.cx, self.map.span, "map", &mut app),
snippet_with_applicability(self.cx, params[1].span, "..", &mut app),
snippet_with_applicability(self.cx, params[2].span, "..", &mut app));

db.span_suggestion(
diag.span_suggestion(
self.span,
"consider using",
help,
Expand All @@ -168,7 +168,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_label(
diag.span_label(
self.span,
&help,
);
Expand Down
Loading

0 comments on commit 6b96dd1

Please sign in to comment.