1
Fork 0

Auto merge of #86194 - RalfJung:const-ub-hard-error, r=oli-obk

make UB during CTFE a hard error

This is a next step for https://github.com/rust-lang/rust/issues/71800. `const_err` has been a future-incompatibility lint for 4 months now since https://github.com/rust-lang/rust/pull/80394 (and err-by-default for many years before that), so I think we could try making it a proper hard error at least in some situations.

I didn't yet adjust the tests, since I first want to gauge the fall-out via crater.
Cc `@rust-lang/wg-const-eval`
This commit is contained in:
bors 2021-06-18 23:17:40 +00:00
commit ec57c60c50
25 changed files with 342 additions and 865 deletions

View file

@ -525,6 +525,7 @@ impl InterpError<'_> {
use InterpError::*; use InterpError::*;
match *self { match *self {
MachineStop(ref err) => err.is_hard_err(), MachineStop(ref err) => err.is_hard_err(),
InterpError::UndefinedBehavior(_) => true,
_ => false, _ => false,
} }
} }

View file

@ -5,9 +5,8 @@ use std::mem;
// Make sure we error with the right kind of error on a too large slice. // Make sure we error with the right kind of error on a too large slice.
const TEST: () = { unsafe { const TEST: () = { unsafe {
let slice: *const [u8] = mem::transmute((1usize, usize::MAX)); let slice: *const [u8] = mem::transmute((1usize, usize::MAX));
let _val = &*slice; //~ ERROR: any use of this value will cause an error let _val = &*slice; //~ ERROR: evaluation of constant value failed
//~| slice is bigger than largest supported object //~| slice is bigger than largest supported object
//~| WARN this was previously accepted by the compiler but is being phased out
} }; } };
fn main() {} fn main() {}

View file

@ -1,18 +1,9 @@
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/dangling.rs:8:16 --> $DIR/dangling.rs:8:16
| |
LL | / const TEST: () = { unsafe { LL | let _val = &*slice;
LL | | let slice: *const [u8] = mem::transmute((1usize, usize::MAX)); | ^^^^^^^ invalid metadata in wide pointer: slice is bigger than largest supported object
LL | | let _val = &*slice;
| | ^^^^^^^ invalid metadata in wide pointer: slice is bigger than largest supported object
LL | |
LL | |
LL | | } };
| |____-
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.

View file

@ -8,8 +8,7 @@ const FOO: i32 = foo();
const fn foo() -> i32 { const fn foo() -> i32 {
unsafe { unsafe {
let _ = intrinsics::const_allocate(4, 3) as * mut i32; let _ = intrinsics::const_allocate(4, 3) as * mut i32;
//~^ error: any use of this value will cause an error [const_err] //~^ error: evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
} }
1 1

View file

@ -1,19 +1,15 @@
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/alloc_intrinsic_errors.rs:10:17 --> $DIR/alloc_intrinsic_errors.rs:10:17
| |
LL | const FOO: i32 = foo(); LL | const FOO: i32 = foo();
| ----------------------- | ----- inside `FOO` at $DIR/alloc_intrinsic_errors.rs:7:18
... ...
LL | let _ = intrinsics::const_allocate(4, 3) as * mut i32; LL | let _ = intrinsics::const_allocate(4, 3) as * mut i32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | | |
| align has to be a power of 2, `3` is not a power of 2 | align has to be a power of 2, `3` is not a power of 2
| inside `foo` at $DIR/alloc_intrinsic_errors.rs:10:17 | inside `foo` at $DIR/alloc_intrinsic_errors.rs:10:17
| inside `FOO` at $DIR/alloc_intrinsic_errors.rs:7:18
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.

View file

@ -17,8 +17,7 @@ const fn wat(x: u64) -> &'static u64 {
unsafe { transmute(&x) } unsafe { transmute(&x) }
} }
const X: u64 = *wat(42); const X: u64 = *wat(42);
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
fn main() { fn main() {
println!("{}", X); println!("{}", X);

View file

@ -1,14 +1,9 @@
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/issue-49296.rs:19:16 --> $DIR/issue-49296.rs:19:16
| |
LL | const X: u64 = *wat(42); LL | const X: u64 = *wat(42);
| ---------------^^^^^^^^- | ^^^^^^^^ pointer to alloc1 was dereferenced after this allocation got freed
| |
| pointer to alloc1 was dereferenced after this allocation got freed
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.

View file

@ -1,30 +1,17 @@
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/ub-incorrect-vtable.rs:19:14 --> $DIR/ub-incorrect-vtable.rs:19:14
| |
LL | / const INVALID_VTABLE_ALIGNMENT: &dyn Trait = LL | unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) };
LL | | unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid vtable: alignment `1000` is not a power of 2
| |______________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^__-
| |
| invalid vtable: alignment `1000` is not a power of 2
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/ub-incorrect-vtable.rs:25:14 --> $DIR/ub-incorrect-vtable.rs:24:14
| |
LL | / const INVALID_VTABLE_SIZE: &dyn Trait = LL | unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) };
LL | | unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid vtable: size is bigger than largest supported object
| |______________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^__-
| |
| invalid vtable: size is bigger than largest supported object
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-incorrect-vtable.rs:36:1 --> $DIR/ub-incorrect-vtable.rs:34:1
| |
LL | / const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = LL | / const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> =
LL | | unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1usize, 1000usize))) }; LL | | unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1usize, 1000usize))) };
@ -36,7 +23,7 @@ LL | | unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1us
} }
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-incorrect-vtable.rs:41:1 --> $DIR/ub-incorrect-vtable.rs:39:1
| |
LL | / const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = LL | / const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> =
LL | | unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usize::MAX, 1usize))) }; LL | | unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usize::MAX, 1usize))) };

View file

@ -1,30 +1,17 @@
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/ub-incorrect-vtable.rs:19:14 --> $DIR/ub-incorrect-vtable.rs:19:14
| |
LL | / const INVALID_VTABLE_ALIGNMENT: &dyn Trait = LL | unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) };
LL | | unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid vtable: alignment `1000` is not a power of 2
| |______________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^__-
| |
| invalid vtable: alignment `1000` is not a power of 2
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/ub-incorrect-vtable.rs:25:14 --> $DIR/ub-incorrect-vtable.rs:24:14
| |
LL | / const INVALID_VTABLE_SIZE: &dyn Trait = LL | unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) };
LL | | unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid vtable: size is bigger than largest supported object
| |______________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^__-
| |
| invalid vtable: size is bigger than largest supported object
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-incorrect-vtable.rs:36:1 --> $DIR/ub-incorrect-vtable.rs:34:1
| |
LL | / const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = LL | / const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> =
LL | | unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1usize, 1000usize))) }; LL | | unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1usize, 1000usize))) };
@ -36,7 +23,7 @@ LL | | unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1us
} }
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-incorrect-vtable.rs:41:1 --> $DIR/ub-incorrect-vtable.rs:39:1
| |
LL | / const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = LL | / const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> =
LL | | unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usize::MAX, 1usize))) }; LL | | unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usize::MAX, 1usize))) };

View file

@ -17,14 +17,12 @@ trait Trait {}
const INVALID_VTABLE_ALIGNMENT: &dyn Trait = const INVALID_VTABLE_ALIGNMENT: &dyn Trait =
unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) }; unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARNING this was previously accepted by the compiler
//~| invalid vtable: alignment `1000` is not a power of 2 //~| invalid vtable: alignment `1000` is not a power of 2
const INVALID_VTABLE_SIZE: &dyn Trait = const INVALID_VTABLE_SIZE: &dyn Trait =
unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) }; unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARNING this was previously accepted by the compiler
//~| invalid vtable: size is bigger than largest supported object //~| invalid vtable: size is bigger than largest supported object
#[repr(transparent)] #[repr(transparent)]

View file

@ -9,29 +9,14 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
00 00 00 00 │ .... 00 00 00 00 │ ....
} }
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/ub-nonnull.rs:19:30 --> $DIR/ub-nonnull.rs:19:30
| |
LL | / const OUT_OF_BOUNDS_PTR: NonNull<u8> = { unsafe { LL | let out_of_bounds_ptr = &ptr[255];
LL | | let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle | ^^^^^^^^ memory access failed: pointer must be in-bounds at offset 256, but is outside bounds of alloc10 which has size 1
LL | | // Use address-of-element for pointer arithmetic. This could wrap around to null!
LL | | let out_of_bounds_ptr = &ptr[255];
| | ^^^^^^^^ memory access failed: pointer must be in-bounds at offset 256, but is outside bounds of alloc10 which has size 1
LL | |
LL | | mem::transmute(out_of_bounds_ptr)
LL | | } };
| |____-
|
note: the lint level is defined here
--> $DIR/ub-nonnull.rs:15:8
|
LL | #[deny(const_err)] // this triggers a `const_err` so validation does not even happen
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:24:1 --> $DIR/ub-nonnull.rs:23:1
| |
LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1
@ -42,7 +27,7 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) };
} }
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:26:1 --> $DIR/ub-nonnull.rs:25:1
| |
LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1
@ -53,7 +38,7 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) };
} }
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:34:1 --> $DIR/ub-nonnull.rs:33:1
| |
LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
@ -64,7 +49,7 @@ LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init };
} }
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:42:1 --> $DIR/ub-nonnull.rs:41:1
| |
LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 42, but expected something in the range 10..=30 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 42, but expected something in the range 10..=30
@ -75,7 +60,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
} }
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:48:1 --> $DIR/ub-nonnull.rs:47:1
| |
LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 20, but expected something less or equal to 10, or greater or equal to 30 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 20, but expected something less or equal to 10, or greater or equal to 30

View file

@ -9,29 +9,14 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
00 00 00 00 00 00 00 00 │ ........ 00 00 00 00 00 00 00 00 │ ........
} }
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/ub-nonnull.rs:19:30 --> $DIR/ub-nonnull.rs:19:30
| |
LL | / const OUT_OF_BOUNDS_PTR: NonNull<u8> = { unsafe { LL | let out_of_bounds_ptr = &ptr[255];
LL | | let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle | ^^^^^^^^ memory access failed: pointer must be in-bounds at offset 256, but is outside bounds of alloc10 which has size 1
LL | | // Use address-of-element for pointer arithmetic. This could wrap around to null!
LL | | let out_of_bounds_ptr = &ptr[255];
| | ^^^^^^^^ memory access failed: pointer must be in-bounds at offset 256, but is outside bounds of alloc10 which has size 1
LL | |
LL | | mem::transmute(out_of_bounds_ptr)
LL | | } };
| |____-
|
note: the lint level is defined here
--> $DIR/ub-nonnull.rs:15:8
|
LL | #[deny(const_err)] // this triggers a `const_err` so validation does not even happen
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:24:1 --> $DIR/ub-nonnull.rs:23:1
| |
LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1
@ -42,7 +27,7 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) };
} }
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:26:1 --> $DIR/ub-nonnull.rs:25:1
| |
LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1
@ -53,7 +38,7 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) };
} }
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:34:1 --> $DIR/ub-nonnull.rs:33:1
| |
LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
@ -64,7 +49,7 @@ LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init };
} }
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:42:1 --> $DIR/ub-nonnull.rs:41:1
| |
LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 42, but expected something in the range 10..=30 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 42, but expected something in the range 10..=30
@ -75,7 +60,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
} }
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:48:1 --> $DIR/ub-nonnull.rs:47:1
| |
LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 20, but expected something less or equal to 10, or greater or equal to 30 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 20, but expected something less or equal to 10, or greater or equal to 30

View file

@ -16,8 +16,7 @@ const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
const OUT_OF_BOUNDS_PTR: NonNull<u8> = { unsafe { const OUT_OF_BOUNDS_PTR: NonNull<u8> = { unsafe {
let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle
// Use address-of-element for pointer arithmetic. This could wrap around to null! // Use address-of-element for pointer arithmetic. This could wrap around to null!
let out_of_bounds_ptr = &ptr[255]; //~ ERROR any use of this value will cause an error let out_of_bounds_ptr = &ptr[255]; //~ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
mem::transmute(out_of_bounds_ptr) mem::transmute(out_of_bounds_ptr)
} }; } };

View file

@ -1,4 +1,4 @@
warning: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/validate_uninhabited_zsts.rs:5:14 --> $DIR/validate_uninhabited_zsts.rs:5:14
| |
LL | unsafe { std::mem::transmute(()) } LL | unsafe { std::mem::transmute(()) }
@ -6,21 +6,12 @@ LL | unsafe { std::mem::transmute(()) }
| | | |
| transmuting to uninhabited type | transmuting to uninhabited type
| inside `foo` at $DIR/validate_uninhabited_zsts.rs:5:14 | inside `foo` at $DIR/validate_uninhabited_zsts.rs:5:14
| inside `FOO` at $DIR/validate_uninhabited_zsts.rs:15:26
... ...
LL | const FOO: [Empty; 3] = [foo(); 3]; LL | const FOO: [Empty; 3] = [foo(); 3];
| ----------------------------------- | ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:14:26
|
note: the lint level is defined here
--> $DIR/validate_uninhabited_zsts.rs:14:8
|
LL | #[warn(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/validate_uninhabited_zsts.rs:18:1 --> $DIR/validate_uninhabited_zsts.rs:17:1
| |
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at [0]: encountered a value of uninhabited type Empty | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at [0]: encountered a value of uninhabited type Empty
@ -41,7 +32,7 @@ LL | unsafe { std::mem::transmute(()) }
= note: the `!` type has no valid value = note: the `!` type has no valid value
warning: the type `Empty` does not permit zero-initialization warning: the type `Empty` does not permit zero-initialization
--> $DIR/validate_uninhabited_zsts.rs:18:35 --> $DIR/validate_uninhabited_zsts.rs:17:35
| |
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
@ -51,6 +42,6 @@ LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
| |
= note: enums with no variants have no valid value = note: enums with no variants have no valid value
error: aborting due to previous error; 3 warnings emitted error: aborting due to 2 previous errors; 2 warnings emitted
For more information about this error, try `rustc --explain E0080`. For more information about this error, try `rustc --explain E0080`.

View file

@ -1,4 +1,4 @@
warning: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/validate_uninhabited_zsts.rs:5:14 --> $DIR/validate_uninhabited_zsts.rs:5:14
| |
LL | unsafe { std::mem::transmute(()) } LL | unsafe { std::mem::transmute(()) }
@ -6,21 +6,12 @@ LL | unsafe { std::mem::transmute(()) }
| | | |
| transmuting to uninhabited type | transmuting to uninhabited type
| inside `foo` at $DIR/validate_uninhabited_zsts.rs:5:14 | inside `foo` at $DIR/validate_uninhabited_zsts.rs:5:14
| inside `FOO` at $DIR/validate_uninhabited_zsts.rs:15:26
... ...
LL | const FOO: [Empty; 3] = [foo(); 3]; LL | const FOO: [Empty; 3] = [foo(); 3];
| ----------------------------------- | ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:14:26
|
note: the lint level is defined here
--> $DIR/validate_uninhabited_zsts.rs:14:8
|
LL | #[warn(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value
--> $DIR/validate_uninhabited_zsts.rs:18:1 --> $DIR/validate_uninhabited_zsts.rs:17:1
| |
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at [0]: encountered a value of uninhabited type Empty | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at [0]: encountered a value of uninhabited type Empty
@ -41,7 +32,7 @@ LL | unsafe { std::mem::transmute(()) }
= note: the `!` type has no valid value = note: the `!` type has no valid value
warning: the type `Empty` does not permit zero-initialization warning: the type `Empty` does not permit zero-initialization
--> $DIR/validate_uninhabited_zsts.rs:18:35 --> $DIR/validate_uninhabited_zsts.rs:17:35
| |
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
@ -51,6 +42,6 @@ LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
| |
= note: enums with no variants have no valid value = note: enums with no variants have no valid value
error: aborting due to previous error; 3 warnings emitted error: aborting due to 2 previous errors; 2 warnings emitted
For more information about this error, try `rustc --explain E0080`. For more information about this error, try `rustc --explain E0080`.

View file

@ -3,9 +3,8 @@
const fn foo() -> ! { const fn foo() -> ! {
unsafe { std::mem::transmute(()) } unsafe { std::mem::transmute(()) }
//~^ WARN any use of this value will cause an error [const_err] //~^ ERROR evaluation of constant value failed
//~| WARN the type `!` does not permit zero-initialization [invalid_value] //~| WARN the type `!` does not permit zero-initialization [invalid_value]
//~| WARN this was previously accepted by the compiler but is being phased out
} }
#[derive(Clone, Copy)] #[derive(Clone, Copy)]

View file

@ -13,186 +13,137 @@ use std::intrinsics;
// unsigned types: // unsigned types:
const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) }; const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) }; const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) }; const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) }; const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) }; const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
// signed types: // signed types:
const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) }; const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_16, 16) }; const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_16, 16) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) }; const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) }; const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) }; const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
// and make sure we capture y < 0: // and make sure we capture y < 0:
const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) }; const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_16, -1) }; const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_16, -1) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) }; const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) }; const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) }; const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
// and that there's no special relation to the value -1 by picking some // and that there's no special relation to the value -1 by picking some
// negative values at random: // negative values at random:
const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) }; const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_16, -13) }; const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_16, -13) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) }; const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) }; const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) }; const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
// Repeat it all over for `unchecked_shr` // Repeat it all over for `unchecked_shr`
// unsigned types: // unsigned types:
const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) }; const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) }; const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) }; const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) }; const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) }; const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
// signed types: // signed types:
const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) }; const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_16, 16) }; const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_16, 16) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) }; const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) }; const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) }; const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
// and make sure we capture y < 0: // and make sure we capture y < 0:
const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) }; const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_16, -1) }; const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_16, -1) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) }; const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) }; const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) }; const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
// and that there's no special relation to the value -1 by picking some // and that there's no special relation to the value -1 by picking some
// negative values at random: // negative values at random:
const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) }; const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_16, -13) }; const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_16, -13) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) }; const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }; const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) }; const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
// Other arithmetic functions: // Other arithmetic functions:
const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) }; const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) }; const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) }; const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) }; const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) }; const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) }; const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) }; const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
// capture fault with zero value // capture fault with zero value
const _: u32 = unsafe { std::intrinsics::ctlz_nonzero(0) }; const _: u32 = unsafe { std::intrinsics::ctlz_nonzero(0) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
const _: u32 = unsafe { std::intrinsics::cttz_nonzero(0) }; const _: u32 = unsafe { std::intrinsics::cttz_nonzero(0) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out
fn main() {} fn main() {}

View file

@ -1,542 +1,297 @@
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:15:29 --> $DIR/const-int-unchecked.rs:15:29
| |
LL | const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) }; LL | const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) };
| ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shl`
| |
| overflowing shift by 8 in `unchecked_shl`
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:18:31 --> $DIR/const-int-unchecked.rs:17:31
| |
LL | const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) }; LL | const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) };
| ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 16 in `unchecked_shl`
| |
| overflowing shift by 16 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:21:31 --> $DIR/const-int-unchecked.rs:19:31
| |
LL | const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) }; LL | const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) };
| ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 32 in `unchecked_shl`
| |
| overflowing shift by 32 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:24:31 --> $DIR/const-int-unchecked.rs:21:31
| |
LL | const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) }; LL | const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) };
| ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shl`
| |
| overflowing shift by 64 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:27:33 --> $DIR/const-int-unchecked.rs:23:33
| |
LL | const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) }; LL | const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) };
| --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 128 in `unchecked_shl`
| |
| overflowing shift by 128 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:33:29 --> $DIR/const-int-unchecked.rs:28:29
| |
LL | const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) }; LL | const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) };
| ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shl`
| |
| overflowing shift by 8 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:36:31 --> $DIR/const-int-unchecked.rs:30:31
| |
LL | const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_16, 16) }; LL | const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_16, 16) };
| ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 16 in `unchecked_shl`
| |
| overflowing shift by 16 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:39:31 --> $DIR/const-int-unchecked.rs:32:31
| |
LL | const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) }; LL | const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) };
| ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 32 in `unchecked_shl`
| |
| overflowing shift by 32 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:42:31 --> $DIR/const-int-unchecked.rs:34:31
| |
LL | const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) }; LL | const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) };
| ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shl`
| |
| overflowing shift by 64 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:45:33 --> $DIR/const-int-unchecked.rs:36:33
| |
LL | const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) }; LL | const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) };
| --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 128 in `unchecked_shl`
| |
| overflowing shift by 128 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:51:33 --> $DIR/const-int-unchecked.rs:41:33
| |
LL | const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) }; LL | const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) };
| --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 255 in `unchecked_shl`
| |
| overflowing shift by 255 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:54:35 --> $DIR/const-int-unchecked.rs:43:35
| |
LL | const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_16, -1) }; LL | const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_16, -1) };
| ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 65535 in `unchecked_shl`
| |
| overflowing shift by 65535 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:57:35 --> $DIR/const-int-unchecked.rs:45:35
| |
LL | const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) }; LL | const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) };
| ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 4294967295 in `unchecked_shl`
| |
| overflowing shift by 4294967295 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:60:35 --> $DIR/const-int-unchecked.rs:47:35
| |
LL | const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) }; LL | const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) };
| ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 18446744073709551615 in `unchecked_shl`
| |
| overflowing shift by 18446744073709551615 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:63:37 --> $DIR/const-int-unchecked.rs:49:37
| |
LL | const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) }; LL | const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) };
| ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 340282366920938463463374607431768211455 in `unchecked_shl`
| |
| overflowing shift by 340282366920938463463374607431768211455 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:70:40 --> $DIR/const-int-unchecked.rs:55:40
| |
LL | const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) }; LL | const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) };
| ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 250 in `unchecked_shl`
| |
| overflowing shift by 250 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:73:42 --> $DIR/const-int-unchecked.rs:57:42
| |
LL | const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_16, -13) }; LL | const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_16, -13) };
| -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 65523 in `unchecked_shl`
| |
| overflowing shift by 65523 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:76:42 --> $DIR/const-int-unchecked.rs:59:42
| |
LL | const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) }; LL | const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) };
| -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 4294967271 in `unchecked_shl`
| |
| overflowing shift by 4294967271 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:79:42 --> $DIR/const-int-unchecked.rs:61:42
| |
LL | const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) }; LL | const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) };
| -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 18446744073709551586 in `unchecked_shl`
| |
| overflowing shift by 18446744073709551586 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:82:44 --> $DIR/const-int-unchecked.rs:63:44
| |
LL | const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) }; LL | const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) };
| -------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 340282366920938463463374607431768211363 in `unchecked_shl`
| |
| overflowing shift by 340282366920938463463374607431768211363 in `unchecked_shl`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:90:29 --> $DIR/const-int-unchecked.rs:70:29
| |
LL | const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) }; LL | const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) };
| ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shr`
| |
| overflowing shift by 8 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:93:31 --> $DIR/const-int-unchecked.rs:72:31
| |
LL | const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) }; LL | const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) };
| ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 16 in `unchecked_shr`
| |
| overflowing shift by 16 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:96:31 --> $DIR/const-int-unchecked.rs:74:31
| |
LL | const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) }; LL | const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) };
| ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 32 in `unchecked_shr`
| |
| overflowing shift by 32 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:99:31 --> $DIR/const-int-unchecked.rs:76:31
| |
LL | const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) }; LL | const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) };
| ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shr`
| |
| overflowing shift by 64 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:102:33 --> $DIR/const-int-unchecked.rs:78:33
| |
LL | const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) }; LL | const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) };
| --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 128 in `unchecked_shr`
| |
| overflowing shift by 128 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:108:29 --> $DIR/const-int-unchecked.rs:83:29
| |
LL | const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) }; LL | const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) };
| ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shr`
| |
| overflowing shift by 8 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:111:31 --> $DIR/const-int-unchecked.rs:85:31
| |
LL | const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_16, 16) }; LL | const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_16, 16) };
| ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 16 in `unchecked_shr`
| |
| overflowing shift by 16 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:114:31 --> $DIR/const-int-unchecked.rs:87:31
| |
LL | const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) }; LL | const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) };
| ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 32 in `unchecked_shr`
| |
| overflowing shift by 32 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:117:31 --> $DIR/const-int-unchecked.rs:89:31
| |
LL | const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) }; LL | const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) };
| ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shr`
| |
| overflowing shift by 64 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:120:33 --> $DIR/const-int-unchecked.rs:91:33
| |
LL | const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) }; LL | const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) };
| --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 128 in `unchecked_shr`
| |
| overflowing shift by 128 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:126:33 --> $DIR/const-int-unchecked.rs:96:33
| |
LL | const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) }; LL | const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) };
| --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 255 in `unchecked_shr`
| |
| overflowing shift by 255 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:129:35 --> $DIR/const-int-unchecked.rs:98:35
| |
LL | const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_16, -1) }; LL | const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_16, -1) };
| ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 65535 in `unchecked_shr`
| |
| overflowing shift by 65535 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:132:35 --> $DIR/const-int-unchecked.rs:100:35
| |
LL | const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) }; LL | const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) };
| ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 4294967295 in `unchecked_shr`
| |
| overflowing shift by 4294967295 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:135:35 --> $DIR/const-int-unchecked.rs:102:35
| |
LL | const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) }; LL | const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) };
| ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 18446744073709551615 in `unchecked_shr`
| |
| overflowing shift by 18446744073709551615 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:138:37 --> $DIR/const-int-unchecked.rs:104:37
| |
LL | const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) }; LL | const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) };
| ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 340282366920938463463374607431768211455 in `unchecked_shr`
| |
| overflowing shift by 340282366920938463463374607431768211455 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:145:40 --> $DIR/const-int-unchecked.rs:110:40
| |
LL | const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) }; LL | const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) };
| ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 250 in `unchecked_shr`
| |
| overflowing shift by 250 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:148:42 --> $DIR/const-int-unchecked.rs:112:42
| |
LL | const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_16, -13) }; LL | const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_16, -13) };
| -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 65523 in `unchecked_shr`
| |
| overflowing shift by 65523 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:151:42 --> $DIR/const-int-unchecked.rs:114:42
| |
LL | const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) }; LL | const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) };
| -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 4294967271 in `unchecked_shr`
| |
| overflowing shift by 4294967271 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:154:42 --> $DIR/const-int-unchecked.rs:116:42
| |
LL | const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }; LL | const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) };
| -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 18446744073709551586 in `unchecked_shr`
| |
| overflowing shift by 18446744073709551586 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:157:44 --> $DIR/const-int-unchecked.rs:118:44
| |
LL | const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) }; LL | const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) };
| -------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 340282366920938463463374607431768211363 in `unchecked_shr`
| |
| overflowing shift by 340282366920938463463374607431768211363 in `unchecked_shr`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:163:25 --> $DIR/const-int-unchecked.rs:123:25
| |
LL | const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) }; LL | const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) };
| ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_add`
| |
| overflow executing `unchecked_add`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:167:25 --> $DIR/const-int-unchecked.rs:126:25
| |
LL | const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) }; LL | const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) };
| ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_sub`
| |
| overflow executing `unchecked_sub`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:171:25 --> $DIR/const-int-unchecked.rs:129:25
| |
LL | const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) }; LL | const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) };
| ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_mul`
| |
| overflow executing `unchecked_mul`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:175:25 --> $DIR/const-int-unchecked.rs:132:25
| |
LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) }; LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) };
| ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dividing by zero
| |
| dividing by zero
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:178:25 --> $DIR/const-int-unchecked.rs:134:25
| |
LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) }; LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) };
| ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_div`
| |
| overflow executing `unchecked_div`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:182:25 --> $DIR/const-int-unchecked.rs:137:25
| |
LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) }; LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) };
| ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero
| |
| calculating the remainder with a divisor of zero
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:185:25 --> $DIR/const-int-unchecked.rs:139:25
| |
LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) }; LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) };
| ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_rem`
| |
| overflow executing `unchecked_rem`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:191:25 --> $DIR/const-int-unchecked.rs:144:25
| |
LL | const _: u32 = unsafe { std::intrinsics::ctlz_nonzero(0) }; LL | const _: u32 = unsafe { std::intrinsics::ctlz_nonzero(0) };
| ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ctlz_nonzero` called on 0
| |
| `ctlz_nonzero` called on 0
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/const-int-unchecked.rs:194:25 --> $DIR/const-int-unchecked.rs:146:25
| |
LL | const _: u32 = unsafe { std::intrinsics::cttz_nonzero(0) }; LL | const _: u32 = unsafe { std::intrinsics::cttz_nonzero(0) };
| ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `cttz_nonzero` called on 0
| |
| `cttz_nonzero` called on 0
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: aborting due to 49 previous errors error: aborting due to 49 previous errors
For more information about this error, try `rustc --explain E0080`.

View file

@ -1,5 +1,4 @@
// build-fail // error-pattern: evaluation of constant value failed
#![feature(const_unreachable_unchecked)] #![feature(const_unreachable_unchecked)]
const unsafe fn foo(x: bool) -> bool { const unsafe fn foo(x: bool) -> bool {
@ -9,12 +8,8 @@ const unsafe fn foo(x: bool) -> bool {
} }
} }
#[warn(const_err)]
const BAR: bool = unsafe { foo(false) }; const BAR: bool = unsafe { foo(false) };
fn main() { fn main() {
assert_eq!(BAR, true); assert_eq!(BAR, true);
//~^ ERROR E0080
//~| ERROR erroneous constant
//~| WARN this was previously accepted by the compiler but is being phased out
} }

View file

@ -1,4 +1,4 @@
warning: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/hint.rs:LL:COL --> $SRC_DIR/core/src/hint.rs:LL:COL
| |
LL | unsafe { intrinsics::unreachable() } LL | unsafe { intrinsics::unreachable() }
@ -6,39 +6,15 @@ LL | unsafe { intrinsics::unreachable() }
| | | |
| entering unreachable code | entering unreachable code
| inside `unreachable_unchecked` at $SRC_DIR/core/src/hint.rs:LL:COL | inside `unreachable_unchecked` at $SRC_DIR/core/src/hint.rs:LL:COL
| inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:8:18
| inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:13:28
| |
::: $DIR/const_unsafe_unreachable_ub.rs:13:1 ::: $DIR/const_unsafe_unreachable_ub.rs:7:18
| |
LL | false => std::hint::unreachable_unchecked(),
| ---------------------------------- inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:7:18
...
LL | const BAR: bool = unsafe { foo(false) }; LL | const BAR: bool = unsafe { foo(false) };
| ---------------------------------------- | ---------- inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:11:28
|
note: the lint level is defined here
--> $DIR/const_unsafe_unreachable_ub.rs:12:8
|
LL | #[warn(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error[E0080]: evaluation of constant value failed error: aborting due to previous error
--> $DIR/const_unsafe_unreachable_ub.rs:16:14
|
LL | assert_eq!(BAR, true);
| ^^^ referenced constant has errors
error: erroneous constant used
--> $DIR/const_unsafe_unreachable_ub.rs:16:3
|
LL | assert_eq!(BAR, true);
| ^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0080`. For more information about this error, try `rustc --explain E0080`.

View file

@ -1,5 +1,8 @@
#![feature(const_raw_ptr_deref)] #![feature(const_raw_ptr_deref)]
#![feature(const_ptr_offset_from)] #![feature(const_ptr_offset_from)]
#![feature(core_intrinsics)]
use std::intrinsics::ptr_offset_from;
#[repr(C)] #[repr(C)]
struct Struct { struct Struct {
@ -8,39 +11,38 @@ struct Struct {
} }
pub const DIFFERENT_ALLOC: usize = { pub const DIFFERENT_ALLOC: usize = {
//~^ NOTE
let uninit = std::mem::MaybeUninit::<Struct>::uninit(); let uninit = std::mem::MaybeUninit::<Struct>::uninit();
let base_ptr: *const Struct = &uninit as *const _ as *const Struct; let base_ptr: *const Struct = &uninit as *const _ as *const Struct;
let uninit2 = std::mem::MaybeUninit::<Struct>::uninit(); let uninit2 = std::mem::MaybeUninit::<Struct>::uninit();
let field_ptr: *const Struct = &uninit2 as *const _ as *const Struct; let field_ptr: *const Struct = &uninit2 as *const _ as *const Struct;
let offset = unsafe { field_ptr.offset_from(base_ptr) }; let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; //~ERROR evaluation of constant value failed
//~| cannot compute offset of pointers into different allocations.
offset as usize offset as usize
}; };
pub const NOT_PTR: usize = { pub const NOT_PTR: usize = {
//~^ NOTE
unsafe { (42 as *const u8).offset_from(&5u8) as usize } unsafe { (42 as *const u8).offset_from(&5u8) as usize }
}; };
pub const NOT_MULTIPLE_OF_SIZE: isize = { pub const NOT_MULTIPLE_OF_SIZE: isize = {
//~^ NOTE
let data = [5u8, 6, 7]; let data = [5u8, 6, 7];
let base_ptr = data.as_ptr(); let base_ptr = data.as_ptr();
let field_ptr = &data[1] as *const u8 as *const u16; let field_ptr = &data[1] as *const u8 as *const u16;
unsafe { field_ptr.offset_from(base_ptr as *const u16) } unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) } //~ERROR evaluation of constant value failed
//~| 1_isize cannot be divided by 2_isize without remainder
}; };
pub const OFFSET_FROM_NULL: isize = { pub const OFFSET_FROM_NULL: isize = {
//~^ NOTE
let ptr = 0 as *const u8; let ptr = 0 as *const u8;
unsafe { ptr.offset_from(ptr) } unsafe { ptr_offset_from(ptr, ptr) } //~ERROR evaluation of constant value failed
//~| null pointer is not a valid pointer
}; };
pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC
//~^ NOTE
let ptr1 = 8 as *const u8; let ptr1 = 8 as *const u8;
let ptr2 = 16 as *const u8; let ptr2 = 16 as *const u8;
unsafe { ptr2.offset_from(ptr1) } unsafe { ptr_offset_from(ptr2, ptr1) } //~ERROR any use of this value will cause an error
//~| WARN previously accepted
}; };
fn main() {} fn main() {}

View file

@ -1,21 +1,23 @@
error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:18:27
|
LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from cannot compute offset of pointers into different allocations.
error: any use of this value will cause an error error: any use of this value will cause an error
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| |
LL | unsafe { intrinsics::ptr_offset_from(self, origin) } LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | | |
| ptr_offset_from cannot compute offset of pointers into different allocations. | unable to turn bytes into a pointer
| inside `ptr::const_ptr::<impl *const Struct>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `DIFFERENT_ALLOC` at $DIR/offset_from_ub.rs:16:27 | inside `NOT_PTR` at $DIR/offset_from_ub.rs:24:14
| |
::: $DIR/offset_from_ub.rs:10:1 ::: $DIR/offset_from_ub.rs:23:1
| |
LL | / pub const DIFFERENT_ALLOC: usize = { LL | / pub const NOT_PTR: usize = {
LL | | LL | | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
LL | | let uninit = std::mem::MaybeUninit::<Struct>::uninit();
LL | | let base_ptr: *const Struct = &uninit as *const _ as *const Struct;
... |
LL | | offset as usize
LL | | }; LL | | };
| |__- | |__-
| |
@ -23,90 +25,27 @@ LL | | };
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $DIR/offset_from_ub.rs:31:14
| |
LL | unsafe { intrinsics::ptr_offset_from(self, origin) } LL | unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 1_isize cannot be divided by 2_isize without remainder
| |
| unable to turn bytes into a pointer error[E0080]: evaluation of constant value failed
| inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $DIR/offset_from_ub.rs:37:14
| inside `NOT_PTR` at $DIR/offset_from_ub.rs:22:14
|
::: $DIR/offset_from_ub.rs:20:1
| |
LL | / pub const NOT_PTR: usize = { LL | unsafe { ptr_offset_from(ptr, ptr) }
LL | | | ^^^^^^^^^^^^^^^^^^^^^^^^^ null pointer is not a valid pointer for this operation
LL | | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
LL | | };
| |__-
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error: any use of this value will cause an error
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $DIR/offset_from_ub.rs:44:14
|
LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| exact_div: 1_isize cannot be divided by 2_isize without remainder
| inside `ptr::const_ptr::<impl *const u16>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `NOT_MULTIPLE_OF_SIZE` at $DIR/offset_from_ub.rs:30:14
|
::: $DIR/offset_from_ub.rs:25:1
|
LL | / pub const NOT_MULTIPLE_OF_SIZE: isize = {
LL | |
LL | | let data = [5u8, 6, 7];
LL | | let base_ptr = data.as_ptr();
LL | | let field_ptr = &data[1] as *const u8 as *const u16;
LL | | unsafe { field_ptr.offset_from(base_ptr as *const u16) }
LL | | };
| |__-
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| null pointer is not a valid pointer for this operation
| inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `OFFSET_FROM_NULL` at $DIR/offset_from_ub.rs:36:14
|
::: $DIR/offset_from_ub.rs:33:1
|
LL | / pub const OFFSET_FROM_NULL: isize = {
LL | |
LL | | let ptr = 0 as *const u8;
LL | | unsafe { ptr.offset_from(ptr) }
LL | | };
| |__-
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unable to turn bytes into a pointer
| inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `DIFFERENT_INT` at $DIR/offset_from_ub.rs:43:14
|
::: $DIR/offset_from_ub.rs:39:1
| |
LL | / pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC LL | / pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC
LL | |
LL | | let ptr1 = 8 as *const u8; LL | | let ptr1 = 8 as *const u8;
LL | | let ptr2 = 16 as *const u8; LL | | let ptr2 = 16 as *const u8;
LL | | unsafe { ptr2.offset_from(ptr1) } LL | | unsafe { ptr_offset_from(ptr2, ptr1) }
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn bytes into a pointer
LL | |
LL | | }; LL | | };
| |__- | |__-
| |
@ -115,3 +54,4 @@ LL | | };
error: aborting due to 5 previous errors error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0080`.

View file

@ -1,4 +1,4 @@
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| |
LL | unsafe { intrinsics::offset(self, count) } LL | unsafe { intrinsics::offset(self, count) }
@ -6,18 +6,13 @@ LL | unsafe { intrinsics::offset(self, count) }
| | | |
| overflowing in-bounds pointer arithmetic | overflowing in-bounds pointer arithmetic
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `BEFORE_START` at $DIR/offset_ub.rs:6:46
| |
::: $DIR/offset_ub.rs:6:1 ::: $DIR/offset_ub.rs:6:46
| |
LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) }; LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) };
| ------------------------------------------------------------------------------ | ------------------------------ inside `BEFORE_START` at $DIR/offset_ub.rs:6:46
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| |
LL | unsafe { intrinsics::offset(self, count) } LL | unsafe { intrinsics::offset(self, count) }
@ -25,17 +20,13 @@ LL | unsafe { intrinsics::offset(self, count) }
| | | |
| pointer arithmetic failed: pointer must be in-bounds at offset 2, but is outside bounds of allocN which has size 1 | pointer arithmetic failed: pointer must be in-bounds at offset 2, but is outside bounds of allocN which has size 1
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `AFTER_END` at $DIR/offset_ub.rs:7:43
| |
::: $DIR/offset_ub.rs:7:1 ::: $DIR/offset_ub.rs:7:43
| |
LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) };
| -------------------------------------------------------------------------- | ----------------------------- inside `AFTER_END` at $DIR/offset_ub.rs:7:43
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| |
LL | unsafe { intrinsics::offset(self, count) } LL | unsafe { intrinsics::offset(self, count) }
@ -43,17 +34,13 @@ LL | unsafe { intrinsics::offset(self, count) }
| | | |
| pointer arithmetic failed: pointer must be in-bounds at offset 101, but is outside bounds of allocN which has size 100 | pointer arithmetic failed: pointer must be in-bounds at offset 101, but is outside bounds of allocN which has size 100
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `AFTER_ARRAY` at $DIR/offset_ub.rs:8:45
| |
::: $DIR/offset_ub.rs:8:1 ::: $DIR/offset_ub.rs:8:45
| |
LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) };
| ------------------------------------------------------------------------------ | ------------------------------- inside `AFTER_ARRAY` at $DIR/offset_ub.rs:8:45
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| |
LL | unsafe { intrinsics::offset(self, count) } LL | unsafe { intrinsics::offset(self, count) }
@ -61,17 +48,13 @@ LL | unsafe { intrinsics::offset(self, count) }
| | | |
| overflowing in-bounds pointer arithmetic | overflowing in-bounds pointer arithmetic
| inside `ptr::const_ptr::<impl *const u16>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | inside `ptr::const_ptr::<impl *const u16>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `OVERFLOW` at $DIR/offset_ub.rs:10:43
| |
::: $DIR/offset_ub.rs:10:1 ::: $DIR/offset_ub.rs:10:43
| |
LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) }; LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) };
| ---------------------------------------------------------------------------------- | ------------------------------------- inside `OVERFLOW` at $DIR/offset_ub.rs:10:43
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| |
LL | unsafe { intrinsics::offset(self, count) } LL | unsafe { intrinsics::offset(self, count) }
@ -79,17 +62,13 @@ LL | unsafe { intrinsics::offset(self, count) }
| | | |
| overflowing in-bounds pointer arithmetic | overflowing in-bounds pointer arithmetic
| inside `ptr::const_ptr::<impl *const u16>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | inside `ptr::const_ptr::<impl *const u16>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `UNDERFLOW` at $DIR/offset_ub.rs:11:44
| |
::: $DIR/offset_ub.rs:11:1 ::: $DIR/offset_ub.rs:11:44
| |
LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) }; LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) };
| ----------------------------------------------------------------------------------- | ------------------------------------- inside `UNDERFLOW` at $DIR/offset_ub.rs:11:44
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| |
LL | unsafe { intrinsics::offset(self, count) } LL | unsafe { intrinsics::offset(self, count) }
@ -97,17 +76,13 @@ LL | unsafe { intrinsics::offset(self, count) }
| | | |
| overflowing in-bounds pointer arithmetic | overflowing in-bounds pointer arithmetic
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `OVERFLOW_ADDRESS_SPACE` at $DIR/offset_ub.rs:12:56
| |
::: $DIR/offset_ub.rs:12:1 ::: $DIR/offset_ub.rs:12:56
| |
LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) }; LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) };
| --------------------------------------------------------------------------------------------- | ----------------------------------- inside `OVERFLOW_ADDRESS_SPACE` at $DIR/offset_ub.rs:12:56
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| |
LL | unsafe { intrinsics::offset(self, count) } LL | unsafe { intrinsics::offset(self, count) }
@ -115,17 +90,13 @@ LL | unsafe { intrinsics::offset(self, count) }
| | | |
| overflowing in-bounds pointer arithmetic | overflowing in-bounds pointer arithmetic
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `UNDERFLOW_ADDRESS_SPACE` at $DIR/offset_ub.rs:13:57
| |
::: $DIR/offset_ub.rs:13:1 ::: $DIR/offset_ub.rs:13:57
| |
LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) };
| -------------------------------------------------------------------------------------- | --------------------------- inside `UNDERFLOW_ADDRESS_SPACE` at $DIR/offset_ub.rs:13:57
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| |
LL | unsafe { intrinsics::offset(self, count) } LL | unsafe { intrinsics::offset(self, count) }
@ -133,15 +104,11 @@ LL | unsafe { intrinsics::offset(self, count) }
| | | |
| pointer arithmetic failed: pointer must be in-bounds at offset 1, but is outside bounds of allocN which has size 0 | pointer arithmetic failed: pointer must be in-bounds at offset 1, but is outside bounds of allocN which has size 0
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `ZERO_SIZED_ALLOC` at $DIR/offset_ub.rs:15:50
| |
::: $DIR/offset_ub.rs:15:1 ::: $DIR/offset_ub.rs:15:50
| |
LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) }; LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) };
| ------------------------------------------------------------------------------- | --------------------------- inside `ZERO_SIZED_ALLOC` at $DIR/offset_ub.rs:15:50
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error: any use of this value will cause an error
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
@ -158,10 +125,11 @@ LL | unsafe { intrinsics::offset(self, count) as *mut T }
LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) }; LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) };
| --------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------
| |
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| |
LL | unsafe { intrinsics::offset(self, count) } LL | unsafe { intrinsics::offset(self, count) }
@ -169,15 +137,11 @@ LL | unsafe { intrinsics::offset(self, count) }
| | | |
| pointer arithmetic failed: 0x0 is not a valid pointer | pointer arithmetic failed: 0x0 is not a valid pointer
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `NULL_OFFSET_ZERO` at $DIR/offset_ub.rs:19:50
| |
::: $DIR/offset_ub.rs:19:1 ::: $DIR/offset_ub.rs:19:50
| |
LL | pub const NULL_OFFSET_ZERO: *const u8 = unsafe { ptr::null::<u8>().offset(0) }; LL | pub const NULL_OFFSET_ZERO: *const u8 = unsafe { ptr::null::<u8>().offset(0) };
| ------------------------------------------------------------------------------- | --------------------------- inside `NULL_OFFSET_ZERO` at $DIR/offset_ub.rs:19:50
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error: any use of this value will cause an error
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@ -199,3 +163,4 @@ LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).off
error: aborting due to 11 previous errors error: aborting due to 11 previous errors
For more information about this error, try `rustc --explain E0080`.

View file

@ -62,8 +62,8 @@ const _: *const usize = unsafe { (FOO as *const usize).offset(2) };
const _: *const u8 = const _: *const u8 =
unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) }; unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) };
//~^ ERROR any use of this value will cause an error //~^ ERROR evaluation of constant value failed
//~| WARN this was previously accepted by the compiler but is being phased out //~| pointer must be in-bounds
const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 }; const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 };
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error

View file

@ -1,4 +1,4 @@
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| |
LL | unsafe { intrinsics::offset(self, count) } LL | unsafe { intrinsics::offset(self, count) }
@ -6,28 +6,17 @@ LL | unsafe { intrinsics::offset(self, count) }
| | | |
| pointer arithmetic failed: pointer must be in-bounds at offset $TWO_WORDS, but is outside bounds of alloc2 which has size $WORD | pointer arithmetic failed: pointer must be in-bounds at offset $TWO_WORDS, but is outside bounds of alloc2 which has size $WORD
| inside `ptr::const_ptr::<impl *const usize>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | inside `ptr::const_ptr::<impl *const usize>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `_` at $DIR/ptr_comparisons.rs:61:34
| |
::: $DIR/ptr_comparisons.rs:61:1 ::: $DIR/ptr_comparisons.rs:61:34
| |
LL | const _: *const usize = unsafe { (FOO as *const usize).offset(2) }; LL | const _: *const usize = unsafe { (FOO as *const usize).offset(2) };
| ------------------------------------------------------------------- | ------------------------------- inside `_` at $DIR/ptr_comparisons.rs:61:34
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error[E0080]: evaluation of constant value failed
--> $DIR/ptr_comparisons.rs:64:33 --> $DIR/ptr_comparisons.rs:64:33
| |
LL | / const _: *const u8 = LL | unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) };
LL | | unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: pointer must be in-bounds at offset 1000, but is outside bounds of alloc2 which has size $WORD
| |_________________________________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^___-
| |
| memory access failed: pointer must be in-bounds at offset 1000, but is outside bounds of alloc2 which has size $WORD
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error error: any use of this value will cause an error
--> $DIR/ptr_comparisons.rs:68:27 --> $DIR/ptr_comparisons.rs:68:27
@ -37,6 +26,7 @@ LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) +
| | | |
| cannot cast pointer to integer because it was not created by cast from integer | cannot cast pointer to integer because it was not created by cast from integer
| |
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
@ -53,3 +43,4 @@ LL | const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4
error: aborting due to 4 previous errors error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0080`.