Skip to content

Update Clippy #91154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 156 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
c3d4577
Fix `match_overlapping_arm` false negative
Nov 1, 2021
693df63
Ensure `match_overlapping_arms` warns on first
Nov 1, 2021
1011e08
Reference nightly-rustc docs in clippy's docs
xFrednet Nov 4, 2021
d134ddd
Improve `clippy_utils` function docs
xFrednet Nov 4, 2021
a276cd2
Add clippy docs to check for a specific type
xFrednet Nov 4, 2021
5405152
Added note about the usage of `clippy_utils::path`
xFrednet Nov 4, 2021
84a4ab7
Auto merge of #7928 - xFrednet:rust-90354-deploy-clippy-docs, r=flip1995
bors Nov 4, 2021
e674d0a
Merge commit 'e18101137866b79045fee0ef996e696e68c920b4' into clippyup
flip1995 Nov 4, 2021
93ffc9d
Remove rustfmt::skip attribute from register_plugins function
flip1995 Nov 5, 2021
14d54f0
Use Span::from_expansion instead of in_macro
camsteffen Oct 29, 2021
85e2592
Auto merge of #7909 - mikerite:fix-7816, r=camsteffen
bors Nov 5, 2021
5b1b6a2
Edit docs about macros
camsteffen Nov 5, 2021
9a60a93
Auto merge of #7897 - camsteffen:in-macro, r=flip1995
bors Nov 5, 2021
445c83f
Auto merge of #7937 - flip1995:rustfmt-skip-artefact, r=Manishearth
bors Nov 5, 2021
1c4dd8d
Remove trim_semicolon
camsteffen Nov 2, 2021
73501da
Add expr_visitor util
camsteffen Oct 20, 2021
5239a90
Factor in some expr_visitor usages
camsteffen Nov 5, 2021
2c7b7e8
Remove if let check for match_ref_pats
camsteffen Nov 5, 2021
c96cd35
Extend author lint
Serial-ATA Oct 29, 2021
b5bae09
Add `cargo dev lint` to manually run clippy on a file
Alexendoo Nov 2, 2021
e3d1e60
Auto merge of #7894 - Serial-ATA:extend-author-lint, r=camsteffen
bors Nov 6, 2021
9a8919d
Fix Clippy with changed format_args!
camsteffen Nov 6, 2021
0cb9ac2
Give inline const separate DefKind
nbdd0121 Oct 2, 2021
07f4f7c
Auto merge of #7917 - Alexendoo:cargo-dev-lint, r=giraffate
bors Nov 7, 2021
c063203
ast: Fix naming conventions in AST structures
petrochenkov Nov 7, 2021
2c6f03d
Fix ICE in undocumented_unsafe_blocks
Serial-ATA Nov 7, 2021
ac9dd36
Don't abort compilation after giving a lint error
jyn514 Jul 21, 2021
6fcdf81
Auto merge of #7945 - Serial-ATA:issue-7934, r=flip1995
bors Nov 8, 2021
94517d3
Auto merge of #7938 - camsteffen:visitors, r=xFrednet
bors Nov 8, 2021
6d23824
Make select_* methods return Vec for TraitEngine
fee1-dead Nov 8, 2021
413d255
Add MSRV to deprecated_cfg_attr
Serial-ATA Nov 7, 2021
830f220
Auto merge of #7944 - Serial-ATA:deprecated-cfg-attr-msrv, r=giraffate
bors Nov 9, 2021
6809234
Fix explicit_counter_loop suggestion for non-usize types
Serial-ATA Nov 9, 2021
98416d7
Remove `unimplemented!()` case in matches code
Nov 9, 2021
949b259
Change `Bound` to `EndBound`
Nov 9, 2021
f829523
Simplify range comparison code
Nov 9, 2021
c8f909e
Improve variable naming
Nov 9, 2021
81fa758
Improve variable naming 2
Nov 9, 2021
8b76915
matches: remove `pub` from some items
Nov 9, 2021
6536c58
Auto merge of #90485 - camsteffen:fmt-args-less-bind, r=m-ou-se
bors Nov 9, 2021
0332a7b
Auto merge of #87337 - jyn514:lint-error, r=oli-obk,flip1995
bors Nov 9, 2021
36d5475
Auto merge of #90700 - fee1-dead:select-returns-vec, r=davidtwco
bors Nov 9, 2021
e54c341
Fix suggestion for deref expressions in redundant_pattern_matching
Serial-ATA Nov 8, 2021
c94d62b
Auto merge of #7949 - Serial-ATA:issue-7921, r=flip1995
bors Nov 9, 2021
3382201
Lint for bool to integer casts in `cast_lossless`
5225225 Nov 8, 2021
96db1d6
fix dogfood lint on clippy_utils
5225225 Nov 8, 2021
6e84f00
Check MSRV for bool to int from impl
5225225 Nov 9, 2021
3b6b1ab
Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakis
matthiaskrgr Nov 9, 2021
f69721f
Auto merge of #7950 - Serial-ATA:issue-7920, r=llogiq
bors Nov 9, 2021
93f13d5
Auto merge of #7951 - mikerite:matches-20211109, r=llogiq
bors Nov 9, 2021
e8861c8
Add `semicolon_if_nothing_returned` test for `let-else` stmts
dswij Nov 10, 2021
a003ca6
`semicolon_if_nothing_returned` now checks if the stmt ends with semi…
dswij Nov 10, 2021
2e17035
Auto merge of #7955 - dswij:let-else-early-return, r=giraffate
bors Nov 10, 2021
7c1e62d
Added `clippy::version` attribute as lint metadata
xFrednet Oct 12, 2021
8565fc4
Add clippy version to Clippy's lint list
xFrednet Oct 12, 2021
23ed792
Document new `clippy::version` attribute and make it mandatory
xFrednet Oct 17, 2021
63cb410
Manually add `clippy::version` attribute to deprecated lints
xFrednet Oct 17, 2021
d647696
Added `clippy::version` attribute to all normal lints
xFrednet Oct 21, 2021
9d9d06d
Add lint to check for invalid `clippy:version` attributes
xFrednet Oct 21, 2021
d68408f
Updated version label and style on Clippy's lint list
xFrednet Nov 2, 2021
94bc0a1
Address review feedback
xFrednet Nov 10, 2021
ce01346
author: name qpath consistently
camsteffen Nov 8, 2021
d0cc201
author: fix some bugs
camsteffen Nov 10, 2021
a806ce7
author: reorder match arm
camsteffen Nov 8, 2021
72d7b9c
author: Remove needless `ref`s
camsteffen Nov 10, 2021
847a95b
Refactor utils on checking attribute
dswij Oct 25, 2021
2d037aa
Check for no_std and no_core attribute in `swap` lint
dswij Oct 25, 2021
dcd1a16
Add test for `swap` lint when `no_std` is present
dswij Oct 25, 2021
8389df9
Auto merge of #7877 - dswij:no-std-fp, r=camsteffen
bors Nov 11, 2021
8c45fd8
New internal lint to make `clippy::version` attribute mandatory
xFrednet Nov 11, 2021
3bfe98d
Auto merge of #7813 - xFrednet:6492-lint-version, r=flip1995
bors Nov 11, 2021
27a1763
Make author DRYer
camsteffen Nov 5, 2021
e444cbe
New `index_refutable_slice` lint
xFrednet Aug 31, 2021
3d4d0cf
Auto merge of #7643 - xFrednet:7569-splits-for-slices, r=camsteffen
bors Nov 11, 2021
8b84a76
Auto merge of #7956 - camsteffen:author, r=llogiq
bors Nov 11, 2021
24d561f
Use rustfmt version from `rust-toolchain`
Jarcho Nov 12, 2021
610b381
Auto merge of #7963 - Jarcho:dev_fmt, r=flip1995
bors Nov 12, 2021
d4c8cb6
Change cast_lossless message for bools only
5225225 Nov 12, 2021
4f82dd8
Auto merge of #7948 - 5225225:castlosslessbool, r=llogiq
bors Nov 12, 2021
91fe265
Add rustfmt component to rust-toolchain
Alexendoo Nov 12, 2021
608c9e8
Run clippy_dev workflow on current rust-toolchain
Alexendoo Nov 12, 2021
507030f
Run rustfmt on batches of multiple files
Alexendoo Nov 12, 2021
cc9d7ff
Auto merge of #7966 - Alexendoo:batch-rustfmt, r=camsteffen
bors Nov 12, 2021
80a263d
Fix `manual_map` suggestion when used with unsafe functions and unsaf…
Jarcho Nov 13, 2021
1df10f0
fix typo
togami2864 Nov 13, 2021
f51fb34
Auto merge of #7969 - togami2864:fix-typo, r=xFrednet
bors Nov 13, 2021
2ed4a8a
fix suggestion in option_map_or_none
togami2864 Nov 13, 2021
3fe11e7
option_if_let_else: don't expand macros in suggestion
matthiaskrgr Nov 13, 2021
3e20e30
Fix specific code outlined in issue #7975.
Blckbrry-Pi Nov 14, 2021
634e79c
Support suggestion for #7854
surechen Nov 11, 2021
f82bf47
Auto merge of #7957 - surechen:fix_for_7854, r=giraffate
bors Nov 15, 2021
4f71ff3
add test case for option_map_or_none
togami2864 Nov 15, 2021
0def42f
Auto merge of #7974 - matthiaskrgr:7973_opt_map_or_else_dont_expand_s…
bors Nov 15, 2021
bbffe82
add reduce_unit_expression
togami2864 Nov 15, 2021
02e0726
fix a bug that the closure arguments are not displayed
togami2864 Nov 15, 2021
cd57816
add comment
togami2864 Nov 15, 2021
300282c
fix fmt
togami2864 Nov 15, 2021
0a30fdc
move the let statement out of the macro
togami2864 Nov 15, 2021
8ded385
Improve `needless_borrow` lint.
Jarcho Nov 15, 2021
2938ffd
Improve heuristics for determining whether eager of lazy evaluation i…
Jarcho Aug 17, 2021
5b1b65b
Auto merge of #7639 - Jarcho:whitelist_cheap_functions, r=camsteffen
bors Nov 16, 2021
7605bac
resolve CI
togami2864 Nov 16, 2021
5b3c00f
Successfully generalize prevention of suggestions causing multiple mu…
Blckbrry-Pi Nov 16, 2021
c52b389
Fix readability suggestions.
Blckbrry-Pi Nov 16, 2021
83ad511
Auto merge of #7982 - Blckbrry-Pi:master, r=llogiq
bors Nov 16, 2021
e9bf5ec
Don't show no_effect warning on unit structs implementing fn* traits
F3real Nov 16, 2021
c051656
fixes: #7889
surechen Oct 29, 2021
46687f1
Auto merge of #7896 - surechen:fix_manual_split_once, r=camsteffen
bors Nov 17, 2021
3f3d7c2
Fix ICE on `undocumented_unsafe_blocks`
giraffate Nov 17, 2021
94ca94f
Auto merge of #7898 - F3real:unit_struct, r=camsteffen
bors Nov 17, 2021
e34927e
add multi-line test case
togami2864 Nov 17, 2021
d550e5f
Auto merge of #7988 - giraffate:fix_ice_on_undocumented_unsafe_blocks…
bors Nov 17, 2021
006c442
check whether stmts is empty or not in block
togami2864 Nov 17, 2021
8506f66
Minor simplification to `manual_map`
Jarcho Nov 17, 2021
5f861ee
Addition `manual_map` test for `unsafe` blocks
Jarcho Nov 17, 2021
8e317f5
fix suggestion message
togami2864 Nov 17, 2021
6ac42fe
Auto merge of #7971 - togami2864:fix/option-map-or-none, r=llogiq
bors Nov 17, 2021
bb58dc8
Auto merge of #7968 - Jarcho:manual_map_unsafe, r=xFrednet
bors Nov 17, 2021
cb62680
rustc: Remove `#[rustc_synthetic]`
petrochenkov Nov 18, 2021
b5a61aa
fix typo
togami2864 Nov 18, 2021
8536647
Auto merge of #7992 - togami2864:fix-typo, r=giraffate
bors Nov 18, 2021
731dfde
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Nov 18, 2021
4bccd59
Bump nightly version -> 2021-11-18
flip1995 Nov 18, 2021
8dd1bce
Auto merge of #7994 - flip1995:rustup, r=flip1995
bors Nov 18, 2021
b7f1891
Pluralize disallowed_type lint
phansch Nov 17, 2021
a0d81d1
Pluralize disallowed_type lint filenames
phansch Nov 17, 2021
9b38fb7
Also pluralize disallowed_method(s) lint
flip1995 Nov 18, 2021
0375d20
Add missing components to rust-toolchain file
couchand Nov 17, 2021
2776076
Auto merge of #7977 - Jarcho:multi_needless_borrow, r=xFrednet
bors Nov 18, 2021
abb7155
add test case for result_map_or_into_option
togami2864 Nov 19, 2021
cd81bb9
fix stderr
togami2864 Nov 19, 2021
0d283cc
Auto merge of #7996 - togami2864:test-map-or-none, r=Manishearth
bors Nov 19, 2021
38bd251
Auto merge of #7984 - phansch:disallowed-type-rename, r=xFrednet
bors Nov 19, 2021
1429949
Don't check for a nightly toolchain in fmt test
Jarcho Nov 20, 2021
982124a
Add new lint `octal_escapes`
birkenfeld Nov 20, 2021
827fd50
Auto merge of #8000 - Jarcho:nightly_fmt, r=llogiq
bors Nov 20, 2021
1c8085d
Allow `suboptimal_flops` in const functions
xFrednet Nov 20, 2021
0c4055c
Avoid inline hints with double backticks for `doc-markdown`
birkenfeld Nov 20, 2021
32048eb
Auto merge of #8011 - birkenfeld:double_backticks, r=xFrednet
bors Nov 20, 2021
846c0be
Fixes #7915
surechen Nov 19, 2021
e58ffb8
Fix Clippy with changed for loop desugar
camsteffen Oct 27, 2021
8c1c763
clippy: Fix pattern_type_mismatch for loop
camsteffen Nov 19, 2021
de2208a
Auto merge of #7997 - surechen:Fixes_7915, r=giraffate
bors Nov 21, 2021
5fbfdfa
Auto merge of #8009 - xFrednet:8004-suboptimal-flops-in-const, r=gira…
bors Nov 22, 2021
4027594
Auto merge of #7989 - couchand:2021-11/toolchain-missing-components, …
bors Nov 22, 2021
850e7f5
`octal_escapes`: updates from review, fix byte string prefix
birkenfeld Nov 21, 2021
0bc25d0
octal_escapes: emit only one lint for all cases found each literal
birkenfeld Nov 22, 2021
1210bb4
octal_escapes: note on print!() format strings
birkenfeld Nov 22, 2021
57a8804
Auto merge of #8007 - birkenfeld:octal_escapes, r=xFrednet
bors Nov 22, 2021
ec3d1c8
Fix FP on `if_then_some_else_none` when there is early return
dswij Nov 16, 2021
d6c707d
Auto merge of #7980 - dswij:7870, r=xFrednet
bors Nov 23, 2021
5740230
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Nov 23, 2021
c46c8c5
Bump nightly version -> 2021-11-23
flip1995 Nov 23, 2021
81f37a8
Auto merge of #8025 - flip1995:rustup, r=flip1995
bors Nov 23, 2021
1ee5aa4
Merge commit '81f37a8150fc86f8de00e6947e86d2b69291906a' into clippyup
flip1995 Nov 23, 2021
b95545b
Update Cargo.lock
flip1995 Nov 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 13 additions & 8 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ dependencies = [
"filetime",
"if_chain",
"itertools 0.10.1",
"parking_lot",
"quote",
"regex",
"rustc-workspace-hack",
Expand All @@ -600,6 +601,7 @@ name = "clippy_dev"
version = "0.0.1"
dependencies = [
"bytecount",
"cargo_metadata 0.14.0",
"clap",
"indoc",
"itertools 0.10.1",
Expand Down Expand Up @@ -1713,9 +1715,12 @@ dependencies = [

[[package]]
name = "instant"
version = "0.1.6"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if 1.0.0",
]

[[package]]
name = "itertools"
Expand Down Expand Up @@ -1992,9 +1997,9 @@ version = "0.1.0"

[[package]]
name = "lock_api"
version = "0.4.1"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c"
checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"
dependencies = [
"scopeguard",
]
Expand Down Expand Up @@ -2511,9 +2516,9 @@ dependencies = [

[[package]]
name = "parking_lot"
version = "0.11.1"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
dependencies = [
"instant",
"lock_api",
Expand All @@ -2522,9 +2527,9 @@ dependencies = [

[[package]]
name = "parking_lot_core"
version = "0.8.3"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
dependencies = [
"cfg-if 1.0.0",
"instant",
Expand Down
12 changes: 0 additions & 12 deletions src/tools/clippy/.github/workflows/clippy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v2.3.3

- name: remove toolchain file
run: rm rust-toolchain

- name: rust-toolchain
uses: actions-rs/toolchain@v1.0.6
with:
toolchain: nightly
target: x86_64-unknown-linux-gnu
profile: minimal
components: rustfmt
default: true

# Run
- name: Build
run: cargo build --features deny-warnings
Expand Down
19 changes: 11 additions & 8 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Current beta, release 2021-12-02
[#7560](https://github.com/rust-lang/rust-clippy/pull/7560)
* [`unnecessary_unwrap`]: Now also checks for `expect`s
[#7584](https://github.com/rust-lang/rust-clippy/pull/7584)
* [`disallowed_method`]: Allow adding a reason that will be displayed with the
* [`disallowed_methods`]: Allow adding a reason that will be displayed with the
lint message
[#7621](https://github.com/rust-lang/rust-clippy/pull/7621)
* [`approx_constant`]: Now checks the MSRV for `LOG10_2` and `LOG2_10`
Expand Down Expand Up @@ -174,7 +174,7 @@ Current stable, released 2021-10-21

* [`needless_continue`]: Now also lints in `loop { continue; }` case
[#7477](https://github.com/rust-lang/rust-clippy/pull/7477)
* [`disallowed_type`]: Now also primitive types can be disallowed
* [`disallowed_types`]: Now also primitive types can be disallowed
[#7488](https://github.com/rust-lang/rust-clippy/pull/7488)
* [`manual_swap`]: Now also lints on xor swaps
[#7506](https://github.com/rust-lang/rust-clippy/pull/7506)
Expand Down Expand Up @@ -248,7 +248,7 @@ Released 2021-09-09
[#7403](https://github.com/rust-lang/rust-clippy/pull/7403)
* [`disallowed_script_idents`]
[#7400](https://github.com/rust-lang/rust-clippy/pull/7400)
* [`disallowed_type`]
* [`disallowed_types`]
[#7315](https://github.com/rust-lang/rust-clippy/pull/7315)
* [`missing_enforced_import_renames`]
[#7300](https://github.com/rust-lang/rust-clippy/pull/7300)
Expand Down Expand Up @@ -294,7 +294,7 @@ Released 2021-09-09
[#7379](https://github.com/rust-lang/rust-clippy/pull/7379)
* [`redundant_closure`]: Suggests `&mut` for `FnMut`
[#7437](https://github.com/rust-lang/rust-clippy/pull/7437)
* [`disallowed_method`], [`disallowed_type`]: The configuration values `disallowed-method` and `disallowed-type`
* [`disallowed_methods`], [`disallowed_types`]: The configuration values `disallowed-method` and `disallowed-type`
no longer require fully qualified paths
[#7345](https://github.com/rust-lang/rust-clippy/pull/7345)
* [`zst_offset`]: Fixed lint invocation after it was accidentally suppressed
Expand Down Expand Up @@ -703,7 +703,7 @@ Released 2021-05-06

### Enhancements

* [`disallowed_method`]: Now supports functions in addition to methods
* [`disallowed_methods`]: Now supports functions in addition to methods
[#6674](https://github.com/rust-lang/rust-clippy/pull/6674)
* [`upper_case_acronyms`]: Added a new configuration `upper-case-acronyms-aggressive` to
trigger the lint if there is more than one uppercase character next to each other
Expand Down Expand Up @@ -1044,7 +1044,7 @@ Released 2020-12-31

* [`field_reassign_with_default`] [#5911](https://github.com/rust-lang/rust-clippy/pull/5911)
* [`await_holding_refcell_ref`] [#6029](https://github.com/rust-lang/rust-clippy/pull/6029)
* [`disallowed_method`] [#6081](https://github.com/rust-lang/rust-clippy/pull/6081)
* [`disallowed_methods`] [#6081](https://github.com/rust-lang/rust-clippy/pull/6081)
* [`inline_asm_x86_att_syntax`] [#6092](https://github.com/rust-lang/rust-clippy/pull/6092)
* [`inline_asm_x86_intel_syntax`] [#6092](https://github.com/rust-lang/rust-clippy/pull/6092)
* [`from_iter_instead_of_collect`] [#6101](https://github.com/rust-lang/rust-clippy/pull/6101)
Expand Down Expand Up @@ -2821,9 +2821,9 @@ Released 2018-09-13
[`derivable_impls`]: https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls
[`derive_hash_xor_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#derive_hash_xor_eq
[`derive_ord_xor_partial_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#derive_ord_xor_partial_ord
[`disallowed_method`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_method
[`disallowed_methods`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
[`disallowed_script_idents`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_script_idents
[`disallowed_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_type
[`disallowed_types`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types
[`diverging_sub_expression`]: https://rust-lang.github.io/rust-clippy/master/index.html#diverging_sub_expression
[`doc_markdown`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
[`double_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_comparisons
Expand Down Expand Up @@ -2904,6 +2904,7 @@ Released 2018-09-13
[`imprecise_flops`]: https://rust-lang.github.io/rust-clippy/master/index.html#imprecise_flops
[`inconsistent_digit_grouping`]: https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_digit_grouping
[`inconsistent_struct_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_struct_constructor
[`index_refutable_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#index_refutable_slice
[`indexing_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing
[`ineffective_bit_mask`]: https://rust-lang.github.io/rust-clippy/master/index.html#ineffective_bit_mask
[`inefficient_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#inefficient_to_string
Expand Down Expand Up @@ -3038,6 +3039,7 @@ Released 2018-09-13
[`needless_question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark
[`needless_range_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop
[`needless_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
[`needless_splitn`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_splitn
[`needless_update`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_update
[`neg_cmp_op_on_partial_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#neg_cmp_op_on_partial_ord
[`neg_multiply`]: https://rust-lang.github.io/rust-clippy/master/index.html#neg_multiply
Expand All @@ -3054,6 +3056,7 @@ Released 2018-09-13
[`nonsensical_open_options`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonsensical_open_options
[`nonstandard_macro_braces`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
[`not_unsafe_ptr_arg_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref
[`octal_escapes`]: https://rust-lang.github.io/rust-clippy/master/index.html#octal_escapes
[`ok_expect`]: https://rust-lang.github.io/rust-clippy/master/index.html#ok_expect
[`op_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#op_ref
[`option_as_ref_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_as_ref_deref
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ itertools = "0.10"
quote = "1.0"
serde = { version = "1.0", features = ["derive"] }
syn = { version = "1.0", features = ["full"] }
parking_lot = "0.11.2"

[build-dependencies]
rustc_tools_util = { version = "0.2", path = "rustc_tools_util" }
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ opener = "0.5"
regex = "1.5"
shell-escape = "0.1"
walkdir = "2.3"
cargo_metadata = "0.14"

[features]
deny-warnings = []
44 changes: 26 additions & 18 deletions src/tools/clippy/clippy_dev/src/fmt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::clippy_project_root;
use itertools::Itertools;
use shell_escape::escape;
use std::ffi::OsStr;
use std::ffi::{OsStr, OsString};
use std::path::Path;
use std::process::{self, Command};
use std::{fs, io};
Expand Down Expand Up @@ -56,15 +57,22 @@ pub fn run(check: bool, verbose: bool) {
success &= cargo_fmt(context, &project_root.join("rustc_tools_util"))?;
success &= cargo_fmt(context, &project_root.join("lintcheck"))?;

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

if path.extension() != Some("rs".as_ref()) || entry.file_name() == "ice-3891.rs" {
continue;
}

success &= rustfmt(context, path)?;
let chunks = WalkDir::new(project_root.join("tests"))
.into_iter()
.filter_map(|entry| {
let entry = entry.expect("failed to find tests");
let path = entry.path();

if path.extension() != Some("rs".as_ref()) || entry.file_name() == "ice-3891.rs" {
None
} else {
Some(entry.into_path().into_os_string())
}
})
.chunks(250);

for chunk in &chunks {
success &= rustfmt(context, chunk)?;
}

Ok(success)
Expand Down Expand Up @@ -149,7 +157,7 @@ fn exec(
}

fn cargo_fmt(context: &FmtContext, path: &Path) -> Result<bool, CliError> {
let mut args = vec!["+nightly", "fmt", "--all"];
let mut args = vec!["fmt", "--all"];
if context.check {
args.push("--");
args.push("--check");
Expand All @@ -162,7 +170,7 @@ fn cargo_fmt(context: &FmtContext, path: &Path) -> Result<bool, CliError> {
fn rustfmt_test(context: &FmtContext) -> Result<(), CliError> {
let program = "rustfmt";
let dir = std::env::current_dir()?;
let args = &["+nightly", "--version"];
let args = &["--version"];

if context.verbose {
println!("{}", format_command(&program, &dir, args));
Expand All @@ -185,14 +193,14 @@ fn rustfmt_test(context: &FmtContext) -> Result<(), CliError> {
}
}

fn rustfmt(context: &FmtContext, path: &Path) -> Result<bool, CliError> {
let mut args = vec!["+nightly".as_ref(), path.as_os_str()];
fn rustfmt(context: &FmtContext, paths: impl Iterator<Item = OsString>) -> Result<bool, CliError> {
let mut args = Vec::new();
if context.check {
args.push("--check".as_ref());
args.push(OsString::from("--check"));
}
args.extend(paths);

let success = exec(context, "rustfmt", std::env::current_dir()?, &args)?;
if !success {
eprintln!("rustfmt failed on {}", path.display());
}

Ok(success)
}
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::path::PathBuf;

pub mod bless;
pub mod fmt;
pub mod lint;
pub mod new_lint;
pub mod serve;
pub mod setup;
Expand Down
20 changes: 20 additions & 0 deletions src/tools/clippy/clippy_dev/src/lint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::process::{self, Command};

pub fn run(filename: &str) {
let code = Command::new("cargo")
.args(["run", "--bin", "clippy-driver", "--"])
.args(["-L", "./target/debug"])
.args(["-Z", "no-codegen"])
.args(["--edition", "2021"])
.arg(filename)
.env("__CLIPPY_INTERNAL_TESTS", "true")
.status()
.expect("failed to run cargo")
.code();

if code.is_none() {
eprintln!("Killed by signal");
}

process::exit(code.unwrap_or(1));
}
15 changes: 14 additions & 1 deletion src/tools/clippy/clippy_dev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![warn(rust_2018_idioms, unused_lifetimes)]

use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
use clippy_dev::{bless, fmt, new_lint, serve, setup, update_lints};
use clippy_dev::{bless, fmt, lint, new_lint, serve, setup, update_lints};
fn main() {
let matches = get_clap_config();

Expand Down Expand Up @@ -55,6 +55,10 @@ fn main() {
let lint = matches.value_of("lint");
serve::run(port, lint);
},
("lint", Some(matches)) => {
let filename = matches.value_of("filename").unwrap();
lint::run(filename);
},
_ => {},
}
}
Expand Down Expand Up @@ -219,5 +223,14 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
)
.arg(Arg::with_name("lint").help("Which lint's page to load initially (optional)")),
)
.subcommand(
SubCommand::with_name("lint")
.about("Manually run clippy on a file")
.arg(
Arg::with_name("filename")
.required(true)
.help("The path to a file to lint"),
),
)
.get_matches()
}
21 changes: 18 additions & 3 deletions src/tools/clippy/clippy_dev/src/new_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ fn to_camel_case(name: &str) -> String {
.collect()
}

fn get_stabilisation_version() -> String {
let mut command = cargo_metadata::MetadataCommand::new();
command.no_deps();
if let Ok(metadata) = command.exec() {
if let Some(pkg) = metadata.packages.iter().find(|pkg| pkg.name == "clippy") {
return format!("{}.{}.0", pkg.version.minor, pkg.version.patch);
}
}

String::from("<TODO set version(see doc/adding_lints.md)>")
}

fn get_test_file_contents(lint_name: &str, header_commands: Option<&str>) -> String {
let mut contents = format!(
indoc! {"
Expand Down Expand Up @@ -178,6 +190,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
},
};

let version = get_stabilisation_version();
let lint_name = lint.name;
let category = lint.category;
let name_camel = to_camel_case(lint.name);
Expand Down Expand Up @@ -212,7 +225,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
});

result.push_str(&format!(
indoc! {"
indoc! {r#"
declare_clippy_lint! {{
/// ### What it does
///
Expand All @@ -226,11 +239,13 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
/// ```rust
/// // example code which does not raise clippy warning
/// ```
#[clippy::version = "{version}"]
pub {name_upper},
{category},
\"default lint description\"
"default lint description"
}}
"},
"#},
version = version,
name_upper = name_upper,
category = category,
));
Expand Down
Loading