fork/rust
git clone https://git.julia.blue/fork/rust
4fb7144ed15
1.43.0
1error[E0080]: it is undefined behavior to use this value 2 --> $DIR/ub-nonnull.rs:11:1 3 | 4LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; 5 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 6 | 7 = 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. 8 9error: any use of this value will cause an error 10 --> $DIR/ub-nonnull.rs:18:29 11 | 12LL | / const OUT_OF_BOUNDS_PTR: NonNull<u8> = { unsafe { 13LL | | let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle 14LL | | // Use address-of-element for pointer arithmetic. This could wrap around to NULL! 15LL | | let out_of_bounds_ptr = &ptr[255]; 16 | | ^^^^^^^^^ Memory access failed: pointer must be in-bounds at offset 256, but is outside bounds of allocation 8 which has size 1 17LL | | mem::transmute(out_of_bounds_ptr) 18LL | | } }; 19 | |____- 20 | 21note: the lint level is defined here 22 --> $DIR/ub-nonnull.rs:14:8 23 | 24LL | #[deny(const_err)] // this triggers a `const_err` so validation does not even happen 25 | ^^^^^^^^^ 26 27error[E0080]: it is undefined behavior to use this value 28 --> $DIR/ub-nonnull.rs:22:1 29 | 30LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; 31 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 32 | 33 = 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. 34 35error[E0080]: it is undefined behavior to use this value 36 --> $DIR/ub-nonnull.rs:24:1 37 | 38LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; 39 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 40 | 41 = 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. 42 43error[E0080]: it is undefined behavior to use this value 44 --> $DIR/ub-nonnull.rs:32:1 45 | 46LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; 47 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes at .0, but expected initialized plain (non-pointer) bytes 48 | 49 = 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. 50 51error[E0080]: it is undefined behavior to use this value 52 --> $DIR/ub-nonnull.rs:40:1 53 | 54LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; 55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 42, but expected something in the range 10..=30 56 | 57 = 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. 58 59error[E0080]: it is undefined behavior to use this value 60 --> $DIR/ub-nonnull.rs:46:1 61 | 62LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; 63 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 20, but expected something less or equal to 10, or greater or equal to 30 64 | 65 = 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. 66 67error: aborting due to 7 previous errors 68 69For more information about this error, try `rustc --explain E0080`.