Skip to content

Commit 111a410

Browse files
committed
Auto merge of #3147 - rust-lang:rustup-2023-10-28, r=saethlin
Automatic Rustup
2 parents 202a088 + 06a78be commit 111a410

12 files changed

+104
-10
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2e4e2a8f288f642cafcc41fff211955ceddc453d
1+
20952db40d5220e8a15c2e569ae480877bbc8417

src/bin/miri.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ fn run_compiler(
241241
mut args: Vec<String>,
242242
target_crate: bool,
243243
callbacks: &mut (dyn rustc_driver::Callbacks + Send),
244+
using_internal_features: std::sync::Arc<std::sync::atomic::AtomicBool>,
244245
) -> ! {
245246
if target_crate {
246247
// Miri needs a custom sysroot for target crates.
@@ -273,7 +274,9 @@ fn run_compiler(
273274

274275
// Invoke compiler, and handle return code.
275276
let exit_code = rustc_driver::catch_with_exit_code(move || {
276-
rustc_driver::RunCompiler::new(&args, callbacks).run()
277+
rustc_driver::RunCompiler::new(&args, callbacks)
278+
.set_using_internal_features(using_internal_features)
279+
.run()
277280
});
278281
std::process::exit(exit_code)
279282
}
@@ -295,7 +298,8 @@ fn main() {
295298
// If the environment asks us to actually be rustc, then do that.
296299
if let Some(crate_kind) = env::var_os("MIRI_BE_RUSTC") {
297300
// Earliest rustc setup.
298-
rustc_driver::install_ice_hook(rustc_driver::DEFAULT_BUG_REPORT_URL, |_| ());
301+
let using_internal_features =
302+
rustc_driver::install_ice_hook(rustc_driver::DEFAULT_BUG_REPORT_URL, |_| ());
299303
rustc_driver::init_rustc_env_logger(&handler);
300304

301305
let target_crate = if crate_kind == "target" {
@@ -311,11 +315,13 @@ fn main() {
311315
env::args().collect(),
312316
target_crate,
313317
&mut MiriBeRustCompilerCalls { target_crate },
318+
using_internal_features,
314319
)
315320
}
316321

317322
// Add an ICE bug report hook.
318-
rustc_driver::install_ice_hook("https://github.com/rust-lang/miri/issues/new", |_| ());
323+
let using_internal_features =
324+
rustc_driver::install_ice_hook("https://github.com/rust-lang/miri/issues/new", |_| ());
319325

320326
// Init loggers the Miri way.
321327
init_early_loggers(&handler);
@@ -578,5 +584,10 @@ fn main() {
578584

579585
debug!("rustc arguments: {:?}", rustc_args);
580586
debug!("crate arguments: {:?}", miri_config.args);
581-
run_compiler(rustc_args, /* target_crate: */ true, &mut MiriCompilerCalls { miri_config })
587+
run_compiler(
588+
rustc_args,
589+
/* target_crate: */ true,
590+
&mut MiriCompilerCalls { miri_config },
591+
using_internal_features,
592+
)
582593
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Make sure we find these even with many checks disabled.
2+
//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
3+
4+
#![allow(unreachable_code)]
5+
#![feature(never_type)]
6+
7+
fn main() {
8+
let p = {
9+
let b = Box::new(42);
10+
&*b as *const i32 as *const !
11+
};
12+
unsafe {
13+
match *p {} //~ ERROR: entering unreachable code
14+
}
15+
panic!("this should never print");
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: entering unreachable code
2+
--> $DIR/dangling_pointer_deref_match_never.rs:LL:CC
3+
|
4+
LL | match *p {}
5+
| ^^ entering unreachable code
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at $DIR/dangling_pointer_deref_match_never.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to previous error
15+

tests/fail/dangling_pointers/out_of_bounds_read.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(pointer_byte_offsets)]
2-
31
fn main() {
42
let v: Vec<u16> = vec![1, 2];
53
// This read is also misaligned. We make sure that the OOB message has priority.

tests/fail/dangling_pointers/out_of_bounds_write.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(pointer_byte_offsets)]
2-
31
fn main() {
42
let mut v: Vec<u16> = vec![1, 2];
53
// This read is also misaligned. We make sure that the OOB message has priority.

tests/fail/never_match_never.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This should fail even without validation
2+
//@compile-flags: -Zmiri-disable-validation
3+
4+
#![feature(never_type)]
5+
#![allow(unreachable_code)]
6+
7+
fn main() {
8+
let ptr: *const (i32, !) = &0i32 as *const i32 as *const _;
9+
unsafe { match (*ptr).1 {} } //~ ERROR: entering unreachable code
10+
}

tests/fail/never_match_never.stderr

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: entering unreachable code
2+
--> $DIR/never_match_never.rs:LL:CC
3+
|
4+
LL | unsafe { match (*ptr).1 {} }
5+
| ^^^^^^^^ entering unreachable code
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at $DIR/never_match_never.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to previous error
15+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// A `_` binding in a match is a nop, so we do not detect that the pointer is dangling.
2+
//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
3+
4+
fn main() {
5+
let p = {
6+
let b = Box::new(42);
7+
&*b as *const i32
8+
};
9+
unsafe {
10+
match *p {
11+
_ => {}
12+
}
13+
}
14+
}

tests/pass/provenance.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@revisions: stack tree
22
//@[tree]compile-flags: -Zmiri-tree-borrows
33
#![feature(strict_provenance)]
4-
#![feature(pointer_byte_offsets)]
54
use std::{mem, ptr};
65

76
const PTR_SIZE: usize = mem::size_of::<&i32>();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
fn main() {
2+
#[derive(Copy, Clone)]
3+
enum Void {}
4+
union Uninit<T: Copy> {
5+
value: T,
6+
uninit: (),
7+
}
8+
unsafe {
9+
let x: Uninit<Void> = Uninit { uninit: () };
10+
match x.value {
11+
// rustc warns about un unreachable pattern,
12+
// but is wrong in unsafe code.
13+
#[allow(unreachable_patterns)]
14+
_ => println!("hi from the void!"),
15+
}
16+
}
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hi from the void!

0 commit comments

Comments
 (0)