Skip to content

Commit 1c82bb2

Browse files
committed
Auto merge of #85954 - flip1995:clippyup, r=Manishearth
Update Clippy Bi-weekly Clippy update. r? `@Manishearth`
2 parents f1cee2c + 647f2b4 commit 1c82bb2

File tree

190 files changed

+2553
-1495
lines changed

Some content is hidden

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

190 files changed

+2553
-1495
lines changed

Cargo.lock

+1-5
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,10 @@ name = "clippy"
552552
version = "0.1.54"
553553
dependencies = [
554554
"cargo_metadata 0.12.0",
555-
"clippy-mini-macro-test",
556555
"clippy_lints",
557556
"compiletest_rs",
558557
"derive-new",
558+
"filetime",
559559
"quote",
560560
"regex",
561561
"rustc-workspace-hack",
@@ -567,10 +567,6 @@ dependencies = [
567567
"tester",
568568
]
569569

570-
[[package]]
571-
name = "clippy-mini-macro-test"
572-
version = "0.2.0"
573-
574570
[[package]]
575571
name = "clippy_dev"
576572
version = "0.0.1"

src/tools/clippy/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2493,6 +2493,7 @@ Released 2018-09-13
24932493
[`manual_ok_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_or
24942494
[`manual_range_contains`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains
24952495
[`manual_saturating_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic
2496+
[`manual_str_repeat`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat
24962497
[`manual_strip`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip
24972498
[`manual_swap`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_swap
24982499
[`manual_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or
@@ -2622,6 +2623,7 @@ Released 2018-09-13
26222623
[`redundant_pub_crate`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pub_crate
26232624
[`redundant_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_slicing
26242625
[`redundant_static_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes
2626+
[`ref_binding_to_reference`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_binding_to_reference
26252627
[`ref_in_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_in_deref
26262628
[`ref_option_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_option_ref
26272629
[`regex_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#regex_macro
@@ -2670,6 +2672,7 @@ Released 2018-09-13
26702672
[`suspicious_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_map
26712673
[`suspicious_op_assign_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_op_assign_impl
26722674
[`suspicious_operation_groupings`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_operation_groupings
2675+
[`suspicious_splitn`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_splitn
26732676
[`suspicious_unary_op_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_unary_op_formatting
26742677
[`tabs_in_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#tabs_in_doc_comments
26752678
[`temporary_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_assignment

src/tools/clippy/COPYRIGHT

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2014-2020 The Rust Project Developers
1+
Copyright 2014-2021 The Rust Project Developers
22

33
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
44
http://www.apache.org/licenses/LICENSE-2.0> or the MIT license

src/tools/clippy/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ tempfile = { version = "3.1.0", optional = true }
3333
cargo_metadata = "0.12"
3434
compiletest_rs = { version = "0.6.0", features = ["tmp"] }
3535
tester = "0.9"
36-
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
3736
serde = { version = "1.0", features = ["derive"] }
3837
derive-new = "0.5"
3938
regex = "1.4"
4039
quote = "1"
4140
syn = { version = "1", features = ["full"] }
41+
# This is used by the `collect-metadata` alias.
42+
filetime = "0.2"
4243

4344
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
4445
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`

src/tools/clippy/LICENSE-APACHE

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2014-2020 The Rust Project Developers
189+
Copyright 2014-2021 The Rust Project Developers
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

src/tools/clippy/LICENSE-MIT

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2014-2020 The Rust Project Developers
3+
Copyright (c) 2014-2021 The Rust Project Developers
44

55
Permission is hereby granted, free of charge, to any
66
person obtaining a copy of this software and associated

src/tools/clippy/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ Some lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml
147147
value` mapping eg.
148148

149149
```toml
150+
avoid-breaking-exported-api = false
150151
blacklisted-names = ["toto", "tata", "titi"]
151152
cognitive-complexity-threshold = 30
152153
```
@@ -236,7 +237,7 @@ If you want to contribute to Clippy, you can find more information in [CONTRIBUT
236237

237238
## License
238239

239-
Copyright 2014-2020 The Rust Project Developers
240+
Copyright 2014-2021 The Rust Project Developers
240241

241242
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
242243
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)> or the MIT license

src/tools/clippy/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ fn main() {
1414
);
1515
println!(
1616
"cargo:rustc-env=RUSTC_RELEASE_CHANNEL={}",
17-
rustc_tools_util::get_channel().unwrap_or_default()
17+
rustc_tools_util::get_channel()
1818
);
1919
}

src/tools/clippy/clippy.toml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
avoid-breaking-exported-api = false

src/tools/clippy/clippy_lints/src/absurd_extreme_comparisons.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use rustc_lint::{LateContext, LateLintPass};
33
use rustc_middle::ty;
44
use rustc_session::{declare_lint_pass, declare_tool_lint};
55

6-
use crate::consts::{constant, Constant};
7-
86
use clippy_utils::comparisons::{normalize_comparison, Rel};
7+
use clippy_utils::consts::{constant, Constant};
98
use clippy_utils::diagnostics::span_lint_and_help;
109
use clippy_utils::source::snippet;
1110
use clippy_utils::ty::is_isize_or_usize;

src/tools/clippy/clippy_lints/src/arithmetic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::consts::constant_simple;
1+
use clippy_utils::consts::constant_simple;
22
use clippy_utils::diagnostics::span_lint;
33
use rustc_hir as hir;
44
use rustc_lint::{LateContext, LateLintPass};

src/tools/clippy/clippy_lints/src/assertions_on_constants.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::consts::{constant, Constant};
1+
use clippy_utils::consts::{constant, Constant};
22
use clippy_utils::diagnostics::span_lint_and_help;
33
use clippy_utils::source::snippet_opt;
44
use clippy_utils::{is_direct_expn_of, is_expn_of, match_panic_call};
@@ -63,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
6363
&format!("`assert!(false, {})` should probably be replaced", panic_message),
6464
None,
6565
&format!("use `panic!({})` or `unreachable!({})`", panic_message, panic_message),
66-
)
66+
);
6767
};
6868

6969
if let Some(debug_assert_span) = is_expn_of(e.span, "debug_assert") {

src/tools/clippy/clippy_lints/src/attrs.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
273273
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
274274
let attrs = cx.tcx.hir().attrs(item.hir_id());
275275
if is_relevant_item(cx, item) {
276-
check_attrs(cx, item.span, item.ident.name, attrs)
276+
check_attrs(cx, item.span, item.ident.name, attrs);
277277
}
278278
match item.kind {
279279
ItemKind::ExternCrate(..) | ItemKind::Use(..) => {
@@ -343,13 +343,13 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
343343

344344
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
345345
if is_relevant_impl(cx, item) {
346-
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()))
346+
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()));
347347
}
348348
}
349349

350350
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
351351
if is_relevant_trait(cx, item) {
352-
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()))
352+
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()));
353353
}
354354
}
355355
}

src/tools/clippy/clippy_lints/src/bit_mask.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::consts::{constant, Constant};
1+
use clippy_utils::consts::{constant, Constant};
22
use clippy_utils::diagnostics::{span_lint, span_lint_and_then};
33
use clippy_utils::sugg::Sugg;
44
use if_chain::if_chain;
@@ -115,9 +115,9 @@ impl<'tcx> LateLintPass<'tcx> for BitMask {
115115
if let ExprKind::Binary(cmp, left, right) = &e.kind {
116116
if cmp.node.is_comparison() {
117117
if let Some(cmp_opt) = fetch_int_literal(cx, right) {
118-
check_compare(cx, left, cmp.node, cmp_opt, e.span)
118+
check_compare(cx, left, cmp.node, cmp_opt, e.span);
119119
} else if let Some(cmp_val) = fetch_int_literal(cx, left) {
120-
check_compare(cx, right, invert_cmp(cmp.node), cmp_val, e.span)
120+
check_compare(cx, right, invert_cmp(cmp.node), cmp_val, e.span);
121121
}
122122
}
123123
}
@@ -171,7 +171,7 @@ fn check_compare(cx: &LateContext<'_>, bit_op: &Expr<'_>, cmp_op: BinOpKind, cmp
171171
}
172172
fetch_int_literal(cx, right)
173173
.or_else(|| fetch_int_literal(cx, left))
174-
.map_or((), |mask| check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span))
174+
.map_or((), |mask| check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span));
175175
}
176176
}
177177

src/tools/clippy/clippy_lints/src/booleans.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for NonminimalBool {
6666
_: Span,
6767
_: HirId,
6868
) {
69-
NonminimalBoolVisitor { cx }.visit_body(body)
69+
NonminimalBoolVisitor { cx }.visit_body(body);
7070
}
7171
}
7272

@@ -184,7 +184,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
184184
Term(n) => {
185185
let terminal = self.terminals[n as usize];
186186
if let Some(str) = simplify_not(self.cx, terminal) {
187-
self.output.push_str(&str)
187+
self.output.push_str(&str);
188188
} else {
189189
self.output.push('!');
190190
let snip = snippet_opt(self.cx, terminal.span)?;
@@ -452,7 +452,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
452452
}
453453
match &e.kind {
454454
ExprKind::Binary(binop, _, _) if binop.node == BinOpKind::Or || binop.node == BinOpKind::And => {
455-
self.bool_expr(e)
455+
self.bool_expr(e);
456456
},
457457
ExprKind::Unary(UnOp::Not, inner) => {
458458
if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() {

src/tools/clippy/clippy_lints/src/casts/cast_sign_loss.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::consts::{constant, Constant};
1+
use clippy_utils::consts::{constant, Constant};
22
use clippy_utils::diagnostics::span_lint;
33
use clippy_utils::{method_chain_args, sext};
44
use if_chain::if_chain;

src/tools/clippy/clippy_lints/src/collapsible_if.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ declare_lint_pass!(CollapsibleIf => [COLLAPSIBLE_IF, COLLAPSIBLE_ELSE_IF]);
9292
impl EarlyLintPass for CollapsibleIf {
9393
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
9494
if !expr.span.from_expansion() {
95-
check_if(cx, expr)
95+
check_if(cx, expr);
9696
}
9797
}
9898
}

src/tools/clippy/clippy_lints/src/comparison_chain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'tcx> LateLintPass<'tcx> for ComparisonChain {
120120
"`if` chain can be rewritten with `match`",
121121
None,
122122
"consider rewriting the `if` chain to use `cmp` and `match`",
123-
)
123+
);
124124
}
125125
}
126126

src/tools/clippy/clippy_lints/src/consts.rs

-1
This file was deleted.

src/tools/clippy/clippy_lints/src/copies.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ fn emit_branches_sharing_code_lint(
476476
}
477477

478478
suggestions.push(("end", span, suggestion.to_string()));
479-
add_expr_note = !cx.typeck_results().expr_ty(if_expr).is_unit()
479+
add_expr_note = !cx.typeck_results().expr_ty(if_expr).is_unit();
480480
}
481481

482482
let add_optional_msgs = |diag: &mut DiagnosticBuilder<'_>| {

src/tools/clippy/clippy_lints/src/default_numeric_fallback.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
181181
match stmt.kind {
182182
StmtKind::Local(local) => {
183183
if local.ty.is_some() {
184-
self.ty_bounds.push(TyBound::Any)
184+
self.ty_bounds.push(TyBound::Any);
185185
} else {
186-
self.ty_bounds.push(TyBound::Nothing)
186+
self.ty_bounds.push(TyBound::Nothing);
187187
}
188188
},
189189

src/tools/clippy/clippy_lints/src/deprecated_lints.rs

+19
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,22 @@ declare_deprecated_lint! {
141141
pub FILTER_MAP,
142142
"this lint has been replaced by `manual_filter_map`, a more specific lint"
143143
}
144+
145+
declare_deprecated_lint! {
146+
/// **What it does:** Nothing. This lint has been deprecated.
147+
///
148+
/// **Deprecation reason:** The `avoid_breaking_exported_api` config option was added, which
149+
/// enables the `enum_variant_names` lint for public items.
150+
/// ```
151+
pub PUB_ENUM_VARIANT_NAMES,
152+
"set the `avoid_breaking_exported_api` config option to `false` to enable the `enum_variant_names` lint for public items"
153+
}
154+
155+
declare_deprecated_lint! {
156+
/// **What it does:** Nothing. This lint has been deprecated.
157+
///
158+
/// **Deprecation reason:** The `avoid_breaking_exported_api` config option was added, which
159+
/// enables the `wrong_self_conversion` lint for public items.
160+
pub WRONG_PUB_SELF_CONVENTION,
161+
"set the `avoid_breaking_exported_api` config option to `false` to enable the `wrong_self_convention` lint for public items"
162+
}

src/tools/clippy/clippy_lints/src/double_comparison.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ impl<'tcx> DoubleComparisons {
7070
#[rustfmt::skip]
7171
match (op, lkind, rkind) {
7272
(BinOpKind::Or, BinOpKind::Eq, BinOpKind::Lt) | (BinOpKind::Or, BinOpKind::Lt, BinOpKind::Eq) => {
73-
lint_double_comparison!(<=)
73+
lint_double_comparison!(<=);
7474
},
7575
(BinOpKind::Or, BinOpKind::Eq, BinOpKind::Gt) | (BinOpKind::Or, BinOpKind::Gt, BinOpKind::Eq) => {
76-
lint_double_comparison!(>=)
76+
lint_double_comparison!(>=);
7777
},
7878
(BinOpKind::Or, BinOpKind::Lt, BinOpKind::Gt) | (BinOpKind::Or, BinOpKind::Gt, BinOpKind::Lt) => {
79-
lint_double_comparison!(!=)
79+
lint_double_comparison!(!=);
8080
},
8181
(BinOpKind::And, BinOpKind::Le, BinOpKind::Ge) | (BinOpKind::And, BinOpKind::Ge, BinOpKind::Le) => {
82-
lint_double_comparison!(==)
82+
lint_double_comparison!(==);
8383
},
8484
_ => (),
8585
};

src/tools/clippy/clippy_lints/src/duration_subsec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_lint::{LateContext, LateLintPass};
77
use rustc_session::{declare_lint_pass, declare_tool_lint};
88
use rustc_span::source_map::Spanned;
99

10-
use crate::consts::{constant, Constant};
10+
use clippy_utils::consts::{constant, Constant};
1111
use clippy_utils::diagnostics::span_lint_and_sugg;
1212
use clippy_utils::paths;
1313

src/tools/clippy/clippy_lints/src/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ impl<'tcx> Visitor<'tcx> for InsertSearcher<'_, 'tcx> {
469469
let mut is_map_used = self.is_map_used;
470470
for arm in arms {
471471
if let Some(Guard::If(guard) | Guard::IfLet(_, guard)) = arm.guard {
472-
self.visit_non_tail_expr(guard)
472+
self.visit_non_tail_expr(guard);
473473
}
474474
is_map_used |= self.visit_cond_arm(arm.body);
475475
}

src/tools/clippy/clippy_lints/src/enum_clike.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! lint on C-like enums that are `repr(isize/usize)` and have values that
22
//! don't fit into an `i32`
33
4-
use crate::consts::{miri_to_const, Constant};
4+
use clippy_utils::consts::{miri_to_const, Constant};
55
use clippy_utils::diagnostics::span_lint;
66
use rustc_hir::{Item, ItemKind};
77
use rustc_lint::{LateContext, LateLintPass};

0 commit comments

Comments
 (0)