-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #3147 - rust-lang:rustup-2023-10-28, r=saethlin
Automatic Rustup
- Loading branch information
Showing
12 changed files
with
104 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2e4e2a8f288f642cafcc41fff211955ceddc453d | ||
20952db40d5220e8a15c2e569ae480877bbc8417 |
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
16 changes: 16 additions & 0 deletions
16
tests/fail/dangling_pointers/dangling_pointer_deref_match_never.rs
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,16 @@ | ||
// Make sure we find these even with many checks disabled. | ||
//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation | ||
|
||
#![allow(unreachable_code)] | ||
#![feature(never_type)] | ||
|
||
fn main() { | ||
let p = { | ||
let b = Box::new(42); | ||
&*b as *const i32 as *const ! | ||
}; | ||
unsafe { | ||
match *p {} //~ ERROR: entering unreachable code | ||
} | ||
panic!("this should never print"); | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/fail/dangling_pointers/dangling_pointer_deref_match_never.stderr
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: Undefined Behavior: entering unreachable code | ||
--> $DIR/dangling_pointer_deref_match_never.rs:LL:CC | ||
| | ||
LL | match *p {} | ||
| ^^ entering unreachable code | ||
| | ||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior | ||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information | ||
= note: BACKTRACE: | ||
= note: inside `main` at $DIR/dangling_pointer_deref_match_never.rs:LL:CC | ||
|
||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace | ||
|
||
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
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,10 @@ | ||
// This should fail even without validation | ||
//@compile-flags: -Zmiri-disable-validation | ||
|
||
#![feature(never_type)] | ||
#![allow(unreachable_code)] | ||
|
||
fn main() { | ||
let ptr: *const (i32, !) = &0i32 as *const i32 as *const _; | ||
unsafe { match (*ptr).1 {} } //~ ERROR: entering unreachable code | ||
} |
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: Undefined Behavior: entering unreachable code | ||
--> $DIR/never_match_never.rs:LL:CC | ||
| | ||
LL | unsafe { match (*ptr).1 {} } | ||
| ^^^^^^^^ entering unreachable code | ||
| | ||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior | ||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information | ||
= note: BACKTRACE: | ||
= note: inside `main` at $DIR/never_match_never.rs:LL:CC | ||
|
||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace | ||
|
||
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,14 @@ | ||
// A `_` binding in a match is a nop, so we do not detect that the pointer is dangling. | ||
//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation | ||
|
||
fn main() { | ||
let p = { | ||
let b = Box::new(42); | ||
&*b as *const i32 | ||
}; | ||
unsafe { | ||
match *p { | ||
_ => {} | ||
} | ||
} | ||
} |
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,17 @@ | ||
fn main() { | ||
#[derive(Copy, Clone)] | ||
enum Void {} | ||
union Uninit<T: Copy> { | ||
value: T, | ||
uninit: (), | ||
} | ||
unsafe { | ||
let x: Uninit<Void> = Uninit { uninit: () }; | ||
match x.value { | ||
// rustc warns about un unreachable pattern, | ||
// but is wrong in unsafe code. | ||
#[allow(unreachable_patterns)] | ||
_ => println!("hi from the void!"), | ||
} | ||
} | ||
} |
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 @@ | ||
hi from the void! |