Skip to content

Commit 273aa0b

Browse files
committed
Remove #[cfg(not(test))] gates in core
1 parent 30f168e commit 273aa0b

File tree

9 files changed

+4
-38
lines changed

9 files changed

+4
-38
lines changed

library/core/src/array/ascii.rs

-1
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.

library/core/src/lib.rs

-16
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,6 @@
4343
//! which do not trigger a panic can be assured that this function is never
4444
//! called. The `lang` attribute is called `eh_personality`.
4545
46-
// Since core defines many fundamental lang items, all tests live in a
47-
// separate crate, coretests (library/coretests), to avoid bizarre issues.
48-
//
49-
// Here we explicitly #[cfg]-out this whole crate when testing. If we don't do
50-
// this, both the generated test artifact and the linked libtest (which
51-
// transitively includes core) will both define the same set of lang items,
52-
// and this will cause the E0152 "found duplicate lang item" error. See
53-
// discussion in #50466 for details.
54-
//
55-
// This cfg won't affect doc tests.
56-
#![cfg(not(test))]
57-
//
5846
#![stable(feature = "core", since = "1.6.0")]
5947
#![doc(
6048
html_playground_url = "https://play.rust-lang.org/",
@@ -225,13 +213,9 @@ extern crate self as core;
225213
#[allow(unused)]
226214
use prelude::rust_2021::*;
227215

228-
#[cfg(not(test))] // See #65860
229216
#[macro_use]
230217
mod macros;
231218

232-
// We don't export this through #[macro_export] for now, to avoid breakage.
233-
// See https://github.com/rust-lang/rust/issues/82913
234-
#[cfg(not(test))]
235219
#[unstable(feature = "assert_matches", issue = "82775")]
236220
/// Unstable module containing the unstable `assert_matches` macro.
237221
pub mod assert_matches {

library/core/src/num/f128.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
#![unstable(feature = "f128", issue = "116909")]
1313

1414
use crate::convert::FloatToInt;
15-
#[cfg(not(test))]
16-
use crate::intrinsics;
17-
use crate::mem;
1815
use crate::num::FpCategory;
1916
use crate::panic::const_assert;
17+
use crate::{intrinsics, mem};
2018

2119
/// Basic mathematical constants.
2220
#[unstable(feature = "f128", issue = "116909")]
@@ -138,7 +136,6 @@ pub mod consts {
138136
pub const LN_10: f128 = 2.30258509299404568401799145468436420760110148862877297603333_f128;
139137
}
140138

141-
#[cfg(not(test))]
142139
impl f128 {
143140
// FIXME(f16_f128): almost all methods in this `impl` are missing examples and a const
144141
// implementation. Add these once we can run code on all platforms and have f16/f128 in CTFE.

library/core/src/num/f16.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
#![unstable(feature = "f16", issue = "116909")]
1313

1414
use crate::convert::FloatToInt;
15-
#[cfg(not(test))]
16-
use crate::intrinsics;
17-
use crate::mem;
1815
use crate::num::FpCategory;
1916
use crate::panic::const_assert;
17+
use crate::{intrinsics, mem};
2018

2119
/// Basic mathematical constants.
2220
#[unstable(feature = "f16", issue = "116909")]
@@ -133,7 +131,6 @@ pub mod consts {
133131
pub const LN_10: f16 = 2.30258509299404568401799145468436421_f16;
134132
}
135133

136-
#[cfg(not(test))]
137134
impl f16 {
138135
// FIXME(f16_f128): almost all methods in this `impl` are missing examples and a const
139136
// implementation. Add these once we can run code on all platforms and have f16/f128 in CTFE.

library/core/src/num/f32.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
#![stable(feature = "rust1", since = "1.0.0")]
1313

1414
use crate::convert::FloatToInt;
15-
#[cfg(not(test))]
16-
use crate::intrinsics;
17-
use crate::mem;
1815
use crate::num::FpCategory;
1916
use crate::panic::const_assert;
17+
use crate::{intrinsics, mem};
2018

2119
/// The radix or base of the internal representation of `f32`.
2220
/// Use [`f32::RADIX`] instead.
@@ -386,7 +384,6 @@ pub mod consts {
386384
pub const LN_10: f32 = 2.30258509299404568401799145468436421_f32;
387385
}
388386

389-
#[cfg(not(test))]
390387
impl f32 {
391388
/// The radix or base of the internal representation of `f32`.
392389
#[stable(feature = "assoc_int_consts", since = "1.43.0")]

library/core/src/num/f64.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
#![stable(feature = "rust1", since = "1.0.0")]
1313

1414
use crate::convert::FloatToInt;
15-
#[cfg(not(test))]
16-
use crate::intrinsics;
17-
use crate::mem;
1815
use crate::num::FpCategory;
1916
use crate::panic::const_assert;
17+
use crate::{intrinsics, mem};
2018

2119
/// The radix or base of the internal representation of `f64`.
2220
/// Use [`f64::RADIX`] instead.
@@ -386,7 +384,6 @@ pub mod consts {
386384
pub const LN_10: f64 = 2.30258509299404568401799145468436421_f64;
387385
}
388386

389-
#[cfg(not(test))]
390387
impl f64 {
391388
/// The radix or base of the internal representation of `f64`.
392389
#[stable(feature = "assoc_int_consts", since = "1.43.0")]

library/core/src/slice/ascii.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::fmt::{self, Write};
77
use crate::intrinsics::const_eval_select;
88
use crate::{ascii, iter, ops};
99

10-
#[cfg(not(test))]
1110
impl [u8] {
1211
/// Checks if all bytes in this slice are within the ASCII range.
1312
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]

library/core/src/slice/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ enum Direction {
9797
Back,
9898
}
9999

100-
#[cfg(not(test))]
101100
impl<T> [T] {
102101
/// Returns the number of elements in the slice.
103102
///
@@ -4845,7 +4844,6 @@ impl<T, const N: usize> [[T; N]] {
48454844
}
48464845
}
48474846

4848-
#[cfg(not(test))]
48494847
impl [f32] {
48504848
/// Sorts the slice of floats.
48514849
///
@@ -4874,7 +4872,6 @@ impl [f32] {
48744872
}
48754873
}
48764874

4877-
#[cfg(not(test))]
48784875
impl [f64] {
48794876
/// Sorts the slice of floats.
48804877
///

library/core/src/str/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ fn slice_error_fail_rt(s: &str, begin: usize, end: usize) -> ! {
114114
);
115115
}
116116

117-
#[cfg(not(test))]
118117
impl str {
119118
/// Returns the length of `self`.
120119
///

0 commit comments

Comments
 (0)