forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#68219 - oli-obk:fix_miri, r=RalfJung,wesley…
…wiser Untangle ZST validation from integer validation and generalize it to all zsts cc @RalfJung r? @wesleywiser
- Loading branch information
Showing
4 changed files
with
37 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
// build-pass | ||
// ignore-32bit | ||
|
||
// This test is a canary test that will essentially not compile in a reasonable time frame | ||
// (so it'll take hours) if any of the optimizations regress. With the optimizations, these compile | ||
// in milliseconds just as if the length were set to `1`. | ||
|
||
#[derive(Clone, Copy)] | ||
struct Foo; | ||
|
||
fn main() { | ||
let _ = [(); 4_000_000_000]; | ||
let _ = [0u8; 4_000_000_000]; | ||
let _ = [Foo; 4_000_000_000]; | ||
let _ = [(Foo, (), Foo, ((), Foo, [0; 0])); 4_000_000_000]; | ||
let _ = [[0; 0]; 4_000_000_000]; | ||
} |
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,5 +1,9 @@ | ||
#![feature(const_raw_ptr_deref, never_type)] | ||
|
||
const FOO: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior | ||
const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior | ||
const _: &[!; 0] = unsafe { &*(1_usize as *const [!; 0]) }; // ok | ||
const _: &[!] = unsafe { &*(1_usize as *const [!; 0]) }; // ok | ||
const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior | ||
const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; //~ ERROR undefined behavior | ||
|
||
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 |
---|---|---|
@@ -1,11 +1,27 @@ | ||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/validate_never_arrays.rs:3:1 | ||
| | ||
LL | const FOO: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of an uninhabited type at .<deref> | ||
LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of an uninhabited type at .<deref> | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
|
||
error: aborting due to previous error | ||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/validate_never_arrays.rs:6:1 | ||
| | ||
LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of an uninhabited type at .<deref>[0] | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/validate_never_arrays.rs:7:1 | ||
| | ||
LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of an uninhabited type at .<deref>[0] | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |