Skip to content

Commit 14ea474

Browse files
committed
Auto merge of #121655 - matthiaskrgr:rollup-qpx3kks, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #121598 (rename 'try' intrinsic to 'catch_unwind') - #121639 (Update books) - #121648 (Update Vec and String `{from,into}_raw_parts`-family docs) - #121651 (Properly emit `expected ;` on `#[attr] expr`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a760b5c + 109c27d commit 14ea474

12 files changed

+27
-27
lines changed

src/concurrency/thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub struct Thread<'mir, 'tcx> {
143143
join_status: ThreadJoinStatus,
144144

145145
/// Stack of active panic payloads for the current thread. Used for storing
146-
/// the argument of the call to `miri_start_panic` (the panic payload) when unwinding.
146+
/// the argument of the call to `miri_start_unwind` (the panic payload) when unwinding.
147147
/// This is pointer-sized, and matches the `Payload` type in `src/libpanic_unwind/miri.rs`.
148148
///
149149
/// In real unwinding, the payload gets passed as an argument to the landing pad,

src/shims/foreign_items.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
6868
let ret = match ret {
6969
None =>
7070
match link_name.as_str() {
71-
"miri_start_panic" => {
72-
// `check_shim` happens inside `handle_miri_start_panic`.
73-
this.handle_miri_start_panic(abi, link_name, args, unwind)?;
71+
"miri_start_unwind" => {
72+
// `check_shim` happens inside `handle_miri_start_unwind`.
73+
this.handle_miri_start_unwind(abi, link_name, args, unwind)?;
7474
return Ok(None);
7575
}
7676
// This matches calls to the foreign item `panic_impl`.

src/shims/intrinsics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
5454

5555
// Some intrinsics are special and need the "ret".
5656
match intrinsic_name {
57-
"try" => return this.handle_try(args, dest, ret),
57+
"catch_unwind" => return this.handle_catch_unwind(args, dest, ret),
5858
_ => {}
5959
}
6060

src/shims/panic.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//! The core pieces of the runtime are:
44
//! - An implementation of `__rust_maybe_catch_panic` that pushes the invoked stack frame with
55
//! some extra metadata derived from the panic-catching arguments of `__rust_maybe_catch_panic`.
6-
//! - A hack in `libpanic_unwind` that calls the `miri_start_panic` intrinsic instead of the
6+
//! - A hack in `libpanic_unwind` that calls the `miri_start_unwind` intrinsic instead of the
77
//! target-native panic runtime. (This lives in the rustc repo.)
8-
//! - An implementation of `miri_start_panic` that stores its argument (the panic payload), and then
8+
//! - An implementation of `miri_start_unwind` that stores its argument (the panic payload), and then
99
//! immediately returns, but on the *unwind* edge (not the normal return edge), thus initiating unwinding.
1010
//! - A hook executed each time a frame is popped, such that if the frame pushed by `__rust_maybe_catch_panic`
1111
//! gets popped *during unwinding*, we take the panic payload and store it according to the extra
@@ -44,9 +44,9 @@ impl VisitProvenance for CatchUnwindData<'_> {
4444

4545
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {}
4646
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
47-
/// Handles the special `miri_start_panic` intrinsic, which is called
47+
/// Handles the special `miri_start_unwind` intrinsic, which is called
4848
/// by libpanic_unwind to delegate the actual unwinding process to Miri.
49-
fn handle_miri_start_panic(
49+
fn handle_miri_start_unwind(
5050
&mut self,
5151
abi: Abi,
5252
link_name: Symbol,
@@ -55,7 +55,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
5555
) -> InterpResult<'tcx> {
5656
let this = self.eval_context_mut();
5757

58-
trace!("miri_start_panic: {:?}", this.frame().instance);
58+
trace!("miri_start_unwind: {:?}", this.frame().instance);
5959

6060
// Get the raw pointer stored in arg[0] (the panic payload).
6161
let [payload] = this.check_shim(abi, Abi::Rust, link_name, args)?;
@@ -69,7 +69,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
6969
}
7070

7171
/// Handles the `try` intrinsic, the underlying implementation of `std::panicking::try`.
72-
fn handle_try(
72+
fn handle_catch_unwind(
7373
&mut self,
7474
args: &[OpTy<'tcx, Provenance>],
7575
dest: &PlaceTy<'tcx, Provenance>,
@@ -85,7 +85,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
8585
// what that is), and returns 1.
8686
// The `payload` is passed (by libstd) to `__rust_panic_cleanup`, which is then expected to
8787
// return a `Box<dyn Any + Send + 'static>`.
88-
// In Miri, `miri_start_panic` is passed exactly that type, so we make the `payload` simply
88+
// In Miri, `miri_start_unwind` is passed exactly that type, so we make the `payload` simply
8989
// a pointer to `Box<dyn Any + Send + 'static>`.
9090

9191
// Get all the arguments.
@@ -141,7 +141,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
141141
// We set the return value of `try` to 1, since there was a panic.
142142
this.write_scalar(Scalar::from_i32(1), &catch_unwind.dest)?;
143143

144-
// The Thread's `panic_payload` holds what was passed to `miri_start_panic`.
144+
// The Thread's `panic_payload` holds what was passed to `miri_start_unwind`.
145145
// This is exactly the second argument we need to pass to `catch_fn`.
146146
let payload = this.active_thread_mut().panic_payloads.pop().unwrap();
147147

tests/fail/function_calls/check_callback_abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn main() {
88
unsafe {
99
// Make sure we check the ABI when Miri itself invokes a function
1010
// as part of a shim implementation.
11-
std::intrinsics::r#try(
11+
std::intrinsics::catch_unwind(
1212
//~^ ERROR: calling a function with ABI C using caller ABI Rust
1313
std::mem::transmute::<extern "C" fn(*mut u8), _>(try_fn),
1414
std::ptr::null_mut(),

tests/fail/function_calls/check_callback_abi.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error: Undefined Behavior: calling a function with ABI C using caller ABI Rust
22
--> $DIR/check_callback_abi.rs:LL:CC
33
|
4-
LL | / std::intrinsics::r#try(
4+
LL | / std::intrinsics::catch_unwind(
55
LL | |
66
LL | | std::mem::transmute::<extern "C" fn(*mut u8), _>(try_fn),
77
LL | | std::ptr::null_mut(),

tests/fail/panic/bad_miri_start_panic.rs renamed to tests/fail/panic/bad_miri_start_unwind.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#![feature(c_unwind)]
44

55
extern "C" {
6-
fn miri_start_panic(payload: *mut u8) -> !;
6+
fn miri_start_unwind(payload: *mut u8) -> !;
77
}
88

99
fn main() {
10-
unsafe { miri_start_panic(&mut 0) }
10+
unsafe { miri_start_unwind(&mut 0) }
1111
//~^ ERROR: unwinding past a stack frame that does not allow unwinding
1212
}

tests/fail/panic/bad_miri_start_panic.stderr renamed to tests/fail/panic/bad_miri_start_unwind.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed.
22
If you have a use-case for it, please file an issue.
33
error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
4-
--> $DIR/bad_miri_start_panic.rs:LL:CC
4+
--> $DIR/bad_miri_start_unwind.rs:LL:CC
55
|
6-
LL | unsafe { miri_start_panic(&mut 0) }
7-
| ^^^^^^^^^^^^^^^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding
6+
LL | unsafe { miri_start_unwind(&mut 0) }
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding
88
|
99
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
1010
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
1111
= note: BACKTRACE:
12-
= note: inside `main` at $DIR/bad_miri_start_panic.rs:LL:CC
12+
= note: inside `main` at $DIR/bad_miri_start_unwind.rs:LL:CC
1313

1414
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1515

tests/fail/panic/unwind_panic_abort.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
//! Unwinding despite `-C panic=abort` is an error.
44
55
extern "Rust" {
6-
fn miri_start_panic(payload: *mut u8) -> !;
6+
fn miri_start_unwind(payload: *mut u8) -> !;
77
}
88

99
fn main() {
1010
unsafe {
11-
miri_start_panic(&mut 0); //~ ERROR: unwinding past a stack frame that does not allow unwinding
11+
miri_start_unwind(&mut 0); //~ ERROR: unwinding past a stack frame that does not allow unwinding
1212
}
1313
}

tests/fail/panic/unwind_panic_abort.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
22
--> $DIR/unwind_panic_abort.rs:LL:CC
33
|
4-
LL | miri_start_panic(&mut 0);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding
4+
LL | miri_start_unwind(&mut 0);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/pass/function_calls/disable_abi_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
unsafe {
1616
let _ = malloc(0);
1717
std::mem::transmute::<fn(), extern "C" fn()>(foo)();
18-
std::intrinsics::r#try(
18+
std::intrinsics::catch_unwind(
1919
std::mem::transmute::<extern "C" fn(*mut u8), _>(try_fn),
2020
std::ptr::null_mut(),
2121
|_, _| unreachable!(),

tests/utils/miri_extern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ extern "Rust" {
5656
///
5757
/// This is internal and unstable and should not be used; we give it here
5858
/// just to be complete.
59-
pub fn miri_start_panic(payload: *mut u8) -> !;
59+
pub fn miri_start_unwind(payload: *mut u8) -> !;
6060

6161
/// Miri-provided extern function to get the internal unique identifier for the allocation that a pointer
6262
/// points to. If this pointer is invalid (not pointing to an allocation), interpretation will abort.

0 commit comments

Comments
 (0)