-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Regression w.r.t. lazy evaluation of cfg predicates #96018
Comments
Ah, thanks for the corrected pointer @kpreid. So in #94295 it was deemed acceptable breakage because the instances witnessed by crater were genuine mistakes, making the error useful. That being said, a lint, even a deny-by-default one, would have been just as useful. And slapping an Now the js-supporting branch of https://docs.rs/safer-ffi won't compile starting from the future Would it be possible to backport a revert of #94295 to |
I'm sorry that you're code doesn't compile anymore; I can confirm that the culprit is #94295 and also that it is intentional. I unfortunately don't know enough macro_rules and their hacks to be able to suggested any workaround, sorry.
There was no need for a lint as the crater run only reported genuine mistakes. We could have definitely added a future-incompatibility lint but there was no need until now and I don't know if we should or not try to have a backport-able patch that transform the previously unevaluated part of the predicate. It would require some non-negligible changes and a far amount of reverts not only in rust-lang/rust but also probably in rust-lang/cargo.
Reverting only #94295 wouldn't be enough there would also need to revert #95109 and maybe another one in rust-lang/rust. |
It was my impression that cfg_attr should work fine for the use case you describe - and is the intended "I want to shortcircuit". Is that not the case? |
I don't think there is a simple replacement until |
Code
I tried this code:
I expected to see this happen: code compiles fine, since the previous cfg resolves to
true
, short-circuiting theany
until it reaches__super_useful_macro_rules_hack = 42
Instead, this happened: on a non-stable Rust compiler, these last attributes are nonetheless evaluated, and the compiler triggers an error for code that otherwise compiles fine.
Version it worked on
It most recently worked on: Rust
1.60.0
Version with regression
rustc --version --verbose
:Backtrace
Backtrace
@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged
I suspect this has to do with #94175 (comment) (cc @Urgau)
Why that code
This pattern is an incredibly useful trick for
macro_rules!
authors, at least until we get something like empty captures or other operators.When using
$( … )*
and$( … )?
Kleene operators, the metavar guiding that repetition count needs to be inside those parenthesis. But sometimes we have no use for the metavariable.When the metavariable is of kind
:literal
, lazily uncheckedcfg
s are an incredibly convenient place to smuggle those:https://github.com/getditto/safer_ffi/blob/277f3e7b9c382532a7b2bb5499d296a8d78b6d8e/src/ffi_export.rs#L137-L138
The text was updated successfully, but these errors were encountered: