diff options
| author | bors <bors@rust-lang.org> | 2024-09-12 18:27:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-12 18:27:55 +0000 |
| commit | 2e8db5e9e39c2bf7729113b3041ef4011d90ac5a (patch) | |
| tree | a927ddd18758af947e6e9fb6f4c4830bc3234c62 /library/alloc | |
| parent | 8c0ec05f7dc9ef185eea9f36c5638e74e43935bf (diff) | |
| parent | ed1602e480a77540593c907a36de7ca3eac3ac81 (diff) | |
| download | rust-2e8db5e9e39c2bf7729113b3041ef4011d90ac5a.tar.gz rust-2e8db5e9e39c2bf7729113b3041ef4011d90ac5a.zip | |
Auto merge of #130281 - matthiaskrgr:rollup-1b2ibs8, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #130101 (some const cleanup: remove unnecessary attributes, add const-hack indications) - #130208 (Introduce `'ra` lifetime name.) - #130263 (coverage: Simplify creation of sum counters) - #130273 (more eagerly discard constraints on overflow) - #130276 (Add test for nalgebra hang in coherence) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/alloc')
| -rw-r--r-- | library/alloc/src/collections/vec_deque/mod.rs | 4 | ||||
| -rw-r--r-- | library/alloc/src/raw_vec.rs | 15 | ||||
| -rw-r--r-- | library/alloc/src/vec/in_place_collect.rs | 2 | ||||
| -rw-r--r-- | library/alloc/src/vec/into_iter.rs | 2 | ||||
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 2 |
5 files changed, 6 insertions, 19 deletions
diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index dc725ec0f56..8c9db063105 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -554,8 +554,8 @@ impl<T> VecDeque<T> { #[rustc_const_stable(feature = "const_vec_deque_new", since = "1.68.0")] #[must_use] pub const fn new() -> VecDeque<T> { - // FIXME: This should just be `VecDeque::new_in(Global)` once that hits stable. - VecDeque { head: 0, len: 0, buf: RawVec::NEW } + // FIXME(const-hack): This should just be `VecDeque::new_in(Global)` once that hits stable. + VecDeque { head: 0, len: 0, buf: RawVec::new() } } /// Creates an empty deque with space for at least `capacity` elements. diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs index a651ba067e4..436e0596e3d 100644 --- a/library/alloc/src/raw_vec.rs +++ b/library/alloc/src/raw_vec.rs @@ -96,13 +96,6 @@ struct RawVecInner<A: Allocator = Global> { } impl<T> RawVec<T, Global> { - /// HACK(Centril): This exists because stable `const fn` can only call stable `const fn`, so - /// they cannot call `Self::new()`. - /// - /// If you change `RawVec<T>::new` or dependencies, please take care to not introduce anything - /// that would truly const-call something unstable. - pub const NEW: Self = Self::new(); - /// Creates the biggest possible `RawVec` (on the system heap) /// without allocating. If `T` has positive size, then this makes a /// `RawVec` with capacity `0`. If `T` is zero-sized, then it makes a @@ -111,7 +104,7 @@ impl<T> RawVec<T, Global> { #[must_use] #[rustc_const_stable(feature = "raw_vec_internals_const", since = "1.81")] pub const fn new() -> Self { - Self { inner: RawVecInner::new::<T>(), _marker: PhantomData } + Self::new_in(Global) } /// Creates a `RawVec` (on the system heap) with exactly the @@ -149,12 +142,6 @@ impl<T> RawVec<T, Global> { } impl RawVecInner<Global> { - #[must_use] - #[rustc_const_stable(feature = "raw_vec_internals_const", since = "1.81")] - const fn new<T>() -> Self { - Self::new_in(Global, core::mem::align_of::<T>()) - } - #[cfg(not(any(no_global_oom_handling, test)))] #[must_use] #[inline] diff --git a/library/alloc/src/vec/in_place_collect.rs b/library/alloc/src/vec/in_place_collect.rs index ec0ab8ee728..cda63da0904 100644 --- a/library/alloc/src/vec/in_place_collect.rs +++ b/library/alloc/src/vec/in_place_collect.rs @@ -191,7 +191,7 @@ const fn in_place_collectible<DEST, SRC>( const fn needs_realloc<SRC, DEST>(src_cap: usize, dst_cap: usize) -> bool { if const { mem::align_of::<SRC>() != mem::align_of::<DEST>() } { - // FIXME: use unreachable! once that works in const + // FIXME(const-hack): use unreachable! once that works in const panic!("in_place_collectible() prevents this"); } diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index 92c5e360da4..f7aad56695d 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -142,7 +142,7 @@ impl<T, A: Allocator> IntoIter<T, A> { // struct and then overwriting &mut self. // this creates less assembly self.cap = 0; - self.buf = RawVec::NEW.non_null(); + self.buf = RawVec::new().non_null(); self.ptr = self.buf; self.end = self.buf.as_ptr(); diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 162791ba59d..ff084edba8d 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -419,7 +419,7 @@ impl<T> Vec<T> { #[stable(feature = "rust1", since = "1.0.0")] #[must_use] pub const fn new() -> Self { - Vec { buf: RawVec::NEW, len: 0 } + Vec { buf: RawVec::new(), len: 0 } } /// Constructs a new, empty `Vec<T>` with at least the specified capacity. |
