Commit Graph

23365 Commits

Author SHA1 Message Date
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
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
Alex Macleod e6223005af Add "PowerPC" to the list of valid CamelCase strings in docs (#15447)
```
changelog: [`doc-valid-idents`]: add "PowerPC" to the list of words not considered as identifiers
```

---

changelog: add "PowerPC" to the list of words not considered as
identifiers by `doc-valid-idents` rule
2025-08-09 16:46:06 +00:00
reddevilmidzy aeec153974 Update CONTRIBUTING.md to use RustRover instead of IntelliJ Rust
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
2025-08-10 01:45:54 +09:00
Dave Rolsky 5c617b4867 Add "PowerPC" to the list of valid CamelCase strings in docs 2025-08-09 10:28:14 -05:00
dswij 386372a0e4 [[infinite_loop] fix infinite loop false positive (#15157)
changelog: [infinite_loop]: Improve handling of infinite loops in async
blocks

Fix rust-lang/rust-clippy#14000

This PR refines the [infinite_loop] lint to avoid false positives when
infinite loops occur inside async blocks that are not awaited (such as
those that are spawned or assigned to variables for later use). The lint
will now only trigger when the async block containing the loop is
directly awaited.
2025-08-09 15:08:54 +00:00
Jason Newcomb ea7ebaa825 Do not attempt to compute size of a type with escaping lifetimes (#15434)
A type with escaping bound vars cannot be wrapped in a dummy binder
during size computation.

Fixes rust-lang/rust-clippy#15429

changelog: [`zero_sized_hashmap_values`]: fix ICE in types with escaping
lifetimes

r? Jarcho

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

- [Beta
nomination](https://github.com/rust-lang/rust-clippy/pull/15434#issuecomment-3164866684)
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-08-09 14:09:43 +00:00
Ada Alakbarova d5f2b66bd8 expect_fun_call: move helper functions out of the main one
allows removing the `#[allow(clippy::too_many_lines)]`
2025-08-09 11:50:00 +02:00
Samuel Tardieu 388d3f3374 use a let-chain in needless_bool (#15444)
This is a small thing I noticed while looking into
https://github.com/rust-lang/rust-clippy/issues/8014. Since I ultimately
decided not to change the code as a response to the issue, I'm now left
with this one commit, and I feel a bit unsure about making a PR just for
that. This is a problem I have relatively often, so I'd like to know
whether I should to batch these small changes somehow, or whether these
small PRs are fine after all

changelog: none
2025-08-08 21:56:02 +00:00
Samuel Moelius 7057cd8f4f Correct needless_borrow_for_generic_args doc comment 2025-08-08 11:06:39 -04:00
Ada Alakbarova 82c1ce77ed misc: use let-chains 2025-08-08 16:56:39 +02:00
Samuel Tardieu 22088843b4 move crosspointer_transmute from complexity to suspicious (#15403)
changelog: [`crosspointer_transmute`]: move from `complexity` to
`suspicious`

this looks to me like an obvious miscategorisation -- and there was
already [a proposal to move the
lint](https://github.com/rust-lang/rust-clippy/issues/6626#issuecomment-1279775089)
2025-08-08 11:14:15 +00:00
Samuel Tardieu d654c267f8 eta_reduction: don't refer to ADT constructors as "function"s (#15436)
fixes https://github.com/rust-lang/rust-clippy/issues/8817

changelog: [`eta_reduction`]: don't refer to ADT constructors as
"function"s
2025-08-08 09:16:31 +00:00
Ada Alakbarova ac9361e18a eta_reduction: don't refer to ADT constructors as "function"s 2025-08-08 11:00:49 +02:00
Chengxu Bian c945393f67 fix inf loop 2025-08-07 22:17:37 -04:00
Ada Alakbarova 7aa75635c8 move crosspointer_transmute from complexity to suspicious 2025-08-07 23:44:33 +02:00
Ada Alakbarova 26cf75a18e unnecessary_operation: add space between stmts in suggestion
makes the suggestion a bit more legible
2025-08-07 23:44:28 +02:00
Alejandra González 32a216ecab Reuse previous Vec allocation in loop (#15428)
Minor optimization to avoid deallocating/reallocating a new `Vec` in the
top `check_doc` loop.

changelog: none

r? blyxyas
2025-08-07 18:21:20 +00:00
Samuel Tardieu c752fb2802 Do not attempt to compute size of a type with escaping lifetimes
A type with escaping bound vars cannot be wrapped in a dummy binder
during size computation.
2025-08-07 18:29:10 +02:00
Philipp Krones 334fb906ae Rustup (#15431)
r? @ghost

changelog: none
2025-08-07 14:53:47 +00:00