rust/tests
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
..
assembly Target definition for wasm32-wali-linux-musl to support the Wasm Linux 2025-03-10 21:26:45 -04:00
auxiliary tests: use minicore more 2025-02-24 09:26:54 +00:00
codegen Implement #[define_opaque] attribute for functions. 2025-03-11 12:05:02 +00:00
codegen-units Remove -Zinline-in-all-cgus and clean up CGU partitioning tests 2025-01-27 23:48:47 -05:00
coverage coverage: Add some more cases to tests/coverage/holes.rs 2025-02-19 13:56:20 +11:00
coverage-run-rustdoc coverage: Restrict empty-span expansion to only cover { and } 2024-11-08 20:43:08 +11:00
crashes Auto merge of #138366 - matthiaskrgr:rollup-cn16m7q, r=matthiaskrgr 2025-03-11 21:17:18 +00:00
debuginfo Rollup merge of #137967 - mustartt:fix-aix-test-hangs, r=workingjubilee 2025-03-11 13:30:50 +01:00
incremental remove most simd_ intrinsic declaration in tests 2025-02-27 12:22:59 +01:00
mir-opt Update tests. 2025-03-10 12:20:05 +01:00
pretty Fix pretty printing of parsed attrs in hir_pretty 2025-03-10 02:04:26 +00:00
run-make Auto merge of #138052 - lqd:lld-linker-messages, r=jieyouxu 2025-03-12 03:32:13 +00:00
rustdoc Rollup merge of #137764 - compiler-errors:always-applicable-negative-impl, r=lcnr 2025-03-06 12:22:16 -05:00
rustdoc-gui Rollup merge of #137539 - GuillaumeGomez:copy-content-tests, r=notriddle 2025-02-25 13:07:34 +01:00
rustdoc-js Rollup merge of #134277 - notriddle:notriddle/inline-into, r=GuillaumeGomez 2024-12-16 20:00:20 +01:00
rustdoc-js-std Remove the common prelude module 2025-02-11 13:04:27 -08:00
rustdoc-json Fix pretty printing of parsed attrs in hir_pretty 2025-03-10 02:04:26 +00:00
rustdoc-ui doctests: build test bundle and harness separately 2025-03-10 01:47:36 +01:00
ui Rollup merge of #138360 - Urgau:fix-fp-expr_or_init, r=wesleywiser 2025-03-12 08:06:50 +01:00
ui-fulldeps Revert "Don't test new error messages with the stage 0 compiler" 2025-03-08 22:45:16 +02:00
COMPILER_TESTS.md