Commit Graph

10734 Commits

Author SHA1 Message Date
Samuel Tardieu 0ea973e49c Fix adjustments 2025-11-18 09:21:21 +01:00
Philipp Krones 72fc40c3d0 Fix fn_to_numeric_cast 32 bit stderr 2025-11-15 00:58:12 +01:00
Philipp Krones 03cd6b6dd8 Merge remote-tracking branch 'upstream/master' into rustup 2025-11-15 00:37:39 +01:00
llogiq 540e2f4a2a feat(ok_expect): add autofix (#15867)
changelog: [`ok_expect`]: add autofix
2025-11-14 12:12:31 +00:00
llogiq 663ef9b31b fix(rc_buffer): don't touch the path to Rc/Arc in the suggestion (#15803)
Fixes https://github.com/rust-lang/rust-clippy/issues/15802

changelog: [`rc_buffer`]: don't touch the path to `Rc`/`Arc` in the
suggestion
2025-11-14 09:52:59 +00:00
Timo 0ac66461bb refactor(needless_arbitrary_self_type): give suggestions with finer diffs (#16005)
changelog: [`needless_arbitrary_self_type`]: give suggestions with finer
diffs
2025-11-12 20:49:39 +00:00
Philipp Krones da2a220a2e incompatible_msrv: Don't check the contents of any std macro. (#16083)
cc rust-lang/rust#148190 @flip1995 @RalfJung

This is a bit of a hack in that it hardcodes the list of crates with
stability attributes. This shouldn't be a big deal since that isn't a
set that changes very frequently and an internal lint could detect when
that happens.

The `fixme`s added aren't new issues and shouldn't get in the way of
unblocking the upstream issue.

changelog: none
2025-11-12 17:22:17 +00:00
Jason Newcomb a537e86e7f incompatible_msrv: Don't check the contents of any std macro. 2025-11-12 12:01:16 -05:00
Mara Bos 3352bea655 Bless clippy tests. 2025-11-12 14:43:05 +01:00
Mara Bos 7ae882efd0 Bless clippy tests. 2025-11-12 12:48:39 +01:00
Mara Bos 18de21629a Make clippy happy. 2025-11-12 12:48:36 +01:00
Samuel Tardieu d599529223 Fix single_range_in_vec_init FP for explicit Range (#16043)
Closes rust-lang/rust-clippy#16042
Closes rust-lang/rust-clippy#16044

changelog: [`single_range_in_vec_init`] fix FP for explicit `Range`
2025-11-11 10:28:46 +00:00
Linshu Yang e1ac7da6a1 fix: useless_let_if_seq wrongly unmangled macros 2025-11-10 20:01:15 +00:00
Linshu Yang 8a1dde1449 fix: useless_let_if_seq FN when if is in the last expr of block 2025-11-10 19:30:50 +00:00
Linshu Yang 6834ab61b1 fix: single_range_in_vec_init wrongly unmangles macros 2025-11-10 17:25:01 +00:00
Linshu Yang c8885d5313 fix: single_range_in_vec_init FP for explicit Range 2025-11-10 17:25:01 +00:00
Guillaume Gomez d16f26b944 Allow function_casts_as_integer in non-related clippy ui tests 2025-11-10 16:38:28 +01:00
bors 5b5709b248 Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU
mgca: Add ConstArg representation for const items

tracking issue: rust-lang/rust#132980
fixes rust-lang/rust#131046
fixes rust-lang/rust#134641

As part of implementing `min_generic_const_args`, we need to distinguish const items that can be used in the type system, such as in associated const equality projections, from const items containing arbitrary const code, which must be kept out of the type system. Specifically, all "type consts" must be either concrete (no generics) or generic with a trivial expression like `N` or a path to another type const item.

To syntactically distinguish these cases, we require, for now at least, that users annotate all type consts with the `#[type_const]` attribute. Then, we validate that the const's right-hand side is indeed eligible to be a type const and represent it differently in the HIR.

We accomplish this representation using a new `ConstItemRhs` enum in the HIR, and a similar but simpler enum in the AST. When `#[type_const]` is **not** applied to a const (e.g. on stable), we represent const item right-hand sides (rhs's) as HIR bodies, like before. However, when the attribute is applied, we instead lower to a `hir::ConstArg`. This syntactically distinguishes between trivial const args (paths) and arbitrary expressions, which are represented using `AnonConst`s. Then in `generics_of`, we can take advantage of the existing machinery to bar the `AnonConst` rhs's from using parent generics.
2025-11-08 22:31:33 +00:00
Noah Lev 8cb6e1bfcf Fix clippy
When mgca is enabled, const rhs's that are paths may have false
negatives with the lints in non_copy_const.rs. But these should probably
be using the trait solver anyway, and it only happens under mgca.
2025-11-08 13:50:48 -05:00
Ada Alakbarova a4a88ea592 refactor(needless_arbitrary_self_type): give suggestions with finer diffs 2025-11-08 19:48:32 +01:00
Jason Newcomb d154da9773 chore(unnecessary_mut_passed): show the intention not to lint &raw references (#16049)
Supersedes https://github.com/rust-lang/rust-clippy/pull/15962

changelog: none

r? @Jarcho
2025-11-08 14:24:20 +00:00
Ada Alakbarova b59b2fdddb chore(unnecessary_mut_passed): show the intention not to lint &raw references 2025-11-08 10:15:17 +01:00
Ada Alakbarova 21ddc50eec chore(unnecessary_map_on_constructor): clean-up
- reduce indentation
- print constructor/method name in backticks
2025-11-07 22:14:03 +01:00
llogiq 8ed05abef3 Fix missing_asserts_for_indexing changes assert_eq to assert (#16040)
Closes rust-lang/rust-clippy#16026

changelog: [`missing_asserts_for_indexing`] fix wrongly changing
`assert_eq` to `assert`
2025-11-06 22:28:32 +00:00
Jason Newcomb c004be44c8 Fix nonminimal_bool wrongly unmangled terms (#16017)
Closes rust-lang/rust-clippy#16014

changelog: [`nonminimal_bool`] fix wrongly unmangled terms
2025-11-06 18:26:11 +00:00
llogiq 36324e8e9c Don't flag cfg(test) as multiple inherent impl (#16041)
changelog: [`multiple_inherent_impl`]: Don't flag cfg(test) impls as
repeats

fixes rust-lang/rust-clippy#13040
2025-11-06 18:25:48 +00:00
Alex Macleod 52a39998fa Fix missing_inline_in_public_items fail to fulfill expect in --test build (#15320)
Closes rust-lang/rust-clippy#13394

changelog: [`missing_inline_in_public_items`] fix failure to fulfill
`expect` in `--test` build
2025-11-06 16:49:21 +00:00
Nick Drozd 8539de9ccf Don't flag cfg(test) as multiple inherent impl 2025-11-06 09:49:10 -06:00
yanglsh a86dd63818 Make missing_inline_in_public_items warn on executables 2025-11-06 15:29:30 +00:00
Linshu Yang 0ab135f9d0 fix: missing_asserts_for_indexing changes assert_eq to assert 2025-11-06 15:12:08 +00:00
llogiq c95d95bf95 Fix match_single_binding suggests wrongly inside tuple (#15539)
Closes rust-lang/rust-clippy#15537
Closes rust-lang/rust-clippy#15840

changelog: [`match_single_binding`] fix wrong suggestions inside tuple
2025-11-06 11:01:03 +00:00
Linshu Yang c100a0808b fix: nonminimal_bool wrongly unmangled terms 2025-11-05 16:14:59 +00:00
Scott Schafer 5db73006f2 feat: Use annotate-snippets by default on nightly 2025-11-05 09:01:07 -07:00
Samuel Tardieu 4eac58a0b0 Consider type conversion that won't overflow (#15950)
Fix rust-lang/rust-clippy#15943

```rust
pub fn from_days(days: u8) -> Duration {
    Duration::from_secs(86400 * u64::from(days))
}
```

An initial foundation that can be used for future improvements. It is
been a while since I touched Clippy so feel free to indicate better
designs if applicable.

Looks like https://github.com/rust-lang/rust-clippy/pull/15342 will help
but it is unclear when it will be finished. This PR provides a partial
solution for the current time.

changelog: [`arithmetic_side_effects`]: Consider type conversion that
won't overflow
2025-11-05 08:07:35 +00:00
Matthias Krüger 99124be1bc Rollup merge of #148004 - Muscraft:only-single-line-item-attributes, r=estebank
fix: Only special case single line item attribute suggestions

`rustc` currently special cases suggestions to add [`#[derive(_)]\n` and other attributes](https://github.com/rust-lang/rust/blob/dc1feabef242259d61bd930713de3250577c1c71/compiler/rustc_errors/src/emitter.rs#L2288C36-L2288C72), to add more context to the suggestions.

> // The suggestion adds an entire line of code, ending on a newline, so we'll also
> // print the *following* line, to provide context of what we're advising people to
> // do. Otherwise you would only see contextless code that can be confused for
> // already existing code, despite the colors and UI elements.
> // We special case `#[derive(_)]\n` and other attribute suggestions, because those
> // are the ones where context is most useful.

This special case is a bit broad at the moment and applies to suggestions just to add an attribute, as well as suggestions that contain an attribute and other code, i.e.
```rust
#[derive(Clone)]
```
and
```rust
#[cfg(not(test))]
impl Default for NewWithCfg {
    fn default() -> Self {
        Self::new()
    }
}
```

In the latter case, adding a line for context after the suggestion doesn't provide much benefit. Example:
![temp](https://github.com/user-attachments/assets/6859b400-aa99-4c1b-9eb0-0cd67ae35bf9)

This PR makes it so that this special case only applies to suggestions that just add an attribute and nothing else. This will also make `rustc`'s output match `annotate-snippets`.
2025-11-03 21:20:22 +01:00
Samuel Tardieu a456519ce0 fix(let_and_return): disallow _any_ text between let and return (#16006)
Fixes https://github.com/rust-lang/rust-clippy/issues/15987

changelog: [`let_and_return`]: disallow _any_ text between let and
return
2025-11-02 09:28:39 +00:00
Samuel Tardieu e121ab877e Fix replace_box FP when the box is moved (#15984)
Closes rust-lang/rust-clippy#15968

changelog: [`replace_box`] fix FP when the box is moved

r? samueltardieu As you wish

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

-
[Beta-nomination](https://github.com/rust-lang/rust-clippy/pull/15984#issuecomment-3469127087)
by [samueltardieu](https://github.com/samueltardieu)

*Managed by `@rustbot`—see
[help](https://forge.rust-lang.org/triagebot/note.html) for details*

<!-- TRIAGEBOT_SUMMARY_END -->
<!-- TRIAGEBOT_END -->
2025-11-02 09:12:28 +00:00
Linshu Yang 098ded3160 fix: replace_box FP when the box is moved 2025-11-02 03:23:16 +00:00
Timo 31d8210a53 unused_enumerate_index: move to loops lint pass (#15279)
Needed to split the lint crate.

Both the method and loop versions of the lint should also behave the
same now.

changelog: None
2025-11-01 19:39:44 +00:00
Ada Alakbarova 6bc8d214b4 fix(let_and_return): disallow _any_ text between let and return 2025-11-01 18:01:28 +01:00
Matthias Krüger 7ec6593bfd Rollup merge of #148340 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? ``@Manishearth``

Cargo.lock update due to Clippy version bump
2025-11-01 08:25:48 +01:00
Matthias Krüger 78adb20385 Rollup merge of #139751 - frank-king:feature/pin-project, r=Nadrieril,traviscross
Implement pin-project in pattern matching for `&pin mut|const T`

This PR implements part of rust-lang/rust#130494. It supports pin-project in pattern matching for `&pin mut|const T`.

~Pin-projection by field access (i.e. `&pin mut|const place.field`) is not fully supported yet since pinned-borrow is not ready (rust-lang/rust#135731).~

CC ``````@traviscross``````
2025-11-01 08:25:44 +01:00
Ada Alakbarova e7b4ae869e clean-up 2025-10-31 22:20:53 +01:00
Jason Newcomb e6298692a5 extend needless_collect (#14361)
changelog: [`needless_collect`]: extend needless_collect to lint more
cases

Fix #14350
2025-10-31 19:12:13 +00:00
Alex Macleod c23eed6ddc refactor(write): split each lint into its own module (#15857)
changelog: none
2025-10-31 19:11:42 +00:00
Philipp Krones c71f7b63f8 Merge commit 'c936595d17413c1f08e162e117e504fb4ed126e4' into clippy-subtree-update 2025-10-31 19:15:42 +01:00
Philipp Krones f64e401f74 Merge remote-tracking branch 'upstream/master' into rustup 2025-10-31 18:58:07 +01:00
Ada Alakbarova 938dd5f404 misc: test cases with escaping are mostly autofixable now 2025-10-31 17:40:12 +01:00
Jason Newcomb e415911f49 fix(use_debug): don't get confused by nested Debug impls (#15946)
Fixes https://github.com/rust-lang/rust-clippy/issues/15942

changelog: [`use_debug`]: don't get confused by nested `Debug` impls
2025-10-31 08:10:46 +00:00
Jason Newcomb bcc40ce3b9 fix(double_parens): don't lint in proc-macros (#15939)
Fixes https://github.com/rust-lang/rust-clippy/issues/15852

changelog: [`double_parens`]: don't lint in proc-macros
2025-10-31 08:09:28 +00:00