Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
182 commits
Select commit Hold shift + click to select a range
a8d417d
rework `useless_vec` lint
y21 Mar 29, 2025
bfd73cc
Add test case for array false positive
y21 Apr 3, 2025
47e8c31
Make sure spans are from the root
y21 Jun 21, 2025
bd33a02
Get the block content from the proper context
samueltardieu Jun 7, 2025
a7162e4
Remove references to two unknown lints in config
samueltardieu Aug 2, 2025
07b04a2
Check that all configuration options reference existing lints
samueltardieu Aug 2, 2025
0170d6c
or_then_unwrap suggestion preserves macro calls
illicitonion Aug 13, 2025
4140545
`missing_inline_in_public_items`: fix lint emission source HirId
zihan0822 Aug 16, 2025
443860d
ptr_as_ptr: use correct span context for `pointer::cast` sugg
notriddle Aug 19, 2025
220249e
fix: `redundant_closure` suggests wrongly with deref overload
profetia Jun 18, 2025
f11d512
fix: `semicolon_inside_block` FP when attribute over expr is not enabled
profetia Aug 13, 2025
71b79ab
Merge commit '877967959ae8da9814df4f2614971f4d784bf53f' into clippy-s…
flip1995 Aug 22, 2025
02bc3c9
`get_diagnostic_name` in other places
ada4a Aug 19, 2025
abb8960
higher: use `get_diagnostic_name`
ada4a Aug 20, 2025
e683346
misc: destruct `args` directly
ada4a Aug 19, 2025
34f96a2
misc: pull condition into guard
ada4a Aug 19, 2025
e243f89
misc: return earlier on `name = None`
ada4a Aug 19, 2025
d32796d
non_octal_unix_permissions: `get_diagnostic_name` once
ada4a Aug 20, 2025
f0daf23
misc: reorder to have struct first, then its method
ada4a Aug 19, 2025
ff831ed
redundant_clone: partially inline `is_type_diagnostic_item`
ada4a Aug 19, 2025
40e67ab
len_zero: use `get_diagnostic_name`
ada4a Aug 19, 2025
ff5f095
misc: pull another condition into match arm
ada4a Aug 19, 2025
0a8a7f9
non_canonical_impls: save diagnostic name to a variable
ada4a Aug 20, 2025
29f19a9
misc: don't bother checking the other case
ada4a Aug 19, 2025
1be146f
entry: use `get_diagnostic_item`
ada4a Aug 20, 2025
b987e01
misc: rewrite as `if let`
ada4a Aug 19, 2025
804c9ac
misc: match in multiple steps
ada4a Aug 19, 2025
5abee43
other uses of `get_diagnostic_name`
ada4a Aug 20, 2025
f51b5af
is_default_equivalent_ctor: check for String once
ada4a Aug 20, 2025
81b4de6
is_default_equivalent_ctor: store name in a var
ada4a Aug 20, 2025
79a95ee
use `option_arg_ty`
ada4a Aug 21, 2025
575b613
use `is_type_diagnostic_item`
ada4a Aug 20, 2025
f042011
useless_conversion: store name in a var
ada4a Aug 21, 2025
d0de0ec
use `result_error_type`
ada4a Aug 21, 2025
a5745a7
use `is_path_diagnostic_item`
ada4a Aug 21, 2025
3c3dc6d
misc: don't bother checking the other branch
ada4a Aug 21, 2025
043346b
use a let-chain
ada4a Aug 20, 2025
cb3e5af
don't repeat the `ty::Adt` check
ada4a Aug 21, 2025
ea7672a
use `span_lint_and_sugg`
ada4a Aug 20, 2025
ed69835
basically `clippy::let_if_seq`
ada4a Aug 21, 2025
a50c339
replace qualified path with `use`
ada4a Aug 20, 2025
4ac5e9c
`get_diagnostic_name` in other places
ada4a Aug 19, 2025
246f9bd
higher: use `get_diagnostic_name`
ada4a Aug 20, 2025
3074396
misc: destruct `args` directly
ada4a Aug 19, 2025
5420d07
misc: pull condition into guard
ada4a Aug 19, 2025
d745829
misc: return earlier on `name = None`
ada4a Aug 19, 2025
0938652
non_octal_unix_permissions: `get_diagnostic_name` once
ada4a Aug 20, 2025
c4e905c
misc: reorder to have struct first, then its method
ada4a Aug 19, 2025
dc94cbe
redundant_clone: partially inline `is_type_diagnostic_item`
ada4a Aug 19, 2025
7473174
len_zero: use `get_diagnostic_name`
ada4a Aug 19, 2025
37b6237
misc: pull another condition into match arm
ada4a Aug 19, 2025
6cf7634
non_canonical_impls: save diagnostic name to a variable
ada4a Aug 20, 2025
58b6462
misc: don't bother checking the other case
ada4a Aug 19, 2025
8a969f7
entry: use `get_diagnostic_item`
ada4a Aug 20, 2025
5142695
misc: rewrite as `if let`
ada4a Aug 19, 2025
c987818
misc: match in multiple steps
ada4a Aug 19, 2025
ebbea34
`is_expr_identity_of_pat`: simplify using `(unordered_)over`
ada4a Aug 10, 2025
0d479c1
fix: `unnested_or_patterns` FP on structs with only shorthand field pats
ada4a Jul 25, 2025
86beecc
Better check for `assign_op_pattern` in `const` context
samueltardieu Jul 16, 2025
228f064
use `is_{type,path}_diagnostic_item` in more places (#15527)
samueltardieu Aug 22, 2025
008b8a5
Add 1.89 beta-accepted changes to changelog
flip1995 Aug 22, 2025
b43e625
Better check for `assign_op_pattern` in `const` context (#15532)
flip1995 Aug 22, 2025
12a4f4d
Add 1.89 beta-accepted changes to changelog (#15534)
samueltardieu Aug 22, 2025
ae97d31
`is_expr_identity_of_pat`: simplify using `(unordered_)over` (#15450)
samueltardieu Aug 22, 2025
7997f33
`try_err`: clean-up (#15526)
samueltardieu Aug 22, 2025
8a8caeb
ptr_as_ptr: fix incorrect suggestion with `pointer::cast` and macros …
samueltardieu Aug 22, 2025
9e3360f
Stabilize `round_char_boundary` feature
okaneco Aug 22, 2025
450e25b
fix: `derivable_impls` suggests wrongly on `derive_const`
profetia Aug 22, 2025
f64fbe1
fix: also get `ty_sugg` in the `matches!` case
ada4a Aug 15, 2025
4bb6a0e
fix `manual_is_ascii_check`: also add explicit type when linting `mat…
samueltardieu Aug 22, 2025
7697b61
bool_comparison: use correct span context for `>`/`<` sugg
notriddle Aug 19, 2025
df0499a
bool_comparison: fix incorrect suggestion with `>`/`<` and macros (#1…
samueltardieu Aug 22, 2025
c2c3e09
fix: don't check for `!x = y`/`x = !y`
ada4a Aug 15, 2025
3a3d3e4
`bool_comparison`: no longer lint on `!x != y` (#15498)
samueltardieu Aug 22, 2025
f0563ad
extract `bool_comparison` to a separate file
ada4a Aug 15, 2025
eb00908
fix: `derivable_impls` FN when enum is qualified with `Self`
profetia Aug 22, 2025
e01cf9b
Apply `derivable_impls` to Clippy itself
profetia Aug 22, 2025
55286e7
Fix `derivable_impls` suggests wrongly on `derive_const` (#15535)
samueltardieu Aug 22, 2025
f794588
Activate `range-diff` feature of triagebot
samueltardieu Aug 22, 2025
5ce5b89
extract `bool_comparison` to a separate file (#15499)
samueltardieu Aug 23, 2025
0c24079
Remove profile section from Clippy
Kobzol Aug 23, 2025
2c28135
Use `.cargo/config.toml` for local compilation options
samueltardieu Aug 23, 2025
b7d76e2
Use `.cargo/config.toml` for local compilation options (#15543)
flip1995 Aug 23, 2025
8a98865
Detect infinite loop in `async fn` not returning `!`
samueltardieu Aug 23, 2025
d32e563
Check that no profile is present in `Cargo.toml` files
samueltardieu Aug 23, 2025
7d43319
Check that no profile is present in `Cargo.toml` files (#15544)
flip1995 Aug 23, 2025
36ef395
Detect infinite loop in `async fn` not returning `!` (#15545)
dswij Aug 23, 2025
ac3492a
simplify `too_many_args`
ada4a Aug 11, 2025
85622ca
simplify `too_many_args` (#15462)
samueltardieu Aug 23, 2025
7dd11b8
Check config options in test suite (#15397)
flip1995 Aug 23, 2025
cf3f61c
`entry`: link to `Entry` API if can't make a suggestion
ada4a Aug 9, 2025
9e1c9eb
`entry`: link to `Entry` API if can't make a suggestion (#15546)
samueltardieu Aug 23, 2025
0744c88
Activate `range-diff` feature of triagebot (#15538)
flip1995 Aug 23, 2025
35fb26f
`get_diagnostic_item` in a bunch more places (#15519)
samueltardieu Aug 23, 2025
65bac18
clean-up `transmute_int_to_non_zero` (#15521)
samueltardieu Aug 23, 2025
4d8b1ae
Adjust clippy lints for rustc `integer_to_ptr_transmutes` lint
Urgau Jul 27, 2025
fdde09b
Use unnamed lifetime spans as primary spans for MISMATCHED_LIFETIME_S…
compiler-errors Aug 23, 2025
ae571c8
Refactor `useless_vec` lint (#14503)
samueltardieu Aug 23, 2025
02111a4
`cast_slice_from_raw_parts`: check for implicit cast to raw slice poi…
zihan0822 Aug 7, 2025
42cc759
changelog: [`cast_slice_from_raw_parts`]: properly select std/core
zihan0822 Aug 7, 2025
e24bd58
`cast_slice_from_raw_parts`: check for implicit cast to raw slice poi…
samueltardieu Aug 23, 2025
f35c203
use `get_diagnostic_item` in even more places (#15528)
samueltardieu Aug 23, 2025
8eca407
Rollup merge of #144531 - Urgau:int_to_ptr_transmutes, r=jackh726
jhpratt Aug 24, 2025
20e3f49
Rollup merge of #145798 - compiler-errors:unnamed-lt-primary, r=lqd
jhpratt Aug 24, 2025
2427ec2
misc: remove one level of nesting
ada4a Aug 13, 2025
9acb48d
`cast_ptr_alignment`: move the `.cast()` check into a separate fn
ada4a Aug 13, 2025
74be6f7
`cast_ptr_alignment`: move the regular check into the `if`
ada4a Aug 13, 2025
0e5b1b1
clean-up `ptr_cast_constness`
ada4a Aug 13, 2025
64d5553
fix: `unnested_or_patterns` FP on structs with only shorthand field p…
llogiq Aug 24, 2025
f6c7786
clean-up `ptr_cast_constness` (#15478)
samueltardieu Aug 24, 2025
9d05ac4
Rewrite `unwrap_in_result` lint
samueltardieu Aug 8, 2025
7b611d4
fix `or_then_unwrap`: suggestion preserves macro calls (#15483)
llogiq Aug 24, 2025
5f80080
`missing_inline_in_public_items`: fix lint emission source HirId (#15…
llogiq Aug 24, 2025
6a4ab68
check f16 and f128 in float_equality_without_abs
usamoi Jun 14, 2025
852e552
get rid of confusing nested `map_or`s
ada4a Aug 23, 2025
e185efe
pattern-match on slices
ada4a Aug 23, 2025
b6343a5
`unused_unit`: small clean-up (#15550)
samueltardieu Aug 24, 2025
ad419b8
check f16 and f128 in float_equality_without_abs (#15054)
llogiq Aug 24, 2025
9373413
Rewrite `unwrap_in_result` lint (#15445)
llogiq Aug 24, 2025
94d3352
`unused_unit`: don't lint on closure return types
ada4a Aug 23, 2025
75d01b7
split `cast_ptr_alignment` (#15479)
llogiq Aug 24, 2025
0cdb47d
move `ptr_as_ptr` to under `if`
ada4a Aug 13, 2025
d4a6061
misc: replace `match` with an equality check
ada4a Aug 13, 2025
22c47f0
`ptr_as_ptr`: move to `if` (#15480)
samueltardieu Aug 24, 2025
0126bc9
Fix `semicolon_inside_block` FP when attribute over expr is not enabl…
blyxyas Aug 24, 2025
a7ff2b0
Suggest naming types before using explicit type names
samueltardieu Jun 6, 2025
597d5a5
`unnecessary_mut_passed`: add structured suggestion
ada4a Aug 8, 2025
1dee616
Suggest naming types before using explicit type names (#14996)
blyxyas Aug 24, 2025
b3d0a09
`unnecessary_mut_passed`: add structured suggestion (#15438)
blyxyas Aug 24, 2025
01fefaa
add span to struct pattern rest (..)
Erk- Aug 23, 2025
137feef
fix: `async_yields_async` wrongly unmangled macros
profetia Aug 25, 2025
f0514d9
Fix `async_yields_async` wrongly unmangled macros (#15553)
samueltardieu Aug 25, 2025
54ced9f
`doc_markdown`: add InfiniBand and RoCE to whitelist
profetia Aug 25, 2025
798f754
`unused_unit`: don't lint on closure return types (#15549)
samueltardieu Aug 25, 2025
1de71c8
ptr_cast_constness: avoid suggesting unresolvable method call
notriddle Aug 22, 2025
cfc9b8f
using full path in suggestion of
relaxcn Aug 26, 2025
79f3ae4
add a flag to codegen fn attrs for foreign items
jdonszelmann Aug 25, 2025
a55391c
docs(cognitive_complexity): Correct lint group
szokeasaurusrex Aug 26, 2025
c4acbce
docs(cognitive_complexity): Correct lint group (#15563)
blyxyas Aug 26, 2025
e54afd3
Enable clippy::panic in const contexts
YohDeadfall Aug 26, 2025
c394c00
Enable clippy::panic in const contexts (#15565)
samueltardieu Aug 26, 2025
a165008
Allow `--print=crate-root-lint-levels`
ShE3py Aug 26, 2025
9bfa95b
Allow `--print=crate-root-lint-levels` (#15567)
llogiq Aug 26, 2025
a527e9f
Preserve `unsafe` blocks in `option_map_unit` suggestion
samueltardieu Aug 26, 2025
27d005a
Document `is_unit_expr()`
samueltardieu Aug 26, 2025
bb8ba69
`unit_cmp`: don't lint on explicitly written unit expr
zihan0822 Aug 26, 2025
d727fa2
using full path in the suggestion of `clone_on_ref_ptr` (#15561)
y21 Aug 27, 2025
cc0df52
Add InfiniBand and RoCE to `doc_markdown` whitelist (#15558)
llogiq Aug 27, 2025
9121dcc
Document `is_unit_expr()` (#15571)
blyxyas Aug 27, 2025
61ce0c5
`map_identity`: suggest making the variable mutable when necessary
ada4a Jul 13, 2025
9910217
fix: `collapsible_match` suggests ref/derefs when needed
vishruth-thimmaiah Feb 14, 2025
0afd6a6
fix: `collapsible_match` suggests ref/derefs when needed (#14221)
samueltardieu Aug 27, 2025
f982b48
`unit_cmp`: don't lint on explicitly written unit expr (#15562)
samueltardieu Aug 27, 2025
7f1dfe0
triagebot: Amend a review to include a link to what was changed since
samueltardieu Aug 27, 2025
c0f29d7
triagebot: Amend a review to include a link to what was changed since…
flip1995 Aug 28, 2025
44abf28
`map_identity`: suggest making the variable mutable when necessary (#…
y21 Aug 28, 2025
b616ba8
fix: `print_literal` suggests wrongly for inline literal following a …
profetia Aug 28, 2025
1a7127c
Fix `print_literal` suggests wrongly for inline literal following a n…
samueltardieu Aug 28, 2025
05f62e0
Fix false positive of `needless_range_loop` when meeting multidimensi…
relaxcn Aug 14, 2025
2badfe8
Fix `redundant_closure` suggests wrongly with deref overload (#15077)
dswij Aug 29, 2025
951e64f
Rollup merge of #145756 - okaneco:stabilize_char_boundary, r=scottmcm
tgross35 Aug 30, 2025
f4e68b2
fix: `assertions_on_result_states` avoid changing return type in more…
ada4a Aug 30, 2025
7fd0b9e
Fix FP of `needless_range_loop` when meeting multidimensional array (…
Jarcho Aug 30, 2025
7f125af
Commas to semicolons in clippy.toml reasons
smoelius Aug 30, 2025
04c6fb7
fix: `needless_for_each` suggests wrongly with explicit closure input…
ada4a Aug 30, 2025
034136d
Commas to semicolons in clippy.toml reasons (#15592)
blyxyas Aug 31, 2025
3f74c96
Get the block content from the proper context (#15014)
y21 Aug 31, 2025
fc39590
Supress excessive_precision when constants are overly precise
teofr Jul 1, 2025
c98ce18
fix: `needless_for_each` suggests wrongly with explicit closure input…
dswij Aug 31, 2025
1b21661
Supress `excessive_precision` when constants are overly precise (#15193)
samueltardieu Aug 31, 2025
7250a1a
fix: `assertions_on_result_states` avoid changing return type in more…
samueltardieu Aug 31, 2025
8f3c6ac
fix: `alloc_instead_of_core` FP when `alloc` is an alias
profetia Aug 27, 2025
d97640c
Fix `alloc_instead_of_core` FP when `alloc` is an alias (#15581)
Jarcho Sep 2, 2025
059cf0e
Preserve `unsafe` blocks in `option_map_unit` suggestion (#15570)
Alexendoo Sep 2, 2025
5ac9657
ptr_cast_constness: avoid suggesting unresolvable method call (#15540)
Alexendoo Sep 2, 2025
2a6b3b6
Rollup merge of #145783 - Erk-:et-cetera-span, r=compiler-errors
GuillaumeGomez Sep 2, 2025
06e4ed6
Set flip1995 to on-vacation
flip1995 Sep 4, 2025
b3c3efe
Set flip1995 to on-vacation (#15614)
flip1995 Sep 4, 2025
4b73b96
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Sep 4, 2025
e9810e5
Bump nightly version -> 2025-09-04
flip1995 Sep 4, 2025
e9b7045
Rustup (#15616)
flip1995 Sep 4, 2025
75b9ee5
Merge commit 'e9b70454e4c9584be3b22ddabd26b741aeb06c10' into clippy-s…
flip1995 Sep 4, 2025
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/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ split-debuginfo = "unpacked"
rustflags = ["--remap-path-prefix", "=clippy_dev"]
[profile.dev.package.lintcheck]
rustflags = ["--remap-path-prefix", "=lintcheck"]

# quine-mc_cluskey makes up a significant part of the runtime in dogfood
# due to the number of conditions in the clippy_lints crate
# and enabling optimizations for that specific dependency helps a bit
# without increasing total build times.
[profile.dev.package.quine-mc_cluskey]
opt-level = 3
6 changes: 6 additions & 0 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Current stable, released 2025-08-07
* Removed superseded lints: `transmute_float_to_int`, `transmute_int_to_char`,
`transmute_int_to_float`, `transmute_num_to_bytes` (now in rustc)
[#14703](https://github.com/rust-lang/rust-clippy/pull/14703)
* Move [`uninlined_format_args`] to `pedantic` (from `style`, now allow-by-default)
[#15287](https://github.com/rust-lang/rust-clippy/pull/15287)

### Enhancements

Expand Down Expand Up @@ -74,6 +76,9 @@ Current stable, released 2025-08-07
[#14719](https://github.com/rust-lang/rust-clippy/pull/14719)
* [`unnecessary_to_owned`] fixed FP when map key is a reference
[#14834](https://github.com/rust-lang/rust-clippy/pull/14834)
* [`swap_with_temporary`]: fix false positive leading to different semantics
being suggested, and use the right number of dereferences in suggestion
[#15172](https://github.com/rust-lang/rust-clippy/pull/15172)

### ICE Fixes

Expand Down Expand Up @@ -6707,6 +6712,7 @@ Released 2018-09-13
[`check-inconsistent-struct-field-initializers`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-inconsistent-struct-field-initializers
[`check-private-items`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-private-items
[`cognitive-complexity-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#cognitive-complexity-threshold
[`const-literal-digits-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#const-literal-digits-threshold
[`disallowed-macros`]: https://doc.rust-lang.org/clippy/lint_configuration.html#disallowed-macros
[`disallowed-methods`]: https://doc.rust-lang.org/clippy/lint_configuration.html#disallowed-methods
[`disallowed-names`]: https://doc.rust-lang.org/clippy/lint_configuration.html#disallowed-names
Expand Down
14 changes: 11 additions & 3 deletions src/tools/clippy/book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,16 @@ The maximum cognitive complexity a function can have
* [`cognitive_complexity`](https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity)


## `const-literal-digits-threshold`
The minimum digits a const float literal must have to supress the `excessive_precicion` lint

**Default Value:** `30`

---
**Affected lints:**
* [`excessive_precision`](https://rust-lang.github.io/rust-clippy/master/index.html#excessive_precision)


## `disallowed-macros`
The list of disallowed macros, written as fully qualified paths.

Expand Down Expand Up @@ -555,7 +565,7 @@ default configuration of Clippy. By default, any configuration will replace the
* `doc-valid-idents = ["ClipPy"]` would replace the default list with `["ClipPy"]`.
* `doc-valid-idents = ["ClipPy", ".."]` would append `ClipPy` to the default list.

**Default Value:** `["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "MHz", "GHz", "THz", "AccessKit", "CoAP", "CoreFoundation", "CoreGraphics", "CoreText", "DevOps", "Direct2D", "Direct3D", "DirectWrite", "DirectX", "ECMAScript", "GPLv2", "GPLv3", "GitHub", "GitLab", "IPv4", "IPv6", "ClojureScript", "CoffeeScript", "JavaScript", "PostScript", "PureScript", "TypeScript", "PowerPC", "WebAssembly", "NaN", "NaNs", "OAuth", "GraphQL", "OCaml", "OpenAL", "OpenDNS", "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenTelemetry", "OpenType", "WebGL", "WebGL2", "WebGPU", "WebRTC", "WebSocket", "WebTransport", "WebP", "OpenExr", "YCbCr", "sRGB", "TensorFlow", "TrueType", "iOS", "macOS", "FreeBSD", "NetBSD", "OpenBSD", "NixOS", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "CamelCase"]`
**Default Value:** `["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "MHz", "GHz", "THz", "AccessKit", "CoAP", "CoreFoundation", "CoreGraphics", "CoreText", "DevOps", "Direct2D", "Direct3D", "DirectWrite", "DirectX", "ECMAScript", "GPLv2", "GPLv3", "GitHub", "GitLab", "IPv4", "IPv6", "InfiniBand", "RoCE", "ClojureScript", "CoffeeScript", "JavaScript", "PostScript", "PureScript", "TypeScript", "PowerPC", "WebAssembly", "NaN", "NaNs", "OAuth", "GraphQL", "OCaml", "OpenAL", "OpenDNS", "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenTelemetry", "OpenType", "WebGL", "WebGL2", "WebGPU", "WebRTC", "WebSocket", "WebTransport", "WebP", "OpenExr", "YCbCr", "sRGB", "TensorFlow", "TrueType", "iOS", "macOS", "FreeBSD", "NetBSD", "OpenBSD", "NixOS", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "CamelCase"]`

---
**Affected lints:**
Expand Down Expand Up @@ -873,15 +883,13 @@ The minimum rust version that the project supports. Defaults to the `rust-versio
* [`needless_borrow`](https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow)
* [`non_std_lazy_statics`](https://rust-lang.github.io/rust-clippy/master/index.html#non_std_lazy_statics)
* [`option_as_ref_deref`](https://rust-lang.github.io/rust-clippy/master/index.html#option_as_ref_deref)
* [`option_map_unwrap_or`](https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unwrap_or)
* [`ptr_as_ptr`](https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr)
* [`question_mark`](https://rust-lang.github.io/rust-clippy/master/index.html#question_mark)
* [`redundant_field_names`](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names)
* [`redundant_static_lifetimes`](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes)
* [`repeat_vec_with_capacity`](https://rust-lang.github.io/rust-clippy/master/index.html#repeat_vec_with_capacity)
* [`same_item_push`](https://rust-lang.github.io/rust-clippy/master/index.html#same_item_push)
* [`seek_from_current`](https://rust-lang.github.io/rust-clippy/master/index.html#seek_from_current)
* [`seek_rewind`](https://rust-lang.github.io/rust-clippy/master/index.html#seek_rewind)
* [`to_digit_is_some`](https://rust-lang.github.io/rust-clippy/master/index.html#to_digit_is_some)
* [`transmute_ptr_to_ref`](https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ref)
* [`tuple_array_conversions`](https://rust-lang.github.io/rust-clippy/master/index.html#tuple_array_conversions)
Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ lint-commented-code = true

[[disallowed-methods]]
path = "rustc_lint::context::LintContext::lint"
reason = "this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint*` functions instead"
reason = "this function does not add a link to our documentation; please use the `clippy_utils::diagnostics::span_lint*` functions instead"

[[disallowed-methods]]
path = "rustc_lint::context::LintContext::span_lint"
reason = "this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint*` functions instead"
reason = "this function does not add a link to our documentation; please use the `clippy_utils::diagnostics::span_lint*` functions instead"

[[disallowed-methods]]
path = "rustc_middle::ty::context::TyCtxt::node_span_lint"
reason = "this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint_hir*` functions instead"
reason = "this function does not add a link to our documentation; please use the `clippy_utils::diagnostics::span_lint_hir*` functions instead"
6 changes: 4 additions & 2 deletions src/tools/clippy/clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const DEFAULT_DOC_VALID_IDENTS: &[&str] = &[
"GPLv2", "GPLv3",
"GitHub", "GitLab",
"IPv4", "IPv6",
"InfiniBand", "RoCE",
"ClojureScript", "CoffeeScript", "JavaScript", "PostScript", "PureScript", "TypeScript",
"PowerPC", "WebAssembly",
"NaN", "NaNs",
Expand Down Expand Up @@ -569,6 +570,9 @@ define_Conf! {
/// The maximum cognitive complexity a function can have
#[lints(cognitive_complexity)]
cognitive_complexity_threshold: u64 = 25,
/// The minimum digits a const float literal must have to supress the `excessive_precicion` lint
#[lints(excessive_precision)]
const_literal_digits_threshold: usize = 30,
/// DEPRECATED LINT: CYCLOMATIC_COMPLEXITY.
///
/// Use the Cognitive Complexity lint instead.
Expand Down Expand Up @@ -775,15 +779,13 @@ define_Conf! {
needless_borrow,
non_std_lazy_statics,
option_as_ref_deref,
option_map_unwrap_or,
ptr_as_ptr,
question_mark,
redundant_field_names,
redundant_static_lifetimes,
repeat_vec_with_capacity,
same_item_push,
seek_from_current,
seek_rewind,
to_digit_is_some,
transmute_ptr_to_ref,
tuple_array_conversions,
Expand Down
4 changes: 4 additions & 0 deletions src/tools/clippy/clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ url = "2.2"
[dev-dependencies]
walkdir = "2.3"

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ['cfg(bootstrap)']

[package.metadata.rust-analyzer]
# This crate uses #[feature(rustc_private)]
rustc_private = true
27 changes: 15 additions & 12 deletions src/tools/clippy/clippy_lints/src/assertions_on_result_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use clippy_utils::macros::{PanicExpn, find_assert_args, root_macro_call_first_no
use clippy_utils::source::snippet_with_context;
use clippy_utils::ty::{has_debug_impl, is_copy, is_type_diagnostic_item};
use clippy_utils::usage::local_used_after_expr;
use clippy_utils::{is_expr_final_block_expr, path_res, sym};
use clippy_utils::{path_res, sym};
use rustc_errors::Applicability;
use rustc_hir::def::Res;
use rustc_hir::{Expr, ExprKind};
use rustc_hir::{Expr, ExprKind, Node};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{self, Ty};
use rustc_session::declare_lint_pass;
Expand Down Expand Up @@ -77,17 +77,20 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnResultStates {
_ => return,
};
span_lint_and_then(cx, ASSERTIONS_ON_RESULT_STATES, macro_call.span, message, |diag| {
let semicolon = if is_expr_final_block_expr(cx.tcx, e) { ";" } else { "" };
let mut app = Applicability::MachineApplicable;
diag.span_suggestion(
macro_call.span,
"replace with",
format!(
"{}.{replacement}(){semicolon}",
snippet_with_context(cx, recv.span, condition.span.ctxt(), "..", &mut app).0
),
app,
);
let recv = snippet_with_context(cx, recv.span, condition.span.ctxt(), "..", &mut app).0;

// `assert!` doesn't return anything, but `Result::unwrap(_err)` does, so we might need to add a
// semicolon to the suggestion to avoid leaking the type
let sugg = match cx.tcx.parent_hir_node(e.hir_id) {
// trailing expr of a block
Node::Block(..) => format!("{recv}.{replacement}();"),
// already has a trailing semicolon
Node::Stmt(..) => format!("{recv}.{replacement}()"),
// this is the last-resort option, because it's rather verbose
_ => format!("{{ {recv}.{replacement}(); }}"),
};
diag.span_suggestion(macro_call.span, "replace with", sugg, app);
});
}
}
Expand Down
60 changes: 35 additions & 25 deletions src/tools/clippy/clippy_lints/src/async_yields_async.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use clippy_utils::diagnostics::span_lint_hir_and_then;
use clippy_utils::source::snippet;
use clippy_utils::is_expr_async_block;
use clippy_utils::source::walk_span_to_context;
use clippy_utils::sugg::Sugg;
use clippy_utils::ty::implements_trait;
use rustc_errors::Applicability;
use rustc_hir::{Closure, ClosureKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, QPath};
use rustc_hir::{
Block, Closure, ClosureKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, QPath,
};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::declare_lint_pass;

Expand Down Expand Up @@ -87,31 +91,37 @@ impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync {
let expr_ty = typeck_results.expr_ty(body_expr);

if implements_trait(cx, expr_ty, future_trait_def_id, &[]) {
let return_expr_span = match &body_expr.kind {
// XXXkhuey there has to be a better way.
ExprKind::Block(block, _) => block.expr.map(|e| e.span),
ExprKind::Path(QPath::Resolved(_, path)) => Some(path.span),
_ => None,
let (return_expr, return_expr_span) = match &body_expr.kind {
ExprKind::Block(Block { expr: Some(e), .. }, _) => (*e, e.span),
ExprKind::Path(QPath::Resolved(_, path)) => (body_expr, path.span),
_ => return,
};
if let Some(return_expr_span) = return_expr_span {
span_lint_hir_and_then(
cx,
ASYNC_YIELDS_ASYNC,
body_expr.hir_id,
return_expr_span,
"an async construct yields a type which is itself awaitable",
|db| {
db.span_label(body_expr.span, "outer async construct");
db.span_label(return_expr_span, "awaitable value not awaited");
db.span_suggestion(
return_expr_span,
"consider awaiting this value",
format!("{}.await", snippet(cx, return_expr_span, "..")),
Applicability::MaybeIncorrect,
);
},
);

let return_expr_span = walk_span_to_context(return_expr_span, expr.span.ctxt()).unwrap_or(return_expr_span);
let mut applicability = Applicability::MaybeIncorrect;
let mut return_expr_snip =
Sugg::hir_with_context(cx, return_expr, expr.span.ctxt(), "..", &mut applicability);
if !is_expr_async_block(return_expr) {
return_expr_snip = return_expr_snip.maybe_paren();
}

span_lint_hir_and_then(
cx,
ASYNC_YIELDS_ASYNC,
body_expr.hir_id,
return_expr_span,
"an async construct yields a type which is itself awaitable",
|db| {
db.span_label(body_expr.span, "outer async construct");
db.span_label(return_expr_span, "awaitable value not awaited");
db.span_suggestion(
return_expr_span,
"consider awaiting this value",
format!("{return_expr_snip}.await"),
applicability,
);
},
);
}
}
}
Loading
Loading