Skip to content

Commit 6b96dd1

Browse files
committed
submodules: update clippy from 6651c1b to 891e1a8
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 ````
1 parent d918cd9 commit 6b96dd1

File tree

89 files changed

+1976
-451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1976
-451
lines changed

.github/workflows/clippy_bors.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ jobs:
7777
run: |
7878
sudo dpkg --add-architecture i386
7979
sudo apt-get update
80+
# perform system upgrade to work around https://github.com/rust-lang/rust-clippy/issues/5477 , revert as soon as that is fixed
81+
sudo apt-get -y upgrade
8082
sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386
8183
if: matrix.host == 'i686-unknown-linux-gnu'
8284

@@ -234,8 +236,7 @@ jobs:
234236
- 'rust-lang/cargo'
235237
- 'rust-lang/rls'
236238
- 'rust-lang/chalk'
237-
# FIXME: Disabled until https://github.com/rust-lang/rust/issues/71077 is fixed
238-
# - 'rust-lang/rustfmt'
239+
- 'rust-lang/rustfmt'
239240
- 'Marwes/combine'
240241
- 'Geal/nom'
241242
- 'rust-lang/stdarch'

.github/workflows/clippy_dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
pull_request:
99
# Only run on paths, that get checked by the clippy_dev tool
1010
paths:
11-
- 'CAHNGELOG.md'
11+
- 'CHANGELOG.md'
1212
- 'README.md'
1313
- '**.stderr'
1414
- '**.rs'

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,7 @@ Released 2018-09-13
12811281
[`for_loop_over_result`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loop_over_result
12821282
[`forget_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_copy
12831283
[`forget_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_ref
1284+
[`future_not_send`]: https://rust-lang.github.io/rust-clippy/master/index.html#future_not_send
12841285
[`get_last_with_len`]: https://rust-lang.github.io/rust-clippy/master/index.html#get_last_with_len
12851286
[`get_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#get_unwrap
12861287
[`identity_conversion`]: https://rust-lang.github.io/rust-clippy/master/index.html#identity_conversion
@@ -1292,6 +1293,7 @@ Released 2018-09-13
12921293
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
12931294
[`implicit_hasher`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_hasher
12941295
[`implicit_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_return
1296+
[`implicit_saturating_sub`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_saturating_sub
12951297
[`imprecise_flops`]: https://rust-lang.github.io/rust-clippy/master/index.html#imprecise_flops
12961298
[`inconsistent_digit_grouping`]: https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_digit_grouping
12971299
[`indexing_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ cargo clippy
8383

8484
#### Automatically applying Clippy suggestions
8585

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

8989
```terminal
90-
cargo fix -Z unstable-options --clippy
90+
cargo clippy --fix -Z unstable-options
9191
```
9292

9393
### Running Clippy from the command line without installing it

clippy_lints/src/assign_ops.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
131131
ASSIGN_OP_PATTERN,
132132
expr.span,
133133
"manual implementation of an assign operation",
134-
|db| {
134+
|diag| {
135135
if let (Some(snip_a), Some(snip_r)) =
136136
(snippet_opt(cx, assignee.span), snippet_opt(cx, rhs.span))
137137
{
138-
db.span_suggestion(
138+
diag.span_suggestion(
139139
expr.span,
140140
"replace it with",
141141
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
@@ -199,12 +199,12 @@ fn lint_misrefactored_assign_op(
199199
MISREFACTORED_ASSIGN_OP,
200200
expr.span,
201201
"variable appears on both sides of an assignment operation",
202-
|db| {
202+
|diag| {
203203
if let (Some(snip_a), Some(snip_r)) = (snippet_opt(cx, assignee.span), snippet_opt(cx, rhs_other.span)) {
204204
let a = &sugg::Sugg::hir(cx, assignee, "..");
205205
let r = &sugg::Sugg::hir(cx, rhs, "..");
206206
let long = format!("{} = {}", snip_a, sugg::make_binop(higher::binop(op.node), a, r));
207-
db.span_suggestion(
207+
diag.span_suggestion(
208208
expr.span,
209209
&format!(
210210
"Did you mean `{} = {} {} {}` or `{}`? Consider replacing it with",
@@ -217,7 +217,7 @@ fn lint_misrefactored_assign_op(
217217
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
218218
Applicability::MaybeIncorrect,
219219
);
220-
db.span_suggestion(
220+
diag.span_suggestion(
221221
expr.span,
222222
"or",
223223
long,

clippy_lints/src/attrs.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes {
273273
USELESS_ATTRIBUTE,
274274
line_span,
275275
"useless lint attribute",
276-
|db| {
276+
|diag| {
277277
sugg = sugg.replacen("#[", "#![", 1);
278-
db.span_suggestion(
278+
diag.span_suggestion(
279279
line_span,
280280
"if you just forgot a `!`, use",
281281
sugg,
@@ -329,7 +329,7 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) {
329329
UNKNOWN_CLIPPY_LINTS,
330330
lint.span(),
331331
&format!("unknown clippy lint: clippy::{}", name),
332-
|db| {
332+
|diag| {
333333
let name_lower = name.as_str().to_lowercase();
334334
let symbols = lint_store.get_lints().iter().map(
335335
|l| Symbol::intern(&l.name_lower())
@@ -341,14 +341,14 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) {
341341
);
342342
if name.as_str().chars().any(char::is_uppercase)
343343
&& lint_store.find_lints(&format!("clippy::{}", name_lower)).is_ok() {
344-
db.span_suggestion(
344+
diag.span_suggestion(
345345
lint.span(),
346346
"lowercase the lint name",
347347
format!("clippy::{}", name_lower),
348348
Applicability::MachineApplicable,
349349
);
350350
} else if let Some(sugg) = sugg {
351-
db.span_suggestion(
351+
diag.span_suggestion(
352352
lint.span(),
353353
"did you mean",
354354
sugg.to_string(),

clippy_lints/src/bit_mask.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
137137
VERBOSE_BIT_MASK,
138138
e.span,
139139
"bit mask could be simplified with a call to `trailing_zeros`",
140-
|db| {
140+
|diag| {
141141
let sugg = Sugg::hir(cx, left1, "...").maybe_par();
142-
db.span_suggestion(
142+
diag.span_suggestion(
143143
e.span,
144144
"try",
145145
format!("{}.trailing_zeros() >= {}", sugg, n.count_ones()),

clippy_lints/src/booleans.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,13 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
376376
LOGIC_BUG,
377377
e.span,
378378
"this boolean expression contains a logic bug",
379-
|db| {
380-
db.span_help(
379+
|diag| {
380+
diag.span_help(
381381
h2q.terminals[i].span,
382382
"this expression can be optimized out by applying boolean operations to the \
383383
outer expression",
384384
);
385-
db.span_suggestion(
385+
diag.span_suggestion(
386386
e.span,
387387
"it would look like the following",
388388
suggest(self.cx, suggestion, &h2q.terminals),
@@ -411,8 +411,8 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
411411
NONMINIMAL_BOOL,
412412
e.span,
413413
"this boolean expression can be simplified",
414-
|db| {
415-
db.span_suggestions(
414+
|diag| {
415+
diag.span_suggestions(
416416
e.span,
417417
"try",
418418
suggestions.into_iter(),

clippy_lints/src/collapsible_if.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: &
137137
if expr.span.ctxt() != inner.span.ctxt() {
138138
return;
139139
}
140-
span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this `if` statement can be collapsed", |db| {
140+
span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this `if` statement can be collapsed", |diag| {
141141
let lhs = Sugg::ast(cx, check, "..");
142142
let rhs = Sugg::ast(cx, check_inner, "..");
143-
db.span_suggestion(
143+
diag.span_suggestion(
144144
expr.span,
145145
"try",
146146
format!(

clippy_lints/src/copies.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ fn lint_match_arms<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr<'_>) {
279279
MATCH_SAME_ARMS,
280280
j.body.span,
281281
"this `match` has identical arm bodies",
282-
|db| {
283-
db.span_note(i.body.span, "same as this");
282+
|diag| {
283+
diag.span_note(i.body.span, "same as this");
284284

285285
// Note: this does not use `span_suggestion` on purpose:
286286
// there is no clean way
@@ -296,15 +296,15 @@ fn lint_match_arms<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr<'_>) {
296296
// if the last arm is _, then i could be integrated into _
297297
// note that i.pat cannot be _, because that would mean that we're
298298
// hiding all the subsequent arms, and rust won't compile
299-
db.span_note(
299+
diag.span_note(
300300
i.body.span,
301301
&format!(
302302
"`{}` has the same arm body as the `_` wildcard, consider removing it",
303303
lhs
304304
),
305305
);
306306
} else {
307-
db.span_help(i.pat.span, &format!("consider refactoring into `{} | {}`", lhs, rhs));
307+
diag.span_help(i.pat.span, &format!("consider refactoring into `{} | {}`", lhs, rhs));
308308
}
309309
},
310310
);

clippy_lints/src/derive.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ fn check_hash_peq<'a, 'tcx>(
119119
span_lint_and_then(
120120
cx, DERIVE_HASH_XOR_EQ, span,
121121
mess,
122-
|db| {
122+
|diag| {
123123
if let Some(node_id) = cx.tcx.hir().as_local_hir_id(impl_id) {
124-
db.span_note(
124+
diag.span_note(
125125
cx.tcx.hir().span(node_id),
126126
"`PartialEq` implemented here"
127127
);
@@ -168,8 +168,8 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item<'_>, trait
168168
EXPL_IMPL_CLONE_ON_COPY,
169169
item.span,
170170
"you are implementing `Clone` explicitly on a `Copy` type",
171-
|db| {
172-
db.span_note(item.span, "consider deriving `Clone` or removing `Copy`");
171+
|diag| {
172+
diag.span_note(item.span, "consider deriving `Clone` or removing `Copy`");
173173
},
174174
);
175175
}

clippy_lints/src/empty_enum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
4545
let ty = cx.tcx.type_of(did);
4646
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
4747
if adt.variants.is_empty() {
48-
span_lint_and_then(cx, EMPTY_ENUM, item.span, "enum with no variants", |db| {
49-
db.span_help(
48+
span_lint_and_then(cx, EMPTY_ENUM, item.span, "enum with no variants", |diag| {
49+
diag.span_help(
5050
item.span,
5151
"consider using the uninhabited type `!` (never type) or a wrapper \
5252
around it to introduce a type which can't be instantiated",

clippy_lints/src/entry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,15 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
148148
if snippet_opt(self.cx, self.map.span) == snippet_opt(self.cx, params[0].span);
149149
then {
150150
span_lint_and_then(self.cx, MAP_ENTRY, self.span,
151-
&format!("usage of `contains_key` followed by `insert` on a `{}`", self.ty), |db| {
151+
&format!("usage of `contains_key` followed by `insert` on a `{}`", self.ty), |diag| {
152152
if self.sole_expr {
153153
let mut app = Applicability::MachineApplicable;
154154
let help = format!("{}.entry({}).or_insert({});",
155155
snippet_with_applicability(self.cx, self.map.span, "map", &mut app),
156156
snippet_with_applicability(self.cx, params[1].span, "..", &mut app),
157157
snippet_with_applicability(self.cx, params[2].span, "..", &mut app));
158158

159-
db.span_suggestion(
159+
diag.span_suggestion(
160160
self.span,
161161
"consider using",
162162
help,
@@ -168,7 +168,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
168168
snippet(self.cx, self.map.span, "map"),
169169
snippet(self.cx, params[1].span, ".."));
170170

171-
db.span_label(
171+
diag.span_label(
172172
self.span,
173173
&help,
174174
);

0 commit comments

Comments
 (0)