-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test = false
is newly treated inconsistently (and was already not behaving as documented)
#15131
Comments
See also the discussion on Zulip: https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/.60test.60.20well.20known.20cfg.20error. |
It's true that #15007 does not address "this code should never ever be built with Adding a new "don't try to build this in test mode even with Of the two crates discussed in the Zulip thread:
Do we know of any other crates where #15007 has triggered a new warning? May be a bit early, but that would be more illuminating than the above special cases.
Yes, such a misunderstanding is possible, but people have already been treating |
…" (#15132) This reverts #15007, as it causes confusions and needs more time to figure out a proper solution. See * #15131 * <https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/.60test.60.20well.20known.20cfg.20error> * <#15007 (comment)>
To make this more explicit: I don't think it's realistic at this stage to fix #8338 as stated, i.e., change In contrast, #15007 doesn't change any behavior (modulo |
Yes, I agree that this would be a breaking change. #8338 is, in my current opinion, more “missing feature; lack of expressiveness” than a bug. Except that the documentation is factually incorrect about when
It’s not pointless. |
Ah, good point, I forgot about benches. If it was up to me I'd like that to change as well, but (1) some |
The current stable behavior of the
test = false
option for targets is:Passing any target selection option that matches the target, including
--all-targets
, or even a test filter, overridestest = false
and causes the target to be tested. (This is somewhat inconsistent with the documentation, which implies that this override occurs particularly when the target is specifically named on the command line.)However, PR #15007 was written with the assumption that
test = false
should be understood to mean “this target contains no tests”, and will cause tests andcfg(test)
code insidetest = false
targets to issue warnings as if test code is useless inside such targets. This behavior is inconsistent and misleading, because it is possible to run such test code, even unintentionally via--all-targets
, yet a user encountering those warnings would reasonably conclude thattest = false
means the crate is never compiled withcfg(test)
.It would be valuable to have a way to actually mark targets as containing no test code (to reduce wasted build effort and to eliminate compilation errors from crates that can’t be compiled as tests, when
--all-targets
is used), buttest = false
is not, in fact, such a way, and so should not be treated as if it is. Therefore, I believe #15007 should be reverted, and some thought should be given to adding a true “this target contains no tests” option.@rustbot label +C-bug +regression-from-stable-to-nightly
The text was updated successfully, but these errors were encountered: