Skip to content

Commit dfa2223

Browse files
committed
Auto merge of #146830 - Zalathar:rollup-lj8jfok, r=Zalathar
Rollup of 8 pull requests Successful merges: - #140983 (Improve doc of some methods that take ranges) - #144091 (Stabilize `new_zeroed_alloc`) - #145664 (Stabilize `std::panic::Location::file_as_c_str`) - #146551 (fix issue with `cmse-nonsecure-entry` ABI being both async and c-variadic) - #146744 (Deref related cleanups in ref_prop) - #146793 (naked_asm: emit a label starting with `func_end`) - #146820 (Add unstable attribute to BTreeMap-related allocator generics) - #146822 (Fix old typo in lang_start_internal comment) r? `@ghost` `@rustbot` modify labels: rollup
2 parents dd7fda5 + 5224279 commit dfa2223

File tree

23 files changed

+164
-111
lines changed

23 files changed

+164
-111
lines changed

compiler/rustc_codegen_ssa/src/mir/naked_asm.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ fn prefix_and_suffix<'tcx>(
228228
writeln!(begin, "{asm_name}:").unwrap();
229229

230230
writeln!(end).unwrap();
231+
// emit a label starting with `func_end` for `cargo asm` and other tooling that might
232+
// pattern match on assembly generated by LLVM.
233+
writeln!(end, ".Lfunc_end_{asm_name}:").unwrap();
231234
writeln!(end, ".size {asm_name}, . - {asm_name}").unwrap();
232235
writeln!(end, ".popsection").unwrap();
233236
if !arch_suffix.is_empty() {
@@ -246,6 +249,7 @@ fn prefix_and_suffix<'tcx>(
246249
writeln!(begin, "{asm_name}:").unwrap();
247250

248251
writeln!(end).unwrap();
252+
writeln!(end, ".Lfunc_end_{asm_name}:").unwrap();
249253
writeln!(end, ".popsection").unwrap();
250254
if !arch_suffix.is_empty() {
251255
writeln!(end, "{}", arch_suffix).unwrap();
@@ -263,6 +267,7 @@ fn prefix_and_suffix<'tcx>(
263267
writeln!(begin, "{asm_name}:").unwrap();
264268

265269
writeln!(end).unwrap();
270+
writeln!(end, ".Lfunc_end_{asm_name}:").unwrap();
266271
writeln!(end, ".popsection").unwrap();
267272
if !arch_suffix.is_empty() {
268273
writeln!(end, "{}", arch_suffix).unwrap();
@@ -287,6 +292,7 @@ fn prefix_and_suffix<'tcx>(
287292
writeln!(end).unwrap();
288293
// .size is ignored for function symbols, so we can skip it
289294
writeln!(end, "end_function").unwrap();
295+
writeln!(end, ".Lfunc_end_{asm_name}:").unwrap();
290296
}
291297
BinaryFormat::Xcoff => {
292298
// the LLVM XCOFFAsmParser is extremely incomplete and does not implement many of the

compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ pub(crate) fn validate_cmse_abi<'tcx>(
8585
return;
8686
};
8787

88+
// An `extern "cmse-nonsecure-entry"` function cannot be c-variadic. We run
89+
// into https://github.com/rust-lang/rust/issues/132142 if we don't explicitly bail.
90+
if decl.c_variadic {
91+
return;
92+
}
93+
8894
match is_valid_cmse_inputs(tcx, fn_sig) {
8995
Ok(Ok(())) => {}
9096
Ok(Err(index)) => {

compiler/rustc_index/src/bit_set.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ impl<T: Idx> ChunkedBitSet<T> {
645645
};
646646
#[cfg(not(feature = "nightly"))]
647647
let mut words = {
648-
// FIXME: unconditionally use `Rc::new_zeroed` once it is stable (#63291).
648+
// FIXME: unconditionally use `Rc::new_zeroed` once it is stable (#129396).
649649
let words = mem::MaybeUninit::<[Word; CHUNK_WORDS]>::zeroed();
650650
// SAFETY: `words` can safely be all zeroes.
651651
let words = unsafe { words.assume_init() };
@@ -708,7 +708,7 @@ impl<T: Idx> ChunkedBitSet<T> {
708708
};
709709
#[cfg(not(feature = "nightly"))]
710710
let mut words = {
711-
// FIXME: unconditionally use `Rc::new_zeroed` once it is stable (#63291).
711+
// FIXME: unconditionally use `Rc::new_zeroed` once it is stable (#129396).
712712
let words = mem::MaybeUninit::<[Word; CHUNK_WORDS]>::zeroed();
713713
// SAFETY: `words` can safely be all zeroes.
714714
let words = unsafe { words.assume_init() };

compiler/rustc_index/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// tidy-alphabetical-start
22
#![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))]
3+
#![cfg_attr(bootstrap, feature(new_zeroed_alloc))]
34
#![cfg_attr(feature = "nightly", allow(internal_features))]
45
#![cfg_attr(feature = "nightly", feature(extend_one, step_trait, test))]
56
#![cfg_attr(feature = "nightly", feature(new_range_api))]
6-
#![cfg_attr(feature = "nightly", feature(new_zeroed_alloc))]
77
// tidy-alphabetical-end
88

99
pub mod bit_set;

compiler/rustc_mir_transform/src/ref_prop.rs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -195,18 +195,18 @@ fn compute_replacement<'tcx>(
195195
// including DEF. This violates the DEF dominates USE condition, and so is impossible.
196196
let is_constant_place = |place: Place<'_>| {
197197
// We only allow `Deref` as the first projection, to avoid surprises.
198-
if place.projection.first() == Some(&PlaceElem::Deref) {
198+
if let Some((&PlaceElem::Deref, rest)) = place.projection.split_first() {
199199
// `place == (*some_local).xxx`, it is constant only if `some_local` is constant.
200200
// We approximate constness using SSAness.
201-
ssa.is_ssa(place.local) && place.projection[1..].iter().all(PlaceElem::is_stable_offset)
201+
ssa.is_ssa(place.local) && rest.iter().all(PlaceElem::is_stable_offset)
202202
} else {
203203
storage_live.has_single_storage(place.local)
204204
&& place.projection[..].iter().all(PlaceElem::is_stable_offset)
205205
}
206206
};
207207

208208
let mut can_perform_opt = |target: Place<'tcx>, loc: Location| {
209-
if target.projection.first() == Some(&PlaceElem::Deref) {
209+
if target.is_indirect_first_projection() {
210210
// We are creating a reborrow. As `place.local` is a reference, removing the storage
211211
// statements should not make it much harder for LLVM to optimize.
212212
storage_to_remove.insert(target.local);
@@ -266,15 +266,15 @@ fn compute_replacement<'tcx>(
266266
Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => {
267267
let mut place = *place;
268268
// Try to see through `place` in order to collapse reborrow chains.
269-
if place.projection.first() == Some(&PlaceElem::Deref)
269+
if let Some((&PlaceElem::Deref, rest)) = place.projection.split_first()
270270
&& let Value::Pointer(target, inner_needs_unique) = targets[place.local]
271271
// Only see through immutable reference and pointers, as we do not know yet if
272272
// mutable references are fully replaced.
273273
&& !inner_needs_unique
274274
// Only collapse chain if the pointee is definitely live.
275275
&& can_perform_opt(target, location)
276276
{
277-
place = target.project_deeper(&place.projection[1..], tcx);
277+
place = target.project_deeper(rest, tcx);
278278
}
279279
assert_ne!(place.local, local);
280280
if is_constant_place(place) {
@@ -323,7 +323,7 @@ fn compute_replacement<'tcx>(
323323
return;
324324
}
325325

326-
if place.projection.first() != Some(&PlaceElem::Deref) {
326+
if !place.is_indirect_first_projection() {
327327
// This is not a dereference, nothing to do.
328328
return;
329329
}
@@ -392,20 +392,15 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'tcx> {
392392
}
393393

394394
fn visit_var_debug_info(&mut self, debuginfo: &mut VarDebugInfo<'tcx>) {
395-
// If the debuginfo is a pointer to another place:
396-
// - if it's a reborrow, see through it;
397-
// - if it's a direct borrow, increase `debuginfo.references`.
395+
// If the debuginfo is a pointer to another place
396+
// and it's a reborrow: see through it
398397
while let VarDebugInfoContents::Place(ref mut place) = debuginfo.value
399398
&& place.projection.is_empty()
400399
&& let Value::Pointer(target, _) = self.targets[place.local]
401-
&& target.projection.iter().all(|p| p.can_use_in_debuginfo())
400+
&& let &[PlaceElem::Deref] = &target.projection[..]
402401
{
403-
if let Some((&PlaceElem::Deref, rest)) = target.projection.split_last() {
404-
*place = Place::from(target.local).project_deeper(rest, self.tcx);
405-
self.any_replacement = true;
406-
} else {
407-
break;
408-
}
402+
*place = Place::from(target.local);
403+
self.any_replacement = true;
409404
}
410405

411406
// Simplify eventual projections left inside `debuginfo`.
@@ -414,9 +409,7 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'tcx> {
414409

415410
fn visit_place(&mut self, place: &mut Place<'tcx>, ctxt: PlaceContext, loc: Location) {
416411
loop {
417-
if place.projection.first() != Some(&PlaceElem::Deref) {
418-
return;
419-
}
412+
let Some((&PlaceElem::Deref, rest)) = place.projection.split_first() else { return };
420413

421414
let Value::Pointer(target, _) = self.targets[place.local] else { return };
422415

@@ -432,7 +425,7 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'tcx> {
432425
return;
433426
}
434427

435-
*place = target.project_deeper(&place.projection[1..], self.tcx);
428+
*place = target.project_deeper(rest, self.tcx);
436429
self.any_replacement = true;
437430
}
438431
}

library/alloc/src/boxed.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,6 @@ impl<T> Box<T> {
290290
/// # Examples
291291
///
292292
/// ```
293-
/// #![feature(new_zeroed_alloc)]
294-
///
295293
/// let zero = Box::<u32>::new_zeroed();
296294
/// let zero = unsafe { zero.assume_init() };
297295
///
@@ -301,7 +299,7 @@ impl<T> Box<T> {
301299
/// [zeroed]: mem::MaybeUninit::zeroed
302300
#[cfg(not(no_global_oom_handling))]
303301
#[inline]
304-
#[unstable(feature = "new_zeroed_alloc", issue = "129396")]
302+
#[stable(feature = "new_zeroed_alloc", since = "CURRENT_RUSTC_VERSION")]
305303
#[must_use]
306304
pub fn new_zeroed() -> Box<mem::MaybeUninit<T>> {
307305
Self::new_zeroed_in(Global)
@@ -358,7 +356,6 @@ impl<T> Box<T> {
358356
/// # Ok::<(), std::alloc::AllocError>(())
359357
/// ```
360358
#[unstable(feature = "allocator_api", issue = "32838")]
361-
// #[unstable(feature = "new_uninit", issue = "63291")]
362359
#[inline]
363360
pub fn try_new_uninit() -> Result<Box<mem::MaybeUninit<T>>, AllocError> {
364361
Box::try_new_uninit_in(Global)
@@ -384,7 +381,6 @@ impl<T> Box<T> {
384381
///
385382
/// [zeroed]: mem::MaybeUninit::zeroed
386383
#[unstable(feature = "allocator_api", issue = "32838")]
387-
// #[unstable(feature = "new_uninit", issue = "63291")]
388384
#[inline]
389385
pub fn try_new_zeroed() -> Result<Box<mem::MaybeUninit<T>>, AllocError> {
390386
Box::try_new_zeroed_in(Global)
@@ -463,7 +459,6 @@ impl<T, A: Allocator> Box<T, A> {
463459
#[unstable(feature = "allocator_api", issue = "32838")]
464460
#[cfg(not(no_global_oom_handling))]
465461
#[must_use]
466-
// #[unstable(feature = "new_uninit", issue = "63291")]
467462
pub fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
468463
where
469464
A: Allocator,
@@ -496,7 +491,6 @@ impl<T, A: Allocator> Box<T, A> {
496491
/// # Ok::<(), std::alloc::AllocError>(())
497492
/// ```
498493
#[unstable(feature = "allocator_api", issue = "32838")]
499-
// #[unstable(feature = "new_uninit", issue = "63291")]
500494
pub fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
501495
where
502496
A: Allocator,
@@ -532,7 +526,6 @@ impl<T, A: Allocator> Box<T, A> {
532526
/// [zeroed]: mem::MaybeUninit::zeroed
533527
#[unstable(feature = "allocator_api", issue = "32838")]
534528
#[cfg(not(no_global_oom_handling))]
535-
// #[unstable(feature = "new_uninit", issue = "63291")]
536529
#[must_use]
537530
pub fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
538531
where
@@ -570,7 +563,6 @@ impl<T, A: Allocator> Box<T, A> {
570563
///
571564
/// [zeroed]: mem::MaybeUninit::zeroed
572565
#[unstable(feature = "allocator_api", issue = "32838")]
573-
// #[unstable(feature = "new_uninit", issue = "63291")]
574566
pub fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
575567
where
576568
A: Allocator,
@@ -660,8 +652,6 @@ impl<T> Box<[T]> {
660652
/// # Examples
661653
///
662654
/// ```
663-
/// #![feature(new_zeroed_alloc)]
664-
///
665655
/// let values = Box::<[u32]>::new_zeroed_slice(3);
666656
/// let values = unsafe { values.assume_init() };
667657
///
@@ -670,7 +660,7 @@ impl<T> Box<[T]> {
670660
///
671661
/// [zeroed]: mem::MaybeUninit::zeroed
672662
#[cfg(not(no_global_oom_handling))]
673-
#[unstable(feature = "new_zeroed_alloc", issue = "129396")]
663+
#[stable(feature = "new_zeroed_alloc", since = "CURRENT_RUSTC_VERSION")]
674664
#[must_use]
675665
pub fn new_zeroed_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> {
676666
unsafe { RawVec::with_capacity_zeroed(len).into_box(len) }
@@ -785,7 +775,6 @@ impl<T, A: Allocator> Box<[T], A> {
785775
/// ```
786776
#[cfg(not(no_global_oom_handling))]
787777
#[unstable(feature = "allocator_api", issue = "32838")]
788-
// #[unstable(feature = "new_uninit", issue = "63291")]
789778
#[must_use]
790779
pub fn new_uninit_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> {
791780
unsafe { RawVec::with_capacity_in(len, alloc).into_box(len) }
@@ -813,7 +802,6 @@ impl<T, A: Allocator> Box<[T], A> {
813802
/// [zeroed]: mem::MaybeUninit::zeroed
814803
#[cfg(not(no_global_oom_handling))]
815804
#[unstable(feature = "allocator_api", issue = "32838")]
816-
// #[unstable(feature = "new_uninit", issue = "63291")]
817805
#[must_use]
818806
pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> {
819807
unsafe { RawVec::with_capacity_zeroed_in(len, alloc).into_box(len) }

library/alloc/src/collections/btree/map.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,11 @@ impl<K, V: fmt::Debug> fmt::Debug for ValuesMut<'_, K, V> {
546546
/// [`into_keys`]: BTreeMap::into_keys
547547
#[must_use = "iterators are lazy and do nothing unless consumed"]
548548
#[stable(feature = "map_into_keys_values", since = "1.54.0")]
549-
pub struct IntoKeys<K, V, A: Allocator + Clone = Global> {
549+
pub struct IntoKeys<
550+
K,
551+
V,
552+
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global,
553+
> {
550554
inner: IntoIter<K, V, A>,
551555
}
552556

library/alloc/src/collections/btree/map/entry.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ impl<K: Debug + Ord, V: Debug, A: Allocator + Clone> Debug for OccupiedEntry<'_,
9999
///
100100
/// Contains the occupied entry, and the value that was not inserted.
101101
#[unstable(feature = "map_try_insert", issue = "82766")]
102-
pub struct OccupiedError<'a, K: 'a, V: 'a, A: Allocator + Clone = Global> {
102+
pub struct OccupiedError<
103+
'a,
104+
K: 'a,
105+
V: 'a,
106+
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global,
107+
> {
103108
/// The entry in the map that was already occupied.
104109
pub entry: OccupiedEntry<'a, K, V, A>,
105110
/// The value which was not inserted, because the entry was already occupied.

library/alloc/src/collections/vec_deque/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,8 +1486,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
14861486
///
14871487
/// # Panics
14881488
///
1489-
/// Panics if the starting point is greater than the end point or if
1490-
/// the end point is greater than the length of the deque.
1489+
/// Panics if the range has `start_bound > end_bound`, or, if the range is
1490+
/// bounded on either end and past the length of the deque.
14911491
///
14921492
/// # Examples
14931493
///
@@ -1522,8 +1522,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
15221522
///
15231523
/// # Panics
15241524
///
1525-
/// Panics if the starting point is greater than the end point or if
1526-
/// the end point is greater than the length of the deque.
1525+
/// Panics if the range has `start_bound > end_bound`, or, if the range is
1526+
/// bounded on either end and past the length of the deque.
15271527
///
15281528
/// # Examples
15291529
///
@@ -1568,8 +1568,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
15681568
///
15691569
/// # Panics
15701570
///
1571-
/// Panics if the starting point is greater than the end point or if
1572-
/// the end point is greater than the length of the deque.
1571+
/// Panics if the range has `start_bound > end_bound`, or, if the range is
1572+
/// bounded on either end and past the length of the deque.
15731573
///
15741574
/// # Leaking
15751575
///

0 commit comments

Comments
 (0)