Skip to content
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

Update Clippy #90564

Merged
merged 108 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
e6e6e7d
Change `unseparated_literal_suffix` type to restriction
dswij Sep 27, 2021
449d68d
Fix clippy with for loop span change
camsteffen Oct 14, 2021
4679eb3
Move const int value code to utils
Oct 20, 2021
c4d5471
Add test for #7829
Oct 20, 2021
1ede540
Fix false positive in `match_overlapping_arm`
Oct 20, 2021
7631fc5
Merge commit '91496c2ac6abf6454c413bb23e8becf6b6dc20ea' into clippyup
flip1995 Oct 21, 2021
1e8d9fb
Handle 'implementation safety' headers as well
Manishearth Oct 21, 2021
96126e7
Fix deploy script
flip1995 Oct 21, 2021
566244a
Do not lint when cast is coming from `signum` method call
ThibsG Oct 20, 2021
081d0f8
Make useless_format recognize format!("")
aDotInTheVoid Oct 11, 2021
c97a06d
Auto merge of #7850 - ThibsG:PossibleCastTruncation5395, r=camsteffen
bors Oct 21, 2021
2ba1a6a
Auto merge of #7801 - aDotInTheVoid:empty-format, r=camsteffen
bors Oct 21, 2021
6714eff
Auto merge of #7857 - flip1995:fix_deploy, r=xFrednet
bors Oct 21, 2021
9def82d
use a variable
Manishearth Oct 21, 2021
df65291
Auto merge of #7856 - Manishearth:impl-safety, r=xFrednet
bors Oct 21, 2021
efef16f
Rollup merge of #89895 - camsteffen:for-loop-head-span, r=davidtwco
JohnTitor Oct 22, 2021
e953dff
Fix `match_str_case_mismatch` false positives
Herschel Oct 23, 2021
a5a3e61
Fix typo on utils/lib
dswij Oct 23, 2021
ba0cfc7
Auto merge of #7867 - dswij:utils-typo, r=llogiq
bors Oct 23, 2021
1b91d98
Rename `clippy_utils::camal_case` to `clippy_utils::str_utils`
xFrednet Oct 24, 2021
20fb7f2
Update rustfmt
camsteffen Oct 24, 2021
73a443d
Auto merge of #7871 - camsteffen:fmt-update, r=camsteffen
bors Oct 24, 2021
d38fddd
Refactor `camel_case` util functions for new `StrIndex`
xFrednet Oct 24, 2021
1b2c57c
docs: recommend new branch
calebcartwright Oct 24, 2021
f674e6f
Always sort suggestions before emitting them
estebank Oct 1, 2021
7517ae2
Refactored some string handling to prevent ICEs and FNs
xFrednet Oct 24, 2021
4064e97
Auto merge of #7872 - calebcartwright:sync-use-new-branch, r=flip1995
bors Oct 25, 2021
949fc44
Update CHANGELOG
flip1995 Oct 21, 2021
cc2d933
Auto merge of #7855 - flip1995:changelog, r=xFrednet
bors Oct 25, 2021
1ad04f4
Move `non_send_fields_in_send_ty` to `suspicious`
xFrednet Oct 24, 2021
4f46f42
Auto merge of #7874 - xFrednet:7756-move-lint, r=llogiq
bors Oct 25, 2021
3ef1f19
Auto merge of #7873 - xFrednet:7869-string-index-ice, r=Manishearth
bors Oct 25, 2021
cb0132d
Auto merge of #7865 - Herschel:fix-match-str-case-mismatch, r=xFrednet
bors Oct 25, 2021
999b300
new lint: string-slice
llogiq Oct 25, 2021
d0c04b4
Clean up tests/ui/rename.rs
devonhollowood Oct 26, 2021
075996e
Auto merge of #7878 - rust-lang:string-slice, r=giraffate
bors Oct 26, 2021
d4196d0
Add #7859 FP test case for `question_mark`
dswij Oct 22, 2021
a1a399d
Fix `question_mark` FP on calls
dswij Oct 22, 2021
a91ec59
Update `question_mark` expected test output
dswij Oct 22, 2021
2fd1682
Update `question_mark` test to behave better
dswij Oct 22, 2021
fb0fbad
Rename variable name in `question_mark`
dswij Oct 26, 2021
6c89c00
Further clean up tests/ui/rename.rs
devonhollowood Oct 26, 2021
e48ab44
Clean up `tests/ui/deprecated.rs`
devonhollowood Oct 26, 2021
bd778e2
Register the generated lints from `cargo dev new_lint`
Alexendoo Oct 25, 2021
dea9402
Remove hidden code lines in Clippy's lint list
xFrednet Oct 26, 2021
5733c75
Apply suggestions from code review
devonhollowood Oct 26, 2021
0d07ec1
Auto merge of #7887 - xFrednet:7172-hiding-hidden-lines-online, r=fli…
bors Oct 26, 2021
ab9a8f2
Update tests after reviewer suggestions
devonhollowood Oct 26, 2021
a48367e
Auto merge of #7884 - devonhollowood:rename-cleanup, r=xFrednet
bors Oct 26, 2021
ba2ac3e
Auto merge of #7860 - dswij:question-mark-fp, r=giraffate
bors Oct 26, 2021
73c026b
Add test case
giraffate Oct 27, 2021
444ef3e
Auto merge of #7880 - Alexendoo:newlint-add-pass, r=flip1995
bors Oct 27, 2021
36d4a4e
Add unit-hash lint
mbStavola Oct 25, 2021
962e21c
Auto merge of #7875 - mbStavola:unit-hash, r=xFrednet
bors Oct 27, 2021
e2c30f0
Ignore references to type aliases in ptr_arg
Alexendoo Oct 27, 2021
ed71add
Auto merge of #7885 - devonhollowood:deprecated-cleanup, r=llogiq
bors Oct 27, 2021
89a1156
Auto merge of #7847 - mikerite:fix-7829, r=flip1995
bors Oct 28, 2021
35bf041
Fix ICE in `undocumented_unsafe_blocks`
giraffate Oct 28, 2021
7788af9
Auto merge of #7891 - giraffate:fix_ice_for_undocumented_unsafe_block…
bors Oct 28, 2021
d8fcfd7
Move if_then_panic to pedantic
camsteffen Oct 12, 2021
022146d
Rename if_then_panic to manual_assert
camsteffen Oct 12, 2021
00821ca
Auto merge of #7810 - camsteffen:if-then-panic-pedantic, r=flip1995
bors Oct 28, 2021
dbe167d
Auto merge of #7890 - Alexendoo:ptr-arg-alias, r=camsteffen
bors Oct 29, 2021
00ea73e
avoid linting `possible_truncation` on bit-reducing operations
llogiq Oct 13, 2021
2f327aa
Disable "if_not_else" lints firing on else-ifs
ahmedkrmn Oct 29, 2021
4c70c18
Auto merge of #7895 - ahmedkrmn:master, r=Manishearth
bors Oct 29, 2021
665ff57
Remove expects from FullInt Partial{Ord,Eq}
Oct 30, 2021
c8edd9a
Remove casts from FullInt impl
Oct 30, 2021
c6dca68
Simplify FullInt Ord impl
Oct 30, 2021
4a86156
Simplify FullInt Ord impl (2)
Oct 30, 2021
e8c4046
Simplify FullInt Ord impl
Oct 30, 2021
a4ede72
update most tests to 2021 edition
llogiq Oct 23, 2021
310ecb0
Auto merge of #7899 - mikerite:fullint-20211030, r=xFrednet
bors Oct 30, 2021
892063e
Add #[must_use] to len and is_empty
jkugelman Oct 11, 2021
d634fae
Rollup merge of #89786 - jkugelman:must-use-len-and-is_empty, r=josht…
matthiaskrgr Oct 31, 2021
28c225f
Move non_ascii_literal to restriction
Alexendoo Oct 31, 2021
1085df5
Add `separated_literal_suffix` as an alternative for
dswij Sep 22, 2021
bb1cf72
Update CHANGELOG to include `separated_literal_suffix`
dswij Oct 4, 2021
7cd9bf5
Auto merge of #7866 - rust-lang:edition-2021-tests, r=Manishearth
bors Nov 1, 2021
7e5f99a
Fix manual_assert for `#![no_std]` and Rust 2021
nbdd0121 Oct 20, 2021
14e0390
Account for revisions in missing-test-files
nbdd0121 Oct 24, 2021
5edb02a
Fix #7903
smoelius Nov 1, 2021
ec456de
Small fixes for missing backticks in doc
giraffate Nov 2, 2021
08b7e87
Auto merge of #7911 - giraffate:small_fixes_for_missing_backticks, r=…
bors Nov 2, 2021
4e355eb
Auto merge of #7819 - rust-lang:avoid-linting-impossible-truncation, …
bors Nov 2, 2021
3f84010
Examine lifetimes in `OpaqueDef` bounds as well
samueltardieu Oct 30, 2021
38d8025
Auto merge of #7726 - dswij:unseparated-literal-suffix, r=flip1995
bors Nov 2, 2021
9bcf966
Add test case for `clippy::needless_lifetimes` in async context
samueltardieu Oct 30, 2021
276e895
Auto merge of #7851 - nbdd0121:master, r=flip1995
bors Nov 2, 2021
9720619
Auto merge of #7901 - samueltardieu:fix-7893, r=xFrednet,flip1995
bors Nov 2, 2021
18cc4e7
Auto merge of #7907 - Alexendoo:non-ascii-restriction, r=flip1995
bors Nov 2, 2021
db9e012
Update clippy dependencies
xFrednet Nov 2, 2021
2ebd535
Auto merge of #7906 - smoelius:master, r=camsteffen
bors Nov 2, 2021
a68c135
Use .cargo/config.toml instead of .cargo/config
samueltardieu Nov 2, 2021
b6c8168
Auto merge of #7918 - samueltardieu:use-config-toml, r=flip1995
bors Nov 2, 2021
7f8198a
Advise to put a :: prefix inside the ticks
samueltardieu Nov 2, 2021
c68af43
Auto merge of #7916 - samueltardieu:double-colon-prefix, r=xFrednet
bors Nov 2, 2021
0db8c52
Add suggestion to missing backticks error
Serial-ATA Oct 31, 2021
3732d11
Specify fixable doc tests
Serial-ATA Nov 2, 2021
4d26c5c
Auto merge of #7904 - Serial-ATA:improve-doc-suggestion, r=xFrednet
bors Nov 2, 2021
c2cbf55
Rollup merge of #90500 - xFrednet:00000-update-clippy-deps, r=flip1995
matthiaskrgr Nov 2, 2021
df9f5e4
Update diagnostics.rs
lengyijun Nov 4, 2021
150a659
Auto merge of #7926 - lengyijun:patch-1, r=giraffate
bors Nov 4, 2021
1cc21db
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Nov 4, 2021
c7f5462
Bump nightly version -> 2021-11-04
flip1995 Nov 4, 2021
e181011
Auto merge of #7929 - flip1995:rustup, r=flip1995
bors Nov 4, 2021
4d6c2cc
Merge commit 'e18101137866b79045fee0ef996e696e68c920b4' into clippyup
flip1995 Nov 4, 2021
4e5319b
Update Cargo.lock
flip1995 Nov 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,9 @@ dependencies = [

[[package]]
name = "compiletest_rs"
version = "0.7.0"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64698e5e2435db061a85e6320af12c30c5fd88eb84b35d2c1e03ce4f143255ca"
checksum = "29843cb8d351febf86557681d049d1e1652b81a086a190fa1173c07fd17fbf83"
dependencies = [
"diff",
"filetime",
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/tools/clippy/.github/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ cp util/gh-pages/lints.json out/master
if [[ -n $TAG_NAME ]]; then
echo "Save the doc for the current tag ($TAG_NAME) and point stable/ to it"
cp -Tr out/master "out/$TAG_NAME"
ln -sf "$TAG_NAME" out/stable
rm -f out/stable
ln -s "$TAG_NAME" out/stable
fi

if [[ $BETA = "true" ]]; then
Expand Down
166 changes: 158 additions & 8 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,162 @@ document.

## Unreleased / In Rust Nightly

[7bfc26e...master](https://github.com/rust-lang/rust-clippy/compare/7bfc26e...master)
[b7f3f7f...master](https://github.com/rust-lang/rust-clippy/compare/b7f3f7f...master)

## Rust 1.57

Current beta, release 2021-12-02

[7bfc26e...b7f3f7f](https://github.com/rust-lang/rust-clippy/compare/7bfc26e...b7f3f7f)

### New Lints

* [`negative_feature_names`]
[#7539](https://github.com/rust-lang/rust-clippy/pull/7539)
* [`redundant_feature_names`]
[#7539](https://github.com/rust-lang/rust-clippy/pull/7539)
* [`mod_module_files`]
[#7543](https://github.com/rust-lang/rust-clippy/pull/7543)
* [`self_named_module_files`]
[#7543](https://github.com/rust-lang/rust-clippy/pull/7543)
* [`manual_split_once`]
[#7565](https://github.com/rust-lang/rust-clippy/pull/7565)
* [`derivable_impls`]
[#7570](https://github.com/rust-lang/rust-clippy/pull/7570)
* [`needless_option_as_deref`]
[#7596](https://github.com/rust-lang/rust-clippy/pull/7596)
* [`iter_not_returning_iterator`]
[#7610](https://github.com/rust-lang/rust-clippy/pull/7610)
* [`same_name_method`]
[#7653](https://github.com/rust-lang/rust-clippy/pull/7653)
* [`manual_assert`] [#7669](https://github.com/rust-lang/rust-clippy/pull/7669)
* [`non_send_fields_in_send_ty`]
[#7709](https://github.com/rust-lang/rust-clippy/pull/7709)
* [`equatable_if_let`]
[#7762](https://github.com/rust-lang/rust-clippy/pull/7762)

### Moves and Deprecations

* Move [`shadow_unrelated`] to `restriction`
[#7338](https://github.com/rust-lang/rust-clippy/pull/7338)
* Move [`option_if_let_else`] to `nursery`
[#7568](https://github.com/rust-lang/rust-clippy/pull/7568)
* Move [`branches_sharing_code`] to `nursery`
[#7595](https://github.com/rust-lang/rust-clippy/pull/7595)
* Rename `if_let_some_result` to [`match_result_ok`] which now also handles
`while let` cases [#7608](https://github.com/rust-lang/rust-clippy/pull/7608)
* Move [`many_single_char_names`] to `pedantic`
[#7671](https://github.com/rust-lang/rust-clippy/pull/7671)
* Move [`float_cmp`] to `pedantic`
[#7692](https://github.com/rust-lang/rust-clippy/pull/7692)
* Rename `box_vec` to [`box_collection`] and lint on more general cases
[#7693](https://github.com/rust-lang/rust-clippy/pull/7693)
* Uplift `invalid_atomic_ordering` to rustc
[rust-lang/rust#84039](https://github.com/rust-lang/rust/pull/84039)

### Enhancements

* Rewrite the `shadow*` lints, so that they find a lot more shadows and are not
limited to certain patterns
[#7338](https://github.com/rust-lang/rust-clippy/pull/7338)
* The `avoid-breaking-exported-api` configuration now also works for
[`box_collection`], [`redundant_allocation`], [`rc_buffer`], [`vec_box`],
[`option_option`], [`linkedlist`], [`rc_mutex`]
[#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
lint message
[#7621](https://github.com/rust-lang/rust-clippy/pull/7621)
* [`approx_constant`]: Now checks the MSRV for `LOG10_2` and `LOG2_10`
[#7629](https://github.com/rust-lang/rust-clippy/pull/7629)
* [`approx_constant`]: Add `TAU`
[#7642](https://github.com/rust-lang/rust-clippy/pull/7642)
* [`needless_borrow`]: Now also lints on needless mutable borrows
[#7657](https://github.com/rust-lang/rust-clippy/pull/7657)
* [`missing_safety_doc`]: Now also lints on unsafe traits
[#7734](https://github.com/rust-lang/rust-clippy/pull/7734)

### False Positive Fixes

* [`manual_map`]: No longer lints when the option is borrowed in the match and
also consumed in the arm
[#7531](https://github.com/rust-lang/rust-clippy/pull/7531)
* [`filter_next`]: No longer lints if `filter` method is not the
`Iterator::filter` method
[#7562](https://github.com/rust-lang/rust-clippy/pull/7562)
* [`manual_flatten`]: No longer lints if expression is used after `if let`
[#7566](https://github.com/rust-lang/rust-clippy/pull/7566)
* [`option_if_let_else`]: Multiple fixes
[#7573](https://github.com/rust-lang/rust-clippy/pull/7573)
* `break` and `continue` statements local to the would-be closure are
allowed
* Don't lint in const contexts
* Don't lint when yield expressions are used
* Don't lint when the captures made by the would-be closure conflict with
the other branch
* Don't lint when a field of a local is used when the type could be
potentially moved from
* In some cases, don't lint when scrutinee expression conflicts with the
captures of the would-be closure
* [`redundant_allocation`]: No longer lints on `Box<Box<dyn T>>` which replaces
wide pointers with thin pointers
[#7592](https://github.com/rust-lang/rust-clippy/pull/7592)
* [`bool_assert_comparison`]: No longer lints on types that do not implement the
`Not` trait with `Output = bool`
[#7605](https://github.com/rust-lang/rust-clippy/pull/7605)
* [`mut_range_bound`]: No longer lints on range bound mutations, that are
immediately followed by a `break;`
[#7607](https://github.com/rust-lang/rust-clippy/pull/7607)
* [`mutable_key_type`]: Improve accuracy and document remaining false positives
and false negatives
[#7640](https://github.com/rust-lang/rust-clippy/pull/7640)
* [`redundant_closure`]: Rewrite the lint to fix various false positives and
false negatives [#7661](https://github.com/rust-lang/rust-clippy/pull/7661)
* [`large_enum_variant`]: No longer wrongly identifies the second largest
variant [#7677](https://github.com/rust-lang/rust-clippy/pull/7677)
* [`needless_return`]: No longer lints on let-else expressions
[#7685](https://github.com/rust-lang/rust-clippy/pull/7685)
* [`suspicious_else_formatting`]: No longer lints in proc-macros
[#7707](https://github.com/rust-lang/rust-clippy/pull/7707)
* [`excessive_precision`]: No longer lints when in some cases the float was
already written in the shortest form
[#7722](https://github.com/rust-lang/rust-clippy/pull/7722)
* [`doc_markdown`]: No longer lints on intra-doc links
[#7772](https://github.com/rust-lang/rust-clippy/pull/7772)

### Suggestion Fixes/Improvements

* [`unnecessary_operation`]: Recommend using an `assert!` instead of using a
function call in an indexing operation
[#7453](https://github.com/rust-lang/rust-clippy/pull/7453)
* [`manual_split_once`]: Produce semantically equivalent suggestion when
`rsplitn` is used [#7663](https://github.com/rust-lang/rust-clippy/pull/7663)
* [`while_let_on_iterator`]: Produce correct suggestion when using `&mut`
[#7690](https://github.com/rust-lang/rust-clippy/pull/7690)
* [`manual_assert`]: No better handles complex conditions
[#7741](https://github.com/rust-lang/rust-clippy/pull/7741)
* Correctly handle signs in exponents in numeric literals lints
[#7747](https://github.com/rust-lang/rust-clippy/pull/7747)
* [`suspicious_map`]: Now also suggests to use `inspect` as an alternative
[#7770](https://github.com/rust-lang/rust-clippy/pull/7770)
* Drop exponent from suggestion if it is 0 in numeric literals lints
[#7774](https://github.com/rust-lang/rust-clippy/pull/7774)

### ICE Fixes

* [`implicit_hasher`]
[#7761](https://github.com/rust-lang/rust-clippy/pull/7761)

### Others

* Clippy now uses the 2021
[Edition!](https://www.youtube.com/watch?v=q0aNduqb2Ro)
[#7664](https://github.com/rust-lang/rust-clippy/pull/7664)

## Rust 1.56

Current beta, release 2021-10-21
Current stable, released 2021-10-21

[74d1561...7bfc26e](https://github.com/rust-lang/rust-clippy/compare/74d1561...7bfc26e)

Expand Down Expand Up @@ -74,13 +225,9 @@ Current beta, release 2021-10-21
* [`unnested_or_patterns`]: Removed `or_patterns` feature gate in the code
example [#7507](https://github.com/rust-lang/rust-clippy/pull/7507)

### New Lints

* Renamed Lint: `if_let_some_result` is now called [`match_result_ok`]. Now also handles `while let` case.

## Rust 1.55

Current stable, released 2021-09-09
Released 2021-09-09

[3ae8faf...74d1561](https://github.com/rust-lang/rust-clippy/compare/3ae8faf...74d1561)

Expand Down Expand Up @@ -2748,7 +2895,6 @@ Released 2018-09-13
[`if_let_redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_let_redundant_pattern_matching
[`if_not_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else
[`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
[`if_then_panic`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
[`if_then_some_else_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
[`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone
Expand Down Expand Up @@ -2806,6 +2952,7 @@ Released 2018-09-13
[`lossy_float_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#lossy_float_literal
[`macro_use_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#macro_use_imports
[`main_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#main_recursion
[`manual_assert`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_assert
[`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn
[`manual_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter_map
[`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map
Expand Down Expand Up @@ -2976,6 +3123,7 @@ Released 2018-09-13
[`self_named_constructors`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_named_constructors
[`self_named_module_files`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_named_module_files
[`semicolon_if_nothing_returned`]: https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
[`separated_literal_suffix`]: https://rust-lang.github.io/rust-clippy/master/index.html#separated_literal_suffix
[`serde_api_misuse`]: https://rust-lang.github.io/rust-clippy/master/index.html#serde_api_misuse
[`shadow_reuse`]: https://rust-lang.github.io/rust-clippy/master/index.html#shadow_reuse
[`shadow_same`]: https://rust-lang.github.io/rust-clippy/master/index.html#shadow_same
Expand All @@ -3000,6 +3148,7 @@ Released 2018-09-13
[`string_extend_chars`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_extend_chars
[`string_from_utf8_as_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_from_utf8_as_bytes
[`string_lit_as_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_lit_as_bytes
[`string_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_slice
[`string_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_to_string
[`strlen_on_c_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#strlen_on_c_strings
[`struct_excessive_bools`]: https://rust-lang.github.io/rust-clippy/master/index.html#struct_excessive_bools
Expand Down Expand Up @@ -3046,6 +3195,7 @@ Released 2018-09-13
[`uninit_vec`]: https://rust-lang.github.io/rust-clippy/master/index.html#uninit_vec
[`unit_arg`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
[`unit_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_cmp
[`unit_hash`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_hash
[`unit_return_expecting_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_return_expecting_ord
[`unnecessary_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
[`unnecessary_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_filter_map
Expand Down
4 changes: 3 additions & 1 deletion src/tools/clippy/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ to be run inside the `rust` directory):
2. Checkout the commit from the latest available nightly. You can get it using `rustup check`.
3. Sync the changes to the rust-copy of Clippy to your Clippy fork:
```bash
# Make sure to change `your-github-name` to your github name in the following command
# Make sure to change `your-github-name` to your github name in the following command. Also be
# sure to either use a net-new branch, e.g. `sync-from-rust`, or delete the branch beforehand
# because changes cannot be fast forwarded
git subtree push -P src/tools/clippy [email protected]:your-github-name/rust-clippy sync-from-rust
```

Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tempfile = { version = "3.2", optional = true }

[dev-dependencies]
cargo_metadata = "0.14"
compiletest_rs = { version = "0.7", features = ["tmp"] }
compiletest_rs = { version = "0.7.1", features = ["tmp"] }
tester = "0.9"
regex = "1.5"
# This is used by the `collect-metadata` alias.
Expand Down
40 changes: 29 additions & 11 deletions src/tools/clippy/clippy_dev/src/new_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ pub fn create(pass: Option<&str>, lint_name: Option<&str>, category: Option<&str
};

create_lint(&lint, msrv).context("Unable to create lint implementation")?;
create_test(&lint).context("Unable to create a test for the new lint")
create_test(&lint).context("Unable to create a test for the new lint")?;
add_lint(&lint, msrv).context("Unable to add lint to clippy_lints/src/lib.rs")
}

fn create_lint(lint: &LintData<'_>, enable_msrv: bool) -> io::Result<()> {
Expand Down Expand Up @@ -80,6 +81,33 @@ fn create_test(lint: &LintData<'_>) -> io::Result<()> {
}
}

fn add_lint(lint: &LintData<'_>, enable_msrv: bool) -> io::Result<()> {
let path = "clippy_lints/src/lib.rs";
let mut lib_rs = fs::read_to_string(path).context("reading")?;

let comment_start = lib_rs.find("// add lints here,").expect("Couldn't find comment");

let new_lint = if enable_msrv {
format!(
"store.register_{lint_pass}_pass(move || Box::new({module_name}::{camel_name}::new(msrv)));\n ",
lint_pass = lint.pass,
module_name = lint.name,
camel_name = to_camel_case(lint.name),
)
} else {
format!(
"store.register_{lint_pass}_pass(|| Box::new({module_name}::{camel_name}));\n ",
lint_pass = lint.pass,
module_name = lint.name,
camel_name = to_camel_case(lint.name),
)
};

lib_rs.insert_str(comment_start, &new_lint);

fs::write(path, lib_rs).context("writing")
}

fn write_file<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> {
fn inner(path: &Path, contents: &[u8]) -> io::Result<()> {
OpenOptions::new()
Expand Down Expand Up @@ -151,7 +179,6 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
};

let lint_name = lint.name;
let pass_name = lint.pass;
let category = lint.category;
let name_camel = to_camel_case(lint.name);
let name_upper = lint_name.to_uppercase();
Expand Down Expand Up @@ -228,18 +255,14 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
extract_msrv_attr!({context_import});
}}

// TODO: Register the lint pass in `clippy_lints/src/lib.rs`,
// e.g. store.register_{pass_name}_pass(move || Box::new({module_name}::{name_camel}::new(msrv)));
// TODO: Add MSRV level to `clippy_utils/src/msrvs.rs` if needed.
// TODO: Add MSRV test to `tests/ui/min_rust_version_attr.rs`.
// TODO: Update msrv config comment in `clippy_lints/src/utils/conf.rs`
"},
pass_type = pass_type,
pass_lifetimes = pass_lifetimes,
pass_name = pass_name,
name_upper = name_upper,
name_camel = name_camel,
module_name = lint_name,
context_import = context_import,
)
} else {
Expand All @@ -248,16 +271,11 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
declare_lint_pass!({name_camel} => [{name_upper}]);

impl {pass_type}{pass_lifetimes} for {name_camel} {{}}
//
// TODO: Register the lint pass in `clippy_lints/src/lib.rs`,
// e.g. store.register_{pass_name}_pass(|| Box::new({module_name}::{name_camel}));
"},
pass_type = pass_type,
pass_lifetimes = pass_lifetimes,
pass_name = pass_name,
name_upper = name_upper,
name_camel = name_camel,
module_name = lint_name,
)
});

Expand Down
Loading