Skip to content

Commit 5fb022a

Browse files
committed
Update Clippy
1 parent 371c74e commit 5fb022a

39 files changed

+494
-259
lines changed

.github/workflows/clippy_bors.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ jobs:
208208
- name: Extract Binaries
209209
run: |
210210
DIR=$CARGO_TARGET_DIR/debug
211+
rm $DIR/deps/integration-*.d
212+
mv $DIR/deps/integration-* $DIR/integration
211213
find $DIR ! -executable -o -type d ! -path $DIR | xargs rm -rf
212-
mv $DIR/integration-* $DIR/integration
213214
rm -rf $CARGO_TARGET_DIR/release
214215
215216
- name: Upload Binaries

CHANGELOG.md

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,21 @@ document.
66

77
## Unreleased / In Rust Beta or Nightly
88

9-
[69f99e7...master](https://github.com/rust-lang/rust-clippy/compare/69f99e7...master)
9+
[329923e...master](https://github.com/rust-lang/rust-clippy/compare/329923e...master)
1010

11-
## Rust 1.42
11+
## Rust 1.43
1212

13-
Current Beta
13+
Current beta, release 2020-04-23
1414

15-
[69f99e7...329923e](https://github.com/rust-lang/rust-clippy/compare/69f99e7...329923e)
15+
[4ee1206...329923e](https://github.com/rust-lang/rust-clippy/compare/4ee1206...329923e)
1616

1717
### New lints
1818

19-
* [`filetype_is_file`] [#4543](https://github.com/rust-lang/rust-clippy/pull/4543)
20-
* [`let_underscore_must_use`] [#4823](https://github.com/rust-lang/rust-clippy/pull/4823)
21-
* [`modulo_arithmetic`] [#4867](https://github.com/rust-lang/rust-clippy/pull/4867)
22-
* [`mem_replace_with_default`] [#4881](https://github.com/rust-lang/rust-clippy/pull/4881)
23-
* [`mutable_key_type`] [#4885](https://github.com/rust-lang/rust-clippy/pull/4885)
2419
* [`imprecise_flops`] [#4897](https://github.com/rust-lang/rust-clippy/pull/4897)
2520
* [`suboptimal_flops`] [#4897](https://github.com/rust-lang/rust-clippy/pull/4897)
26-
* [`option_as_ref_deref`] [#4945](https://github.com/rust-lang/rust-clippy/pull/4945)
27-
* [`wildcard_in_or_patterns`] [#4960](https://github.com/rust-lang/rust-clippy/pull/4960)
28-
* [`iter_nth_zero`] [#4966](https://github.com/rust-lang/rust-clippy/pull/4966)
29-
* [`invalid_atomic_ordering`] [#4999](https://github.com/rust-lang/rust-clippy/pull/4999)
3021
* [`wildcard_imports`] [#5029](https://github.com/rust-lang/rust-clippy/pull/5029)
3122
* [`single_component_path_imports`] [#5058](https://github.com/rust-lang/rust-clippy/pull/5058)
3223
* [`match_single_binding`] [#5061](https://github.com/rust-lang/rust-clippy/pull/5061)
33-
* [`skip_while_next`] [#5067](https://github.com/rust-lang/rust-clippy/pull/5067)
3424
* [`let_underscore_lock`] [#5101](https://github.com/rust-lang/rust-clippy/pull/5101)
3525
* [`struct_excessive_bools`] [#5125](https://github.com/rust-lang/rust-clippy/pull/5125)
3626
* [`fn_params_excessive_bools`] [#5125](https://github.com/rust-lang/rust-clippy/pull/5125)
@@ -40,21 +30,73 @@ Current Beta
4030

4131
### Moves and Deprecations
4232

33+
* Move [`unneeded_field_pattern`] to pedantic group [#5200](https://github.com/rust-lang/rust-clippy/pull/5200)
34+
35+
### Enhancements
36+
37+
* Make [`missing_errors_doc`] lint also trigger on `async` functions
38+
[#5181](https://github.com/rust-lang/rust-clippy/pull/5181)
39+
* Add more constants to [`approx_constant`] [#5193](https://github.com/rust-lang/rust-clippy/pull/5193)
40+
* Extend [`question_mark`] lint [#5266](https://github.com/rust-lang/rust-clippy/pull/5266)
41+
42+
### False Positive Fixes
43+
44+
* [`use_debug`] [#5047](https://github.com/rust-lang/rust-clippy/pull/5047)
45+
* [`unnecessary_unwrap`] [#5132](https://github.com/rust-lang/rust-clippy/pull/5132)
46+
* [`zero_prefixed_literal`] [#5170](https://github.com/rust-lang/rust-clippy/pull/5170)
47+
* [`missing_const_for_fn`] [#5216](https://github.com/rust-lang/rust-clippy/pull/5216)
48+
49+
### Suggestion Improvements
50+
51+
* Improve suggestion when blocks of code are suggested [#5134](https://github.com/rust-lang/rust-clippy/pull/5134)
52+
53+
### ICE Fixes
54+
55+
* `misc_early` lints [#5129](https://github.com/rust-lang/rust-clippy/pull/5129)
56+
* [`missing_errors_doc`] [#5213](https://github.com/rust-lang/rust-clippy/pull/5213)
57+
* Fix ICE when evaluating `usize`s [#5256](https://github.com/rust-lang/rust-clippy/pull/5256)
58+
59+
### Documentation
60+
61+
* Improve documentation of [`iter_nth_zero`]
62+
* Add documentation pages for stable releases [#5171](https://github.com/rust-lang/rust-clippy/pull/5171)
63+
64+
### Others
65+
66+
* Clippy now completely runs on GitHub Actions [#5190](https://github.com/rust-lang/rust-clippy/pull/5190)
67+
68+
69+
## Rust 1.42
70+
71+
Current stable, released 2020-03-12
72+
73+
[69f99e7...4ee1206](https://github.com/rust-lang/rust-clippy/compare/69f99e7...4ee1206)
74+
75+
### New lints
76+
77+
* [`filetype_is_file`] [#4543](https://github.com/rust-lang/rust-clippy/pull/4543)
78+
* [`let_underscore_must_use`] [#4823](https://github.com/rust-lang/rust-clippy/pull/4823)
79+
* [`modulo_arithmetic`] [#4867](https://github.com/rust-lang/rust-clippy/pull/4867)
80+
* [`mem_replace_with_default`] [#4881](https://github.com/rust-lang/rust-clippy/pull/4881)
81+
* [`mutable_key_type`] [#4885](https://github.com/rust-lang/rust-clippy/pull/4885)
82+
* [`option_as_ref_deref`] [#4945](https://github.com/rust-lang/rust-clippy/pull/4945)
83+
* [`wildcard_in_or_patterns`] [#4960](https://github.com/rust-lang/rust-clippy/pull/4960)
84+
* [`iter_nth_zero`] [#4966](https://github.com/rust-lang/rust-clippy/pull/4966)
85+
* [`invalid_atomic_ordering`] [#4999](https://github.com/rust-lang/rust-clippy/pull/4999)
86+
* [`skip_while_next`] [#5067](https://github.com/rust-lang/rust-clippy/pull/5067)
87+
88+
### Moves and Deprecations
89+
4390
* Move [`transmute_float_to_int`] from nursery to complexity group
4491
[#5015](https://github.com/rust-lang/rust-clippy/pull/5015)
4592
* Move [`range_plus_one`] to pedantic group [#5057](https://github.com/rust-lang/rust-clippy/pull/5057)
46-
* Move [`unneeded_field_pattern`] to pedantic group [#5200](https://github.com/rust-lang/rust-clippy/pull/5200)
4793
* Move [`debug_assert_with_mut_call`] to nursery group [#5106](https://github.com/rust-lang/rust-clippy/pull/5106)
4894
* Deprecate [`unused_label`] [#4930](https://github.com/rust-lang/rust-clippy/pull/4930)
4995

5096
### Enhancements
5197

5298
* Lint vectored IO in [`unused_io_amount`] [#5027](https://github.com/rust-lang/rust-clippy/pull/5027)
5399
* Make [`vec_box`] configurable by adding a size threshold [#5081](https://github.com/rust-lang/rust-clippy/pull/5081)
54-
* Make [`missing_errors_doc`] lint also trigger an `async` functions
55-
[#5181](https://github.com/rust-lang/rust-clippy/pull/5181)
56-
* Add more constants to [`approx_constant`] [#5193](https://github.com/rust-lang/rust-clippy/pull/5193)
57-
* Extend [`question_mark`] lint [#5266](https://github.com/rust-lang/rust-clippy/pull/5266)
58100
* Also lint constants in [`cmp_nan`] [#4910](https://github.com/rust-lang/rust-clippy/pull/4910)
59101
* Fix false negative in [`expect_fun_call`] [#4915](https://github.com/rust-lang/rust-clippy/pull/4915)
60102
* Fix false negative in [`redundant_clone`] [#5017](https://github.com/rust-lang/rust-clippy/pull/5017)
@@ -64,13 +106,9 @@ Current Beta
64106
* [`map_clone`] [#4937](https://github.com/rust-lang/rust-clippy/pull/4937)
65107
* [`replace_consts`] [#4977](https://github.com/rust-lang/rust-clippy/pull/4977)
66108
* [`let_and_return`] [#5008](https://github.com/rust-lang/rust-clippy/pull/5008)
67-
* [`use_debug`] [#5047](https://github.com/rust-lang/rust-clippy/pull/5047)
68109
* [`eq_op`] [#5079](https://github.com/rust-lang/rust-clippy/pull/5079)
69110
* [`possible_missing_comma`] [#5083](https://github.com/rust-lang/rust-clippy/pull/5083)
70111
* [`debug_assert_with_mut_call`] [#5106](https://github.com/rust-lang/rust-clippy/pull/5106)
71-
* [`unnecessary_unwrap`] [#5132](https://github.com/rust-lang/rust-clippy/pull/5132)
72-
* [`zero_prefixed_literal`] [#5170](https://github.com/rust-lang/rust-clippy/pull/5170)
73-
* [`missing_const_for_fn`] [#5216](https://github.com/rust-lang/rust-clippy/pull/5216)
74112
* Don't trigger [`let_underscore_must_use`] in external macros
75113
[#5082](https://github.com/rust-lang/rust-clippy/pull/5082)
76114
* Don't trigger [`empty_loop`] in `no_std` crates [#5086](https://github.com/rust-lang/rust-clippy/pull/5086)
@@ -85,28 +123,19 @@ Current Beta
85123
* [`explicit_into_iter_loop`] [#4978](https://github.com/rust-lang/rust-clippy/pull/4978)
86124
* [`useless_attribute`] [#5022](https://github.com/rust-lang/rust-clippy/pull/5022)
87125
* [`if_let_some_result`] [#5032](https://github.com/rust-lang/rust-clippy/pull/5032)
88-
* Improve suggestion when blocks of code are suggested [#5134](https://github.com/rust-lang/rust-clippy/pull/5134)
89126

90127
### ICE fixes
91128

92129
* [`unsound_collection_transmute`] [#4975](https://github.com/rust-lang/rust-clippy/pull/4975)
93-
* `misc_early` lints [#5129](https://github.com/rust-lang/rust-clippy/pull/5129)
94-
* [`missing_errors_doc`] [#5213](https://github.com/rust-lang/rust-clippy/pull/5213)
95-
* Fix ICE when evaluating `usize`s [#5256](https://github.com/rust-lang/rust-clippy/pull/5256)
96130

97131
### Documentation
98132

99-
* Improve documentation of `empty_enum`, `replace_consts`, `redundant_clone`, and `iterator_step_by_zero`
100-
* Add documentation pages for stable releases [#5171](https://github.com/rust-lang/rust-clippy/pull/5171)
101-
102-
### Others
103-
104-
* Clippy now completely runs on GitHub Actions [#5190](https://github.com/rust-lang/rust-clippy/pull/5190)
133+
* Improve documentation of [`empty_enum`], [`replace_consts`], [`redundant_clone`], and [`iterator_step_by_zero`]
105134

106135

107136
## Rust 1.41
108137

109-
Current stable, released 2020-01-30
138+
Released 2020-01-30
110139

111140
[c8e3cfb...69f99e7](https://github.com/rust-lang/rust-clippy/compare/c8e3cfb...69f99e7)
112141

clippy_dev/src/new_lint.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ declare_clippy_lint! {{
131131
/// **Example:**
132132
///
133133
/// ```rust
134-
/// // example code
134+
/// // example code where clippy issues a warning
135+
/// ```
136+
/// Use instead:
137+
/// ```rust
138+
/// // example code which does not raise clippy warning
135139
/// ```
136140
pub {name_upper},
137141
{category},

clippy_dev/src/stderr_length_check.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use std::path::{Path, PathBuf};
44

55
use walkdir::WalkDir;
66

7+
use clippy_dev::clippy_project_root;
8+
79
// The maximum length allowed for stderr files.
810
//
911
// We limit this because small files are easier to deal with than bigger files.
@@ -14,22 +16,24 @@ pub fn check() {
1416

1517
if !exceeding_files.is_empty() {
1618
eprintln!("Error: stderr files exceeding limit of {} lines:", LENGTH_LIMIT);
17-
for path in exceeding_files {
18-
println!("{}", path.display());
19+
for (path, count) in exceeding_files {
20+
println!("{}: {}", path.display(), count);
1921
}
2022
std::process::exit(1);
2123
}
2224
}
2325

24-
fn exceeding_stderr_files() -> Vec<PathBuf> {
26+
fn exceeding_stderr_files() -> Vec<(PathBuf, usize)> {
2527
// We use `WalkDir` instead of `fs::read_dir` here in order to recurse into subdirectories.
26-
WalkDir::new("../tests/ui")
28+
WalkDir::new(clippy_project_root().join("tests/ui"))
2729
.into_iter()
2830
.filter_map(Result::ok)
31+
.filter(|f| !f.file_type().is_dir())
2932
.filter_map(|e| {
3033
let p = e.into_path();
31-
if p.extension() == Some(OsStr::new("stderr")) && count_linenumbers(&p) > LENGTH_LIMIT {
32-
Some(p)
34+
let count = count_linenumbers(&p);
35+
if p.extension() == Some(OsStr::new("stderr")) && count > LENGTH_LIMIT {
36+
Some((p, count))
3337
} else {
3438
None
3539
}

clippy_lints/src/approx_const.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ declare_clippy_lint! {
2323
///
2424
/// **Example:**
2525
/// ```rust
26-
/// // Bad
2726
/// let x = 3.14;
2827
/// let y = 1_f64 / x;
29-
///
30-
/// // Good
28+
/// ```
29+
/// Use predefined constants instead:
30+
/// ```rust
3131
/// let x = std::f32::consts::PI;
3232
/// let y = std::f64::consts::FRAC_1_PI;
3333
/// ```

clippy_lints/src/arithmetic.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
8181
| hir::BinOpKind::Gt => return,
8282
_ => (),
8383
}
84+
8485
let (l_ty, r_ty) = (cx.tables.expr_ty(l), cx.tables.expr_ty(r));
85-
if l_ty.is_integral() && r_ty.is_integral() {
86+
if l_ty.peel_refs().is_integral() && r_ty.peel_refs().is_integral() {
8687
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
8788
self.expr_span = Some(expr.span);
88-
} else if l_ty.is_floating_point() && r_ty.is_floating_point() {
89+
} else if l_ty.peel_refs().is_floating_point() && r_ty.peel_refs().is_floating_point() {
8990
span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected");
9091
self.expr_span = Some(expr.span);
9192
}

clippy_lints/src/assertions_on_constants.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ declare_clippy_lint! {
1111
/// **What it does:** Checks for `assert!(true)` and `assert!(false)` calls.
1212
///
1313
/// **Why is this bad?** Will be optimized out by the compiler or should probably be replaced by a
14-
/// panic!() or unreachable!()
14+
/// `panic!()` or `unreachable!()`
1515
///
1616
/// **Known problems:** None
1717
///
1818
/// **Example:**
1919
/// ```rust,ignore
2020
/// assert!(false)
21-
/// // or
2221
/// assert!(true)
23-
/// // or
2422
/// const B: bool = false;
2523
/// assert!(B)
2624
/// ```

clippy_lints/src/block_in_if_condition.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ declare_clippy_lint! {
3535
/// **Known problems:** None.
3636
///
3737
/// **Example:**
38-
/// ```ignore
38+
/// ```rust,ignore
3939
/// if { let x = somefunc(); x } {}
4040
/// // or
4141
/// if somefunc(|x| { x == 47 }) {}

clippy_lints/src/functions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ fn is_mutable_pat(cx: &LateContext<'_, '_>, pat: &hir::Pat<'_>, tys: &mut FxHash
486486
if let hir::PatKind::Wild = pat.kind {
487487
return false; // ignore `_` patterns
488488
}
489-
let def_id = pat.hir_id.owner_def_id();
489+
let def_id = pat.hir_id.owner.to_def_id();
490490
if cx.tcx.has_typeck_tables(def_id) {
491491
is_mutable_ty(cx, &cx.tcx.typeck_tables_of(def_id).pat_ty(pat), pat.span, tys)
492492
} else {
@@ -601,7 +601,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
601601
Call(_, args) | MethodCall(_, _, args) => {
602602
let mut tys = FxHashSet::default();
603603
for arg in args {
604-
let def_id = arg.hir_id.owner_def_id();
604+
let def_id = arg.hir_id.owner.to_def_id();
605605
if self.cx.tcx.has_typeck_tables(def_id)
606606
&& is_mutable_ty(
607607
self.cx,

clippy_lints/src/inherent_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MultipleInherentImpl {
5959
// but filter out implementations that have generic params (type or lifetime)
6060
// or are derived from a macro
6161
if !in_macro(item.span) && generics.params.is_empty() {
62-
self.impls.insert(item.hir_id.owner_def_id(), item.span);
62+
self.impls.insert(item.hir_id.owner.to_def_id(), item.span);
6363
}
6464
}
6565
}
@@ -69,7 +69,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MultipleInherentImpl {
6969
// Retrieve all inherent implementations from the crate, grouped by type
7070
for impls in cx
7171
.tcx
72-
.crate_inherent_impls(item.hir_id.owner_def_id().krate)
72+
.crate_inherent_impls(item.hir_id.owner.to_def_id().krate)
7373
.inherent_impls
7474
.values()
7575
{

0 commit comments

Comments
 (0)