Skip to content

Commit f2be26f

Browse files
committed
Update clippy submodule
1 parent 4e2fe45 commit f2be26f

27 files changed

+784
-42
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ matrix:
5151
# We don't want to run these always because they go towards
5252
# the build limit within the Travis rust-lang account.
5353
# The jobs are approximately sorted by execution time
54-
- env: INTEGRATION=rust-lang/cargo
55-
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
54+
# disabled cargo integration test due to https://github.com/rust-lang/rust-clippy/issues/4121
55+
#- env: INTEGRATION=rust-lang/cargo
56+
# if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
5657
- env: INTEGRATION=rust-lang-nursery/chalk
5758
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
5859
- env: INTEGRATION=rust-lang/rls

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,36 @@ All notable changes to this project will be documented in this file.
66

77
[eb9f9b1...master](https://github.com/rust-lang/rust-clippy/compare/eb9f9b1...master)
88

9+
* New lints: [`find_map`], [`filter_map_next`] [#4039](https://github.com/rust-lang/rust-clippy/pull/4039)
10+
* New lint: [`path_buf_push_overwrite`] [#3954](https://github.com/rust-lang/rust-clippy/pull/3954)
11+
* Move `path_buf_push_overwrite` to the nursery [#4013](https://github.com/rust-lang/rust-clippy/pull/4013)
12+
* Split [`redundant_closure`] into [`redundant_closure`] and [`redundant_closure_for_method_calls`] [#4110](https://github.com/rust-lang/rust-clippy/pull/4101)
13+
* Allow allowing of [`toplevel_ref_arg`] lint [#4007](https://github.com/rust-lang/rust-clippy/pull/4007)
14+
* Fix false negative in [`or_fun_call`] pertaining to nested constructors [#4084](https://github.com/rust-lang/rust-clippy/pull/4084)
15+
* Fixed false positive in [`or_fn_call`] pertaining to enum variant constructors [#4018](https://github.com/rust-lang/rust-clippy/pull/4018)
16+
* Fix false positive in [`useless_let_if_seq`] pertaining to interior mutability [#4035](https://github.com/rust-lang/rust-clippy/pull/4035)
17+
* Fix false positive in [`redundant_closure`] pertaining to non-function types [#4008](https://github.com/rust-lang/rust-clippy/pull/4008)
18+
* Fix false positive in [`let_and_return`] pertaining to attributes on `let`s [#4024](https://github.com/rust-lang/rust-clippy/pull/4024)
19+
* Fix false positive in [`module_name_repetitions`] lint pertaining to attributes [#4006](https://github.com/rust-lang/rust-clippy/pull/4006)
20+
* Fix false positive on [`assertions_on_constants`] pertaining to `debug_assert!` [#3989](https://github.com/rust-lang/rust-clippy/pull/3989)
21+
* Improve suggestion in [`map_clone`] to suggest `.copied()` where applicable [#3970](https://github.com/rust-lang/rust-clippy/pull/3970) [#4043](https://github.com/rust-lang/rust-clippy/pull/4043)
22+
* Improve suggestion for [`search_is_some`] [#4049](https://github.com/rust-lang/rust-clippy/pull/4049)
23+
* Improve suggestion applicability for [`naive_bytecount`] [#3984](https://github.com/rust-lang/rust-clippy/pull/3984)
24+
* Improve suggestion applicability for [`while_let_loop`] [#3975](https://github.com/rust-lang/rust-clippy/pull/3975)
25+
* Improve diagnostics for [`too_many_arguments`] [#4053](https://github.com/rust-lang/rust-clippy/pull/4053)
26+
* Improve diagnostics for [`cast_lossless`] [#4021](https://github.com/rust-lang/rust-clippy/pull/4021)
27+
* Deal with macro checks in desugarings better [#4082](https://github.com/rust-lang/rust-clippy/pull/4082)
28+
* Add macro check for [`unnecessary_cast`] [#4026](https://github.com/rust-lang/rust-clippy/pull/4026)
29+
* Remove [`approx_constant`]'s documentation's "Known problems" section. [#4027](https://github.com/rust-lang/rust-clippy/pull/4027)
30+
* Fix ICE in [`suspicious_else_formatting`] [#3960](https://github.com/rust-lang/rust-clippy/pull/3960)
31+
* Fix ICE in [`decimal_literal_representation`] [#3931](https://github.com/rust-lang/rust-clippy/pull/3931)
32+
33+
934
## Rust 1.35 (beta)
1035
[1fac380..37f5c1e](https://github.com/rust-lang/rust-clippy/compare/1fac380...37f5c1e)
1136

1237
* New lint: [`drop_bounds`] to detect `T: Drop` bounds
38+
* Split [`redundant_closure`] into [`redundant_closure`] and [`redundant_closure_for_method_calls`] [#4110](https://github.com/rust-lang/rust-clippy/pull/4101)
1339
* Rename `cyclomatic_complexity` to [`cognitive_complexity`], start work on making lint more practical for Rust code
1440
* Move [`get_unwrap`] to the restriction category
1541
* Improve suggestions for [`iter_cloned_collect`]
@@ -846,6 +872,7 @@ All notable changes to this project will be documented in this file.
846872
[`char_lit_as_u8`]: https://rust-lang.github.io/rust-clippy/master/index.html#char_lit_as_u8
847873
[`chars_last_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_last_cmp
848874
[`chars_next_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_next_cmp
875+
[`checked_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#checked_conversions
849876
[`clone_double_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_double_ref
850877
[`clone_on_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
851878
[`clone_on_ref_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_ref_ptr

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
99

10-
[There are 302 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
10+
[There are 303 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
1111

1212
We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:
1313

ci/base-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export CARGO_TARGET_DIR=`pwd`/target/
2323

2424
# Perform various checks for lint registration
2525
./util/dev update_lints --check
26+
./util/dev --limit-stderr-length
2627
cargo +nightly fmt --all -- --check
2728

2829
# Check running clippy-driver without cargo

clippy_dev/src/main.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ extern crate clap;
22
extern crate clippy_dev;
33
extern crate regex;
44

5-
use clap::{App, AppSettings, Arg, SubCommand};
5+
use clap::{App, Arg, SubCommand};
66
use clippy_dev::*;
7+
mod stderr_length_check;
78

89
#[derive(PartialEq)]
910
enum UpdateMode {
@@ -13,7 +14,6 @@ enum UpdateMode {
1314

1415
fn main() {
1516
let matches = App::new("Clippy developer tooling")
16-
.setting(AppSettings::SubcommandRequiredElseHelp)
1717
.subcommand(
1818
SubCommand::with_name("update_lints")
1919
.about("Updates lint registration and information from the source code")
@@ -36,8 +36,16 @@ fn main() {
3636
.help("Checks that util/dev update_lints has been run. Used on CI."),
3737
),
3838
)
39+
.arg(
40+
Arg::with_name("limit-stderr-length")
41+
.long("limit-stderr-length")
42+
.help("Ensures that stderr files do not grow longer than a certain amount of lines."),
43+
)
3944
.get_matches();
4045

46+
if matches.is_present("limit-stderr-length") {
47+
stderr_length_check::check();
48+
}
4149
if let Some(matches) = matches.subcommand_matches("update_lints") {
4250
if matches.is_present("print-only") {
4351
print_lints();

clippy_dev/src/stderr_length_check.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
use std::ffi::OsStr;
2+
use walkdir::WalkDir;
3+
4+
use std::fs::File;
5+
use std::io::prelude::*;
6+
7+
// The maximum length allowed for stderr files.
8+
//
9+
// We limit this because small files are easier to deal with than bigger files.
10+
const LIMIT: usize = 320;
11+
12+
pub fn check() {
13+
let stderr_files = stderr_files();
14+
let exceeding_files = exceeding_stderr_files(stderr_files).collect::<Vec<String>>();
15+
16+
if !exceeding_files.is_empty() {
17+
eprintln!("Error: stderr files exceeding limit of {} lines:", LIMIT);
18+
for path in exceeding_files {
19+
println!("{}", path);
20+
}
21+
std::process::exit(1);
22+
}
23+
}
24+
25+
fn exceeding_stderr_files(files: impl Iterator<Item = walkdir::DirEntry>) -> impl Iterator<Item = String> {
26+
files
27+
.filter_map(|file| {
28+
let path = file.path().to_str().expect("Could not convert path to str").to_string();
29+
let linecount = count_linenumbers(&path);
30+
if linecount > LIMIT {
31+
Some(path)
32+
} else {
33+
None
34+
}
35+
})
36+
}
37+
38+
fn stderr_files() -> impl Iterator<Item = walkdir::DirEntry> {
39+
// We use `WalkDir` instead of `fs::read_dir` here in order to recurse into subdirectories.
40+
WalkDir::new("../tests/ui")
41+
.into_iter()
42+
.filter_map(std::result::Result::ok)
43+
.filter(|f| f.path().extension() == Some(OsStr::new("stderr")))
44+
}
45+
46+
fn count_linenumbers(filepath: &str) -> usize {
47+
if let Ok(mut file) = File::open(filepath) {
48+
let mut content = String::new();
49+
file.read_to_string(&mut content).expect("Failed to read file?");
50+
content.lines().count()
51+
} else {
52+
0
53+
}
54+
}

clippy_lints/src/attrs.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ declare_clippy_lint! {
4949
/// **What it does:** Checks for `extern crate` and `use` items annotated with
5050
/// lint attributes.
5151
///
52-
/// This lint whitelists `#[allow(unused_imports)]` and `#[allow(deprecated)]` on
53-
/// `use` items and `#[allow(unused_imports)]` on `extern crate` items with a
54-
/// `#[macro_use]` attribute.
52+
/// This lint whitelists `#[allow(unused_imports)]`, `#[allow(deprecated)]` and
53+
/// `#[allow(unreachable_pub)]` on `use` items and `#[allow(unused_imports)]` on
54+
/// `extern crate` items with a `#[macro_use]` attribute.
5555
///
5656
/// **Why is this bad?** Lint attributes have no effect on crate imports. Most
5757
/// likely a `!` was forgotten.
@@ -239,13 +239,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes {
239239
if let Some(ident) = attr.ident() {
240240
match &*ident.as_str() {
241241
"allow" | "warn" | "deny" | "forbid" => {
242-
// whitelist `unused_imports` and `deprecated` for `use` items
242+
// whitelist `unused_imports`, `deprecated` and `unreachable_pub` for `use` items
243243
// and `unused_imports` for `extern crate` items with `macro_use`
244244
for lint in lint_list {
245245
match item.node {
246246
ItemKind::Use(..) => {
247247
if is_word(lint, sym!(unused_imports))
248248
|| is_word(lint, sym!(deprecated))
249+
|| is_word(lint, sym!(unreachable_pub))
249250
{
250251
return;
251252
}

0 commit comments

Comments
 (0)