Commit Graph

23395 Commits

Author SHA1 Message Date
Nick Drozd 64d6f82825 Cut needless mut 2025-08-18 15:16:04 -04:00
dswij 0e4ce7ffff msrv: replace nested ifs with guard clauses (#15490)
reads a bit more natural imo

changelog: none
2025-08-18 16:23:22 +00:00
Alejandra González 73b5a59c22 Do not suggest to use implicit DerefMut on ManuallyDrop reached through unions (#14387)
This requires making the `deref_addrof` lint a late lint instead of an
early lint to check for types.

changelog: [`deref_addrof`]: do not suggest implicit `DerefMut` on
`ManuallyDrop` union fields

Fix rust-lang/rust-clippy#14386
2025-08-18 15:10:31 +00:00
llogiq feb18ca1ee clean-up collapsible_if a bit (#15503)
changelog: none
2025-08-17 15:44:04 +00:00
Jason Newcomb fc42a205e9 Misc clippy_dev changes (#14896)
changelog: none
2025-08-17 11:26:46 +00:00
Alejandra González 1fd9504619 similar_names stop linting for 3-char names (#15100)
fixes rust-lang/rust-clippy#14869

Added a simple check if both chars are of length 3
If they are, we skip the check for that pair.

This won't handle the 4 v 3 case.
Not sure if this was the intent of the issue.

Also saw we have some hardcoded exemptions for `set, get` and `lhs, rhs`
Tried removing them thinking they would be handled by the new condition.
But we have to keep because they allow for `bla_lhs` v `bla_rhs` to be
skipped

changelog:[`similar_names`]: Stop triggering for 3-character names
2025-08-16 16:58:06 +00:00
Abderahmane Bouziane e41fb7ca52 similar_names stop linting for 3-char names 2025-08-16 12:36:50 -04:00
Ada Alakbarova 8418fb8eb1 shorten expr_block 2025-08-16 15:56:22 +02:00
Ada Alakbarova 42ddaa3a38 inline ctxt; use eq_ctxt 2025-08-16 15:56:22 +02:00
Ada Alakbarova 27784f29a7 use str::ends_with 2025-08-16 15:56:22 +02:00
Ada Alakbarova 43f832d37b use Option::is_some_and 2025-08-16 15:56:21 +02:00
Timo aa8b09d468 clean-up unnecessary_unwrap a bit (#15489)
changelog: none
2025-08-16 01:24:43 +00:00
Ada Alakbarova a8b52bacfe clean-up unnecessary_unwrap a bit
replace multiple `if-let`s with `match`

turn the condition into a match guard

allows removing the `else` branch

replace `Vec::append` with `extend`

don't need the second vec after this operation anyway

remove `return`s
2025-08-16 03:03:53 +02:00
Jason Newcomb 9563a5ce46 {borrow,ptr}_as_ptr: don't lint inside proc-macros (#15473)
this could arguably be 2 separate PRs, but both of these were brought up
in the same issue, so..

fixes https://github.com/rust-lang/rust-clippy/issues/15398

- [x] I'm a bit doubtful about the last commit -- see the message for my
reasoning and do let me know whether it's right.

changelog: [`borrow_as_ptr`]: don't lint inside proc-macros
changelog: [`ptr_as_ptr`]: don't lint inside proc-macros
2025-08-15 13:34:52 +00:00
Ada Alakbarova 9570ed8363 ptr_as_ptr: don't allow in proc-macros
notice that this stops `inline!` from working as well
2025-08-15 14:04:37 +02:00
Ada Alakbarova 22bbb4eba2 use let-else to reduce nesting
..and create a nice linear structure
2025-08-14 23:17:54 +02:00
Ada Alakbarova 066bdb2155 replace with ? 2025-08-14 23:14:12 +02:00
Timo aeaa348b42 unnecessary_operation: add space between stmts in suggestion (#15432)
makes the suggestion a bit more legible

changelog: [`unnecessary_operation`]: add space between stmts in
suggestion
2025-08-14 18:06:06 +00:00
Timo 871df561a0 Fix match_ref_pats FP on match scrutinee of never type (#15474)
Closes rust-lang/rust-clippy#15378

changelog: [`match_ref_pats`] fix FP on match scrutinee of never type
2025-08-14 18:02:36 +00:00
dswij 3e86f05b89 result_large_err: get DefId from AdtDef instead of expecting (#15467)
tiny simplification

changelog: none
2025-08-14 11:06:08 +00:00
Timo ca194053d1 Adjust declare_interior_mutable_const lint's category (#15454)
Per the root readme, `clippy::style` is a category with

> code that should be written in a more idiomatic way

description.

The code this lint guards from may be much worse than badly styled:

```rs
use std::sync::LazyLock;

// `const` instead of `static` causes `dbg!` to be printed 10 times
// instead of one.
const LICENSE_FILE_NAME_REGEX: LazyLock<String> = LazyLock::new(|| {
    dbg!("I am a large regex initialized in a lazy lock!");
    format!("Hello {}", "World".to_string())
});

fn main() {
    for _ in 0..10 {
        let _ = LICENSE_FILE_NAME_REGEX.split(" ");
    }
}
```

In large projects, it's unfortunate but sometimes possible to see style
lints suppressed with

```toml
[workspace.lints.clippy]
style = { level = "allow", priority = -1 }
```

effectively turning off crucial checks for the code like above.

To keep them, promote this lint to `clippy::suspicious`:

> code that is most likely wrong or useless

category that has the same, `warn` default level, thus not failing on
false-positives which lead to
https://github.com/rust-lang/rust-clippy/issues/5863

---

changelog: [`declare_interior_mutable_const`]: promote lint's category
to `clippy::suspicious`
2025-08-14 08:29:55 +00:00
yanglsh 05c2d72abc fix: match_ref_pats FP on match scrutinee of never type 2025-08-14 11:23:31 +08:00
Philipp Krones b3faf62b28 Bump slab from 0.4.10 to 0.4.11 in /clippy_test_deps (#15471)
Bumps [slab](https://github.com/tokio-rs/slab) from 0.4.10 to 0.4.11.

changelog: none
2025-08-13 20:26:59 +00:00
Ada Alakbarova e19a11f3ac misc: import macros explicitly 2025-08-13 19:35:32 +02:00
Ada Alakbarova bc0e43c0f2 fix borrow_as_ptr: don't lint in proc-macros 2025-08-13 19:35:31 +02:00
Ada Alakbarova 371b174711 misc: move is_expr_temporary_value check into let-chain
we return `false` outside of the `if` anyway
2025-08-13 19:35:31 +02:00
Jason Newcomb 355e4bacf5 as_ptr_cast: move the unfixable case into a separate file (#15475)
allows creating `.fixed` for the main file

changelog: none
2025-08-13 17:11:14 +00:00
Jason Newcomb 6659540425 move char_lit_as_u8 under the explicit-cast case (#15477)
allows reusing `cast_from_expr` and `cast_to`

also make the test files a bit more.. standard

changelog: none
2025-08-13 17:08:30 +00:00
Ada Alakbarova e6f3cb00a7 move char_lit_as_u8 into the if
allows reusing `cast_from_expr` and `cast_to`
2025-08-13 16:44:32 +02:00
Ada Alakbarova ff2b5e66a1 test: make suggestions the main file
since it's the one that has suggestions
2025-08-13 16:34:24 +02:00
Ada Alakbarova ad9686e0c7 test: move the main file to unfixable
since it's the one that makes no suggestions
2025-08-13 16:33:48 +02:00
Ada Alakbarova f0bb5cde69 as_ptr_cast: move the unfixable case into a separate file
allows creating `.fixed` for the main file
2025-08-13 16:09:04 +02:00
dependabot[bot] e28266dbc0 Bump slab from 0.4.10 to 0.4.11 in /clippy_test_deps
Bumps [slab](https://github.com/tokio-rs/slab) from 0.4.10 to 0.4.11.
- [Release notes](https://github.com/tokio-rs/slab/releases)
- [Changelog](https://github.com/tokio-rs/slab/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/slab/compare/v0.4.10...v0.4.11)

---
updated-dependencies:
- dependency-name: slab
  dependency-version: 0.4.11
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-13 04:41:26 +00:00
dswij 306d4e39de fix unnecessary_semicolon: don't lint on stmts with attrs (#15466)
fixes https://github.com/rust-lang/rust-clippy/issues/15426

changelog: [`unnecessary_semicolon`]: don't lint on statements with
attributes
2025-08-12 19:56:16 +00:00
Ada Alakbarova 8725fac6f3 misc: use Ty::is_unit 2025-08-12 19:36:03 +02:00
Ada Alakbarova 7f23aba595 get DefId from AdtDef instead of expecting 2025-08-12 19:28:33 +02:00
Ada Alakbarova af2dd2d3bc fix unnecessary_semicolon: don't lint on stmts with attrs 2025-08-12 19:12:47 +02:00
Philipp Krones 874f1c8dc0 Update actions/checkouts to v5 (#15457)
Update
[actions/checkouts](https://github.com/actions/checkout?tab=readme-ov-file#usage)
to v5

changelog: none
2025-08-11 17:59:04 +00:00
Samuel Tardieu dfbbeee151 Get myself off assignment rotation (#15459)
r? ghost
changelog: none
2025-08-11 16:31:45 +00:00
Samuel Tardieu 2ba5fe8ddc Get myself off assignment rotation 2025-08-11 18:26:24 +02:00
Alexey Semenyuk 696d96daa1 Update actions/checkouts to v5 2025-08-11 19:40:49 +05:00
Alejandra González 1f9a6ad00e Correct needless_borrow_for_generic_args doc comment (#15440)
I think the comment is meant to refer to `needless_borrow_count`.

changelog: none
2025-08-11 14:30:14 +00:00
Philipp Krones 02eb548054 doc: use is_some_and instead of map_or(false, _) (#15455)
see
https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or

changelog: none
2025-08-11 11:04:51 +00:00
Ada Alakbarova 2293095c91 doc: use is_some_and instead of map_or(false, _)
see
https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
2025-08-11 09:48:20 +02:00
Kirill Bulatov a43e386280 Adjust declare_interior_mutable_const lint's category
Per the root readme, `clippy::style` is a category with

> code that should be written in a more idiomatic way

description.

The code this lint guards from may be much worse than badly styled:

```rs
use std::sync::LazyLock;

// `const` instead of `static` causes `dbg!` to be printed 10 times
// instead of one.
const LICENSE_FILE_NAME_REGEX: LazyLock<String> = LazyLock::new(|| {
    dbg!("I am large regex initialized in a lazy lock!");
    format!("Hello {}", "World".to_string())
});

fn main() {
    for _ in 0..10 {
        let _ = LICENSE_FILE_NAME_REGEX.split(" ");
    }
}
```

In large projects, it's unfortunate but sometimes possible to see style lints suppressed with

```toml
[workspace.lints.clippy]
style = { level = "allow", priority = -1 }
```

effectively turning off crucial checks for the code like above.

To keep them, promote this lint to `clippy::suspicious`:

> code that is most likely wrong or useless

category that has the same, `warn` default level, thus not failing on false-positives which lead to https://github.com/rust-lang/rust-clippy/issues/5863
2025-08-11 10:11:41 +03:00
Alex Macleod 7dd3ecb1f9 Update CONTRIBUTING.md to use RustRover instead of IntelliJ Rust (#15448)
JetBrains has transitioned from the IntelliJ Rust plugin to RustRover as
their dedicated Rust IDE. This updates the documentation to reflect this
change while maintaining backward compatibility with the existing `cargo
dev setup intellij` command.

Changes:
- Replace IntelliJ Rust references with RustRover in CONTRIBUTING.md
- Update links to point to official RustRover homepage
- Update development guide in book/src/development/basics.md
- Keep existing command names for backward compatibility

**Question**: Do we also need to change the `intellij` command to
`rustrover`?

fixes rust-lang/rust-clippy#15406

changelog: Update CONTRIBUTING.md to reference RustRover instead of
deprecated IntelliJ Rust
2025-08-10 13:52:35 +00:00
Timo 14dfc03597 feat: introduce path_to_local_with_projections (#15396)
As suggested in
https://github.com/rust-lang/rust-clippy/pull/15268#discussion_r2249249661

WIP because:
- [x] what should be done with the now-error-pattern-less
`tests/ui/double_ended_iterator_last_unfixable.rs`?
- [x] is the change in behaviour of `double_ended_iterator_last` okay in
general?
- cc @samueltardieu because this changes the code you added in
https://github.com/rust-lang/rust-clippy/pull/14140

changelog: none

r? @y21
2025-08-10 10:33:05 +00:00
Samuel Tardieu e6b63d15fa fix &str type check in from_str_radix_10 (#15410)
minor fix in `from_str_radix_10` lint, `is_type_diagnostic_item` only
checks `Adt`, use `.is_str()` instead

changelog: [`from_str_radix_10`]: properly lint references to `&str` as
well
2025-08-09 22:30:18 +00:00
llogiq f3ced4d1c1 expect_fun_call: move helper functions out of the main one (#15446)
just a clean-up

changelog: none
2025-08-09 21:47:37 +00:00
Ada Alakbarova 04606e27dc introduce path_to_local_with_projections
combine two similar arms

use in `eager_transmute`

use in `double_ended_iterator_last`

use different numbers in the new test case to avoid possible confusion

move the other "unfixable" case as well; it shouldn't lint anyway, so
having it in the main test file is fine
2025-08-09 20:27:30 +02:00