Commit graph

2417 commits

Author SHA1 Message Date
Philipp Krones
9aa70f2bdd
Bump nightly version -> 2025-10-16 2025-10-16 15:57:16 +02:00
Philipp Krones
cf7aaa5ecf
Merge remote-tracking branch 'upstream/master' into rustup 2025-10-16 15:57:00 +02:00
Diggory Blake
e8fec08b9c Restrict sysroot crate imports to those defined in this repo.
It's common to import dependencies from the sysroot via `extern crate`
rather than use an explicit cargo dependency, when it's necessary to use
the same dependency version as used by rustc itself. However, this is
dangerous for crates.io crates, since rustc may not pull in the
dependency on some targets, or may pull in multiple versions. In both
cases, the `extern crate` fails to resolve.

To address this, re-export all such dependencies from the appropriate
`rustc_*` crates, and use this alias from crates which would otherwise
need to use `extern crate`.
2025-10-15 13:17:25 +01:00
Samuel Tardieu
5de7da824c
New internal lint: unusual_names
This lint aims at detecting unusual names used in Clippy source code,
such as `appl` or `application` for a `rustc_errors::Applicability`
variable, instead of `app` and `applicability` which are commonly used
throughout Clippy.

This helps maintaining the consistency of the Clippy source code.
2025-10-11 09:37:25 +02:00
Jason Newcomb
6bfb524e9a Remove is_trait_item 2025-10-10 23:15:59 -04:00
Jason Newcomb
e69d88bb10 Remove is_trait_method 2025-10-10 23:15:59 -04:00
Jason Newcomb
d0be3356ba Remove is_inherent_method_call 2025-10-10 23:12:44 -04:00
Jason Newcomb
e78f86d550 Remove is_diag_item_method 2025-10-10 23:09:26 -04:00
Jason Newcomb
2e6729ea64 Remove is_diag_trait_item 2025-10-10 23:09:26 -04:00
Jason Newcomb
a6078f87db Remove path_to_local_id 2025-10-10 23:09:26 -04:00
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
Camille Gillot
15575602da Remove StatementKind::Deinit. 2025-10-10 12:57:24 +00: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
Boxy Uwu
f6336bc8e4 rename select_where_possible and select_all_or_error 2025-10-07 23:02:23 +01: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
843f4d8488 Merge commit '2dc84cb744' into clippy-subtree-update 2025-10-06 18:10:37 +02: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