Files
rust/tests/ui/transmute/transmute-array-to-scalar.rs
Kivooeo 98934707eb cleaned up some tests
Additionally, remove unused `tests/ui/auxiliary/svh-*` crates that are duplicates of `tests/ui/svh/auxiliary/svh-*`.
2025-07-13 00:03:31 +05:00

15 lines
503 B
Rust

//! Verify transmuting from a single-element array to a scalar is allowed.
//!
//! Regression test: <https://github.com/rust-lang/rust/issues/7988>
//@ run-pass
pub fn main() {
unsafe {
// Transmute a single-element array `[1]` (which might be treated as a "non-immediate" type)
// to a scalar `isize` (an "immediate" type).
// This is safe because `[isize; 1]` and `isize` have the same size and alignment.
::std::mem::transmute::<[isize; 1], isize>([1]);
}
}