Skip to content

Commit

Permalink
Rollup merge of #129592 - saethlin:core-cfg-test, r=tgross35
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthiaskrgr authored Aug 26, 2024
2 parents d0b3c3a + 4f3ef2a commit b9dfb4d
Show file tree
Hide file tree
Showing 5 changed files with 649 additions and 659 deletions.
3 changes: 0 additions & 3 deletions library/core/src/error.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
1 change: 0 additions & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ mod intrinsics;
mod io;
mod iter;
mod lazy;
#[cfg(test)]
mod macros;
mod manually_drop;
mod mem;
Expand Down
Loading

0 comments on commit b9dfb4d

Please sign in to comment.