Files
rust/tests/ui/lint
Matthias Krüger b849aa9f61 Rollup merge of #138360 - Urgau:fix-fp-expr_or_init, r=wesleywiser
Fix false-positive in `expr_or_init` and in the `invalid_from_utf8` lint

This PR fixes the logic for finding initializer in the `expr_or_init` and `expr_or_init_with_outside_body` functions.

If the binding were to be mutable (`let mut`), the logic wouldn't consider that the initializer expression could have been modified and would return the init expression even-trough multiple subsequent assignments could have been done.

Example:
```rust
let mut a = [99, 108, 130, 105, 112, 112]; // invalid, not UTF-8
loop {
    a = *b"clippy"; // valid
    break;
}
std::str::from_utf8_mut(&mut a); // currently warns, with this PR it doesn't
```

This PR modifies the logic to excludes mutable let bindings.

Found when using `expr_or_init` in https://github.com/rust-lang/rust/pull/119220.

r? compiler
2025-03-12 08:06:50 +01:00
..
2024-12-12 23:36:27 +00:00
2025-03-07 10:50:31 +08:00
2025-01-07 16:04:14 +01:00
2024-11-16 20:03:31 +00:00
2024-12-09 17:31:16 +08:00
2024-12-09 17:31:16 +08:00
2024-09-23 12:55:56 -04:00
2025-01-07 16:04:14 +01:00
2025-01-07 16:04:14 +01:00
2024-06-25 17:22:22 +02:00
2024-06-25 17:22:22 +02:00
2024-12-24 11:35:38 +08:00