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-11-27 07:18:25 -08:00
2025-01-22 00:00:31 -05:00
2025-03-07 10:50:31 +08:00
2025-02-10 20:21:39 +00:00
2024-12-23 20:25:41 +00:00
2025-03-11 12:05:02 +00:00
2024-12-18 19:27:44 +00:00
2024-12-12 23:36:27 +00:00
2025-02-10 20:21:39 +00:00
2024-11-27 07:18:25 -08:00
2025-02-22 23:03:14 +00:00
2024-11-27 07:18:25 -08:00
2025-03-07 10:50:31 +08:00
2025-02-10 20:21:39 +00:00
2025-02-11 08:52:08 +00:00
2025-03-06 10:50:23 +00:00
2025-02-11 19:42:47 -08:00
2025-02-11 19:42:47 -08:00
2025-02-11 19:42:47 -08:00
2024-12-23 20:25:41 +00:00
2024-11-03 13:55:52 -08:00
2024-11-03 13:55:52 -08:00
2024-12-09 17:31:16 +08:00
2024-12-09 17:31:16 +08:00
2024-12-15 23:46:42 +01:00
2024-12-20 23:48:46 +01:00
2024-12-20 23:48:46 +01:00
2024-12-02 18:43:37 +01:00
2024-12-02 18:43:37 +01:00
2024-12-02 18:43:37 +01:00
2024-12-02 18:43:37 +01:00
2025-02-10 20:21:39 +00:00
2025-02-10 20:21:39 +00:00
2024-11-27 21:48:23 +01:00
2024-11-27 21:48:23 +01:00
2024-11-27 21:48:23 +01:00
2024-11-27 21:48:23 +01:00
2024-11-27 21:48:23 +01:00
2024-11-27 21:48:23 +01:00
2024-11-27 21:48:23 +01:00
2024-11-27 21:48:23 +01:00
2024-11-27 21:48:23 +01:00
2024-11-27 15:27:41 +01:00
2024-11-27 15:27:41 +01:00
2025-01-07 16:04:14 +01:00
2024-12-09 17:39:08 +08:00
2024-12-09 17:39:08 +08:00
2025-03-11 21:56:53 +01:00
2025-03-11 21:56:53 +01:00
2025-01-09 23:47:11 -08:00
2024-10-31 21:26:36 -05:00
2024-10-31 21:26:36 -05:00
2024-10-31 21:26:36 -05:00
2024-10-31 21:26:36 -05:00
2024-10-31 21:26:36 -05:00
2024-11-26 02:50:48 +08:00
2024-11-26 02:50:48 +08:00
2024-11-26 02:50:48 +08:00
2024-11-26 02:50:48 +08:00
2025-02-10 20:21:39 +00:00
2024-11-27 15:27:41 +01:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2024-11-16 20:03:31 +00:00
2025-02-02 01:00:33 +00:00
2025-02-02 01:00:33 +00:00
2025-02-10 20:21:39 +00:00
2025-02-10 20:21:39 +00:00
2025-01-20 16:46:00 -05:00
2025-01-20 16:46:00 -05:00
2025-01-20 16:46:00 -05:00
2025-02-10 20:21:39 +00:00
2025-01-06 03:17:04 +00:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2024-12-09 17:31:16 +08:00
2024-12-09 17:31:16 +08:00
2024-12-09 17:31:16 +08:00
2025-02-11 08:30:35 +00:00
2025-02-11 08:30:35 +00:00
2024-12-09 17:31:16 +08:00
2024-12-09 17:31:16 +08:00
2025-01-07 16:04:14 +01:00
2025-01-07 16:04:14 +01:00
2025-01-26 12:18:33 +01:00
2025-01-26 12:18:33 +01:00
2025-02-20 13:39:39 +00:00
2025-02-20 13:39:39 +00:00
2024-12-23 20:25:41 +00:00
2024-12-23 20:25:41 +00:00
2024-11-26 02:50:48 +08:00
2024-11-03 13:55:52 -08:00
2025-02-09 20:39:43 +08:00
2025-02-09 20:39:43 +08:00
2024-12-27 19:58:16 +11:00
2024-11-03 13:55:52 -08:00
2024-11-03 13:55:52 -08:00
2024-11-03 13:55:52 -08:00
2024-11-03 13:55:52 -08:00
2024-11-03 13:55:52 -08:00
2025-02-10 20:21:39 +00:00
2025-02-14 00:44:10 -08:00
2025-01-26 12:18:33 +01:00
2025-01-26 12:18:33 +01:00
2024-12-12 23:36:27 +00:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2025-03-11 12:05:02 +00:00
2024-11-27 15:27:41 +01:00
2025-02-10 20:21:39 +00:00
2024-12-01 11:31:09 +13:00
2025-02-21 00:41:17 +00:00
2025-02-21 00:41:17 +00:00
2024-11-28 14:32:45 -08:00
2025-02-28 07:25:52 +05:30
2025-02-28 07:25:52 +05:30
2025-02-21 17:50:11 +00:00
2024-12-24 11:35:38 +08:00
2024-11-04 19:09:40 +01:00
2024-11-04 19:09:40 +01:00
2024-11-04 19:09:40 +01:00
2024-11-14 09:08:56 +08:00
2024-11-14 09:08:56 +08:00
2024-11-14 09:08:56 +08:00
2024-11-14 09:08:56 +08:00
2024-11-14 09:08:56 +08:00
2024-11-14 09:08:56 +08:00
2024-11-27 07:18:25 -08:00
2024-11-26 02:50:48 +08:00
2025-02-14 00:27:13 -08:00