|
| 1 | +error[E0080]: constructing invalid value at .<deref>: encountered a pointer, but expected an integer |
| 2 | + --> $DIR/promotion-in-const-validation.rs:3:1 |
| 3 | + | |
| 4 | +LL | const _: &usize = unsafe { &std::mem::transmute(foo as fn()) }; |
| 5 | + | ^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 6 | + | |
| 7 | + = help: this code performed an operation that depends on the underlying bytes representing a pointer |
| 8 | + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 9 | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 10 | + = note: the raw bytes of the constant (size: 8, align: 8) { |
| 11 | + ╾ALLOC0<imm>╼ │ ╾──────╼ |
| 12 | + } |
| 13 | + |
| 14 | +note: erroneous constant encountered |
| 15 | + --> $DIR/promotion-in-const-validation.rs:3:28 |
| 16 | + | |
| 17 | +LL | const _: &usize = unsafe { &std::mem::transmute(foo as fn()) }; |
| 18 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 19 | + |
| 20 | +error[E0080]: unable to turn pointer into integer |
| 21 | + --> $DIR/promotion-in-const-validation.rs:6:1 |
| 22 | + | |
| 23 | +LL | const _: usize = unsafe { std::mem::transmute(foo as fn()) }; |
| 24 | + | ^^^^^^^^^^^^^^ evaluation of `_` failed here |
| 25 | + | |
| 26 | + = help: this code performed an operation that depends on the underlying bytes representing a pointer |
| 27 | + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 28 | + |
| 29 | +error: aborting due to 2 previous errors |
| 30 | + |
| 31 | +For more information about this error, try `rustc --explain E0080`. |
0 commit comments