Volatile reads and writes to non-primitive types are not well-defined,
and can cause problems.
Fixesrust-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.
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
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
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.
This might be due to a low edition (< 2024) or too low a MSRV. In this
case, we will suggest only `match`.
Fixesrust-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
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
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
Fixesrust-lang/rust-clippy#14929
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