Skip to content

Commit 71ffdf7

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

File tree

36 files changed

+123
-72
lines changed

36 files changed

+123
-72
lines changed

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_middle::ty::layout::{HasParamEnv, ValidityRequirement};
2323
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
2424
use rustc_middle::ty::GenericArgsRef;
2525
use rustc_span::source_map::Spanned;
26-
use rustc_span::symbol::{kw, sym, Symbol};
26+
use rustc_span::symbol::{sym, Symbol};
2727

2828
pub(crate) use self::llvm::codegen_llvm_intrinsic_call;
2929
use crate::prelude::*;
@@ -1132,7 +1132,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
11321132
ret.write_cvalue(fx, val);
11331133
}
11341134

1135-
kw::Try => {
1135+
sym::catch_unwind => {
11361136
intrinsic_args!(fx, args => (f, data, catch_fn); intrinsic);
11371137
let f = f.load_scalar(fx);
11381138
let data = data.load_scalar(fx);

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_middle::ty::{self, Instance, Ty};
2121
use rustc_middle::ty::layout::LayoutOf;
2222
#[cfg(feature="master")]
2323
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt};
24-
use rustc_span::{Span, Symbol, symbol::kw, sym};
24+
use rustc_span::{Span, Symbol, sym};
2525
use rustc_target::abi::HasDataLayout;
2626
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
2727
use rustc_target::spec::PanicStrategy;
@@ -129,7 +129,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
129129
let res = self.context.new_call(None, builtin, &[a]);
130130
self.icmp(IntPredicate::IntEQ, res, self.const_i32(0))
131131
}
132-
kw::Try => {
132+
sym::catch_unwind => {
133133
try_intrinsic(
134134
self,
135135
args[0].immediate(),

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_hir as hir;
1717
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf};
1818
use rustc_middle::ty::{self, GenericArgsRef, Ty};
1919
use rustc_middle::{bug, span_bug};
20-
use rustc_span::{sym, symbol::kw, Span, Symbol};
20+
use rustc_span::{sym, Span, Symbol};
2121
use rustc_target::abi::{self, Align, HasDataLayout, Primitive};
2222
use rustc_target::spec::{HasTargetSpec, PanicStrategy};
2323

@@ -133,8 +133,8 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
133133
}
134134
sym::unlikely => self
135135
.call_intrinsic("llvm.expect.i1", &[args[0].immediate(), self.const_bool(false)]),
136-
kw::Try => {
137-
try_intrinsic(
136+
sym::catch_unwind => {
137+
catch_unwind_intrinsic(
138138
self,
139139
args[0].immediate(),
140140
args[1].immediate(),
@@ -457,7 +457,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
457457
}
458458
}
459459

460-
fn try_intrinsic<'ll>(
460+
fn catch_unwind_intrinsic<'ll>(
461461
bx: &mut Builder<'_, 'll, '_>,
462462
try_func: &'ll Value,
463463
data: &'ll Value,

compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_hir as hir;
1212
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
1313
use rustc_middle::ty::{self, Ty, TyCtxt};
1414
use rustc_span::def_id::LocalDefId;
15-
use rustc_span::symbol::{kw, sym};
15+
use rustc_span::symbol::sym;
1616
use rustc_span::{Span, Symbol};
1717
use rustc_target::spec::abi::Abi;
1818

@@ -445,7 +445,7 @@ pub fn check_intrinsic_type(
445445
)
446446
}
447447

448-
kw::Try => {
448+
sym::catch_unwind => {
449449
let mut_u8 = Ty::new_mut_ptr(tcx, tcx.types.u8);
450450
let try_fn_ty = ty::Binder::dummy(tcx.mk_fn_sig(
451451
[mut_u8],

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,8 @@ impl<'a> Parser<'a> {
800800
{
801801
Ok(next_attr) => next_attr,
802802
Err(inner_err) => {
803-
err.cancel();
804803
inner_err.cancel();
805-
return self.dcx().span_delayed_bug(expr.span, "not a tail expression");
804+
return err.emit();
806805
}
807806
}
808807
&& let ast::AttrKind::Normal(next_attr_kind) = next_attr.kind
@@ -813,9 +812,8 @@ impl<'a> Parser<'a> {
813812
let next_expr = match snapshot.parse_expr() {
814813
Ok(next_expr) => next_expr,
815814
Err(inner_err) => {
816-
err.cancel();
817815
inner_err.cancel();
818-
return self.dcx().span_delayed_bug(expr.span, "not a tail expression");
816+
return err.emit();
819817
}
820818
};
821819
// We have for sure

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ symbols! {
487487
call_once,
488488
caller_location,
489489
capture_disjoint_fields,
490+
catch_unwind,
490491
cause,
491492
cdylib,
492493
ceilf32,

library/alloc/src/string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ impl String {
864864
}
865865
}
866866

867-
/// Decomposes a `String` into its raw components.
867+
/// Decomposes a `String` into its raw components: `(pointer, length, capacity)`.
868868
///
869869
/// Returns the raw pointer to the underlying data, the length of
870870
/// the string (in bytes), and the allocated capacity of the data
@@ -896,7 +896,7 @@ impl String {
896896
self.vec.into_raw_parts()
897897
}
898898

899-
/// Creates a new `String` from a length, capacity, and pointer.
899+
/// Creates a new `String` from a pointer, a length and a capacity.
900900
///
901901
/// # Safety
902902
///

library/alloc/src/vec/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ impl<T> Vec<T> {
481481
Self::with_capacity_in(capacity, Global)
482482
}
483483

484-
/// Creates a `Vec<T>` directly from a pointer, a capacity, and a length.
484+
/// Creates a `Vec<T>` directly from a pointer, a length, and a capacity.
485485
///
486486
/// # Safety
487487
///
@@ -672,7 +672,7 @@ impl<T, A: Allocator> Vec<T, A> {
672672
Vec { buf: RawVec::with_capacity_in(capacity, alloc), len: 0 }
673673
}
674674

675-
/// Creates a `Vec<T, A>` directly from a pointer, a capacity, a length,
675+
/// Creates a `Vec<T, A>` directly from a pointer, a length, a capacity,
676676
/// and an allocator.
677677
///
678678
/// # Safety
@@ -786,7 +786,7 @@ impl<T, A: Allocator> Vec<T, A> {
786786
unsafe { Vec { buf: RawVec::from_raw_parts_in(ptr, capacity, alloc), len: length } }
787787
}
788788

789-
/// Decomposes a `Vec<T>` into its raw components.
789+
/// Decomposes a `Vec<T>` into its raw components: `(pointer, length, capacity)`.
790790
///
791791
/// Returns the raw pointer to the underlying data, the length of
792792
/// the vector (in elements), and the allocated capacity of the
@@ -824,7 +824,7 @@ impl<T, A: Allocator> Vec<T, A> {
824824
(me.as_mut_ptr(), me.len(), me.capacity())
825825
}
826826

827-
/// Decomposes a `Vec<T>` into its raw components.
827+
/// Decomposes a `Vec<T>` into its raw components: `(pointer, length, capacity, allocator)`.
828828
///
829829
/// Returns the raw pointer to the underlying data, the length of the vector (in elements),
830830
/// the allocated capacity of the data (in elements), and the allocator. These are the same

library/core/src/intrinsics.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
7575
unsafe { crate::ptr::drop_in_place(to_drop) }
7676
}
7777

78+
#[cfg(bootstrap)]
79+
pub use self::r#try as catch_unwind;
80+
7881
extern "rust-intrinsic" {
7982
// N.B., these intrinsics take raw pointers because they mutate aliased
8083
// memory, which is not valid for either `&` or `&mut`.
@@ -2382,16 +2385,24 @@ extern "rust-intrinsic" {
23822385
#[rustc_nounwind]
23832386
pub fn variant_count<T>() -> usize;
23842387

2385-
/// Rust's "try catch" construct which invokes the function pointer `try_fn`
2386-
/// with the data pointer `data`.
2387-
///
2388-
/// The third argument is a function called if a panic occurs. This function
2389-
/// takes the data pointer and a pointer to the target-specific exception
2390-
/// object that was caught. For more information see the compiler's
2391-
/// source as well as std's catch implementation.
2388+
/// Rust's "try catch" construct for unwinding. Invokes the function pointer `try_fn` with the
2389+
/// data pointer `data`, and calls `catch_fn` if unwinding occurs while `try_fn` runs.
23922390
///
23932391
/// `catch_fn` must not unwind.
2392+
///
2393+
/// The third argument is a function called if an unwind occurs (both Rust unwinds and foreign
2394+
/// unwinds). This function takes the data pointer and a pointer to the target-specific
2395+
/// exception object that was caught. For more information, see the compiler's source as well as
2396+
/// std's `catch_unwind` implementation.
2397+
///
2398+
/// The stable version of this intrinsic is `std::panic::catch_unwind`.
2399+
#[rustc_nounwind]
2400+
#[cfg(not(bootstrap))]
2401+
pub fn catch_unwind(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32;
2402+
2403+
/// For bootstrap only, see `catch_unwind`.
23942404
#[rustc_nounwind]
2405+
#[cfg(bootstrap)]
23952406
pub fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32;
23962407

23972408
/// Emits a `!nontemporal` store according to LLVM (see their docs).

library/panic_unwind/src/miri.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ type Payload = Box<Box<dyn Any + Send>>;
88

99
extern "Rust" {
1010
/// Miri-provided extern function to begin unwinding.
11-
fn miri_start_panic(payload: *mut u8) -> !;
11+
fn miri_start_unwind(payload: *mut u8) -> !;
1212
}
1313

1414
pub unsafe fn panic(payload: Box<dyn Any + Send>) -> u32 {
15-
// The payload we pass to `miri_start_panic` will be exactly the argument we get
15+
// The payload we pass to `miri_start_unwind` will be exactly the argument we get
1616
// in `cleanup` below. So we just box it up once, to get something pointer-sized.
1717
let payload_box: Payload = Box::new(payload);
18-
miri_start_panic(Box::into_raw(payload_box) as *mut u8)
18+
miri_start_unwind(Box::into_raw(payload_box) as *mut u8)
1919
}
2020

2121
pub unsafe fn cleanup(payload_box: *mut u8) -> Box<dyn Any + Send> {

0 commit comments

Comments
 (0)