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
This commit is contained in:
commit
71ffdf7ff7
36 changed files with 123 additions and 72 deletions
|
@ -508,12 +508,12 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
|
|||
// Access to the union's fields: this is `std` and we know that the `r#try`
|
||||
// intrinsic fills in the `r` or `p` union field based on its return value.
|
||||
//
|
||||
// The call to `intrinsics::r#try` is made safe by:
|
||||
// The call to `intrinsics::catch_unwind` is made safe by:
|
||||
// - `do_call`, the first argument, can be called with the initial `data_ptr`.
|
||||
// - `do_catch`, the second argument, can be called with the `data_ptr` as well.
|
||||
// See their safety preconditions for more information
|
||||
unsafe {
|
||||
return if intrinsics::r#try(do_call::<F, R>, data_ptr, do_catch::<F, R>) == 0 {
|
||||
return if intrinsics::catch_unwind(do_call::<F, R>, data_ptr, do_catch::<F, R>) == 0 {
|
||||
Ok(ManuallyDrop::into_inner(data.r))
|
||||
} else {
|
||||
Err(ManuallyDrop::into_inner(data.p))
|
||||
|
@ -540,7 +540,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
|
|||
// Its must contains a valid `f` (type: F) value that can be use to fill
|
||||
// `data.r`.
|
||||
//
|
||||
// This function cannot be marked as `unsafe` because `intrinsics::r#try`
|
||||
// This function cannot be marked as `unsafe` because `intrinsics::catch_unwind`
|
||||
// expects normal function pointers.
|
||||
#[inline]
|
||||
fn do_call<F: FnOnce() -> R, R>(data: *mut u8) {
|
||||
|
@ -562,7 +562,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
|
|||
// Since this uses `cleanup` it also hinges on a correct implementation of
|
||||
// `__rustc_panic_cleanup`.
|
||||
//
|
||||
// This function cannot be marked as `unsafe` because `intrinsics::r#try`
|
||||
// This function cannot be marked as `unsafe` because `intrinsics::catch_unwind`
|
||||
// expects normal function pointers.
|
||||
#[inline]
|
||||
#[rustc_nounwind] // `intrinsic::r#try` requires catch fn to be nounwind
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue