-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Treat #[test]
like #[cfg(test)]
in non-test builds
#34002
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
Conversation
cc @LeoTestard |
👍 |
Could you add a test similar to the #33946 case? |
I'd be against doing this (but not strongly so) - I like the orthogonal-ness of |
@nrc These are my reasons for supporting this:
#[cfg(test)] fn f() {}
#[cfg(test)] macro_rules! m { () => {} }
#[test]
fn test() {
f(); //< this is OK,
m!(); //< but this is currently an error (on non-test builds).
}
#![cfg_attr(test, feature(stmt_expr_attributes))]
#[test]
fn test() {
let _ = #[attr] (); //< Currently, this is a gated feature error (on non-test builds).
}
|
lang-team thinks this is good :) |
c18660a
to
369a996
Compare
We discussed this at the language meeting last week. The important point I missed earlier was that to some extent |
@bors: r+ (Would be good to add a test for 33946, but not essential, keep r=me with the test too) |
📌 Commit 369a996 has been approved by |
⌛ Testing commit 369a996 with merge 6af2e10... |
💔 Test failed - auto-win-msvc-64-cargotest |
369a996
to
29c4b67
Compare
@bors r=nrc |
📌 Commit 29c4b67 has been approved by |
This PR treats
#[test]
like#[cfg(test)]
in non-test builds. In particular, like#[cfg(test)]
,#[test]
nodes are stripped duringcfg
processing, and#[test]
is disallowed on non-optional expressions.Closes #33946.
r? @nrc