Skip to content

Commit 896446d

Browse files
committed
Auto merge of #146825 - tgross35:rollup-hpuv09x, r=tgross35
Rollup of 6 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`) - #146744 (Deref related cleanups in ref_prop) - #146793 (naked_asm: emit a label starting with `func_end`) - #146822 (Fix old typo in lang_start_internal comment) r? `@ghost` `@rustbot` modify labels: rollup
2 parents dd7fda5 + 0c666a5 commit 896446d

File tree

15 files changed

+48
-83
lines changed

15 files changed

+48
-83
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_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/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
///

library/alloc/src/rc.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,6 @@ impl<T> Rc<T> {
515515
/// # Examples
516516
///
517517
/// ```
518-
/// #![feature(new_zeroed_alloc)]
519-
///
520518
/// use std::rc::Rc;
521519
///
522520
/// let zero = Rc::<u32>::new_zeroed();
@@ -527,7 +525,7 @@ impl<T> Rc<T> {
527525
///
528526
/// [zeroed]: mem::MaybeUninit::zeroed
529527
#[cfg(not(no_global_oom_handling))]
530-
#[unstable(feature = "new_zeroed_alloc", issue = "129396")]
528+
#[stable(feature = "new_zeroed_alloc", since = "CURRENT_RUSTC_VERSION")]
531529
#[must_use]
532530
pub fn new_zeroed() -> Rc<mem::MaybeUninit<T>> {
533531
unsafe {
@@ -589,7 +587,6 @@ impl<T> Rc<T> {
589587
/// # Ok::<(), std::alloc::AllocError>(())
590588
/// ```
591589
#[unstable(feature = "allocator_api", issue = "32838")]
592-
// #[unstable(feature = "new_uninit", issue = "63291")]
593590
pub fn try_new_uninit() -> Result<Rc<mem::MaybeUninit<T>>, AllocError> {
594591
unsafe {
595592
Ok(Rc::from_ptr(Rc::try_allocate_for_layout(
@@ -622,7 +619,6 @@ impl<T> Rc<T> {
622619
///
623620
/// [zeroed]: mem::MaybeUninit::zeroed
624621
#[unstable(feature = "allocator_api", issue = "32838")]
625-
//#[unstable(feature = "new_uninit", issue = "63291")]
626622
pub fn try_new_zeroed() -> Result<Rc<mem::MaybeUninit<T>>, AllocError> {
627623
unsafe {
628624
Ok(Rc::from_ptr(Rc::try_allocate_for_layout(
@@ -690,7 +686,6 @@ impl<T, A: Allocator> Rc<T, A> {
690686
/// ```
691687
#[cfg(not(no_global_oom_handling))]
692688
#[unstable(feature = "allocator_api", issue = "32838")]
693-
// #[unstable(feature = "new_uninit", issue = "63291")]
694689
#[inline]
695690
pub fn new_uninit_in(alloc: A) -> Rc<mem::MaybeUninit<T>, A> {
696691
unsafe {
@@ -728,7 +723,6 @@ impl<T, A: Allocator> Rc<T, A> {
728723
/// [zeroed]: mem::MaybeUninit::zeroed
729724
#[cfg(not(no_global_oom_handling))]
730725
#[unstable(feature = "allocator_api", issue = "32838")]
731-
// #[unstable(feature = "new_uninit", issue = "63291")]
732726
#[inline]
733727
pub fn new_zeroed_in(alloc: A) -> Rc<mem::MaybeUninit<T>, A> {
734728
unsafe {
@@ -873,7 +867,6 @@ impl<T, A: Allocator> Rc<T, A> {
873867
/// # Ok::<(), std::alloc::AllocError>(())
874868
/// ```
875869
#[unstable(feature = "allocator_api", issue = "32838")]
876-
// #[unstable(feature = "new_uninit", issue = "63291")]
877870
#[inline]
878871
pub fn try_new_uninit_in(alloc: A) -> Result<Rc<mem::MaybeUninit<T>, A>, AllocError> {
879872
unsafe {
@@ -912,7 +905,6 @@ impl<T, A: Allocator> Rc<T, A> {
912905
///
913906
/// [zeroed]: mem::MaybeUninit::zeroed
914907
#[unstable(feature = "allocator_api", issue = "32838")]
915-
//#[unstable(feature = "new_uninit", issue = "63291")]
916908
#[inline]
917909
pub fn try_new_zeroed_in(alloc: A) -> Result<Rc<mem::MaybeUninit<T>, A>, AllocError> {
918910
unsafe {
@@ -1054,8 +1046,6 @@ impl<T> Rc<[T]> {
10541046
/// # Examples
10551047
///
10561048
/// ```
1057-
/// #![feature(new_zeroed_alloc)]
1058-
///
10591049
/// use std::rc::Rc;
10601050
///
10611051
/// let values = Rc::<[u32]>::new_zeroed_slice(3);
@@ -1066,7 +1056,7 @@ impl<T> Rc<[T]> {
10661056
///
10671057
/// [zeroed]: mem::MaybeUninit::zeroed
10681058
#[cfg(not(no_global_oom_handling))]
1069-
#[unstable(feature = "new_zeroed_alloc", issue = "129396")]
1059+
#[stable(feature = "new_zeroed_alloc", since = "CURRENT_RUSTC_VERSION")]
10701060
#[must_use]
10711061
pub fn new_zeroed_slice(len: usize) -> Rc<[mem::MaybeUninit<T>]> {
10721062
unsafe {
@@ -1129,7 +1119,6 @@ impl<T, A: Allocator> Rc<[T], A> {
11291119
/// ```
11301120
#[cfg(not(no_global_oom_handling))]
11311121
#[unstable(feature = "allocator_api", issue = "32838")]
1132-
// #[unstable(feature = "new_uninit", issue = "63291")]
11331122
#[inline]
11341123
pub fn new_uninit_slice_in(len: usize, alloc: A) -> Rc<[mem::MaybeUninit<T>], A> {
11351124
unsafe { Rc::from_ptr_in(Rc::allocate_for_slice_in(len, &alloc), alloc) }
@@ -1158,7 +1147,6 @@ impl<T, A: Allocator> Rc<[T], A> {
11581147
/// [zeroed]: mem::MaybeUninit::zeroed
11591148
#[cfg(not(no_global_oom_handling))]
11601149
#[unstable(feature = "allocator_api", issue = "32838")]
1161-
// #[unstable(feature = "new_uninit", issue = "63291")]
11621150
#[inline]
11631151
pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Rc<[mem::MaybeUninit<T>], A> {
11641152
unsafe {

0 commit comments

Comments
 (0)