Commit Graph

2599 Commits

Author SHA1 Message Date
Jason Newcomb 0776e01ff4 fix(needless_maybe_sized): don't lint in proc-macro-generated code (#15629)
Fixes https://github.com/rust-lang/rust-clippy/issues/13360

changelog: [`needless_maybe_sized`]: don't lint in proc-macro-generated
code
2026-02-23 01:09:15 +00:00
llogiq 9a1cabf77e Fix panic/assert message detection in edition 2015/2018 (#16473)
changelog: fix FP: [`assertions_on_result_states`],
[`missing_assert_message`] on edition 2015 and 2018

Fixes https://github.com/rust-lang/rust-clippy/issues/13490
2026-02-22 14:20:10 +00:00
llogiq 6211fa92e8 The path from a type to itself is Self (#16362)
changelog: [`redundant_closure_for_method_calls`]: fix ICE when
computing the path from a type to itself

Fixes rust-lang/rust-clippy#16360
2026-02-22 14:18:59 +00:00
llogiq ad08bd62dd Enhance collapsible_match to cover if-elses (#16560)
Closes rust-lang/rust-clippy#16558

changelog: [`collapsible_match`] extend to cover if-elses
2026-02-22 13:07:10 +00:00
Samuel Tardieu d074e48dcb feat(clone_on_ref_ptr): don't add a & to the receiver if it's a reference (#15742)
Fixes https://github.com/rust-lang/rust-clippy/issues/15741

changelog: [clone_on_ref_ptr]: don't add a `&` to the receiver if it's a
reference
2026-02-21 22:47:41 +00:00
llogiq 94337ce1d8 DRY: make all span_lint_* use span_lint{_hir,}_and_then (#16587)
This removes code duplication. Also, this limits the number of places to
update when rustc lint code interface is modified to two places.

changelog: none
2026-02-21 22:21:38 +00:00
Samuel Tardieu 2f6e9e4d55 Add Sugg::strip_paren() 2026-02-21 22:35:51 +01:00
Samuel Tardieu 296fe3a74a Make unchecked_time_subtraction to better handle Duration literals (#16528)
Closes rust-lang/rust-clippy#16499

changelog: [`unchecked_time_subtraction`] extend to better handle
`Duration` literals
2026-02-21 18:14:14 +00:00
linshuy2 ef1ee71666 Enhance unchecked_time_subtraction to better handle Duration literals 2026-02-21 18:04:19 +00:00
Jason Newcomb 349e809e6f Handle Result<T, !> and ControlFlow<!, T> as T wrt #[must_use] (#16353)
There is a proposal to change the behaviour of rustc's `must_use` lint
to consider `Result<T, U>` and `ControlFlow<U, T>` as `T` when `U` is
uninhabited. See <https://github.com/rust-lang/rust/pull/148214>.

This might make the user adding extra `#[must_use]` attributes to
functions returning `Result<T, !>` or `ControlFlow<!, T>`, which would
trigger the `double_must_use` lint in Clippy without the current change.

changelog: [`double_muse_use`, `drop_non_drop`,
`let_underscore_must_use`]: consider `Result<T, U>` and `ControlFlow<U,
T>` as `T` wrt the `#[must_use]` attribute if `U` is uninhabited.
2026-02-21 17:57:22 +00:00
Samuel Tardieu 5137bb3ceb Handle Result<T, !> and ControlFlow<!, T> as T wrt #[must_use]
There is a proposal to change the behaviour of rustc's `must_use` lint
to consider `Result<T, U>` and `ControlFlow<U, T>` as `T` when `U` is
uninhabited. See <https://github.com/rust-lang/rust/pull/148214>.

This might make the user adding extra `#[must_use]` attributes to
functions returning `Result<T, !>` or `ControlFlow<!, T>`, which would
trigger the `double_must_use` lint in Clippy without the current change.
2026-02-21 15:48:33 +01:00
Jason Newcomb 70647514ff Add new disallowed_fields lint (#16218)
Fixes https://github.com/rust-lang/rust-clippy/issues/9278.

This is something that we need for `cg_gcc` (cc @antoyo). It's almost
the same as https://github.com/rust-lang/rust-clippy/pull/6674 (which I
used as base).

changelog: Add new `disallowed_fields` lint

r? @samueltardieu
2026-02-20 13:19:36 +00:00
Philipp Krones 650809e8a2 Bump nightly version -> 2026-02-19 2026-02-19 15:39:12 +01:00
Philipp Krones e96a83b4b7 Merge remote-tracking branch 'upstream/master' into rustup 2026-02-19 15:38:57 +01:00
Samuel Tardieu 3b2b250db5 DRY: make all span_lint_* use span_lint{_hir,}_and_then
This removes code duplication. Also, this limits the number of places to
update when rustc lint code interface is modified to two places.
2026-02-19 12:19:01 +01:00
Camille Gillot 175070309c Remove ShallowInitBox. 2026-02-17 11:25:50 +00:00
Stuart Cook d5643a0e2d Rollup merge of #151783 - mu001999-contrib:impl/final-method, r=fee1-dead
Implement RFC 3678: Final trait methods

Tracking: https://github.com/rust-lang/rust/issues/131179

This PR is based on rust-lang/rust#130802, with some minor changes and conflict resolution.

Futhermore, this PR excludes final methods from the vtable of a dyn Trait.

And some excerpt from the original PR description:
> Implements the surface part of https://github.com/rust-lang/rfcs/pull/3678.
>
> I'm using the word "method" in the title, but in the diagnostics and the feature gate I used "associated function", since that's more accurate.

cc @joshtriplett
2026-02-17 13:02:21 +11:00
Ralf Jung 32d32b6891 adjust clippy to fix some of the issues 2026-02-16 17:27:40 +01:00
linshuy2 5be3049e9c Apply collapsible_match to Clippy itself 2026-02-15 00:27:19 +00:00
Oscar Bray 6c04e465af Port #[rustc_test_marker] to the attribute parser 2026-02-14 13:14:57 +00:00
Philipp Krones c8fd55b457 Merge commit 'a62c6af53676bb15a40488ce2d632de558f001de' into clippy-subtree-update 2026-02-12 14:50:58 +01:00
mu001999 ae2d679bdd Fix clippy ast utils
Co-authored-by: Michael Goulet <michael@errs.io>
2026-02-12 15:18:15 +08:00
Philipp Krones 24b1392c87 Bump nightly version -> 2026-02-11 2026-02-11 20:02:32 +01:00
Philipp Krones c9841a63af Merge remote-tracking branch 'upstream/master' into rustup 2026-02-11 20:02:28 +01:00
Lukas Bergdoll 99e47220fc Stabilize assert_matches 2026-02-11 14:13:44 +01:00
Jonathan Brouwer bbc5b531dd Rollup merge of #152351 - JonathanBrouwer:remove_subdiag, r=nnethercote
Remove `SubdiagMessage` in favour of the identical `DiagMessage`

For https://github.com/rust-lang/rust/issues/151366
Just some more cleanup :)
SubdiagMessage is now identical to DiagMessage, so there's no point in having both of them
2026-02-10 13:00:47 +01:00
Jonathan Brouwer b1847b59cc Remove SubdiagMessage in favour of the identical DiagMessage 2026-02-10 09:13:45 +00:00
Guillaume Gomez cb68b21cb3 Extend disallowed_fields lint on variant fields 2026-02-09 18:51:44 +01:00
Keith-Cancel 9bf9a12381 Allow provisional mgca syntax of type const <IDENT> = <EXPR> to be reconized.
Revert, but without type const.

Update symbol for feature err, then update suggestion output, and lastly update tests that change because of those.

Update these new tests with the correct syntax, and few existing tests with the new outputs the merge with main added.

Fix for tidyfmt and some errors when manually resolving a merge conflicts.

Update these tests to use update error messages and type const syntax.

Update comments and error message to use new syntax instead of old type_const attribute.

Remove the type_const attribute

update some more tests to use the new syntax.

Update these test cases.

update feature gate test

Change gate logic for `mgca_type_const_syntax` to work also if `min_generic_const_args` is enabled.

Create a new feature gate that checks for the feature before expansion.

Make rustfmt handle the `type const` syntax correctly.

Add a convience method to check if a RhsKind is type const.

Rename `Const` discriminant to `Body` for `ConstItemRhsKind`

Give the `TraitItemKind` flag an enum instead of a simple bool to better describe what the flag is for.

Update formatting for these match statements.

Update clippy test to use type const syntax.

Update test to use type const syntax.

update rustfmt to match ast items.

Update clippy to match ast and hir items.

Few more test cases that used old attribute, instead of 'type const'

Update to match the output from the feature gate checks.

tidyfmt adjustments.

Update the is_type_const, so I can constrain record!(..) in encoder.rs

Update conditional compilation test.

Move the feature gate to after expansion to allow for cfg(...) to work.

Update some more tests to use the new syntax.

Update type const tests in associated-const-bindings to use new syntax.

Don't check based off the attribute, but the item here.

Update some tests outside of the const_generics folder that were using #[type_const]

update the tests in associated consts that use #[type_const] to use type const

Update these mgca tests with the type const syntax.

Add a flag to TraitItemKind for detecting type const for now. Maybe later change ItemConstRhs to have optional consts but that touches a lot more lines of code.

Don't need into for these now that it's a query.

Add is_type_const query to handle foreign def ids.

update this test to use type const syntax.

Fix logic here, we only want to lower if there is expression in this case.

Update built-in macros to use ConstItemRhsKind

Update more instance of the old ConstItemRhs.

Rename ConstItemKind to ConstItemRhsKind, I noticed there is a typed called ConstantItemKind, so add the Rhs to the name to avoid confusion.

Update lower to use ConstItemKind

Add an other helper method to check if the rhs kinda has an expr.

Update item parse to use ConstItemKind enum.

Felt the field name could a be little clear when editing a few other things.

Change the ConstItem struct see know if we have a type const or regular const.

Make sure this syntax is properly feature gated.
2026-02-09 07:59:24 -08:00
Guillaume Gomez 12109e4b2c Create new clippy_utils::ty::get_field_def_id_by_name function 2026-02-09 16:57:55 +01:00
khyperia e94a62d800 mGCA: Support directly represented negated literals 2026-02-06 14:04:55 +01:00
vishnupoddar12 992a6f6c89 fix: allow_attributes false negative on attributes with whitespace 2026-02-02 12:46:57 +05:30
Frank King cdee2fbff5 refactor: add an enum DerefAdjustKind in favor of Option<OverloadedDeref> 2026-01-31 16:25:32 +08:00
James Barford-Evans f992358ab7 Part 2 refactoring of moving placeholder types to rustc_type_ir 2026-01-29 11:11:40 +00:00
Alex Macleod b05aec3f7b Fix panic/assert message detection in edition 2015/2018
Fixes a FP for assertions_on_result_states, missing_assert_message
on edition 2015/2018
2026-01-27 17:27:47 +00:00
Kevin Reid 17f89e76ab Fix useless_attribute FP on exported_private_dependencies lint attributes. 2026-01-26 11:15:13 -08:00
bors 529b82046f Auto merge of #151501 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? Manishearth 

`Cargo.lock` update due to Clippy version bump.
2026-01-23 14:57:31 +00:00
Philipp Krones 977eddef3f Merge commit '54482290b5f32e6c6b57cc9e0a17153f432b0036' into clippy-subtree-update 2026-01-22 19:02:54 +01:00
Philipp Krones 0f9b027859 Bump Clippy version -> 0.1.95 2026-01-22 16:55:20 +01:00
Philipp Krones 21e84b5da8 Bump nightly version -> 2026-01-22 2026-01-22 16:55:13 +01:00
Philipp Krones 94fe3ddd93 Merge remote-tracking branch 'upstream/master' into rustup 2026-01-22 16:55:00 +01:00
Jonathan Brouwer 3c9a08456e Rollup merge of #151423 - Voultapher:move-assert-matches, r=Amanieu
Move assert_matches to planned stable path

Another prep PR for https://github.com/rust-lang/rust/pull/137487
2026-01-22 13:35:41 +01:00
Jacob Pratt 63c69a7c04 Rollup merge of #151439 - Mark-Simulacrum:bootstrap-bump, r=nnethercote
Bump bootstrap compiler to 1.94

https://forge.rust-lang.org/release/process.html#default-branch-bootstrap-update-tuesday
2026-01-22 00:37:43 -05:00
Mark Rousskov a0d33e07b0 Bump stage0 2026-01-21 20:03:56 -05:00
Lukas Bergdoll e8c449dfbd Move assert_matches to planned stable path 2026-01-21 23:17:24 +01:00
León Orell Valerian Liehr 19bfad0693 Introduce AssocTag::descr & refactor in the vicinity 2026-01-21 12:53:46 +01:00
dswij 4b98bd3db5 Do not consider binary operators as commutative by default (#16420)
Only `==` (and thus `!=`) are supposed to be commutative according to
Rust's documentation. Do not make assumptions about other operators
whose meaning may depend on the types on which they apply. However,
special-case operators known to be commutative for primitive types such
as addition or multiplication.

changelog: [`if_same_then_else`]: do not consider binary operators
commutative by default

Fixes rust-lang/rust-clippy#16416
2026-01-20 03:50:23 +00:00
Jonathan Brouwer c591bc103a Remove all allows for diagnostic_outside_of_impl and untranslatable_diagnostic throughout the codebase
This PR was mostly made by search&replacing
2026-01-19 17:39:49 +01:00
llogiq fe4bc3123f fix(collapsible_span_lint_calls): use snippet_with_context for spans that are likely to contain macro expns (#15881)
Fixes https://github.com/rust-lang/rust-clippy/issues/15880

changelog: none
2026-01-18 15:51:15 +00:00
Samuel Tardieu bcde8c1070 Do not consider binary operators as commutative by default
Only `==` (and thus `!=`) are supposed to be commutative according to
Rust's documentation. Do not make assumptions about other operators
whose meaning may depend on the types on which they apply. However,
special-case operators known to be commutative for primitive types
such as addition or multiplication.
2026-01-17 00:36:09 +01:00