-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add do_not_recommend
annotation to all_tuples
to improve error messages
#14591
Comments
Is this actually available in nightly already? With version
Also what's the preferred way to guard this to nightly? If we need to go the feature path, I suppose a On the implementation side, I'm not sure if we can actually add this directly inside of |
@weiznich, I'd very much appreciate your guidance here. I haven't worked much with either macros or nightly. |
I think Edit: It's actually usable on beta without the feature gate. We could suppress the unknown warning. |
I would prefer not to use a build script to detect whether Bevy is being compiled with the nightly toolchain or not. Build scripts are notorious for slowing down compilation time, and are generally risky to work with. I would prefer to add an opt-in feature, or just wait until this attribute is released to stable Rust. |
Seems like you found a bug in the implementation. I will likely fill a PR soon to disallow that workaround.
It requires the Crates like axum use essentially a buildscript/proc macro to detect the current compiler version via |
i'll note that i'm not in favour of using the heuristics for deciding when proc macros should recompile are hazy at best (it can be as frequent as after any change in the enclosing file), and placing them over entire items/modules has been problematic in my experience. my preferred solution would be to use cargo feature gating, either a single feature, |
This commit adds additional checks for the feature flag as apparently it is possible to use this on a beta compiler without feature flags. This PR might be a candidate for backporting. Reported in the bevy issue tracker: bevyengine/bevy#14591 (comment)
This commit adds additional checks for the feature flag as apparently it is possible to use this on a beta compiler without feature flags. To track whether a diagnostic attribute is allowed based of the feature in certain possibly upstream crate we introduce a new boolean flag stored in each attribute. This hopefully enables future diagnostic attributes to prevent this situation, as there is now a single place that can be checked whether the attribute should be honored or not. This0PR might be a candidate for backporting to the latest beta release. Reported in the bevy issue tracker: bevyengine/bevy#14591 (comment)
…d_feature, r=<try> Do not apply `#[do_not_recommend]` if the feature flag is not set This commit adds additional checks for the feature flag as apparently it is possible to use this on a beta compiler without feature flags. This PR might be a candidate for backporting. Reported in the bevy issue tracker: bevyengine/bevy#14591 (comment) r? `@compiler-errors`
What problem does this solve or what need does it fill?
The error messages that Bevy / Rust provides when a malformed system, query or system set are provided are notoriously unhelpful (rust-lang/rust#89681). A huge complex error message is displayed, suggesting complex types in a tuple pyramid.
What solution would you like?
Per https://blog.weiznich.de/blog/diagnostic-namespace-do-not-recommend/, the
#[diagnostic(do_not_recommend)]
annotation is now ready to use, added in rust-lang/rust#124708.We should add the
do_not_recommend
to theall_tuples!
macro: these implementations are universally verbose and confusing.Because this feature is not yet stable, we need to detect if it's available:
https://users.rust-lang.org/t/add-unstable-feature-only-if-compiled-on-nightly/27886/2
What alternative(s) have you considered?
We could wait until this feature is stable to use it. This is less than ideal because a) if there are problems for our use case, we want to be able to fix them now. b) stabilization requires successful use in the wild, and Bevy is a prominent user of this functionality.
Or, we could just use the fabled generics. This will take even longer.
The text was updated successfully, but these errors were encountered: