parse: unify function front matter parsing#69023
Merged
bors merged 13 commits intorust-lang:masterfrom Feb 13, 2020
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
Addressed the comments. :) |
This comment has been minimized.
This comment has been minimized.
Contributor
|
r=me after rebase |
Same idea for `Unsafety` & use new span for better diagnostics.
use new span for better diagnostics.
Contributor
Author
|
@bors r=petrochenkov |
Collaborator
|
📌 Commit 9828559 has been approved by |
Collaborator
bors
added a commit
that referenced
this pull request
Feb 13, 2020
parse: unify function front matter parsing Part of #68728. - `const extern fn` feature gating is now done post-expansion such that we do not have conditional compatibilities of function qualifiers *in parsing*. - The `FnFrontMatter` grammar becomes: ```rust Extern = "extern" StringLit ; FnQual = "const"? "async"? "unsafe"? Extern? ; FnFrontMatter = FnQual "fn" ; ``` That is, all item contexts now *syntactically* allow `const async unsafe extern "C" fn` and use semantic restrictions to rule out combinations previously prevented syntactically. The semantic restrictions include in particular: - `fn`s in `extern { ... }` can have no qualifiers. - `const` and `async` cannot be combined. - We change `ast::{Unsafety, Spanned<Constness>}>` into `enum ast::{Unsafe, Const} { Yes(Span), No }` respectively. This change in formulation allow us to exclude `Span` in the case of `No`, which facilitates parsing. Moreover, we also add a `Span` to `IsAsync` which is renamed to `Async`. The new `Span`s in `Unsafety` and `Async` are then taken advantage of for better diagnostics. A reason this change was made is to have a more uniform and clear naming scheme. The HIR keeps the structures in AST (with those definitions moved into HIR) for now to avoid regressing perf. r? @petrochenkov
Collaborator
|
☀️ Test successful - checks-azure |
Contributor
|
📣 Toolstate changed by #69023! Tested on commit be493fe. 💔 rustc-guide on linux: test-pass → test-fail (cc @JohnTitor @amanjeev @spastorino @mark-i-m, @rust-lang/infra). |
rust-highfive
added a commit
to rust-lang-nursery/rust-toolstate
that referenced
this pull request
Feb 13, 2020
Tested on commit rust-lang/rust@be493fe. Direct link to PR: <rust-lang/rust#69023> 💔 rustc-guide on linux: test-pass → test-fail (cc @JohnTitor @amanjeev @spastorino @mark-i-m, @rust-lang/infra).
This was referenced Feb 13, 2020
Member
|
(Toolstate failure is spurious, can be ignored.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #68728.
const extern fnfeature gating is now done post-expansion such that we do not have conditional compatibilities of function qualifiers in parsing.The
FnFrontMattergrammar becomes:That is, all item contexts now syntactically allow
const async unsafe extern "C" fnand use semantic restrictions to rule out combinations previously prevented syntactically. The semantic restrictions include in particular:fns inextern { ... }can have no qualifiers.constandasynccannot be combined.We change
ast::{Unsafety, Spanned<Constness>}>intoenum ast::{Unsafe, Const} { Yes(Span), No }respectively. This change in formulation allow us to excludeSpanin the case ofNo, which facilitates parsing. Moreover, we also add aSpantoIsAsyncwhich is renamed toAsync. The newSpans inUnsafetyandAsyncare then taken advantage of for better diagnostics. A reason this change was made is to have a more uniform and clear naming scheme.The HIR keeps the structures in AST (with those definitions moved into HIR) for now to avoid regressing perf.
r? @petrochenkov