Skip to content

Update Clippy #108474

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

Merged
merged 139 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
c6692a8
Add configuration to lint missing docs of `pub(crate)` items
pvdrz Feb 6, 2023
8eac9e3
bless tests
pvdrz Feb 6, 2023
374c393
Introduce `-Zterminal-urls` to use OSC8 for error codes
estebank Feb 9, 2023
e2e23c0
Add docs and update tests
pvdrz Feb 9, 2023
cc19fbe
update metadata
pvdrz Feb 9, 2023
179c037
improve almost swap to look for let statement
DevAccentor Jun 4, 2022
e7fe1f9
Merge commit '0f7558148c22e53cd4608773b56cdfa50dcdeac3' into clippyup
flip1995 Feb 10, 2023
cd3bcbb
add `AliasEq` to `PredicateKind`
BoxyUwU Feb 10, 2023
145e6a9
Add suspicious_command_arg_space lint.
m-ou-se Feb 10, 2023
5fefe8b
Add test.
m-ou-se Feb 10, 2023
984c47b
Clarify description of suspicious_command_arg_space.
m-ou-se Feb 10, 2023
8f56767
Update lints.
m-ou-se Feb 10, 2023
078f149
[significant_drop_tightening] Add MVP
c410-f3r Feb 10, 2023
805a0ae
Add more test cases for suspicious_command_arg_space.
m-ou-se Feb 10, 2023
863e96d
Auto merge of #107507 - BoxyUwU:deferred_projection_equality, r=lcnr
bors Feb 11, 2023
8789b37
Fix false positives for `extra_unused_type_parameters`
mkrasnitski Feb 11, 2023
d9dc167
cast_possible_truncation: issue proper help message
samueltardieu Feb 12, 2023
aeaa1cc
lintcheck: fix clap panic
samueltardieu Feb 12, 2023
d880cae
Auto merge of #10330 - samueltardieu:10325, r=xFrednet
bors Feb 12, 2023
21433ab
book: move warning to the right place
samueltardieu Feb 12, 2023
ad2135e
Auto merge of #10333 - samueltardieu:lintcheck-clap-panic, r=flip1995
bors Feb 12, 2023
09d3097
manual_let_else: do not suggest semantically different replacements
samueltardieu Feb 12, 2023
1b286b1
Address comments
c410-f3r Feb 12, 2023
e70a7a6
[arithmetic_side_effects] Evaluate integers originated from constant …
c410-f3r Feb 9, 2023
1ed8ed3
Address comment
c410-f3r Feb 12, 2023
6f353fd
Auto merge of #10310 - c410-f3r:arith-2, r=Alexendoo
bors Feb 12, 2023
1f77866
Add SUSPICIOUS_COMMAND_ARG_SPACE to lint pass.
m-ou-se Feb 12, 2023
298f139
Auto merge of #10317 - m-ou-se:suspicious-command-arg-space, r=Manish…
bors Feb 12, 2023
ebca1b5
Refactor `almost_swapped` to lint with `let` statement correctly
chansuke Jan 8, 2023
e8e9c32
Alias folding/visiting traits instead of re-export
eggyal Feb 9, 2023
340d9e8
Make visiting traits generic over the Interner
eggyal Feb 9, 2023
b3077fb
Rollup merge of #107838 - estebank:terminal_hyperlinks, r=nagisa
matthiaskrgr Feb 13, 2023
ac60dca
Auto merge of #10177 - chansuke:almost_swapped, r=Alexendoo
bors Feb 13, 2023
42d4bd7
Auto merge of #107924 - eggyal:move_fold_visit_traits_to_type_lib_wit…
bors Feb 13, 2023
63562a6
Auto merge of #10334 - samueltardieu:book-warning-text, r=Manishearth
bors Feb 13, 2023
4b8f112
Use is_str instead of string kind comparison
compiler-errors Feb 13, 2023
89314a0
Add question-mark-used lint
mitsuhiko Feb 13, 2023
c231b41
Remove useless call to combine_seq
samueltardieu Feb 9, 2023
1fec292
Replace combine_both by combine_seq
samueltardieu Feb 13, 2023
8e96ade
fix [`needless_return`] incorrect suggestion when returning if sequence
J-ZhengLi Feb 14, 2023
e9dffa3
Fix a bug in never_loop when anonymous blocks are nested in named blocks
samueltardieu Feb 14, 2023
e3a739a
s/eval_usize/eval_target_usize/ for clarity
oli-obk Feb 14, 2023
657ee48
Ignore instructions following a break from block in never_loop lint
samueltardieu Feb 13, 2023
e4e5924
Do not base map_entry lint suggestion on expanded code
samueltardieu Feb 14, 2023
b8c3642
Rollup merge of #108007 - compiler-errors:str-less-kind, r=Nilstrieb
matthiaskrgr Feb 14, 2023
a182a67
Auto merge of #10311 - samueltardieu:issue-10304, r=Jarcho
bors Feb 14, 2023
e41c373
Add `of_trait` to DefKind::Impl.
cjgillot Feb 12, 2023
5a8b288
Auto merge of #108056 - matthiaskrgr:rollup-oa6bxvh, r=matthiaskrgr
bors Feb 14, 2023
0e40f94
Auto merge of #10346 - samueltardieu:issue-10331, r=Manishearth
bors Feb 14, 2023
17cb2e4
Liberate late-bound regions rather than erasing them in needless_pass…
compiler-errors Feb 12, 2023
7f15a11
manual_let_else: let/else is not divergent by default
samueltardieu Feb 12, 2023
4c28fdd
Auto merge of #10332 - samueltardieu:issue-10296, r=Alexendoo
bors Feb 14, 2023
8b93eb8
add some adjustment regarding review suggestion
J-ZhengLi Feb 15, 2023
e018a2c
Auto merge of #10328 - compiler-errors:fix-re-erased-in-needless_pass…
bors Feb 15, 2023
75aa2b9
uninlined_format_args: do not inline argument with generic parameters
samueltardieu Feb 13, 2023
cecc45c
Use target instead of machine for mir interpreter integer handling.
oli-obk Feb 14, 2023
d3d235d
Auto merge of #10345 - J-ZhengLi:issue_10049, r=xFrednet
bors Feb 15, 2023
8754d5a
Auto merge of #10343 - samueltardieu:issue-10339, r=Alexendoo
bors Feb 15, 2023
595f783
Auto merge of #10321 - mkrasnitski:false-positives, r=flip1995
bors Feb 15, 2023
1ee4651
Ignore synthetic type parameters for `extra_unused_type_parameters`
mkrasnitski Feb 12, 2023
5b6795f
Auto merge of #10338 - mkrasnitski:synthetic-params, r=flip1995
bors Feb 15, 2023
30f38d6
Auto merge of #108006 - cjgillot:def-impl, r=oli-obk
bors Feb 15, 2023
8ec9543
Add `impl_trait_param` lint
blyxyas Jan 9, 2023
dd6534a
Rollup merge of #108047 - oli-obk:machine->🞋, r=RalfJung
matthiaskrgr Feb 15, 2023
ade4c9b
Rename lint to better fit lint naming conventions
blyxyas Jan 13, 2023
6c9983b
Exec `cargo dev update_lints`
blyxyas Jan 13, 2023
bdf4fd3
Tests pass
blyxyas Jan 13, 2023
8a2245d
Change lint's from `style` to `restriction`
blyxyas Jan 13, 2023
6aa06b7
Remove `#[allow]`s. Apply conversations from @Jarcho
blyxyas Jan 19, 2023
4166b7d
Fix lint message
blyxyas Jan 25, 2023
6ef34bf
Remove commented code
blyxyas Feb 3, 2023
27a4768
Rename some region-specific stuff
compiler-errors Feb 6, 2023
f12b492
Change unusual_byte_groupings to require byte groupings of equal size
nindalf Feb 16, 2023
86fb33a
Auto merge of #10353 - nindalf:master, r=llogiq
bors Feb 16, 2023
2d4d39d
Add the `let_underscore_untyped` lint
JirkaVebr Feb 16, 2023
0933798
Added check for local spans
mitsuhiko Feb 16, 2023
0b1ae20
Fix dogfood tests by adding type annotations
JirkaVebr Feb 16, 2023
4369a67
Auto merge of #10163 - c410-f3r:lock-1, r=llogiq
bors Feb 16, 2023
99d4ea4
Auto merge of #10356 - JirkaVebr:let_underscore_untyped, r=llogiq
bors Feb 16, 2023
52c8b53
Auto merge of #10342 - mitsuhiko:feature/question-mark-used, r=Alexendoo
bors Feb 16, 2023
9c9dbc2
Fix DOC_MARKDOWN requiring backticks on links to external websites
nindalf Feb 16, 2023
6d0df84
Add the `transmute_int_to_non_zero` lint
JirkaVebr Feb 16, 2023
dfe23dc
Auto merge of #10360 - JirkaVebr:transmute_integer_to_non_zero_wrappe…
bors Feb 16, 2023
64b8aaf
remove empty file
pvdrz Feb 16, 2023
7e53e27
Stop bytes_nth from suggesting code that does not compile
nindalf Feb 16, 2023
be74773
Auto merge of #10357 - nindalf:doc_markdown_relax, r=llogiq
bors Feb 16, 2023
eac0bd9
Auto merge of #10361 - nindalf:nth_bytes_copy, r=llogiq
bors Feb 16, 2023
6444621
Auto merge of #10336 - samueltardieu:issue-10241, r=llogiq
bors Feb 16, 2023
747f81e
[significant_drop_tightening] Ignore inexpensive statements
c410-f3r Feb 16, 2023
cc60e21
Rollup merge of #107489 - compiler-errors:non_lifetime_binders, r=cjg…
matthiaskrgr Feb 16, 2023
f0565c9
change usages of type_of to bound_type_of
kylematsuda Feb 7, 2023
98c4a49
remove bound_type_of query; make type_of return EarlyBinder; change t…
kylematsuda Feb 7, 2023
9554045
Auto merge of #107753 - kylematsuda:type-of, r=BoxyUwU
bors Feb 17, 2023
8a66a68
Add `Clause::ConstArgHasType` variant
BoxyUwU Feb 16, 2023
ae12b72
Replace `mk_foo` calls with `infer_foo` where possible.
nnethercote Feb 16, 2023
a3837c6
Replace more `mk_foo` calls with `infer_foo`.
nnethercote Feb 16, 2023
c29e767
Address review comments
pvdrz Feb 17, 2023
c0373f5
Auto merge of #108112 - nnethercote:clarify-iterator-interners, r=oli…
bors Feb 18, 2023
e1da002
Auto merge of #10363 - c410-f3r:lock-1, r=xFrednet
bors Feb 18, 2023
7518969
Evaluate the return expression of a block
c410-f3r Feb 18, 2023
85d4b5a
Auto merge of #10368 - c410-f3r:lock-1, r=xFrednet
bors Feb 18, 2023
89fde4a
Add placeholders, remove name suggesting
blyxyas Feb 18, 2023
0905838
Ignore lifetimes from differing contexts in `needless_lifetimes`
Alexendoo Feb 20, 2023
92c403c
Box::default(): do not omit the type of the removed trait object
samueltardieu Feb 19, 2023
574c8ae
Auto merge of #10382 - samueltardieu:issue-10381, r=llogiq
bors Feb 20, 2023
790f28b
Update documentation
pvdrz Feb 20, 2023
b1cf1e7
Auto merge of #10303 - pvdrz:pub_crate_missing_docs, r=giraffate
bors Feb 20, 2023
71b8646
Use `ThinVec` in various AST types.
nnethercote Nov 23, 2022
5ef3cc8
Auto merge of #10197 - blyxyas:impl_trait_param, r=Jarcho
bors Feb 21, 2023
803ce88
Auto merge of #10380 - Alexendoo:needless-lifetime-macro-expansion, r…
bors Feb 21, 2023
0aad34e
Normalize projections types when checking `explicit_auto_deref`
Jarcho Feb 21, 2023
5166882
Auto merge of #10386 - Jarcho:issue_10384, r=Manishearth
bors Feb 21, 2023
bf7c209
Update readme description of `restriction` lints to dissuade casual use.
Jarcho Feb 21, 2023
aa0e543
errors: generate typed identifiers in each crate
davidtwco Oct 13, 2022
ab69a2a
various: translation resources from cg backend
davidtwco Oct 17, 2022
8d08917
Auto merge of #10385 - Jarcho:readme_restriction, r=xFrednet
bors Feb 22, 2023
72e773f
Fix test function checker in [unwrap_used], [expect_used]
ldm0 Feb 22, 2023
b9c617a
correct comments
ldm0 Feb 22, 2023
1a474d9
Recover tests
ldm0 Feb 22, 2023
a5acb92
fix fmt
ldm0 Feb 22, 2023
79a9024
bless
ldm0 Feb 22, 2023
d254516
clippy: update clippy to use new `TyCtxt::def_descr`
notriddle Feb 21, 2023
430c4ab
Remove type-traversal trait aliases
eggyal Feb 22, 2023
95cd528
Auto merge of #108340 - eggyal:remove_traversal_trait_aliases, r=oli-obk
bors Feb 22, 2023
daa94d2
Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, r=compil…
bors Feb 23, 2023
528bb63
Fix more false positives for `extra_unused_type_parameters`
mkrasnitski Feb 22, 2023
f9adb83
Auto merge of #10392 - mkrasnitski:false-positives, r=Jarcho
bors Feb 23, 2023
00c294a
Add new lint no_mangle_with_rust_abi
nindalf Feb 18, 2023
659112c
Auto merge of #10369 - nindalf:no_mangle_lint, r=llogiq
bors Feb 23, 2023
84ceca8
run cargo collect-metadata
ldm0 Feb 23, 2023
b528cc9
Auto merge of #10391 - ldm0:ldm0_fix_unwrap_in_tests, r=xFrednet
bors Feb 24, 2023
bc184e9
Merge branch 'master' into rustup
Jarcho Feb 25, 2023
5552f4a
Bump nightly version -> 2023-02-25
Jarcho Feb 25, 2023
64775f3
Do not panic when analyzing the malformed origin of a format string
samueltardieu Feb 25, 2023
5155119
Auto merge of #10401 - samueltardieu:issue-10148, r=Alexendoo
bors Feb 25, 2023
e825adf
Fix normalization of `custom_ice_message` test.
Jarcho Feb 25, 2023
69c4ff6
Emit `unnecessary_def_path` in source order.
Jarcho Feb 25, 2023
149392b
Auto merge of #10402 - Jarcho:rustup, r=Jarcho
bors Feb 25, 2023
4a2de63
Merge commit '149392b0baa4730c68f3c3eadf5c6ed7b16b85a4' into clippyup
Jarcho Feb 26, 2023
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
7 changes: 7 additions & 0 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4430,6 +4430,7 @@ Released 2018-09-13
[`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
[`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
[`impl_trait_in_params`]: https://rust-lang.github.io/rust-clippy/master/index.html#impl_trait_in_params
[`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone
[`implicit_hasher`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_hasher
[`implicit_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_return
Expand Down Expand Up @@ -4494,6 +4495,7 @@ Released 2018-09-13
[`let_underscore_future`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_future
[`let_underscore_lock`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_lock
[`let_underscore_must_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_must_use
[`let_underscore_untyped`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_untyped
[`let_unit_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
[`linkedlist`]: https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist
[`logic_bug`]: https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug
Expand Down Expand Up @@ -4620,6 +4622,7 @@ Released 2018-09-13
[`no_effect`]: https://rust-lang.github.io/rust-clippy/master/index.html#no_effect
[`no_effect_replace`]: https://rust-lang.github.io/rust-clippy/master/index.html#no_effect_replace
[`no_effect_underscore_binding`]: https://rust-lang.github.io/rust-clippy/master/index.html#no_effect_underscore_binding
[`no_mangle_with_rust_abi`]: https://rust-lang.github.io/rust-clippy/master/index.html#no_mangle_with_rust_abi
[`non_ascii_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#non_ascii_literal
[`non_octal_unix_permissions`]: https://rust-lang.github.io/rust-clippy/master/index.html#non_octal_unix_permissions
[`non_send_fields_in_send_ty`]: https://rust-lang.github.io/rust-clippy/master/index.html#non_send_fields_in_send_ty
Expand Down Expand Up @@ -4675,6 +4678,7 @@ Released 2018-09-13
[`pub_enum_variant_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_enum_variant_names
[`pub_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_use
[`question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
[`question_mark_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#question_mark_used
[`range_minus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_minus_one
[`range_plus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_plus_one
[`range_step_by_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_step_by_zero
Expand Down Expand Up @@ -4734,6 +4738,7 @@ Released 2018-09-13
[`should_assert_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#should_assert_eq
[`should_implement_trait`]: https://rust-lang.github.io/rust-clippy/master/index.html#should_implement_trait
[`significant_drop_in_scrutinee`]: https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_in_scrutinee
[`significant_drop_tightening`]: https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_tightening
[`similar_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#similar_names
[`single_char_add_str`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str
[`single_char_lifetime_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_char_lifetime_names
Expand Down Expand Up @@ -4764,6 +4769,7 @@ Released 2018-09-13
[`suboptimal_flops`]: https://rust-lang.github.io/rust-clippy/master/index.html#suboptimal_flops
[`suspicious_arithmetic_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_arithmetic_impl
[`suspicious_assignment_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_assignment_formatting
[`suspicious_command_arg_space`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_command_arg_space
[`suspicious_else_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_else_formatting
[`suspicious_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_map
[`suspicious_op_assign_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_op_assign_impl
Expand All @@ -4790,6 +4796,7 @@ Released 2018-09-13
[`transmute_int_to_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_int_to_bool
[`transmute_int_to_char`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_int_to_char
[`transmute_int_to_float`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_int_to_float
[`transmute_int_to_non_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_int_to_non_zero
[`transmute_null_to_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_null_to_fn
[`transmute_num_to_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_num_to_bytes
[`transmute_ptr_to_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ptr
Expand Down
39 changes: 28 additions & 11 deletions src/tools/clippy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,35 @@ You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the
| `clippy::complexity` | code that does something simple but in a complex way | **warn** |
| `clippy::perf` | code that can be written to run faster | **warn** |
| `clippy::pedantic` | lints which are rather strict or have occasional false positives | allow |
| `clippy::restriction` | lints which prevent the use of language and library features[^restrict] | allow |
| `clippy::nursery` | new lints that are still under development | allow |
| `clippy::cargo` | lints for the cargo manifest | allow |

More to come, please [file an issue](https://github.com/rust-lang/rust-clippy/issues) if you have ideas!

The [lint list](https://rust-lang.github.io/rust-clippy/master/index.html) also contains "restriction lints", which are
for things which are usually not considered "bad", but may be useful to turn on in specific cases. These should be used
very selectively, if at all.
The `restriction` category should, *emphatically*, not be enabled as a whole. The contained
lints may lint against perfectly reasonable code, may not have an alternative suggestion,
and may contradict any other lints (including other categories). Lints should be considered
on a case-by-case basis before enabling.

[^restrict]: Some use cases for `restriction` lints include:
- Strict coding styles (e.g. [`clippy::else_if_without_else`]).
- Additional restrictions on CI (e.g. [`clippy::todo`]).
- Preventing panicking in certain functions (e.g. [`clippy::unwrap_used`]).
- Running a lint only on a subset of code (e.g. `#[forbid(clippy::float_arithmetic)]` on a module).

[`clippy::else_if_without_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#else_if_without_else
[`clippy::todo`]: https://rust-lang.github.io/rust-clippy/master/index.html#todo
[`clippy::unwrap_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used

---

Table of contents:

* [Usage instructions](#usage)
* [Configuration](#configuration)
* [Contributing](#contributing)
* [License](#license)
* [Usage instructions](#usage)
* [Configuration](#configuration)
* [Contributing](#contributing)
* [License](#license)

## Usage

Expand Down Expand Up @@ -64,6 +78,7 @@ Once you have rustup and the latest stable release (at least Rust 1.29) installe
```terminal
rustup component add clippy
```

If it says that it can't find the `clippy` component, please run `rustup self update`.

#### Step 3: Run Clippy
Expand Down Expand Up @@ -143,16 +158,16 @@ line. (You can swap `clippy::all` with the specific lint category you are target

You can add options to your code to `allow`/`warn`/`deny` Clippy lints:

* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy::all)]`).
* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy::all)]`).
Note that `rustc` has additional [lint groups](https://doc.rust-lang.org/rustc/lints/groups.html).

* all lints using both the `clippy` and `clippy::pedantic` lint groups (`#![deny(clippy::all)]`,
* all lints using both the `clippy` and `clippy::pedantic` lint groups (`#![deny(clippy::all)]`,
`#![deny(clippy::pedantic)]`). Note that `clippy::pedantic` contains some very aggressive
lints prone to false positives.

* only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc.)
* only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc.)

* `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc.
* `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc.

Note: `allow` means to suppress the lint for your code. With `warn` the lint
will only emit a warning, while with `deny` the lint will emit an error, when
Expand All @@ -176,12 +191,14 @@ cargo clippy -- -W clippy::lint_name

This also works with lint groups. For example, you
can run Clippy with warnings for all lints enabled:

```terminal
cargo clippy -- -W clippy::pedantic
```

If you care only about a single lint, you can allow all others and then explicitly warn on
the lint(s) you are interested in:

```terminal
cargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::...
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ repository. You can do this with:
```bash
# Assuming the current directory corresponds to the Rust repository
$ git checkout beta
# Make sure to change `your-github-name` to your github name in the following command
$ git subtree pull -p src/tools/clippy https://github.com/<your-github-name>/rust-clippy backport
$ ./x.py test src/tools/clippy
```
Expand Down
3 changes: 1 addition & 2 deletions src/tools/clippy/book/src/development/infrastructure/sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ to be run inside the `rust` directory):
`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. Also be
# sure to either use a net-new branch, e.g. `sync-from-rust`, or delete the branch beforehand
# 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 and you have to run this command again.
git subtree push -P src/tools/clippy clippy-local sync-from-rust
```
Expand Down
18 changes: 14 additions & 4 deletions src/tools/clippy/book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Please use that command to update the file and do not edit it by hand.
| [ignore-interior-mutability](#ignore-interior-mutability) | `["bytes::Bytes"]` |
| [allow-mixed-uninlined-format-args](#allow-mixed-uninlined-format-args) | `true` |
| [suppress-restriction-lint-in-const](#suppress-restriction-lint-in-const) | `false` |
| [missing-docs-in-crate-items](#missing-docs-in-crate-items) | `false` |

### arithmetic-side-effects-allowed
Suppress checking of the passed type names in all types of operations.
Expand Down Expand Up @@ -471,31 +472,31 @@ The maximum size of a file included via `include_bytes!()` or `include_str!()`,


### allow-expect-in-tests
Whether `expect` should be allowed within `#[cfg(test)]`
Whether `expect` should be allowed in test functions or `#[cfg(test)]`

**Default Value:** `false` (`bool`)

* [expect_used](https://rust-lang.github.io/rust-clippy/master/index.html#expect_used)


### allow-unwrap-in-tests
Whether `unwrap` should be allowed in test cfg
Whether `unwrap` should be allowed in test functions or `#[cfg(test)]`

**Default Value:** `false` (`bool`)

* [unwrap_used](https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used)


### allow-dbg-in-tests
Whether `dbg!` should be allowed in test functions
Whether `dbg!` should be allowed in test functions or `#[cfg(test)]`

**Default Value:** `false` (`bool`)

* [dbg_macro](https://rust-lang.github.io/rust-clippy/master/index.html#dbg_macro)


### allow-print-in-tests
Whether print macros (ex. `println!`) should be allowed in test functions
Whether print macros (ex. `println!`) should be allowed in test functions or `#[cfg(test)]`

**Default Value:** `false` (`bool`)

Expand Down Expand Up @@ -540,4 +541,13 @@ if no suggestion can be made.
* [indexing_slicing](https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing)


### missing-docs-in-crate-items
Whether to **only** check for missing documentation in items visible within the current
crate. For example, `pub(crate)` items.

**Default Value:** `false` (`bool`)

* [missing_docs_in_private_items](https://rust-lang.github.io/rust-clippy/master/index.html#missing_docs_in_private_items)



9 changes: 5 additions & 4 deletions src/tools/clippy/clippy_dev/src/new_lint.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::clippy_project_root;
use indoc::{formatdoc, writedoc};
use std::fmt;
use std::fmt::Write as _;
use std::fs::{self, OpenOptions};
use std::io::prelude::*;
Expand Down Expand Up @@ -256,7 +257,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
)
});

let _ = write!(result, "{}", get_lint_declaration(&name_upper, category));
let _: fmt::Result = write!(result, "{}", get_lint_declaration(&name_upper, category));

result.push_str(&if enable_msrv {
formatdoc!(
Expand Down Expand Up @@ -353,7 +354,7 @@ fn create_lint_for_ty(lint: &LintData<'_>, enable_msrv: bool, ty: &str) -> io::R
let mut lint_file_contents = String::new();

if enable_msrv {
let _ = writedoc!(
let _: fmt::Result = writedoc!(
lint_file_contents,
r#"
use clippy_utils::msrvs::{{self, Msrv}};
Expand All @@ -373,7 +374,7 @@ fn create_lint_for_ty(lint: &LintData<'_>, enable_msrv: bool, ty: &str) -> io::R
name_upper = name_upper,
);
} else {
let _ = writedoc!(
let _: fmt::Result = writedoc!(
lint_file_contents,
r#"
use rustc_lint::{{{context_import}, LintContext}};
Expand Down Expand Up @@ -521,7 +522,7 @@ fn setup_mod_file(path: &Path, lint: &LintData<'_>) -> io::Result<&'static str>
.chain(std::iter::once(&*lint_name_upper))
.filter(|s| !s.is_empty())
{
let _ = write!(new_arr_content, "\n {ident},");
let _: fmt::Result = write!(new_arr_content, "\n {ident},");
}
new_arr_content.push('\n');

Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/clippy_dev/src/update_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use itertools::Itertools;
use rustc_lexer::{tokenize, unescape, LiteralKind, TokenKind};
use std::collections::{HashMap, HashSet};
use std::ffi::OsStr;
use std::fmt::Write;
use std::fmt::{self, Write};
use std::fs::{self, OpenOptions};
use std::io::{self, Read, Seek, SeekFrom, Write as _};
use std::ops::Range;
Expand Down Expand Up @@ -691,7 +691,7 @@ fn gen_deprecated(lints: &[DeprecatedLint]) -> String {
let mut output = GENERATED_FILE_COMMENT.to_string();
output.push_str("{\n");
for lint in lints {
let _ = write!(
let _: fmt::Result = write!(
output,
concat!(
" store.register_removed(\n",
Expand Down Expand Up @@ -726,7 +726,7 @@ fn gen_declared_lints<'a>(
if !is_public {
output.push_str(" #[cfg(feature = \"internal\")]\n");
}
let _ = writeln!(output, " crate::{module_name}::{lint_name}_INFO,");
let _: fmt::Result = writeln!(output, " crate::{module_name}::{lint_name}_INFO,");
}
output.push_str("];\n");

Expand Down
3 changes: 2 additions & 1 deletion src/tools/clippy/clippy_lints/src/box_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ fn given_type(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
) => {
if let Some(index) = args.iter().position(|arg| arg.hir_id == expr.hir_id) &&
let Some(sig) = expr_sig(cx, path) &&
let Some(input) = sig.input(index)
let Some(input) = sig.input(index) &&
!cx.typeck_results().expr_ty_adjusted(expr).boxed_ty().is_trait()
{
input.no_bound_vars().is_some()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub(super) fn check(
let suggestion = format!("{cast_to_snip}::try_from({name_of_cast_from})");

span_lint_and_then(cx, CAST_POSSIBLE_TRUNCATION, expr.span, &msg, |diag| {
diag.help("if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...");
diag.help("if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...");
diag.span_suggestion_with_style(
expr.span,
"... or use `try_from` and handle the error accordingly",
Expand Down
7 changes: 7 additions & 0 deletions src/tools/clippy/clippy_lints/src/declared_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
crate::from_raw_with_void_ptr::FROM_RAW_WITH_VOID_PTR_INFO,
crate::from_str_radix_10::FROM_STR_RADIX_10_INFO,
crate::functions::DOUBLE_MUST_USE_INFO,
crate::functions::IMPL_TRAIT_IN_PARAMS_INFO,
crate::functions::MISNAMED_GETTERS_INFO,
crate::functions::MUST_USE_CANDIDATE_INFO,
crate::functions::MUST_USE_UNIT_INFO,
Expand Down Expand Up @@ -224,6 +225,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
crate::let_underscore::LET_UNDERSCORE_FUTURE_INFO,
crate::let_underscore::LET_UNDERSCORE_LOCK_INFO,
crate::let_underscore::LET_UNDERSCORE_MUST_USE_INFO,
crate::let_underscore::LET_UNDERSCORE_UNTYPED_INFO,
crate::lifetimes::EXTRA_UNUSED_LIFETIMES_INFO,
crate::lifetimes::NEEDLESS_LIFETIMES_INFO,
crate::literal_representation::DECIMAL_LITERAL_REPRESENTATION_INFO,
Expand Down Expand Up @@ -378,6 +380,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
crate::methods::SKIP_WHILE_NEXT_INFO,
crate::methods::STABLE_SORT_PRIMITIVE_INFO,
crate::methods::STRING_EXTEND_CHARS_INFO,
crate::methods::SUSPICIOUS_COMMAND_ARG_SPACE_INFO,
crate::methods::SUSPICIOUS_MAP_INFO,
crate::methods::SUSPICIOUS_SPLITN_INFO,
crate::methods::SUSPICIOUS_TO_OWNED_INFO,
Expand Down Expand Up @@ -447,6 +450,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
crate::no_effect::NO_EFFECT_INFO,
crate::no_effect::NO_EFFECT_UNDERSCORE_BINDING_INFO,
crate::no_effect::UNNECESSARY_OPERATION_INFO,
crate::no_mangle_with_rust_abi::NO_MANGLE_WITH_RUST_ABI_INFO,
crate::non_copy_const::BORROW_INTERIOR_MUTABLE_CONST_INFO,
crate::non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST_INFO,
crate::non_expressive_names::JUST_UNDERSCORES_AND_DIGITS_INFO,
Expand Down Expand Up @@ -506,6 +510,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
crate::ptr_offset_with_cast::PTR_OFFSET_WITH_CAST_INFO,
crate::pub_use::PUB_USE_INFO,
crate::question_mark::QUESTION_MARK_INFO,
crate::question_mark_used::QUESTION_MARK_USED_INFO,
crate::ranges::MANUAL_RANGE_CONTAINS_INFO,
crate::ranges::RANGE_MINUS_ONE_INFO,
crate::ranges::RANGE_PLUS_ONE_INFO,
Expand Down Expand Up @@ -536,6 +541,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
crate::shadow::SHADOW_REUSE_INFO,
crate::shadow::SHADOW_SAME_INFO,
crate::shadow::SHADOW_UNRELATED_INFO,
crate::significant_drop_tightening::SIGNIFICANT_DROP_TIGHTENING_INFO,
crate::single_char_lifetime_names::SINGLE_CHAR_LIFETIME_NAMES_INFO,
crate::single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS_INFO,
crate::size_of_in_element_count::SIZE_OF_IN_ELEMENT_COUNT_INFO,
Expand Down Expand Up @@ -573,6 +579,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
crate::transmute::TRANSMUTE_INT_TO_BOOL_INFO,
crate::transmute::TRANSMUTE_INT_TO_CHAR_INFO,
crate::transmute::TRANSMUTE_INT_TO_FLOAT_INFO,
crate::transmute::TRANSMUTE_INT_TO_NON_ZERO_INFO,
crate::transmute::TRANSMUTE_NULL_TO_FN_INFO,
crate::transmute::TRANSMUTE_NUM_TO_BYTES_INFO,
crate::transmute::TRANSMUTE_PTR_TO_PTR_INFO,
Expand Down
Loading