diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-12-07 18:26:46 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-01-21 16:01:57 +0100 |
| commit | aedc3a51dfab0fa7205f1c0fd68a4e62dd6df712 (patch) | |
| tree | 1e67a7725f854bc7c4c099f2d7e09d7dfba146c9 /src/test/ui/cast | |
| parent | 64afc6b51779c32b3d68a45b956b76b8899a135e (diff) | |
| download | rust-aedc3a51dfab0fa7205f1c0fd68a4e62dd6df712.tar.gz rust-aedc3a51dfab0fa7205f1c0fd68a4e62dd6df712.zip | |
Declare some unconst operations as unsafe in const fn
Diffstat (limited to 'src/test/ui/cast')
| -rw-r--r-- | src/test/ui/cast/cast-ptr-to-int-const.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/cast/cast-ptr-to-int-const.stderr | 12 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/test/ui/cast/cast-ptr-to-int-const.rs b/src/test/ui/cast/cast-ptr-to-int-const.rs index 70b4869ef63..ac153cb5742 100644 --- a/src/test/ui/cast/cast-ptr-to-int-const.rs +++ b/src/test/ui/cast/cast-ptr-to-int-const.rs @@ -1,7 +1,11 @@ // gate-test-const_raw_ptr_to_usize_cast fn main() { - const X: u32 = main as u32; //~ ERROR casting pointers to integers in constants is unstable + const X: u32 = unsafe { + main as u32 //~ ERROR casting pointers to integers in constants is unstable + }; const Y: u32 = 0; - const Z: u32 = &Y as *const u32 as u32; //~ ERROR is unstable + const Z: u32 = unsafe { + &Y as *const u32 as u32 //~ ERROR is unstable + }; } diff --git a/src/test/ui/cast/cast-ptr-to-int-const.stderr b/src/test/ui/cast/cast-ptr-to-int-const.stderr index 3cce07d64ec..d04595ee4e8 100644 --- a/src/test/ui/cast/cast-ptr-to-int-const.stderr +++ b/src/test/ui/cast/cast-ptr-to-int-const.stderr @@ -1,16 +1,16 @@ error[E0658]: casting pointers to integers in constants is unstable (see issue #51910) - --> $DIR/cast-ptr-to-int-const.rs:4:20 + --> $DIR/cast-ptr-to-int-const.rs:5:9 | -LL | const X: u32 = main as u32; //~ ERROR casting pointers to integers in constants is unstable - | ^^^^^^^^^^^ +LL | main as u32 //~ ERROR casting pointers to integers in constants is unstable + | ^^^^^^^^^^^ | = help: add #![feature(const_raw_ptr_to_usize_cast)] to the crate attributes to enable error[E0658]: casting pointers to integers in constants is unstable (see issue #51910) - --> $DIR/cast-ptr-to-int-const.rs:6:20 + --> $DIR/cast-ptr-to-int-const.rs:9:9 | -LL | const Z: u32 = &Y as *const u32 as u32; //~ ERROR is unstable - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | &Y as *const u32 as u32 //~ ERROR is unstable + | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(const_raw_ptr_to_usize_cast)] to the crate attributes to enable |
