-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Write lint for usage of edition-gated keywords #49716
Comments
This is trickier than usual. We want to run this lint for code actually specified in this crate -- ideally in the place where we lex the tokens. So code from a macro from a different crate should not trigger the lint, but code within a macro def/invocation from this crate should. However, the lint levels aren't available to the lexer. We can persist this info till parsing and lint there, but the lint levels aren't available there either. The node IDs used during parsing are dummy ids, so we cannot stash the lint info there and emit it lated. The way I see it, we have the following options:
thoughts? @nikomatsakis @oli-obk @eddyb |
We could stash the lints with their span instead of an ID. This is doable in the lexer. Then, later, we can run a normal early lint pass which only does lint level checking and runs through the list of stashed lints and checks whether their span is a subset of any span it encounters. Not sure whether those spans would still match after expansion, so maybe we need that pre expansion lint pass |
Hey, I'd like to take a stab at this, if someone wouldn't mind pointing me in the right direction.
@oli-obk just so I understand what you're suggesting: We add the ability to persist partial-lint information in the tokens emitted by the lexer, then later pull the lint information back out again once we have actual ids for things? |
The lint level is whether or not a particular lint is allow/warn/deny. We'd be doing this for a single lint. We could keep track of info for all lints but that's not necessary. Note that #49611 hasn't landed yet and @petrochenkov is redoing the approach, so there's a chance the approach for this issue won't work anymore. But I don't think that's going to be the case, so you can go ahead with writing the framework code without writing the lint itself. |
visiting for triage assigning to @oli-obk to make sure that this gets mentoring instructions (or outright implemented), hopefully before Preview 2. |
A PR for this is now at #52375 |
…anishearth Lint `async` identifiers in 2018 preparation mode r? @Manishearth fixes #49716
After #49611 lands, attempting to use
async
as an identifier will work if on the 2015 edition, but not on the 2018 edition.So that editions can be
rustfix
ed, we need the ability to lint this and suggest fixes.The text was updated successfully, but these errors were encountered: