-
Notifications
You must be signed in to change notification settings - Fork 12.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
Many feature gates are not checked in macros #18102
Comments
Notably, this compiles today when it shouldn't: fn main() {
let a = ('a', 1u);
println!("{}", a.0);
} |
P-backcompat-lang, 1.0 |
Note that we may be able to use a technique similar to that for the stability lint: #17286 |
This is a duplicate of #12122 |
While somewhat similar I don't think that this is a dupe of #12122. The definition of a macro should be subject to the feature gates in the defining crate, but the usage of a macro should be subject to the feature gates in the consumer crate. #12122 indicates that we don't check macro definitions, and this indicates that we don't check macro invocations. |
I think the best we can do right now is check after the expansion of macros, in the stable channel. Outside of the stable channel, this might cause some undesirable noise when the used features are supposed to be "internal implementation details" of a lib, but I think that sort of claim is baloney because the feature could disappear at any moment. It ought to require work on the macro user's part if it could stop working at any moment due to a compiler upgrade. |
Uses the same approach as #17286 (and subsequent changes making it more correct), where the visitor will skip any pieces of the AST that are from "foreign code", where the spans don't line up, indicating that that piece of code is due to a macro expansion. If this breaks your code, read the error message to determine which feature gate you should add to your crate. Closes #18102 [breaking-change]
Feature gates are generally checked before expansion so feature gates are defeated by code inside macros.
The text was updated successfully, but these errors were encountered: