diff options
| author | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-07-02 19:00:07 +0200 |
|---|---|---|
| committer | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-08-07 14:41:33 +0200 |
| commit | 3ef863bfdfb9173a0ad55d24e20202948dda6bbe (patch) | |
| tree | 88363d22f4c514b1b5ca7f7e086258506096d306 /src/test/ui/error-codes | |
| parent | 9e472c2acea2b7714985390abb6b7fe420a4f346 (diff) | |
| download | rust-3ef863bfdfb9173a0ad55d24e20202948dda6bbe.tar.gz rust-3ef863bfdfb9173a0ad55d24e20202948dda6bbe.zip | |
Place unions, pointer casts and pointer derefs behind extra feature gates
Diffstat (limited to 'src/test/ui/error-codes')
| -rw-r--r-- | src/test/ui/error-codes/E0396-fixed.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0396-fixed.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0396.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0396.stderr | 10 |
4 files changed, 39 insertions, 5 deletions
diff --git a/src/test/ui/error-codes/E0396-fixed.rs b/src/test/ui/error-codes/E0396-fixed.rs new file mode 100644 index 00000000000..08d20e7850d --- /dev/null +++ b/src/test/ui/error-codes/E0396-fixed.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_raw_ptr_deref)] + +const REG_ADDR: *const u8 = 0x5f3759df as *const u8; + +const VALUE: u8 = unsafe { *REG_ADDR }; +//~^ ERROR this constant cannot be used + +fn main() { +} diff --git a/src/test/ui/error-codes/E0396-fixed.stderr b/src/test/ui/error-codes/E0396-fixed.stderr new file mode 100644 index 00000000000..7d3c98c8ea8 --- /dev/null +++ b/src/test/ui/error-codes/E0396-fixed.stderr @@ -0,0 +1,12 @@ +error: this constant cannot be used + --> $DIR/E0396-fixed.rs:15:1 + | +LL | const VALUE: u8 = unsafe { *REG_ADDR }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^^^ + | | + | a memory access tried to interpret some bytes as a pointer + | + = note: #[deny(const_err)] on by default + +error: aborting due to previous error + diff --git a/src/test/ui/error-codes/E0396.rs b/src/test/ui/error-codes/E0396.rs index 7f34acdfb90..6434620d26a 100644 --- a/src/test/ui/error-codes/E0396.rs +++ b/src/test/ui/error-codes/E0396.rs @@ -10,7 +10,8 @@ const REG_ADDR: *const u8 = 0x5f3759df as *const u8; -const VALUE: u8 = unsafe { *REG_ADDR }; //~ ERROR E0396 +const VALUE: u8 = unsafe { *REG_ADDR }; +//~^ ERROR dereferencing raw pointers in constants is unstable fn main() { } diff --git a/src/test/ui/error-codes/E0396.stderr b/src/test/ui/error-codes/E0396.stderr index 87dfd50dc97..70331acc0e9 100644 --- a/src/test/ui/error-codes/E0396.stderr +++ b/src/test/ui/error-codes/E0396.stderr @@ -1,9 +1,11 @@ -error[E0396]: raw pointers cannot be dereferenced in constants +error[E0658]: dereferencing raw pointers in constants is unstable (see issue #51911) --> $DIR/E0396.rs:13:28 | -LL | const VALUE: u8 = unsafe { *REG_ADDR }; //~ ERROR E0396 - | ^^^^^^^^^ dereference of raw pointer in constant +LL | const VALUE: u8 = unsafe { *REG_ADDR }; + | ^^^^^^^^^ + | + = help: add #![feature(const_raw_ptr_deref)] to the crate attributes to enable error: aborting due to previous error -For more information about this error, try `rustc --explain E0396`. +For more information about this error, try `rustc --explain E0658`. |
