#[test] functions should not go in library/core, because they are not actually run. The crate library/coretests exists for this purpose instead. cfg(test) is similarly suspicious, because core doesn't end up being built under that cfg when running ./x.py test library.
We should have a lint against both of these constructs. It may also be desirable to lint in alloc and std, but there's significant use of the cfg in those crates, so presumably they're doing something.
This was discovered in practice due to the use of #[cfg(test)] in library/core/cell/covariant_unsafe_cell.rs causing CovariantUnsafeCell's variance to not actually be tested.
#[test]functions should not go inlibrary/core, because they are not actually run. The cratelibrary/coretestsexists for this purpose instead.cfg(test)is similarly suspicious, becausecoredoesn't end up being built under thatcfgwhen running./x.py test library.We should have a lint against both of these constructs. It may also be desirable to lint in
allocandstd, but there's significant use of the cfg in those crates, so presumably they're doing something.This was discovered in practice due to the use of
#[cfg(test)]inlibrary/core/cell/covariant_unsafe_cell.rscausingCovariantUnsafeCell's variance to not actually be tested.