Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Place unions, pointer casts and pointer derefs behind extra feature g…
…ates
- Loading branch information
Showing
20 changed files
with
118 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
error[E0396]: raw pointers cannot be dereferenced in statics | ||
error[E0658]: dereferencing raw pointers in statics is unstable (see issue #51911) | ||
--> $DIR/const-deref-ptr.rs:14:29 | ||
| | ||
LL | static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; //~ ERROR E0396 | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer in constant | ||
LL | static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= 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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
// compile-pass | ||
|
||
#![feature(const_fn)] | ||
#![feature(const_fn, const_fn_union)] | ||
|
||
#![deny(const_err)] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
|
||
//compile-pass | ||
|
||
#![feature(const_fn_union)] | ||
|
||
fn main() {} | ||
|
||
static FOO: u32 = 42; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: internal compiler error: unexpected region for local data ReStatic | ||
--> $DIR/union_promotion.rs:19:29 | ||
| | ||
LL | let x: &'static bool = &unsafe { //~ borrowed value does not live long enough | ||
| _____________________________^ | ||
LL | | Foo { a: &1 }.b == Foo { a: &2 }.b | ||
LL | | }; | ||
| |_____^ | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
// except according to those terms. | ||
|
||
// compile-pass | ||
#![feature(const_fn_union)] | ||
|
||
union U { | ||
a: usize, | ||
|