Skip to content

Commit f2f2a00

Browse files
committed
Merge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup
1 parent 36a27ec commit f2f2a00

File tree

297 files changed

+15608
-12460
lines changed

Some content is hidden

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

297 files changed

+15608
-12460
lines changed

Diff for: .cargo/config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[alias]
22
uitest = "test --test compile-test"
33
dev = "run --target-dir clippy_dev/target --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
4-
dev-lintcheck = "run --target-dir clippy_dev/target --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --features lintcheck -- lintcheck"
4+
lintcheck = "run --target-dir lintcheck/target --package lintcheck --bin lintcheck --manifest-path lintcheck/Cargo.toml -- "
55

66
[build]
77
rustflags = ["-Zunstable-options"]

Diff for: .github/workflows/clippy.yml

+14-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ env:
2727

2828
jobs:
2929
base:
30+
# NOTE: If you modify this job, make sure you copy the changes to clippy_bors.yml
3031
runs-on: ubuntu-latest
3132

3233
steps:
@@ -50,11 +51,16 @@ jobs:
5051
- name: Build
5152
run: cargo build --features deny-warnings,internal-lints
5253

53-
- name: Test "--fix -Zunstable-options"
54-
run: cargo run --features deny-warnings,internal-lints --bin cargo-clippy -- clippy --fix -Zunstable-options
54+
- name: Test
55+
run: cargo test --features deny-warnings,internal-lints
5556

56-
- name: Test Workspace
57-
run: cargo test --all --features deny-warnings,internal-lints
57+
- name: Test clippy_lints
58+
run: cargo test --features deny-warnings,internal-lints
59+
working-directory: clippy_lints
60+
61+
- name: Test rustc_tools_util
62+
run: cargo test --features deny-warnings
63+
working-directory: rustc_tools_util
5864

5965
- name: Test clippy_dev
6066
run: cargo test --features deny-warnings
@@ -64,6 +70,10 @@ jobs:
6470
run: ../target/debug/cargo-clippy
6571
working-directory: clippy_workspace_tests
6672

73+
- name: Test cargo-clippy --fix
74+
run: ../target/debug/cargo-clippy clippy --fix -Zunstable-options
75+
working-directory: clippy_workspace_tests
76+
6777
- name: Test clippy-driver
6878
run: bash .github/driver.sh
6979
env:

Diff for: .github/workflows/clippy_bors.yml

+22-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ jobs:
7272

7373
runs-on: ${{ matrix.os }}
7474

75+
# NOTE: If you modify this job, make sure you copy the changes to clippy.yml
7576
steps:
7677
# Setup
7778
- uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
@@ -112,8 +113,16 @@ jobs:
112113
- name: Build
113114
run: cargo build --features deny-warnings,internal-lints
114115

115-
- name: Test Workspace
116-
run: cargo test --all --features deny-warnings,internal-lints
116+
- name: Test
117+
run: cargo test --features deny-warnings,internal-lints
118+
119+
- name: Test clippy_lints
120+
run: cargo test --features deny-warnings,internal-lints
121+
working-directory: clippy_lints
122+
123+
- name: Test rustc_tools_util
124+
run: cargo test --features deny-warnings
125+
working-directory: rustc_tools_util
117126

118127
- name: Test clippy_dev
119128
run: cargo test --features deny-warnings
@@ -123,11 +132,22 @@ jobs:
123132
run: ../target/debug/cargo-clippy
124133
working-directory: clippy_workspace_tests
125134

135+
- name: Test cargo-clippy --fix
136+
run: ../target/debug/cargo-clippy clippy --fix -Zunstable-options
137+
working-directory: clippy_workspace_tests
138+
126139
- name: Test clippy-driver
127140
run: bash .github/driver.sh
128141
env:
129142
OS: ${{ runner.os }}
130143

144+
- name: Test cargo dev new lint
145+
run: |
146+
cargo dev new_lint --name new_early_pass --pass early
147+
cargo dev new_lint --name new_late_pass --pass late
148+
cargo check
149+
git reset --hard HEAD
150+
131151
integration_build:
132152
needs: changelog
133153
runs-on: ubuntu-latest

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ out
2121
/clippy_utils/target
2222
/clippy_workspace_tests/target
2323
/clippy_dev/target
24+
/lintcheck/target
2425
/rustc_tools_util/target
2526

2627
# Generated by dogfood

Diff for: CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2104,6 +2104,7 @@ Released 2018-09-13
21042104
[`if_not_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else
21052105
[`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
21062106
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
2107+
[`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone
21072108
[`implicit_hasher`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_hasher
21082109
[`implicit_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_return
21092110
[`implicit_saturating_sub`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_saturating_sub
@@ -2134,6 +2135,7 @@ Released 2018-09-13
21342135
[`invisible_characters`]: https://rust-lang.github.io/rust-clippy/master/index.html#invisible_characters
21352136
[`items_after_statements`]: https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
21362137
[`iter_cloned_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_cloned_collect
2138+
[`iter_count`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_count
21372139
[`iter_next_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_next_loop
21382140
[`iter_next_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_next_slice
21392141
[`iter_nth`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_nth

Diff for: Cargo.toml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
[package]
22
name = "clippy"
33
version = "0.1.52"
4-
authors = [
5-
"Manish Goregaokar <[email protected]>",
6-
"Andre Bogus <[email protected]>",
7-
"Georg Brandl <[email protected]>",
8-
"Martin Carton <[email protected]>",
9-
"Oliver Schneider <[email protected]>"
10-
]
4+
authors = ["The Rust Clippy Developers"]
115
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
126
repository = "https://github.com/rust-lang/rust-clippy"
137
readme = "README.md"
@@ -42,6 +36,7 @@ tester = "0.9"
4236
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
4337
serde = { version = "1.0", features = ["derive"] }
4438
derive-new = "0.5"
39+
regex = "1.4"
4540

4641
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
4742
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
@@ -55,3 +50,7 @@ rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util" }
5550
deny-warnings = []
5651
integration = ["tempfile"]
5752
internal-lints = ["clippy_lints/internal-lints"]
53+
54+
[package.metadata.rust-analyzer]
55+
# This package uses #[feature(rustc_private)]
56+
rustc_private = true

Diff for: README.md

-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ the lint(s) you are interested in:
202202
```terminal
203203
cargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::...
204204
```
205-
Note that if you've run clippy before, this may only take effect after you've modified a file or ran `cargo clean`.
206205

207206
### Specifying the minimum supported Rust version
208207

Diff for: clippy_dev/Cargo.toml

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
11
[package]
22
name = "clippy_dev"
33
version = "0.0.1"
4-
authors = ["Philipp Hansch <[email protected]>"]
4+
authors = ["The Rust Clippy Developers"]
55
edition = "2018"
66

7-
87
[dependencies]
98
bytecount = "0.6"
109
clap = "2.33"
11-
flate2 = { version = "1.0.19", optional = true }
12-
fs_extra = { version = "1.2.0", optional = true }
1310
itertools = "0.9"
1411
opener = "0.4"
1512
regex = "1"
16-
serde = { version = "1.0", features = ["derive"], optional = true }
17-
serde_json = { version = "1.0", optional = true }
1813
shell-escape = "0.1"
19-
tar = { version = "0.4.30", optional = true }
20-
toml = { version = "0.5", optional = true }
21-
ureq = { version = "2.0.0-rc3", optional = true }
22-
rayon = { version = "1.5.0", optional = true }
2314
walkdir = "2"
2415

2516
[features]
26-
lintcheck = ["flate2", "serde_json", "tar", "toml", "ureq", "serde", "fs_extra", "rayon"]
2717
deny-warnings = []

Diff for: clippy_dev/src/fmt.rs

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub fn run(check: bool, verbose: bool) {
5454
success &= cargo_fmt(context, project_root.as_path())?;
5555
success &= cargo_fmt(context, &project_root.join("clippy_dev"))?;
5656
success &= cargo_fmt(context, &project_root.join("rustc_tools_util"))?;
57+
success &= cargo_fmt(context, &project_root.join("lintcheck"))?;
5758

5859
for entry in WalkDir::new(project_root.join("tests")) {
5960
let entry = entry?;

Diff for: clippy_dev/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use walkdir::WalkDir;
1212

1313
pub mod bless;
1414
pub mod fmt;
15-
pub mod lintcheck;
1615
pub mod new_lint;
1716
pub mod ra_setup;
1817
pub mod serve;
@@ -530,7 +529,7 @@ fn test_gen_deprecated() {
530529
#[should_panic]
531530
fn test_gen_deprecated_fail() {
532531
let lints = vec![Lint::new("should_assert_eq2", "group2", "abc", None, "module_name")];
533-
let _ = gen_deprecated(lints.iter());
532+
let _deprecated_lints = gen_deprecated(lints.iter());
534533
}
535534

536535
#[test]

Diff for: clippy_dev/src/main.rs

+3-41
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@
22

33
use clap::{App, Arg, ArgMatches, SubCommand};
44
use clippy_dev::{bless, fmt, new_lint, ra_setup, serve, stderr_length_check, update_lints};
5-
6-
#[cfg(feature = "lintcheck")]
7-
use clippy_dev::lintcheck;
8-
95
fn main() {
106
let matches = get_clap_config();
117

128
match matches.subcommand() {
139
("bless", Some(matches)) => {
1410
bless::bless(matches.is_present("ignore-timestamp"));
1511
},
16-
#[cfg(feature = "lintcheck")]
17-
("lintcheck", Some(matches)) => {
18-
lintcheck::run(&matches);
19-
},
2012
("fmt", Some(matches)) => {
2113
fmt::run(matches.is_present("check"), matches.is_present("verbose"));
2214
},
@@ -53,33 +45,7 @@ fn main() {
5345
}
5446

5547
fn get_clap_config<'a>() -> ArgMatches<'a> {
56-
#[cfg(feature = "lintcheck")]
57-
let lintcheck_sbcmd = SubCommand::with_name("lintcheck")
58-
.about("run clippy on a set of crates and check output")
59-
.arg(
60-
Arg::with_name("only")
61-
.takes_value(true)
62-
.value_name("CRATE")
63-
.long("only")
64-
.help("only process a single crate of the list"),
65-
)
66-
.arg(
67-
Arg::with_name("crates-toml")
68-
.takes_value(true)
69-
.value_name("CRATES-SOURCES-TOML-PATH")
70-
.long("crates-toml")
71-
.help("set the path for a crates.toml where lintcheck should read the sources from"),
72-
)
73-
.arg(
74-
Arg::with_name("threads")
75-
.takes_value(true)
76-
.value_name("N")
77-
.short("j")
78-
.long("jobs")
79-
.help("number of threads to use, 0 automatic choice"),
80-
);
81-
82-
let app = App::new("Clippy developer tooling")
48+
App::new("Clippy developer tooling")
8349
.subcommand(
8450
SubCommand::with_name("bless")
8551
.about("bless the test output changes")
@@ -196,10 +162,6 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
196162
.validator_os(serve::validate_port),
197163
)
198164
.arg(Arg::with_name("lint").help("Which lint's page to load initially (optional)")),
199-
);
200-
201-
#[cfg(feature = "lintcheck")]
202-
let app = app.subcommand(lintcheck_sbcmd);
203-
204-
app.get_matches()
165+
)
166+
.get_matches()
205167
}

Diff for: clippy_dummy/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy_dummy" # rename to clippy before publishing
33
version = "0.0.303"
4-
authors = ["Manish Goregaokar <[email protected]>"]
4+
authors = ["The Rust Clippy Developers"]
55
edition = "2018"
66
readme = "crates-readme.md"
77
description = "A bunch of helpful lints to avoid common pitfalls in Rust."

Diff for: clippy_lints/Cargo.toml

+7-8
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ name = "clippy_lints"
33
# begin automatic update
44
version = "0.1.52"
55
# end automatic update
6-
authors = [
7-
"Manish Goregaokar <[email protected]>",
8-
"Andre Bogus <[email protected]>",
9-
"Georg Brandl <[email protected]>",
10-
"Martin Carton <[email protected]>"
11-
]
6+
authors = ["The Rust Clippy Developers"]
127
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
138
repository = "https://github.com/rust-lang/rust-clippy"
149
readme = "README.md"
@@ -29,14 +24,18 @@ smallvec = { version = "1", features = ["union"] }
2924
toml = "0.5.3"
3025
unicode-normalization = "0.1"
3126
semver = "0.11"
32-
rustc-semver="1.1.0"
27+
rustc-semver = "1.1.0"
3328
# NOTE: cargo requires serde feat in its url dep
3429
# see <https://github.com/rust-lang/rust/pull/63587#issuecomment-522343864>
35-
url = { version = "2.1.0", features = ["serde"] }
30+
url = { version = "2.1.0", features = ["serde"] }
3631
quote = "1"
3732
syn = { version = "1", features = ["full"] }
3833

3934
[features]
4035
deny-warnings = []
4136
# build clippy with internal lints enabled, off by default
4237
internal-lints = ["clippy_utils/internal-lints"]
38+
39+
[package.metadata.rust-analyzer]
40+
# This crate uses #[feature(rustc_private)]
41+
rustc_private = true

Diff for: clippy_lints/src/assign_ops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ fn lint_misrefactored_assign_op(
209209
diag.span_suggestion(
210210
expr.span,
211211
&format!(
212-
"Did you mean `{} = {} {} {}` or `{}`? Consider replacing it with",
212+
"did you mean `{} = {} {} {}` or `{}`? Consider replacing it with",
213213
snip_a,
214214
snip_a,
215215
op.node.as_str(),

Diff for: clippy_lints/src/async_yields_async.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync {
5050
let body_id = BodyId {
5151
hir_id: body.value.hir_id,
5252
};
53-
let def_id = cx.tcx.hir().body_owner_def_id(body_id);
54-
let typeck_results = cx.tcx.typeck(def_id);
53+
let typeck_results = cx.tcx.typeck_body(body_id);
5554
let expr_ty = typeck_results.expr_ty(&body.value);
5655

5756
if implements_trait(cx, expr_ty, future_trait_def_id, &[]) {

Diff for: clippy_lints/src/attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ fn check_mismatched_target_os(cx: &EarlyContext<'_>, attr: &Attribute) {
640640
diag.span_suggestion(span, "try", sugg, Applicability::MaybeIncorrect);
641641

642642
if !unix_suggested && is_unix(os) {
643-
diag.help("Did you mean `unix`?");
643+
diag.help("did you mean `unix`?");
644644
unix_suggested = true;
645645
}
646646
}

Diff for: clippy_lints/src/await_holding_invalid.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ impl LateLintPass<'_> for AwaitHolding {
9797
let body_id = BodyId {
9898
hir_id: body.value.hir_id,
9999
};
100-
let def_id = cx.tcx.hir().body_owner_def_id(body_id);
101-
let typeck_results = cx.tcx.typeck(def_id);
100+
let typeck_results = cx.tcx.typeck_body(body_id);
102101
check_interior_types(
103102
cx,
104103
&typeck_results.generator_interior_types.as_ref().skip_binder(),
@@ -116,20 +115,20 @@ fn check_interior_types(cx: &LateContext<'_>, ty_causes: &[GeneratorInteriorType
116115
cx,
117116
AWAIT_HOLDING_LOCK,
118117
ty_cause.span,
119-
"this MutexGuard is held across an 'await' point. Consider using an async-aware Mutex type or ensuring the MutexGuard is dropped before calling await.",
118+
"this MutexGuard is held across an 'await' point. Consider using an async-aware Mutex type or ensuring the MutexGuard is dropped before calling await",
120119
ty_cause.scope_span.or(Some(span)),
121120
"these are all the await points this lock is held through",
122121
);
123122
}
124123
if is_refcell_ref(cx, adt.did) {
125124
span_lint_and_note(
126-
cx,
127-
AWAIT_HOLDING_REFCELL_REF,
128-
ty_cause.span,
129-
"this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await.",
130-
ty_cause.scope_span.or(Some(span)),
131-
"these are all the await points this ref is held through",
132-
);
125+
cx,
126+
AWAIT_HOLDING_REFCELL_REF,
127+
ty_cause.span,
128+
"this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await",
129+
ty_cause.scope_span.or(Some(span)),
130+
"these are all the await points this ref is held through",
131+
);
133132
}
134133
}
135134
}

0 commit comments

Comments
 (0)