-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #120883 - RalfJung:extern-static-err, r=oli-obk
interpret: rename ReadExternStatic → ExternStatic This error shows up for reads and writes, so `ReadExternStatic` is misleading.
- Loading branch information
Showing
8 changed files
with
49 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// compile-flags: -Zunleash-the-miri-inside-of-you | ||
#![feature(thread_local)] | ||
#![allow(static_mut_ref)] | ||
|
||
extern "C" { | ||
static mut DATA: u8; | ||
} | ||
|
||
// Make sure we catch accessing extern static. | ||
static TEST_READ: () = { | ||
unsafe { let _val = DATA; } | ||
//~^ ERROR could not evaluate static initializer | ||
//~| NOTE cannot access extern static | ||
}; | ||
static TEST_WRITE: () = { | ||
unsafe { DATA = 0; } | ||
//~^ ERROR could not evaluate static initializer | ||
//~| NOTE cannot access extern static | ||
}; | ||
|
||
// Just creating a reference is fine, as long as we are not reading or writing. | ||
static TEST_REF: &u8 = unsafe { &DATA }; | ||
|
||
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,15 @@ | ||
error[E0080]: could not evaluate static initializer | ||
--> $DIR/extern-static.rs:11:25 | ||
| | ||
LL | unsafe { let _val = DATA; } | ||
| ^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA)) | ||
|
||
error[E0080]: could not evaluate static initializer | ||
--> $DIR/extern-static.rs:16:14 | ||
| | ||
LL | unsafe { DATA = 0; } | ||
| ^^^^^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA)) | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
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