File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 1
- //@ run-pass
2
- // Issue #7988
3
- // Transmuting non-immediate type to immediate type
1
+ //! This test verifies the correct behavior of `std::mem::transmute` when converting
2
+ //! a value from a single-element array type (`[isize; 1]`) to a scalar integer type (`isize`).
3
+ //! This is a regression test ensuring that such transmutations, where source and destination
4
+ //! types have the same size and alignment but differ in their "immediacy" or structure,
5
+ //! are handled correctly.
6
+ //!
7
+ //! Regression test: <https://github.com/rust-lang/rust/issues/7988>
4
8
9
+ //@ run-pass
5
10
6
11
pub fn main ( ) {
7
12
unsafe {
8
- :: std:: mem:: transmute :: < [ isize ; 1 ] , isize > ( [ 1 ] )
9
- } ;
13
+ // Transmute a single-element array `[1]` (which might be treated as a "non-immediate" type)
14
+ // to a scalar `isize` (an "immediate" type).
15
+ // This is safe because `[isize; 1]` and `isize` have the same size and alignment.
16
+ :: std:: mem:: transmute :: < [ isize ; 1 ] , isize > ( [ 1 ] ) ;
17
+ }
10
18
}
You can’t perform that action at this time.
0 commit comments