Rollup merge of #129592 - saethlin:core-cfg-test, r=tgross35
Remove cfg(test) from library/core The diff here is very small with the ignore whitespace option. `core` doesn't/can't have unit tests. All of its tests are just modules under `tests/`, so it has no use for `cfg(test)`, because the entire contents of `library/core/src` are only ever compiled with that cfg off, and the entire contents of `library/core/tests` are only ever compiled with that cfg on. You can tell this is what's happening because we had `#[cfg(test)]` on a module declaration that has no source file. I also deleted the extra `mod tests {` layer of nesting; there's no need to mention again in the module path that this is a module of tests. This exposes a name collision between the `u128` module of tests and `core::u128`. Fixed that by using `<u128>::MAX` like is done in the `check!` macro, which is what avoids this name ambiguity for the other types.
This commit is contained in:
commit
b9dfb4d6f8
@ -1,9 +1,6 @@
|
||||
#![doc = include_str!("error.md")]
|
||||
#![stable(feature = "error_in_core", since = "1.81.0")]
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use crate::any::TypeId;
|
||||
use crate::fmt::{Debug, Display, Formatter, Result};
|
||||
|
||||
|
@ -141,7 +141,6 @@ mod intrinsics;
|
||||
mod io;
|
||||
mod iter;
|
||||
mod lazy;
|
||||
#[cfg(test)]
|
||||
mod macros;
|
||||
mod manually_drop;
|
||||
mod mem;
|
||||
|
@ -1,7 +1,5 @@
|
||||
macro_rules! int_module {
|
||||
($T:ident) => {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use core::ops::{BitAnd, BitOr, BitXor, Not, Shl, Shr};
|
||||
use core::$T::*;
|
||||
|
||||
@ -422,6 +420,5 @@ macro_rules! int_module {
|
||||
assert_eq!(<$T>::midpoint(<$T>::MAX, 6), <$T>::MAX / 2 + 3);
|
||||
assert_eq!(<$T>::midpoint(6, <$T>::MAX), <$T>::MAX / 2 + 3);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ fn test_can_not_overflow() {
|
||||
|
||||
// Check u128 separately:
|
||||
for base in 2..=36 {
|
||||
let num = u128::MAX as u128;
|
||||
let num = <u128>::MAX;
|
||||
let max_len_string = format_radix(num, base as u128);
|
||||
// base 16 fits perfectly for u128 and won't overflow:
|
||||
assert_eq!(can_overflow::<u128>(base, &max_len_string), base != 16);
|
||||
|
@ -1,7 +1,5 @@
|
||||
macro_rules! uint_module {
|
||||
($T:ident) => {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use core::ops::{BitAnd, BitOr, BitXor, Not, Shl, Shr};
|
||||
use core::$T::*;
|
||||
use std::str::FromStr;
|
||||
@ -315,6 +313,5 @@ macro_rules! uint_module {
|
||||
assert_eq!(<$T>::midpoint(<$T>::MAX, 6), (<$T>::MAX - <$T>::MIN) / 2 + 3);
|
||||
assert_eq!(<$T>::midpoint(6, <$T>::MAX), (<$T>::MAX - <$T>::MIN) / 2 + 3);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user