Skip to content

Commit 434ac8d

Browse files
committed
fix rustfmt
1 parent bd7e4c5 commit 434ac8d

File tree

2 files changed

+17
-32
lines changed

2 files changed

+17
-32
lines changed

library/alloc/src/raw_vec/mod.rs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ const fn min_non_zero_cap(size: usize) -> usize {
165165
}
166166
}
167167

168+
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
169+
#[rustfmt::skip] // FIXME(fee1-dead): temporary measure before rustfmt is bumped
168170
const impl<T, A: [const] Allocator + [const] Destruct> RawVec<T, A> {
169171
/// Like `with_capacity`, but parameterized over the choice of
170172
/// allocator for the returned `RawVec`.
171173
#[cfg(not(no_global_oom_handling))]
172174
#[inline]
173-
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
174-
pub(crate) fn with_capacity_in(capacity: usize, alloc: A) -> Self
175-
{
175+
pub(crate) fn with_capacity_in(capacity: usize, alloc: A) -> Self {
176176
Self {
177177
inner: RawVecInner::with_capacity_in(capacity, alloc, T::LAYOUT),
178178
_marker: PhantomData,
@@ -183,9 +183,7 @@ const impl<T, A: [const] Allocator + [const] Destruct> RawVec<T, A> {
183183
/// caller to ensure `len == self.capacity()`.
184184
#[cfg(not(no_global_oom_handling))]
185185
#[inline(never)]
186-
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
187-
pub(crate) fn grow_one(&mut self)
188-
{
186+
pub(crate) fn grow_one(&mut self) {
189187
// SAFETY: All calls on self.inner pass T::LAYOUT as the elem_layout
190188
unsafe { self.inner.grow_one(T::LAYOUT) }
191189
}
@@ -411,12 +409,12 @@ unsafe impl<#[may_dangle] T, A: Allocator> Drop for RawVec<T, A> {
411409
}
412410
}
413411

412+
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
413+
#[rustfmt::skip] // FIXME(fee1-dead): temporary measure before rustfmt is bumped
414414
const impl<A: [const] Allocator + [const] Destruct> RawVecInner<A> {
415415
#[cfg(not(no_global_oom_handling))]
416416
#[inline]
417-
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
418-
fn with_capacity_in(capacity: usize, alloc: A, elem_layout: Layout) -> Self
419-
{
417+
fn with_capacity_in(capacity: usize, alloc: A, elem_layout: Layout) -> Self {
420418
match Self::try_allocate_in(capacity, AllocInit::Uninitialized, alloc, elem_layout) {
421419
Ok(this) => {
422420
unsafe {
@@ -428,14 +426,13 @@ const impl<A: [const] Allocator + [const] Destruct> RawVecInner<A> {
428426
Err(err) => handle_error(err),
429427
}
430428
}
431-
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
429+
432430
fn try_allocate_in(
433431
capacity: usize,
434432
init: AllocInit,
435433
alloc: A,
436434
elem_layout: Layout,
437-
) -> Result<Self, TryReserveError>
438-
{
435+
) -> Result<Self, TryReserveError> {
439436
// We avoid `unwrap_or_else` here because it bloats the amount of
440437
// LLVM IR generated.
441438
let layout = match layout_array(capacity, elem_layout) {
@@ -474,29 +471,24 @@ const impl<A: [const] Allocator + [const] Destruct> RawVecInner<A> {
474471
/// - `elem_layout`'s size must be a multiple of its alignment
475472
#[cfg(not(no_global_oom_handling))]
476473
#[inline]
477-
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
478-
unsafe fn grow_one(&mut self, elem_layout: Layout)
479-
{
474+
unsafe fn grow_one(&mut self, elem_layout: Layout) {
480475
// SAFETY: Precondition passed to caller
481476
if let Err(err) = unsafe { self.grow_amortized(self.cap.as_inner(), 1, elem_layout) } {
482477
handle_error(err);
483478
}
484479
}
485480

486-
487481
/// # Safety
488482
/// - `elem_layout` must be valid for `self`, i.e. it must be the same `elem_layout` used to
489483
/// initially construct `self`
490484
/// - `elem_layout`'s size must be a multiple of its alignment
491485
/// - The sum of `len` and `additional` must be greater than the current capacity
492-
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
493486
unsafe fn grow_amortized(
494487
&mut self,
495488
len: usize,
496489
additional: usize,
497490
elem_layout: Layout,
498-
) -> Result<(), TryReserveError>
499-
{
491+
) -> Result<(), TryReserveError> {
500492
// This is ensured by the calling contexts.
501493
debug_assert!(additional > 0);
502494

@@ -532,13 +524,11 @@ const impl<A: [const] Allocator + [const] Destruct> RawVecInner<A> {
532524
// not marked inline(never) since we want optimizers to be able to observe the specifics of this
533525
// function, see tests/codegen-llvm/vec-reserve-extend.rs.
534526
#[cold]
535-
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
536527
unsafe fn finish_grow(
537528
&self,
538529
cap: usize,
539530
elem_layout: Layout,
540-
) -> Result<NonNull<[u8]>, TryReserveError>
541-
{
531+
) -> Result<NonNull<[u8]>, TryReserveError> {
542532
let new_layout = layout_array(cap, elem_layout)?;
543533

544534
let memory = if let Some((ptr, old_layout)) = unsafe { self.current_memory(elem_layout) } {

library/alloc/src/vec/mod.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,8 @@ impl<T> Vec<T> {
902902
}
903903
}
904904

905+
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
906+
#[rustfmt::skip] // FIXME(fee1-dead): temporary measure before rustfmt is bumped
905907
const impl<T, A: [const] Allocator + [const] Destruct> Vec<T, A> {
906908
/// Constructs a new, empty `Vec<T, A>` with at least the specified capacity
907909
/// with the provided allocator.
@@ -961,13 +963,10 @@ const impl<T, A: [const] Allocator + [const] Destruct> Vec<T, A> {
961963
#[cfg(not(no_global_oom_handling))]
962964
#[inline]
963965
#[unstable(feature = "allocator_api", issue = "32838")]
964-
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
965-
pub fn with_capacity_in(capacity: usize, alloc: A) -> Self
966-
{
966+
pub fn with_capacity_in(capacity: usize, alloc: A) -> Self {
967967
Vec { buf: RawVec::with_capacity_in(capacity, alloc), len: 0 }
968968
}
969969

970-
971970
/// Appends an element to the back of a collection.
972971
///
973972
/// # Panics
@@ -992,9 +991,7 @@ const impl<T, A: [const] Allocator + [const] Destruct> Vec<T, A> {
992991
#[inline]
993992
#[stable(feature = "rust1", since = "1.0.0")]
994993
#[rustc_confusables("push_back", "put", "append")]
995-
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
996-
pub fn push(&mut self, value: T)
997-
{
994+
pub fn push(&mut self, value: T) {
998995
let _ = self.push_mut(value);
999996
}
1000997

@@ -1030,9 +1027,7 @@ const impl<T, A: [const] Allocator + [const] Destruct> Vec<T, A> {
10301027
#[inline]
10311028
#[unstable(feature = "push_mut", issue = "135974")]
10321029
#[must_use = "if you don't need a reference to the value, use `Vec::push` instead"]
1033-
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
1034-
pub fn push_mut(&mut self, value: T) -> &mut T
1035-
{
1030+
pub fn push_mut(&mut self, value: T) -> &mut T {
10361031
// Inform codegen that the length does not change across grow_one().
10371032
let len = self.len;
10381033
// This will panic or abort if we would allocate > isize::MAX bytes

0 commit comments

Comments
 (0)