Commit graph

2404 commits

Author SHA1 Message Date
Jason Newcomb
53675ce061 Remove path_to_local 2025-10-10 23:09:26 -04:00
Jason Newcomb
3f686a074d Remove is_res_lang_ctor 2025-10-10 23:00:17 -04:00
Jason Newcomb
3ed7aa0d5f Remove path_def_id 2025-10-10 23:00:17 -04:00
Jason Newcomb
5b659ba0b4 Remove path_res 2025-10-10 22:51:33 -04:00
Jason Newcomb
53783de8f0 Remove MaybePath 2025-10-10 22:51:33 -04:00
Jason Newcomb
e1a4c90f61 Remove get_type_diagnostic_name 2025-10-10 22:47:41 -04:00
Jason Newcomb
083b1c1059 Remove is_type_lang_item 2025-10-10 22:44:01 -04:00
Jason Newcomb
fe13e0675a Remove is_type_ref_to_diagnostic_item 2025-10-10 22:41:10 -04:00
Jason Newcomb
4914f5908f Remove is_type_diagnostic_item 2025-10-10 22:41:10 -04:00
Jason Newcomb
cb32444ee6 Remove is_path_diagnostic_item 2025-10-10 22:30:57 -04:00
Jason Newcomb
d32ef64ed5 Remove is_path_lang_item 2025-10-10 22:30:57 -04:00
Jason Newcomb
748a593a7f Add new utils for defninition identification. 2025-10-10 22:30:25 -04:00
Nick Drozd
b71fe9254d Check structs and enums for use_self 2025-10-09 18:23:12 -05:00
Timo
99b810634e
Cleanup: do not handle methods from several places (#15751)
Some methods lints were handled in the `methods` module outside the
`check_methods()` function.

changelog: none
2025-10-09 09:26:13 +00:00
Samuel Tardieu
c425389f18
Cleanup: do not handle methods from several places
Some methods lints were handled in the `methods` module outside the
`check_methods()` function.
2025-10-09 06:45:30 +02:00
yanglsh
0415d96f1e Migrate needless_continue to late pass 2025-10-08 00:03:48 +08:00
Nick Drozd
5318883d75 Use expect for lint warnings 2025-10-06 20:17:12 -04:00
Samuel Tardieu
2c71638be5
Implement volatile_composites lint (#15686)
Volatile reads and writes to non-primitive types are not well-defined,
and can cause problems.

Fixes rust-lang/rust-clippy#15529

changelog: [`volatile_composites`]: Lint when read/write_volatile is
used on composite types
(structs, arrays, etc) as their semantics are not well defined.
2025-10-06 21:06:29 +00:00
Philipp Krones
085ddaaa97
Bump nightly version -> 2025-10-06 2025-10-06 17:26:17 +02:00
Philipp Krones
15727e0522
Merge remote-tracking branch 'upstream/master' into rustup 2025-10-06 17:26:03 +02:00
Samuel Tardieu
d289009eea
Const eval changes (#15773)
First commit treats all constants containing a macro call as non-local
and renames `eval_simple` to be a little clearer.

Second commit removes `CoreConstant` and treats most of them as though
they were local. A couple of the constants like `usize::MAX` are treated
as non-local as different targets may have different values.
`const_is_empty` will now ignore non-local constants since there's no
guarantee that they are the same across all targets/features/versions.

The third commit just changes some `eval` calls to `eval_local`. Most of
these were style lints which shouldn't be assuming the value of a
constant won't ever change.

changelog: none
2025-10-04 18:16:35 +00:00
Jason Newcomb
47b0f903a3 Use eval_local in more places. 2025-10-04 10:41:35 -04:00
Jason Newcomb
3d351c839d Const eval changes:
* Remove `CoreConstant`.
* Treat most constants from core as though they were inlined.
* Don't evaluate `is_empty` for named constants.
2025-10-04 10:41:35 -04:00
bors
d36a5607d6 Auto merge of #147138 - jackh726:split-canonical-bound, r=lcnr
Split Bound index into Canonical and Bound

See [#t-types/trait-system-refactor > perf `async-closures/post-mono-higher-ranked-hang.rs`](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/perf.20.60async-closures.2Fpost-mono-higher-ranked-hang.2Ers.60/with/541535613) for context

Things compile and tests pass, but not sure if this actually solves the perf issue (edit: it does). Opening up this to do a perf (and maybe crater) run.

r? lcnr
2025-10-02 08:09:33 +00:00
Jason Newcomb
6cc8f8dbaa
Do not trigger inefficient_to_string after Rust 1.82 (#15729)
Starting with Rust version 1.82.0, the compiler generates similar code
with and without the `with_ref` cfg:

```rust
fn f(x: impl IntoIterator<Item = String>) {
    for y in x { println!("{y}"); }
}

fn main() {
    #[cfg(with_ref)]
    let a = ["foo", "bar"].iter().map(|&s| s.to_string());
    #[cfg(not(with_ref))]
    let a = ["foo", "bar"].iter().map(|s| s.to_string());
    f(a);
}
```

The generated code is strictly identical with `-O`, and identical modulo
some minor reordering without.

changelog: [`inefficient_to_string`]: do not trigger for Rust ≥ 1.82.0
2025-10-01 22:02:53 +00:00
Samuel Tardieu
951d35eeb6
Do not trigger inefficient_to_string after Rust 1.82
Starting with Rust version 1.82.0, the compiler generates similar code with
and without the `with_ref` cfg:

```rust
fn f(x: impl IntoIterator<Item = String>) {
    for y in x { println!("{y}"); }
}

fn main() {
    #[cfg(with_ref)]
    let a = ["foo", "bar"].iter().map(|&s| s.to_string());
    #[cfg(not(with_ref))]
    let a = ["foo", "bar"].iter().map(|s| s.to_string());
    f(a);
}
```

The generated code is strictly identical with `-O`, and identical modulo
some minor reordering without.
2025-10-01 23:13:33 +02:00
Alejandra González
0c7e0344cf
Do not suggest using a if let chain if it is not supported (#15746)
This might be due to a low edition (< 2024) or too low a MSRV. In this
case, we will suggest only `match`.

Fixes rust-lang/rust-clippy#15744

changelog: [`unnecessary_unwrap`]: do not suggest using `if let` chains
if this is not supported with the current edition or MSRV
changelog:[`collapsible_if`]: Do not suggest using `if let` if this is
not supported with the current edition or MSRV
2025-10-01 16:08:15 +00:00
Jason Newcomb
3e24d50407 Rename eval_simple to eval_local and take the SyntaxContext as an argument. 2025-10-01 05:20:44 -04:00
Samuel Tardieu
f1079915b4
Do not suggest using a if let chain if it is not supported
This might be due to a low edition (< 2024) or too low a MSRV.
2025-10-01 07:41:49 +02:00
Jason Newcomb
61b1f0e37f assertions_on_constants: Don't suggest removing assertions with non-local constants. 2025-09-30 13:59:06 -04:00
jackh726
1db4d8ebfd Split Bound into Canonical and Bound 2025-09-30 12:58:28 -04:00
Ada Alakbarova
6b4febeeb7
simplify and inline is_async_fn 2025-09-28 17:31:03 +02:00
Jeremy Fitzhardinge
1d7c1afde0 Implement volatile_composites lint
Volatile reads and writes to non-primitive types are not well-defined, and can cause problems.

See https://github.com/rust-lang/rust-clippy/issues/15529 for more details.
2025-09-27 16:22:00 -07:00
beepster4096
36d6327fa4 castkind::subtype in clippy 2025-09-26 12:19:25 -07:00
Jason Newcomb
abdc61fb88
filter_next: check for filter().next_back() (#15748)
Closes: rust-lang/rust-clippy#15715

changelog: [`filter_next`]: suggest replacing `filter().next_back()`
with `rfind()` for `DoubleEndedIterator`
2025-09-26 08:02:18 +00:00
Samuel Tardieu
24b0282344
inline clippy_utils::ptr into needless_pass_by_value (#15760)
While looking into
https://github.com/rust-lang/rust-clippy/issues/15569, I stumbled upon
`clippy_utils::ptr`.

This module was created in
https://github.com/rust-lang/rust-clippy/pull/2117, to share the logic
from `ptr_arg` with `needless_pass_by_value`. But then later,
https://github.com/rust-lang/rust-clippy/pull/8409 removed the use of
the logic from `ptr_arg`, which left `needless_pass_by_value` as the
only user of this module.

Still, I wanted to try to add docs to the module, but the two functions
looked all too specific, so I thought it'd be better to just move them
to `needless_pass_by_value`, in the hopes that whoever is looking at
that lint will hopefully have enough context to understand what those
functions are doing.

changelog: none
2025-09-25 21:21:24 +00:00
Ada Alakbarova
bd39ea463f
inline clippy_utils::ptr into needless_pass_by_value
..and make it less generic, thanks to all the callers being known
2025-09-25 20:34:10 +02:00
Zihan
56194654c6
filter_next: check for filter().next_back()
changelog: [`filter_next`]: suggest replacing `filter().next_back()` with
`rfind()` for `DoubleEndedIterator`

Signed-off-by: Zihan <zihanli0822@gmail.com>
2025-09-25 09:27:41 -04:00
Jason Newcomb
4b236fc18a
fix(collapsible{,_else}_if): respect #[expect] on inner if (#15647)
Fixes https://github.com/rust-lang/rust-clippy/issues/13365

Pretty much the exact approach described in
https://github.com/rust-lang/rust-clippy/issues/13365#issuecomment-2344850167,
thank you @Jarcho!
r? @Jarcho

changelog: [`collapsible_if`]: respect `#[expect]` on inner `if`
changelog: [`collapsible_else_if`]: respect `#[expect]` on inner `if`
2025-09-25 07:03:34 +00:00
Ada Alakbarova
7449d63ab7
fix(or_fun_call): respect MSRV for Result::unwrap_or_default suggestion 2025-09-24 19:25:08 +02:00
Alejandra González
c2325dcb75
Note that using enumerate() will swap the arguments (#14969)
The autofix now:

- includes the swapping of index and element in the closure in which the
content will be consumed;
- notes, with applicability `MaybeIncorrect` (because it will be), that
the element and the index will be swapped.

changelog: [`range_zip_with_len`]: better suggestion, and better
applicability

Fixes rust-lang/rust-clippy#14929
2025-09-19 17:14:42 +00:00
Philipp Krones
47bcee4ee2 Merge commit '20ce69b9a6' into clippy-subtree-update 2025-09-18 17:21:44 +02:00
Philipp Krones
6b14443a02
Bump Clippy version -> 0.1.92 2025-09-18 16:59:44 +02:00
Philipp Krones
2c7350269c
Bump nightly version -> 2025-09-18 2025-09-18 16:59:20 +02:00
Philipp Krones
2d3efb0f0b
Merge remote-tracking branch 'upstream/master' into rustup 2025-09-18 16:59:09 +02:00
Stuart Cook
2267234673 Rollup merge of #146664 - fmease:clean-up-dyn, r=jdonszelmann
Clean up `ty::Dynamic`

1. As a follow-up to PR rust-lang/rust#143036, remove `DynKind` entirely.
2. Inside HIR ty lowering, consolidate modules `dyn_compatibility` and `lint` into `dyn_trait`
   * `dyn_compatibility` wasn't about dyn compatibility itself, it's about lowering trait object types
   * `lint` contained dyn-Trait-specific diagnostics+lints only
2025-09-18 11:48:51 +10:00
Samuel Tardieu
c1f782919b
match_as_ref: do not lint if other arm is not None => None 2025-09-17 19:35:05 +02:00
León Orell Valerian Liehr
4d931e643a Remove DynKind 2025-09-17 04:46:46 +02:00
Camille Gillot
4516fee8cb Remove Rvalue::Len. 2025-09-16 22:23:19 +00:00
Ada Alakbarova
593a9c98ae
fix(collapsible{,_else}_if): respect #[expect] on inner if 2025-09-16 10:28:01 +02:00