Skip to content

Commit 7b06cb1

Browse files
committed
Auto merge of #77747 - flip1995:clippyup, r=Manishearth
Update Clippy Biweekly Clippy update. This includes a `Cargo.lock` update: 7ea42be r? `@Manishearth`
2 parents be719d1 + 7ea42be commit 7b06cb1

File tree

110 files changed

+1502
-617
lines changed

Some content is hidden

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

110 files changed

+1502
-617
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,6 @@ dependencies = [
548548
"cargo_metadata 0.11.1",
549549
"if_chain",
550550
"itertools 0.9.0",
551-
"lazy_static",
552551
"pulldown-cmark 0.8.0",
553552
"quine-mc_cluskey",
554553
"quote",

src/tools/clippy/CHANGELOG.md

+125-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,129 @@ document.
66

77
## Unreleased / In Rust Nightly
88

9-
[09bd400...master](https://github.com/rust-lang/rust-clippy/compare/09bd400...master)
9+
[e636b88...master](https://github.com/rust-lang/rust-clippy/compare/e636b88...master)
10+
11+
## Rust 1.48
12+
13+
Current beta, release 2020-11-19
14+
15+
[09bd400...e636b88](https://github.com/rust-lang/rust-clippy/compare/09bd400...e636b88)
16+
17+
### New lints
18+
19+
* [`self_assignment`] [#5894](https://github.com/rust-lang/rust-clippy/pull/5894)
20+
* [`unnecessary_lazy_evaluations`] [#5720](https://github.com/rust-lang/rust-clippy/pull/5720)
21+
* [`manual_strip`] [#6038](https://github.com/rust-lang/rust-clippy/pull/6038)
22+
* [`map_err_ignore`] [#5998](https://github.com/rust-lang/rust-clippy/pull/5998)
23+
* [`rc_buffer`] [#6044](https://github.com/rust-lang/rust-clippy/pull/6044)
24+
* [`to_string_in_display`] [#5831](https://github.com/rust-lang/rust-clippy/pull/5831)
25+
* [`single_char_push_str`] [#5881](https://github.com/rust-lang/rust-clippy/pull/5881)
26+
27+
### Moves and Deprecations
28+
29+
* Downgrade [`verbose_bit_mask`] to pedantic
30+
[#6036](https://github.com/rust-lang/rust-clippy/pull/6036)
31+
32+
### Enhancements
33+
34+
* Extend [`precedence`] to handle chains of methods combined with unary negation
35+
[#5928](https://github.com/rust-lang/rust-clippy/pull/5928)
36+
* [`useless_vec`]: add a configuration value for the maximum allowed size on the stack
37+
[#5907](https://github.com/rust-lang/rust-clippy/pull/5907)
38+
* [`suspicious_arithmetic_impl`]: extend to implementations of `BitAnd`, `BitOr`, `BitXor`, `Rem`, `Shl`, and `Shr`
39+
[#5884](https://github.com/rust-lang/rust-clippy/pull/5884)
40+
* [`invalid_atomic_ordering`]: detect misuse of `compare_exchange`, `compare_exchange_weak`, and `fetch_update`
41+
[#6025](https://github.com/rust-lang/rust-clippy/pull/6025)
42+
* Avoid [`redundant_pattern_matching`] triggering in macros
43+
[#6069](https://github.com/rust-lang/rust-clippy/pull/6069)
44+
* [`option_if_let_else`]: distinguish pure from impure `else` expressions
45+
[#5937](https://github.com/rust-lang/rust-clippy/pull/5937)
46+
* [`needless_doctest_main`]: parse doctests instead of using textual search
47+
[#5912](https://github.com/rust-lang/rust-clippy/pull/5912)
48+
* [`wildcard_imports`]: allow `prelude` to appear in any segment of an import
49+
[#5929](https://github.com/rust-lang/rust-clippy/pull/5929)
50+
* Re-enable [`len_zero`] for ranges now that `range_is_empty` is stable
51+
[#5961](https://github.com/rust-lang/rust-clippy/pull/5961)
52+
* [`option_as_ref_deref`]: catch fully-qualified calls to `Deref::deref` and `DerefMut::deref_mut`
53+
[#5933](https://github.com/rust-lang/rust-clippy/pull/5933)
54+
55+
### False Positive Fixes
56+
57+
* [`useless_attribute`]: permit allowing [`wildcard_imports`] and [`enum_glob_use`]
58+
[#5994](https://github.com/rust-lang/rust-clippy/pull/5994)
59+
* [`transmute_ptr_to_ptr`]: avoid suggesting dereferencing raw pointers in const contexts
60+
[#5999](https://github.com/rust-lang/rust-clippy/pull/5999)
61+
* [`redundant_closure_call`]: take into account usages of the closure in nested functions and closures
62+
[#5920](https://github.com/rust-lang/rust-clippy/pull/5920)
63+
* Fix false positive in [`borrow_interior_mutable_const`] when referencing a field behind a pointer
64+
[#5949](https://github.com/rust-lang/rust-clippy/pull/5949)
65+
* [`doc_markdown`]: allow using "GraphQL" without backticks
66+
[#5996](https://github.com/rust-lang/rust-clippy/pull/5996)
67+
* [`to_string_in_display`]: avoid linting when calling `to_string()` on anything that is not `self`
68+
[#5971](https://github.com/rust-lang/rust-clippy/pull/5971)
69+
* [`indexing_slicing`] and [`out_of_bounds_indexing`] treat references to arrays as arrays
70+
[#6034](https://github.com/rust-lang/rust-clippy/pull/6034)
71+
* [`should_implement_trait`]: ignore methods with lifetime parameters
72+
[#5725](https://github.com/rust-lang/rust-clippy/pull/5725)
73+
* [`needless_return`]: avoid linting if a temporary borrows a local variable
74+
[#5903](https://github.com/rust-lang/rust-clippy/pull/5903)
75+
* Restrict [`unnecessary_sort_by`] to non-reference, Copy types
76+
[#6006](https://github.com/rust-lang/rust-clippy/pull/6006)
77+
* Avoid suggesting `from_bits`/`to_bits` in const contexts in [`transmute_int_to_float`]
78+
[#5919](https://github.com/rust-lang/rust-clippy/pull/5919)
79+
* [`declare_interior_mutable_const`] and [`borrow_interior_mutable_const`]: improve detection of interior mutable types
80+
[#6046](https://github.com/rust-lang/rust-clippy/pull/6046)
81+
82+
### Suggestion Fixes/Improvements
83+
84+
* [`let_and_return`]: add a cast to the suggestion when the return expression has adjustments
85+
[#5946](https://github.com/rust-lang/rust-clippy/pull/5946)
86+
* [`useless_conversion`]: show the type in the error message
87+
[#6035](https://github.com/rust-lang/rust-clippy/pull/6035)
88+
* [`unnecessary_mut_passed`]: discriminate between functions and methods in the error message
89+
[#5892](https://github.com/rust-lang/rust-clippy/pull/5892)
90+
* [`float_cmp`] and [`float_cmp_const`]: change wording to make margin of error less ambiguous
91+
[#6043](https://github.com/rust-lang/rust-clippy/pull/6043)
92+
* [`default_trait_access`]: do not use unnecessary type parameters in the suggestion
93+
[#5993](https://github.com/rust-lang/rust-clippy/pull/5993)
94+
* [`collapsible_if`]: don't use expanded code in the suggestion
95+
[#5992](https://github.com/rust-lang/rust-clippy/pull/5992)
96+
* Do not suggest empty format strings in [`print_with_newline`] and [`write_with_newline`]
97+
[#6042](https://github.com/rust-lang/rust-clippy/pull/6042)
98+
* [`unit_arg`]: improve the readability of the suggestion
99+
[#5931](https://github.com/rust-lang/rust-clippy/pull/5931)
100+
* [`stable_sort_primitive`]: print the type that is being sorted in the lint message
101+
[#5935](https://github.com/rust-lang/rust-clippy/pull/5935)
102+
* Show line count and max lines in [`too_many_lines`] lint message
103+
[#6009](https://github.com/rust-lang/rust-clippy/pull/6009)
104+
* Keep parentheses in the suggestion of [`useless_conversion`] where applicable
105+
[#5900](https://github.com/rust-lang/rust-clippy/pull/5900)
106+
* [`option_map_unit_fn`] and [`result_map_unit_fn`]: print the unit type `()` explicitly
107+
[#6024](https://github.com/rust-lang/rust-clippy/pull/6024)
108+
* [`redundant_allocation`]: suggest replacing `Rc<Box<T>>` with `Rc<T>`
109+
[#5899](https://github.com/rust-lang/rust-clippy/pull/5899)
110+
* Make lint messages adhere to rustc dev guide conventions
111+
[#5893](https://github.com/rust-lang/rust-clippy/pull/5893)
112+
113+
### ICE Fixes
114+
115+
* Fix ICE in [`repeat_once`]
116+
[#5948](https://github.com/rust-lang/rust-clippy/pull/5948)
117+
118+
### Documentation Improvements
119+
120+
* [`mutable_key_type`]: explain potential for false positives when the interior mutable type is not accessed in the `Hash` implementation
121+
[#6019](https://github.com/rust-lang/rust-clippy/pull/6019)
122+
* [`unnecessary_mut_passed`]: fix typo
123+
[#5913](https://github.com/rust-lang/rust-clippy/pull/5913)
124+
* Add example of false positive to [`ptr_arg`] docs.
125+
[#5885](https://github.com/rust-lang/rust-clippy/pull/5885)
126+
* [`box_vec`], [`vec_box`] and [`borrowed_box`]: add link to the documentation of `Box`
127+
[#6023](https://github.com/rust-lang/rust-clippy/pull/6023)
10128

11129
## Rust 1.47
12130

13-
Current beta, release 2020-10-08
131+
Current stable, released 2020-10-08
14132

15133
[c2c07fa...09bd400](https://github.com/rust-lang/rust-clippy/compare/c2c07fa...09bd400)
16134

@@ -112,7 +230,7 @@ Current beta, release 2020-10-08
112230

113231
## Rust 1.46
114232

115-
Current stable, released 2020-08-27
233+
Released 2020-08-27
116234

117235
[7ea7cd1...c2c07fa](https://github.com/rust-lang/rust-clippy/compare/7ea7cd1...c2c07fa)
118236

@@ -1559,6 +1677,7 @@ Released 2018-09-13
15591677
[`deref_addrof`]: https://rust-lang.github.io/rust-clippy/master/index.html#deref_addrof
15601678
[`derive_hash_xor_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#derive_hash_xor_eq
15611679
[`derive_ord_xor_partial_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#derive_ord_xor_partial_ord
1680+
[`disallowed_method`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_method
15621681
[`diverging_sub_expression`]: https://rust-lang.github.io/rust-clippy/master/index.html#diverging_sub_expression
15631682
[`doc_markdown`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
15641683
[`double_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_comparisons
@@ -1634,6 +1753,8 @@ Released 2018-09-13
16341753
[`inherent_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#inherent_to_string
16351754
[`inherent_to_string_shadow_display`]: https://rust-lang.github.io/rust-clippy/master/index.html#inherent_to_string_shadow_display
16361755
[`inline_always`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_always
1756+
[`inline_asm_x86_att_syntax`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_asm_x86_att_syntax
1757+
[`inline_asm_x86_intel_syntax`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_asm_x86_intel_syntax
16371758
[`inline_fn_without_body`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_fn_without_body
16381759
[`int_plus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#int_plus_one
16391760
[`integer_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#integer_arithmetic
@@ -1644,6 +1765,7 @@ Released 2018-09-13
16441765
[`invalid_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_ref
16451766
[`invalid_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_regex
16461767
[`invalid_upcast_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_upcast_comparisons
1768+
[`invisible_characters`]: https://rust-lang.github.io/rust-clippy/master/index.html#invisible_characters
16471769
[`items_after_statements`]: https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
16481770
[`iter_cloned_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_cloned_collect
16491771
[`iter_next_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_next_loop
@@ -1919,6 +2041,5 @@ Released 2018-09-13
19192041
[`zero_divided_by_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_divided_by_zero
19202042
[`zero_prefixed_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
19212043
[`zero_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_ptr
1922-
[`zero_width_space`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_width_space
19232044
[`zst_offset`]: https://rust-lang.github.io/rust-clippy/master/index.html#zst_offset
19242045
<!-- end autogenerated links to lint list -->

src/tools/clippy/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

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

8-
[There are over 350 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
8+
[There are over 400 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
99

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

src/tools/clippy/clippy_dev/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ edition = "2018"
88
bytecount = "0.6"
99
clap = "2.33"
1010
itertools = "0.9"
11+
opener = "0.4"
1112
regex = "1"
12-
lazy_static = "1.0"
1313
shell-escape = "0.1"
1414
walkdir = "2"
1515

src/tools/clippy/clippy_dev/src/lib.rs

+24-19
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
11
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
2+
#![feature(once_cell)]
23

34
use itertools::Itertools;
4-
use lazy_static::lazy_static;
55
use regex::Regex;
66
use std::collections::HashMap;
77
use std::ffi::OsStr;
88
use std::fs;
9+
use std::lazy::SyncLazy;
910
use std::path::{Path, PathBuf};
1011
use walkdir::WalkDir;
1112

1213
pub mod fmt;
1314
pub mod new_lint;
1415
pub mod ra_setup;
16+
pub mod serve;
1517
pub mod stderr_length_check;
1618
pub mod update_lints;
1719

18-
lazy_static! {
19-
static ref DEC_CLIPPY_LINT_RE: Regex = Regex::new(
20+
static DEC_CLIPPY_LINT_RE: SyncLazy<Regex> = SyncLazy::new(|| {
21+
Regex::new(
2022
r#"(?x)
21-
declare_clippy_lint!\s*[\{(]
22-
(?:\s+///.*)*
23-
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
24-
(?P<cat>[a-z_]+)\s*,\s*
25-
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
26-
"#
23+
declare_clippy_lint!\s*[\{(]
24+
(?:\s+///.*)*
25+
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
26+
(?P<cat>[a-z_]+)\s*,\s*
27+
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
28+
"#,
2729
)
28-
.unwrap();
29-
static ref DEC_DEPRECATED_LINT_RE: Regex = Regex::new(
30+
.unwrap()
31+
});
32+
33+
static DEC_DEPRECATED_LINT_RE: SyncLazy<Regex> = SyncLazy::new(|| {
34+
Regex::new(
3035
r#"(?x)
31-
declare_deprecated_lint!\s*[{(]\s*
32-
(?:\s+///.*)*
33-
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
34-
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
35-
"#
36+
declare_deprecated_lint!\s*[{(]\s*
37+
(?:\s+///.*)*
38+
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
39+
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
40+
"#,
3641
)
37-
.unwrap();
38-
static ref NL_ESCAPE_RE: Regex = Regex::new(r#"\\\n\s*"#).unwrap();
39-
}
42+
.unwrap()
43+
});
44+
static NL_ESCAPE_RE: SyncLazy<Regex> = SyncLazy::new(|| Regex::new(r#"\\\n\s*"#).unwrap());
4045

4146
pub static DOCS_LINK: &str = "https://rust-lang.github.io/rust-clippy/master/index.html";
4247

src/tools/clippy/clippy_dev/src/main.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
22

33
use clap::{App, Arg, SubCommand};
4-
use clippy_dev::{fmt, new_lint, ra_setup, stderr_length_check, update_lints};
4+
use clippy_dev::{fmt, new_lint, ra_setup, serve, stderr_length_check, update_lints};
55

66
fn main() {
77
let matches = App::new("Clippy developer tooling")
@@ -100,6 +100,19 @@ fn main() {
100100
.required(true),
101101
),
102102
)
103+
.subcommand(
104+
SubCommand::with_name("serve")
105+
.about("Launch a local 'ALL the Clippy Lints' website in a browser")
106+
.arg(
107+
Arg::with_name("port")
108+
.long("port")
109+
.short("p")
110+
.help("Local port for the http server")
111+
.default_value("8000")
112+
.validator_os(serve::validate_port),
113+
)
114+
.arg(Arg::with_name("lint").help("Which lint's page to load initially (optional)")),
115+
)
103116
.get_matches();
104117

105118
match matches.subcommand() {
@@ -129,6 +142,11 @@ fn main() {
129142
stderr_length_check::check();
130143
},
131144
("ra-setup", Some(matches)) => ra_setup::run(matches.value_of("rustc-repo-path")),
145+
("serve", Some(matches)) => {
146+
let port = matches.value_of("port").unwrap().parse().unwrap();
147+
let lint = matches.value_of("lint");
148+
serve::run(port, lint);
149+
},
132150
_ => {},
133151
}
134152
}
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
use std::ffi::{OsStr, OsString};
2+
use std::path::Path;
3+
use std::process::Command;
4+
use std::thread;
5+
use std::time::{Duration, SystemTime};
6+
7+
pub fn run(port: u16, lint: Option<&str>) -> ! {
8+
let mut url = Some(match lint {
9+
None => format!("http://localhost:{}", port),
10+
Some(lint) => format!("http://localhost:{}/#{}", port, lint),
11+
});
12+
13+
loop {
14+
if mtime("util/gh-pages/lints.json") < mtime("clippy_lints/src") {
15+
Command::new("python3")
16+
.arg("util/export.py")
17+
.spawn()
18+
.unwrap()
19+
.wait()
20+
.unwrap();
21+
}
22+
if let Some(url) = url.take() {
23+
thread::spawn(move || {
24+
Command::new("python3")
25+
.arg("-m")
26+
.arg("http.server")
27+
.arg(port.to_string())
28+
.current_dir("util/gh-pages")
29+
.spawn()
30+
.unwrap();
31+
// Give some time for python to start
32+
thread::sleep(Duration::from_millis(500));
33+
// Launch browser after first export.py has completed and http.server is up
34+
let _ = opener::open(url);
35+
});
36+
}
37+
thread::sleep(Duration::from_millis(1000));
38+
}
39+
}
40+
41+
fn mtime(path: impl AsRef<Path>) -> SystemTime {
42+
let path = path.as_ref();
43+
if path.is_dir() {
44+
path.read_dir()
45+
.into_iter()
46+
.flatten()
47+
.flatten()
48+
.map(|entry| mtime(&entry.path()))
49+
.max()
50+
.unwrap_or(SystemTime::UNIX_EPOCH)
51+
} else {
52+
path.metadata()
53+
.and_then(|metadata| metadata.modified())
54+
.unwrap_or(SystemTime::UNIX_EPOCH)
55+
}
56+
}
57+
58+
#[allow(clippy::missing_errors_doc)]
59+
pub fn validate_port(arg: &OsStr) -> Result<(), OsString> {
60+
match arg.to_string_lossy().parse::<u16>() {
61+
Ok(_port) => Ok(()),
62+
Err(err) => Err(OsString::from(err.to_string())),
63+
}
64+
}

src/tools/clippy/clippy_lints/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ edition = "2018"
2020
cargo_metadata = "0.11.1"
2121
if_chain = "1.0.0"
2222
itertools = "0.9"
23-
lazy_static = "1.0.2"
2423
pulldown-cmark = { version = "0.8", default-features = false }
2524
quine-mc_cluskey = "0.2.2"
2625
regex-syntax = "0.6"

0 commit comments

Comments
 (0)