Skip to content

Commit 7b4656e

Browse files
thaliaarchitautschnig
authored andcommitted
Remove #[cfg(not(test))] gates in core
These gates are unnecessary now that unit tests for `core` are in a separate package, `coretests`, instead of in the same files as the source code. They previously prevented the two `core` versions from conflicting with each other.
1 parent 5277df8 commit 7b4656e

File tree

33 files changed

+79
-114
lines changed

33 files changed

+79
-114
lines changed

core/src/any.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ use crate::{fmt, hash, intrinsics};
109109
// unsafe traits and unsafe methods (i.e., `type_id` would still be safe to call,
110110
// but we would likely want to indicate as such in documentation).
111111
#[stable(feature = "rust1", since = "1.0.0")]
112-
#[cfg_attr(not(test), rustc_diagnostic_item = "Any")]
112+
#[rustc_diagnostic_item = "Any"]
113113
pub trait Any: 'static {
114114
/// Gets the `TypeId` of `self`.
115115
///

core/src/array/ascii.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::ascii;
22

3-
#[cfg(not(test))]
43
impl<const N: usize> [u8; N] {
54
/// Converts this array of bytes into an array of ASCII characters,
65
/// or returns `None` if any of the characters is non-ASCII.

core/src/bool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl bool {
5656
/// ```
5757
#[doc(alias = "then_with")]
5858
#[stable(feature = "lazy_bool_to_option", since = "1.50.0")]
59-
#[cfg_attr(not(test), rustc_diagnostic_item = "bool_then")]
59+
#[rustc_diagnostic_item = "bool_then"]
6060
#[inline]
6161
pub fn then<T, F: FnOnce() -> T>(self, f: F) -> Option<T> {
6262
if self { Some(f()) } else { None }

core/src/cell.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ pub use once::OnceCell;
304304
/// ```
305305
///
306306
/// See the [module-level documentation](self) for more.
307-
#[cfg_attr(not(test), rustc_diagnostic_item = "Cell")]
307+
#[rustc_diagnostic_item = "Cell"]
308308
#[stable(feature = "rust1", since = "1.0.0")]
309309
#[repr(transparent)]
310310
#[rustc_pub_transparent]
@@ -725,7 +725,7 @@ impl<T, const N: usize> Cell<[T; N]> {
725725
/// A mutable memory location with dynamically checked borrow rules
726726
///
727727
/// See the [module-level documentation](self) for more.
728-
#[cfg_attr(not(test), rustc_diagnostic_item = "RefCell")]
728+
#[rustc_diagnostic_item = "RefCell"]
729729
#[stable(feature = "rust1", since = "1.0.0")]
730730
pub struct RefCell<T: ?Sized> {
731731
borrow: Cell<BorrowFlag>,

core/src/char/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ impl char {
11781178
#[must_use]
11791179
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
11801180
#[rustc_const_stable(feature = "const_char_is_ascii", since = "1.32.0")]
1181-
#[cfg_attr(not(test), rustc_diagnostic_item = "char_is_ascii")]
1181+
#[rustc_diagnostic_item = "char_is_ascii"]
11821182
#[inline]
11831183
pub const fn is_ascii(&self) -> bool {
11841184
*self as u32 <= 0x7F

core/src/cmp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ pub macro PartialOrd($item:item) {
14811481
#[inline]
14821482
#[must_use]
14831483
#[stable(feature = "rust1", since = "1.0.0")]
1484-
#[cfg_attr(not(test), rustc_diagnostic_item = "cmp_min")]
1484+
#[rustc_diagnostic_item = "cmp_min"]
14851485
pub fn min<T: Ord>(v1: T, v2: T) -> T {
14861486
v1.min(v2)
14871487
}
@@ -1573,7 +1573,7 @@ pub fn min_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
15731573
#[inline]
15741574
#[must_use]
15751575
#[stable(feature = "rust1", since = "1.0.0")]
1576-
#[cfg_attr(not(test), rustc_diagnostic_item = "cmp_max")]
1576+
#[rustc_diagnostic_item = "cmp_max"]
15771577
pub fn max<T: Ord>(v1: T, v2: T) -> T {
15781578
v1.max(v2)
15791579
}

core/src/convert/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub const fn identity<T>(x: T) -> T {
214214
/// is_hello(s);
215215
/// ```
216216
#[stable(feature = "rust1", since = "1.0.0")]
217-
#[cfg_attr(not(test), rustc_diagnostic_item = "AsRef")]
217+
#[rustc_diagnostic_item = "AsRef"]
218218
pub trait AsRef<T: ?Sized> {
219219
/// Converts this type into a shared reference of the (usually inferred) input type.
220220
#[stable(feature = "rust1", since = "1.0.0")]
@@ -365,7 +365,7 @@ pub trait AsRef<T: ?Sized> {
365365
/// Note, however, that APIs don't need to be generic. In many cases taking a `&mut [u8]` or
366366
/// `&mut Vec<u8>`, for example, is the better choice (callers need to pass the correct type then).
367367
#[stable(feature = "rust1", since = "1.0.0")]
368-
#[cfg_attr(not(test), rustc_diagnostic_item = "AsMut")]
368+
#[rustc_diagnostic_item = "AsMut"]
369369
pub trait AsMut<T: ?Sized> {
370370
/// Converts this type into a mutable reference of the (usually inferred) input type.
371371
#[stable(feature = "rust1", since = "1.0.0")]

core/src/default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ use crate::ascii::Char as AsciiChar;
101101
/// bar: f32,
102102
/// }
103103
/// ```
104-
#[cfg_attr(not(test), rustc_diagnostic_item = "Default")]
104+
#[rustc_diagnostic_item = "Default"]
105105
#[stable(feature = "rust1", since = "1.0.0")]
106106
#[rustc_trivial_field_reads]
107107
pub trait Default: Sized {

core/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use crate::fmt::{self, Debug, Display, Formatter};
4747
/// impl Error for ReadConfigError {}
4848
/// ```
4949
#[stable(feature = "rust1", since = "1.0.0")]
50-
#[cfg_attr(not(test), rustc_diagnostic_item = "Error")]
50+
#[rustc_diagnostic_item = "Error"]
5151
#[rustc_has_incoherent_inherent_impls]
5252
#[allow(multiple_supertrait_upcastable)]
5353
pub trait Error: Debug + Display {

core/src/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mod num;
1818
mod rt;
1919

2020
#[stable(feature = "fmt_flags_align", since = "1.28.0")]
21-
#[cfg_attr(not(test), rustc_diagnostic_item = "Alignment")]
21+
#[rustc_diagnostic_item = "Alignment"]
2222
/// Possible alignments returned by `Formatter::align`
2323
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
2424
pub enum Alignment {

0 commit comments

Comments
 (0)