Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7befc24

Browse files
authoredMar 8, 2025
Unrolled build for rust-lang#136642
Rollup merge of rust-lang#136642 - bjorn3:separate_alloctest_crate, r=cuviper Put the alloc unit tests in a separate alloctests package Same rationale as rust-lang#135937. This PR has some extra complexity though as a decent amount of tests are testing internal implementation details rather than the public api. As such I opted to include the modules containing the types under test using `#[path]` into the alloctests package. This means that those modules still need `#[cfg(test)]`, but the rest of liballoc no longer need it.
2 parents cdd8af2 + 22d0440 commit 7befc24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+579
-603
lines changed
 

‎library/alloc/src/borrow.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ where
3232
/// implementing the `Clone` trait. But `Clone` works only for going from `&T`
3333
/// to `T`. The `ToOwned` trait generalizes `Clone` to construct owned data
3434
/// from any borrow of a given type.
35-
#[cfg_attr(not(test), rustc_diagnostic_item = "ToOwned")]
35+
#[rustc_diagnostic_item = "ToOwned"]
3636
#[stable(feature = "rust1", since = "1.0.0")]
3737
pub trait ToOwned {
3838
/// The resulting type after obtaining ownership.
@@ -54,7 +54,7 @@ pub trait ToOwned {
5454
/// ```
5555
#[stable(feature = "rust1", since = "1.0.0")]
5656
#[must_use = "cloning is often expensive and is not expected to have side effects"]
57-
#[cfg_attr(not(test), rustc_diagnostic_item = "to_owned_method")]
57+
#[rustc_diagnostic_item = "to_owned_method"]
5858
fn to_owned(&self) -> Self::Owned;
5959

6060
/// Uses borrowed data to replace owned data, usually by cloning.
@@ -175,7 +175,7 @@ where
175175
/// }
176176
/// ```
177177
#[stable(feature = "rust1", since = "1.0.0")]
178-
#[cfg_attr(not(test), rustc_diagnostic_item = "Cow")]
178+
#[rustc_diagnostic_item = "Cow"]
179179
pub enum Cow<'a, B: ?Sized + 'a>
180180
where
181181
B: ToOwned,

‎library/alloc/src/bstr.rs

-20
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@ use core::ops::{
1212
Deref, DerefMut, DerefPure, Index, IndexMut, Range, RangeFrom, RangeFull, RangeInclusive,
1313
RangeTo, RangeToInclusive,
1414
};
15-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
1615
use core::str::FromStr;
1716
use core::{fmt, hash};
1817

19-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
2018
use crate::borrow::{Cow, ToOwned};
21-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
2219
use crate::boxed::Box;
2320
#[cfg(not(no_rc))]
2421
use crate::rc::Rc;
@@ -181,7 +178,6 @@ impl Default for ByteString {
181178

182179
// Omitted due to inference failures
183180
//
184-
// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
185181
// #[unstable(feature = "bstr", issue = "134915")]
186182
// impl<'a, const N: usize> From<&'a [u8; N]> for ByteString {
187183
// #[inline]
@@ -190,7 +186,6 @@ impl Default for ByteString {
190186
// }
191187
// }
192188
//
193-
// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
194189
// #[unstable(feature = "bstr", issue = "134915")]
195190
// impl<const N: usize> From<[u8; N]> for ByteString {
196191
// #[inline]
@@ -199,7 +194,6 @@ impl Default for ByteString {
199194
// }
200195
// }
201196
//
202-
// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
203197
// #[unstable(feature = "bstr", issue = "134915")]
204198
// impl<'a> From<&'a [u8]> for ByteString {
205199
// #[inline]
@@ -226,7 +220,6 @@ impl From<ByteString> for Vec<u8> {
226220

227221
// Omitted due to inference failures
228222
//
229-
// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
230223
// #[unstable(feature = "bstr", issue = "134915")]
231224
// impl<'a> From<&'a str> for ByteString {
232225
// #[inline]
@@ -243,7 +236,6 @@ impl From<ByteString> for Vec<u8> {
243236
// }
244237
// }
245238

246-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
247239
#[unstable(feature = "bstr", issue = "134915")]
248240
impl<'a> From<&'a ByteStr> for ByteString {
249241
#[inline]
@@ -252,7 +244,6 @@ impl<'a> From<&'a ByteStr> for ByteString {
252244
}
253245
}
254246

255-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
256247
#[unstable(feature = "bstr", issue = "134915")]
257248
impl<'a> From<ByteString> for Cow<'a, ByteStr> {
258249
#[inline]
@@ -261,7 +252,6 @@ impl<'a> From<ByteString> for Cow<'a, ByteStr> {
261252
}
262253
}
263254

264-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
265255
#[unstable(feature = "bstr", issue = "134915")]
266256
impl<'a> From<&'a ByteString> for Cow<'a, ByteStr> {
267257
#[inline]
@@ -330,7 +320,6 @@ impl FromIterator<ByteString> for ByteString {
330320
}
331321
}
332322

333-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
334323
#[unstable(feature = "bstr", issue = "134915")]
335324
impl FromStr for ByteString {
336325
type Err = core::convert::Infallible;
@@ -488,7 +477,6 @@ impl PartialEq for ByteString {
488477

489478
macro_rules! impl_partial_eq_ord_cow {
490479
($lhs:ty, $rhs:ty) => {
491-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
492480
#[allow(unused_lifetimes)]
493481
#[unstable(feature = "bstr", issue = "134915")]
494482
impl<'a> PartialEq<$rhs> for $lhs {
@@ -499,7 +487,6 @@ macro_rules! impl_partial_eq_ord_cow {
499487
}
500488
}
501489

502-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
503490
#[allow(unused_lifetimes)]
504491
#[unstable(feature = "bstr", issue = "134915")]
505492
impl<'a> PartialEq<$lhs> for $rhs {
@@ -510,7 +497,6 @@ macro_rules! impl_partial_eq_ord_cow {
510497
}
511498
}
512499

513-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
514500
#[allow(unused_lifetimes)]
515501
#[unstable(feature = "bstr", issue = "134915")]
516502
impl<'a> PartialOrd<$rhs> for $lhs {
@@ -521,7 +507,6 @@ macro_rules! impl_partial_eq_ord_cow {
521507
}
522508
}
523509

524-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
525510
#[allow(unused_lifetimes)]
526511
#[unstable(feature = "bstr", issue = "134915")]
527512
impl<'a> PartialOrd<$lhs> for $rhs {
@@ -572,7 +557,6 @@ impl PartialOrd for ByteString {
572557
}
573558
}
574559

575-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
576560
#[unstable(feature = "bstr", issue = "134915")]
577561
impl ToOwned for ByteStr {
578562
type Owned = ByteString;
@@ -605,7 +589,6 @@ impl<'a> TryFrom<&'a ByteString> for &'a str {
605589

606590
// Additional impls for `ByteStr` that require types from `alloc`:
607591

608-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
609592
#[unstable(feature = "bstr", issue = "134915")]
610593
impl Clone for Box<ByteStr> {
611594
#[inline]
@@ -614,7 +597,6 @@ impl Clone for Box<ByteStr> {
614597
}
615598
}
616599

617-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
618600
#[unstable(feature = "bstr", issue = "134915")]
619601
impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> {
620602
#[inline]
@@ -623,7 +605,6 @@ impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> {
623605
}
624606
}
625607

626-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
627608
#[unstable(feature = "bstr", issue = "134915")]
628609
impl From<Box<[u8]>> for Box<ByteStr> {
629610
#[inline]
@@ -633,7 +614,6 @@ impl From<Box<[u8]>> for Box<ByteStr> {
633614
}
634615
}
635616

636-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
637617
#[unstable(feature = "bstr", issue = "134915")]
638618
impl From<Box<ByteStr>> for Box<[u8]> {
639619
#[inline]

‎library/alloc/src/collections/binary_heap/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ use core::{fmt, ptr};
153153
use crate::alloc::Global;
154154
use crate::collections::TryReserveError;
155155
use crate::slice;
156-
use crate::vec::{self, AsVecIntoIter, Vec};
156+
#[cfg(not(test))]
157+
use crate::vec::AsVecIntoIter;
158+
use crate::vec::{self, Vec};
157159

158160
/// A priority queue implemented with a binary heap.
159161
///
@@ -1600,6 +1602,7 @@ unsafe impl<I, A: Allocator> InPlaceIterable for IntoIter<I, A> {
16001602
const MERGE_BY: Option<NonZero<usize>> = NonZero::new(1);
16011603
}
16021604

1605+
#[cfg(not(test))]
16031606
unsafe impl<I> AsVecIntoIter for IntoIter<I> {
16041607
type Item = I;
16051608

There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.