Add support for experimental features in the parsing phase #7124
+202
−56
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.
Description
This PR brings support for experimental features to the parsing phase. This is needed so that we can support use cases like, e.g., adding new language keywords behind a feature flag.
A concrete example would be the
panic
keyword added in #7073. The parsing of thepanic
token differs if it is interpreted as a keyword (when theerror_type
experimental feature is active) or as a regular identifier (whenerror_type
is off).Because
ExperimentalFeatures
are needed in theParse::parse(parser: &mut Parser)
methods, theParser
got extended with theexperimental
field.The consequence of bringing the
ExperimentalFeatures
to the parsing phase is, thatswayfmt
andforc fmt
can also require an experimental feature to be set, to properly parse a project. In those tools,ExperimentalFeatures
are passed as a field on theFormatter
.Note that this PR does not put the provided experimental flags into use. The first concrete usage will be in #7073.
This PR is a prerequisite for #7073.
Checklist
Breaking*
orNew Feature
labels where relevant.