Skip to content

Commit ab7e525

Browse files
committed
Merge remote-tracking branch 'upstream/master' into rustup
2 parents 978ed96 + 41d7e45 commit ab7e525

File tree

377 files changed

+6364
-3662
lines changed

Some content is hidden

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

377 files changed

+6364
-3662
lines changed

.github/workflows/clippy_changelog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Check Changelog
2525
if: ${{ github.event_name == 'pull_request' }}
2626
run: |
27-
body=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR_NUMBER" | \
27+
body=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" | \
2828
python -c "import sys, json; print(json.load(sys.stdin)['body'])")
2929
output=$(awk '/^changelog:\s*\S/ && !/changelog: \[.*\]: your change/' <<< "$body" | sed "s/changelog:\s*//g")
3030
if [ -z "$output" ]; then

.github/workflows/deploy.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
tags:
99
- rust-1.**
1010

11+
concurrency:
12+
group: ${{ github.workflow }}
13+
cancel-in-progress: false
14+
1115
env:
1216
TARGET_BRANCH: 'gh-pages'
1317
SHA: '${{ github.sha }}'

.github/workflows/lintcheck.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666

6767
- name: Run lintcheck
6868
if: steps.cache-json.outputs.cache-hit != 'true'
69-
run: ./target/debug/lintcheck --format json --all-lints --crates-toml ./lintcheck/ci_crates.toml
69+
run: env CLIPPY_CONF_DIR="$PWD/lintcheck/ci-config" ./target/debug/lintcheck --format json --all-lints --crates-toml ./lintcheck/ci_crates.toml
7070

7171
- name: Upload base JSON
7272
uses: actions/upload-artifact@v4
@@ -97,7 +97,7 @@ jobs:
9797
run: cargo build --manifest-path=lintcheck/Cargo.toml
9898

9999
- name: Run lintcheck
100-
run: ./target/debug/lintcheck --format json --all-lints --crates-toml ./lintcheck/ci_crates.toml
100+
run: env CLIPPY_CONF_DIR="$PWD/lintcheck/ci-config" ./target/debug/lintcheck --format json --all-lints --crates-toml ./lintcheck/ci_crates.toml
101101

102102
- name: Upload head JSON
103103
uses: actions/upload-artifact@v4

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5516,6 +5516,7 @@ Released 2018-09-13
55165516
[`cast_slice_different_sizes`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_slice_different_sizes
55175517
[`cast_slice_from_raw_parts`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_slice_from_raw_parts
55185518
[`cfg_not_test`]: https://rust-lang.github.io/rust-clippy/master/index.html#cfg_not_test
5519+
[`char_indices_as_byte_indices`]: https://rust-lang.github.io/rust-clippy/master/index.html#char_indices_as_byte_indices
55195520
[`char_lit_as_u8`]: https://rust-lang.github.io/rust-clippy/master/index.html#char_lit_as_u8
55205521
[`chars_last_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_last_cmp
55215522
[`chars_next_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_next_cmp
@@ -5681,6 +5682,7 @@ Released 2018-09-13
56815682
[`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
56825683
[`if_then_some_else_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none
56835684
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
5685+
[`ignore_without_reason`]: https://rust-lang.github.io/rust-clippy/master/index.html#ignore_without_reason
56845686
[`ignored_unit_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#ignored_unit_patterns
56855687
[`impl_hash_borrow_with_str_and_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#impl_hash_borrow_with_str_and_bytes
56865688
[`impl_trait_in_params`]: https://rust-lang.github.io/rust-clippy/master/index.html#impl_trait_in_params
@@ -5789,6 +5791,7 @@ Released 2018-09-13
57895791
[`manual_c_str_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_c_str_literals
57905792
[`manual_clamp`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp
57915793
[`manual_contains`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_contains
5794+
[`manual_dangling_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_dangling_ptr
57925795
[`manual_div_ceil`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_div_ceil
57935796
[`manual_filter`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter
57945797
[`manual_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter_map
@@ -6346,6 +6349,7 @@ Released 2018-09-13
63466349
[`await-holding-invalid-types`]: https://doc.rust-lang.org/clippy/lint_configuration.html#await-holding-invalid-types
63476350
[`cargo-ignore-publish`]: https://doc.rust-lang.org/clippy/lint_configuration.html#cargo-ignore-publish
63486351
[`check-incompatible-msrv-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-incompatible-msrv-in-tests
6352+
[`check-inconsistent-struct-field-initializers`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-inconsistent-struct-field-initializers
63496353
[`check-private-items`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-private-items
63506354
[`cognitive-complexity-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#cognitive-complexity-threshold
63516355
[`disallowed-macros`]: https://doc.rust-lang.org/clippy/lint_configuration.html#disallowed-macros
@@ -6362,7 +6366,7 @@ Released 2018-09-13
63626366
[`future-size-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#future-size-threshold
63636367
[`ignore-interior-mutability`]: https://doc.rust-lang.org/clippy/lint_configuration.html#ignore-interior-mutability
63646368
[`large-error-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#large-error-threshold
6365-
[`lint-inconsistent-struct-field-initializers`]: https://doc.rust-lang.org/clippy/lint_configuration.html#lint-inconsistent-struct-field-initializers
6369+
[`lint-commented-code`]: https://doc.rust-lang.org/clippy/lint_configuration.html#lint-commented-code
63666370
[`literal-representation-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#literal-representation-threshold
63676371
[`matches-for-let-else`]: https://doc.rust-lang.org/clippy/lint_configuration.html#matches-for-let-else
63686372
[`max-fn-params-bools`]: https://doc.rust-lang.org/clippy/lint_configuration.html#max-fn-params-bools

Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ walkdir = "2.3"
4242
filetime = "0.2.9"
4343
itertools = "0.12"
4444
pulldown-cmark = { version = "0.11", default-features = false, features = ["html"] }
45-
rinja = { version = "0.3", default-features = false, features = ["config"] }
45+
askama = { version = "0.13", default-features = false, features = ["alloc", "config", "derive"] }
4646

4747
# UI test dependencies
4848
clippy_utils = { path = "clippy_utils" }
@@ -71,3 +71,10 @@ harness = false
7171
[[test]]
7272
name = "dogfood"
7373
harness = false
74+
75+
# quine-mc_cluskey makes up a significant part of the runtime in dogfood
76+
# due to the number of conditions in the clippy_lints crate
77+
# and enabling optimizations for that specific dependency helps a bit
78+
# without increasing total build times.
79+
[profile.dev.package.quine-mc_cluskey]
80+
opt-level = 3

rinja.toml renamed to askama.toml

File renamed without changes.

book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
- [Updating the Changelog](development/infrastructure/changelog_update.md)
3131
- [Release a New Version](development/infrastructure/release.md)
3232
- [The Clippy Book](development/infrastructure/book.md)
33+
- [Benchmarking Clippy](development/infrastructure/benchmarking.md)
3334
- [Proposals](development/proposals/README.md)
3435
- [Roadmap 2021](development/proposals/roadmap-2021.md)
3536
- [Syntax Tree Patterns](development/proposals/syntax-tree-patterns.md)

book/src/development/adding_lints.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,22 @@ struct A;
9999
impl A {
100100
pub fn fo(&self) {}
101101
pub fn foo(&self) {}
102+
//~^ foo_functions
102103
pub fn food(&self) {}
103104
}
104105

105106
// Default trait methods
106107
trait B {
107108
fn fo(&self) {}
108109
fn foo(&self) {}
110+
//~^ foo_functions
109111
fn food(&self) {}
110112
}
111113

112114
// Plain functions
113115
fn fo() {}
114116
fn foo() {}
117+
//~^ foo_functions
115118
fn food() {}
116119

117120
fn main() {
@@ -122,17 +125,20 @@ fn main() {
122125
}
123126
```
124127

125-
Now we can run the test with `TESTNAME=foo_functions cargo uibless`, currently
126-
this test is meaningless though.
128+
Note that we are adding comment annotations with the name of our lint to mark
129+
lines where we expect an error. Once we have implemented our lint we can run
130+
`TESTNAME=foo_functions cargo uibless` to generate the `.stderr` file. If our
131+
lint makes use of structured suggestions then this command will also generate
132+
the corresponding `.fixed` file.
127133

128134
While we are working on implementing our lint, we can keep running the UI test.
129135
That allows us to check if the output is turning into what we want by checking the
130136
`.stderr` file that gets updated on every test run.
131137

132-
Running `TESTNAME=foo_functions cargo uitest` should pass on its own. When we
133-
commit our lint, we need to commit the generated `.stderr` files, too. In
134-
general, you should only commit files changed by `cargo bless` for the
135-
specific lint you are creating/editing.
138+
Once we have implemented our lint running `TESTNAME=foo_functions cargo uitest`
139+
should pass on its own. When we commit our lint, we need to commit the generated
140+
`.stderr` and if applicable `.fixed` files, too. In general, you should only
141+
commit files changed by `cargo bless` for the specific lint you are creating/editing.
136142

137143
> _Note:_ you can run multiple test files by specifying a comma separated list:
138144
> `TESTNAME=foo_functions,test2,test3`.

book/src/development/basics.md

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

148148
First, take note of the toolchain
149149
[override](https://rust-lang.github.io/rustup/overrides.html) in
150-
`/rust-toolchain`. We will use this override to install Clippy into the right
150+
`/rust-toolchain.toml`. We will use this override to install Clippy into the right
151151
toolchain.
152152

153153
> Tip: You can view the active toolchain for the current directory with `rustup
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Benchmarking Clippy
2+
3+
Benchmarking Clippy is similar to using our Lintcheck tool, in fact, it even
4+
uses the same tool! Just by adding a `--perf` flag it will transform Lintcheck
5+
into a very simple but powerful benchmarking tool!
6+
7+
It requires having the [`perf` tool][perf] installed, as `perf` is what's actually
8+
profiling Clippy under the hood.
9+
10+
The lintcheck `--perf` tool generates a series of `perf.data` in the
11+
`target/lintcheck/sources/<package>-<version>` directories. Each `perf.data`
12+
corresponds to the package which is contained.
13+
14+
Lintcheck uses the `-g` flag, meaning that you can get stack traces for richer
15+
analysis, including with tools such as [flamegraph][flamegraph-perf]
16+
(or [`flamegraph-rs`][flamegraph-rs]).
17+
18+
Currently, we only measure instruction count, as it's the most reproducible metric
19+
and [rustc-perf][rustc-perf] also considers it the main number to focus on.
20+
21+
## Benchmarking a PR
22+
23+
Having a benchmarking tool directly implemented into lintcheck gives us the
24+
ability to benchmark any given PR just by making a before and after
25+
26+
Here's the way you can get into any PR, benchmark it, and then benchmark
27+
`master`.
28+
29+
The first `perf.data` will not have any numbers appended, but any subsequent
30+
benchmark will be written to `perf.data.number` with a number growing for 0.
31+
All benchmarks are compressed so that you can
32+
33+
```bash
34+
git fetch upstream pull/<PR_NUMBER>/head:<BRANCH_NAME>
35+
git switch BRANCHNAME
36+
37+
# Bench
38+
cargo lintcheck --perf
39+
40+
# Get last common commit, checkout that
41+
LAST_COMMIT=$(git log BRANCHNAME..master --oneline | tail -1 | cut -c 1-11)
42+
git switch -c temporary $LAST_COMMIT
43+
44+
# We're now on master
45+
46+
# Bench
47+
cargo lintcheck --perf
48+
perf diff ./target/lintcheck/sources/CRATE/perf.data ./target/lintcheck/sources/CRATE/perf.data.0
49+
```
50+
51+
52+
[perf]: https://perfwiki.github.io/main/
53+
[flamegraph-perf]: https://github.com/brendangregg/FlameGraph
54+
[flamegraph-rs]: https://github.com/flamegraph-rs/flamegraph
55+
[rustc-perf]: https://github.com/rust-lang/rustc-perf

book/src/development/infrastructure/release.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ git push upstream stable
8888
After updating the `stable` branch, tag the HEAD commit and push it to the
8989
Clippy repo.
9090

91-
> Note: Only push the tag once the Deploy GitHub action of the `beta` branch is
92-
> finished. Otherwise the deploy for the tag might fail.
93-
9491
```bash
9592
git tag rust-1.XX.0 # XX should be exchanged with the corresponding version
9693
git push upstream rust-1.XX.0 # `upstream` is the `rust-lang/rust-clippy` remote

book/src/development/infrastructure/sync.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ to be run inside the `rust` directory):
8686
4. Bump the nightly version in the Clippy repository by running these commands:
8787
```bash
8888
cargo dev sync update_nightly
89-
git commit -m "Bump nightly version -> YYYY-MM-DD" rust-toolchain clippy_utils/README.md
89+
git commit -m "Bump nightly version -> YYYY-MM-DD" rust-toolchain.toml clippy_utils/README.md
9090
```
9191
5. Open a PR to `rust-lang/rust-clippy` and wait for it to get merged (to
9292
accelerate the process ping the `@rust-lang/clippy` team in your PR and/or

book/src/development/writing_tests.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,23 @@ Update the file with some examples to get started:
4141
struct A;
4242
impl A {
4343
pub fn fo(&self) {}
44-
pub fn foo(&self) {} //~ ERROR: function called "foo"
44+
pub fn foo(&self) {}
45+
//~^ foo_functions
4546
pub fn food(&self) {}
4647
}
4748

4849
// Default trait methods
4950
trait B {
5051
fn fo(&self) {}
51-
fn foo(&self) {} //~ ERROR: function called "foo"
52+
fn foo(&self) {}
53+
//~^ foo_functions
5254
fn food(&self) {}
5355
}
5456

5557
// Plain functions
5658
fn fo() {}
57-
fn foo() {} //~ ERROR: function called "foo"
59+
fn foo() {}
60+
//~^ foo_functions
5861
fn food() {}
5962

6063
fn main() {
@@ -66,19 +69,38 @@ fn main() {
6669
```
6770

6871
Without actual lint logic to emit the lint when we see a `foo` function name,
69-
this test will just pass, because no lint will be emitted. However, we can now
70-
run the test with the following command:
72+
this test will fail, because we expect errors at lines marked with
73+
`//~^ foo_functions`. However, we can now run the test with the following command:
7174

7275
```sh
7376
$ TESTNAME=foo_functions cargo uitest
7477
```
7578

76-
Clippy will compile and it will conclude with an `ok` for the tests:
79+
Clippy will compile and it will fail complaining it didn't receive any errors:
7780

7881
```
7982
...Clippy warnings and test outputs...
80-
test compile_test ... ok
81-
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.48s
83+
error: diagnostic code `clippy::foo_functions` not found on line 8
84+
--> tests/ui/foo_functions.rs:9:10
85+
|
86+
9 | //~^ foo_functions
87+
| ^^^^^^^^^^^^^ expected because of this pattern
88+
|
89+
90+
error: diagnostic code `clippy::foo_functions` not found on line 16
91+
--> tests/ui/foo_functions.rs:17:10
92+
|
93+
17 | //~^ foo_functions
94+
| ^^^^^^^^^^^^^ expected because of this pattern
95+
|
96+
97+
error: diagnostic code `clippy::foo_functions` not found on line 23
98+
--> tests/ui/foo_functions.rs:24:6
99+
|
100+
24 | //~^ foo_functions
101+
| ^^^^^^^^^^^^^ expected because of this pattern
102+
|
103+
82104
```
83105

84106
This is normal. After all, we wrote a bunch of Rust code but we haven't really

book/src/lint_configuration.md

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,33 @@ Whether to check MSRV compatibility in `#[test]` and `#[cfg(test)]` code.
425425
* [`incompatible_msrv`](https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv)
426426

427427

428+
## `check-inconsistent-struct-field-initializers`
429+
Whether to suggest reordering constructor fields when initializers are present.
430+
431+
Warnings produced by this configuration aren't necessarily fixed by just reordering the fields. Even if the
432+
suggested code would compile, it can change semantics if the initializer expressions have side effects. The
433+
following example [from rust-clippy#11846] shows how the suggestion can run into borrow check errors:
434+
435+
```rust
436+
struct MyStruct {
437+
vector: Vec<u32>,
438+
length: usize
439+
}
440+
fn main() {
441+
let vector = vec![1,2,3];
442+
MyStruct { length: vector.len(), vector};
443+
}
444+
```
445+
446+
[from rust-clippy#11846]: https://github.com/rust-lang/rust-clippy/issues/11846#issuecomment-1820747924
447+
448+
**Default Value:** `false`
449+
450+
---
451+
**Affected lints:**
452+
* [`inconsistent_struct_constructor`](https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_struct_constructor)
453+
454+
428455
## `check-private-items`
429456
Whether to also run the listed lints on private items.
430457

@@ -613,31 +640,15 @@ The maximum size of the `Err`-variant in a `Result` returned from a function
613640
* [`result_large_err`](https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err)
614641

615642

616-
## `lint-inconsistent-struct-field-initializers`
617-
Whether to suggest reordering constructor fields when initializers are present.
618-
619-
Warnings produced by this configuration aren't necessarily fixed by just reordering the fields. Even if the
620-
suggested code would compile, it can change semantics if the initializer expressions have side effects. The
621-
following example [from rust-clippy#11846] shows how the suggestion can run into borrow check errors:
622-
623-
```rust
624-
struct MyStruct {
625-
vector: Vec<u32>,
626-
length: usize
627-
}
628-
fn main() {
629-
let vector = vec![1,2,3];
630-
MyStruct { length: vector.len(), vector};
631-
}
632-
```
633-
634-
[from rust-clippy#11846]: https://github.com/rust-lang/rust-clippy/issues/11846#issuecomment-1820747924
643+
## `lint-commented-code`
644+
Whether collapsible `if` chains are linted if they contain comments inside the parts
645+
that would be collapsed.
635646

636647
**Default Value:** `false`
637648

638649
---
639650
**Affected lints:**
640-
* [`inconsistent_struct_constructor`](https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_struct_constructor)
651+
* [`collapsible_if`](https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if)
641652

642653

643654
## `literal-representation-threshold`
@@ -1059,7 +1070,8 @@ The maximum allowed size of a bit mask before suggesting to use 'trailing_zeros'
10591070

10601071

10611072
## `warn-on-all-wildcard-imports`
1062-
Whether to allow certain wildcard imports (prelude, super in tests).
1073+
Whether to emit warnings on all wildcard imports, including those from `prelude`, from `super` in tests,
1074+
or for `pub use` reexports.
10631075

10641076
**Default Value:** `false`
10651077

0 commit comments

Comments
 (0)