-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
"auto trait" syntax gets accepted on stable in cfg-disabled code #116121
Comments
from the code I'd expect a warning:
|
ah no, auto traits don't use that gating:
When parsing an auto trait in the parser, we need to gate it's span and then in the feature gating pass gate it too. This will look similar to, for example, trait_alias. |
#99935 was just for syntax which was previously attempted to reverse stabilization and had the gating code there but disabled. Now that the plumbing exists, using that as a template to add this syntax to the warning should be fairly straightforward. It might make sense to go ahead and crater immediately making this a hard feature gate, though. |
I can already tell you of one large regression, the PyO3 crate. We should do the feature gating normally as a warning and worry about making it an error later. Once it's a warning, people adding uses get warnings and we should be fine. |
A bit unrelated, but I think it would be useful to have docs somewhere that show how to resolve this issue if you have the feature behind a cfg, the easiest solution being a macro_rules macro. #[cfg(feature = "nightly")]
macro_rules! define {
($($tt:tt)*) => { $($tt)* }
}
#[cfg(not(feature = "nightly"))]
macro_rules! define {
($($tt:tt)*) => {}
}
define! { pub auto trait Uwu {} } But that doesn't have to be fixed here. |
Rollup merge of rust-lang#116393 - compiler-errors:auto-bad, r=WaffleLapkin Emit feature gate *warning* for `auto` traits pre-expansion Auto traits were introduced before we were more careful about not stabilizing new syntax pre-expansion. This is a more conservative step in the general direction we want to go in https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Removal.20of.20.60auto.20trait.60.20syntax. Fixes rust-lang#116121
The following code builds on stable without even a warning:
That is surprising since there was some effort recently to start ensuring that unstable syntax does not "leak" into stable Rust, so I expected at least a future-compatibility warning. (See e.g. #99935)
Cc @petrochenkov @CAD97
The text was updated successfully, but these errors were encountered: