rust/tests
Matthias Krüger 1b4b0e9a4d
Rollup merge of #125834 - workingjubilee:weaken-thir-unsafeck-for-addr-of-static-mut, r=compiler-errors
treat `&raw (const|mut) UNSAFE_STATIC` implied deref as safe

Fixes rust-lang/rust#125833

As reported in that and related issues, `static mut STATIC_MUT: T` is very often used in embedded code, and is in many ways equivalent to `static STATIC_CELL: SyncUnsafeCell<T>`. The Rust expression of `&raw mut STATIC_MUT` and `SyncUnsafeCell::get(&STATIC_CELL)` are approximately equal, and both evaluate to `*mut T`. The library function is safe because it has *declared itself* to be safe. However, the raw ref operator is unsafe because all uses of `static mut` are considered unsafe, even though the static's value is not used by this expression (unlike, for example, `&STATIC_MUT`).

We can fix this unnatural difference by simply adding the proper exclusion for the safety check inside the THIR unsafeck, so that we do not declare it unsafe if it is not.

While the primary concern here is `static mut`, this change is made for all instances of an "unsafe static", which includes a static declared inside `extern "abi" {}`. Hypothetically, we could go as far as generalizing this to all instances of `&raw (const|mut) *ptr`, but today we do not, as we have not actually considered the range of possible expressions that use a similar encoding. We do not even extend this to thread-local equivalents, because they have less clear semantics.
2024-07-23 13:06:54 +02:00
..
assembly Auto merge of #123351 - beetrees:x86-ret-snan-rust, r=nikic,workingjubilee 2024-07-12 20:36:43 +00:00
auxiliary
codegen Auto merge of #127715 - klensy:tests-w, r=Mark-Simulacrum 2024-07-21 03:06:32 +00:00
codegen-units Avoid MIR bloat in inlining 2024-07-01 05:17:13 -07:00
coverage Bless coverage. 2024-07-13 12:02:12 +00:00
coverage-run-rustdoc coverage: Extract hole spans from HIR instead of MIR 2024-07-08 21:22:56 +10:00
crashes Rollup merge of #128036 - matthiaskrgr:ccrashes, r=jieyouxu 2024-07-22 11:40:22 -05:00
debuginfo Add Natvis visualiser and debuginfo tests for f16 2024-07-09 03:47:50 +01:00
incremental Auto merge of #126409 - pacak:incr-uplorry, r=michaelwoerister 2024-06-20 09:06:16 +00:00
mir-opt Auto merge of #127722 - BoxyUwU:new_adt_const_params_limitations, r=compiler-errors 2024-07-21 05:36:21 +00:00
pretty Mark format! with must_use hint 2024-07-06 14:24:20 +02:00
run-make Auto merge of #127778 - Oneirical:artificial-intestlligence, r=jieyouxu 2024-07-23 01:51:57 +00:00
run-pass-valgrind
rustdoc Auto merge of #120812 - compiler-errors:impl-sorting, r=lcnr 2024-07-21 22:43:47 +00:00
rustdoc-gui Add regression test for items list size (#128023) 2024-07-22 11:33:03 +02:00
rustdoc-js
rustdoc-js-std
rustdoc-json Update all rustdoc-json/ tests to use the new style 2024-07-19 16:54:42 +02:00
rustdoc-ui Move all error reporting into rustc_trait_selection 2024-07-21 22:34:35 -04:00
ui Rollup merge of #125834 - workingjubilee:weaken-thir-unsafeck-for-addr-of-static-mut, r=compiler-errors 2024-07-23 13:06:54 +02:00
ui-fulldeps Auto merge of #125915 - camelid:const-arg-refactor, r=BoxyUwU 2024-07-19 08:44:51 +00:00
COMPILER_TESTS.md