driver: set the syntax edition in phase 1 #53226
Merged
+28
−5
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.
Fixes #53203
It seems the way libsyntax handles the desired edition is to use a global, set via
syntax_pos::hygiene::set_default_edition
. Right now, this is set in the driver inrun_compiler
, which is the entry point for running the compiler all the way through to emitting files. Since rustdoc doesn't use this function, it wasn't properly setting this global. (When initially setting up editions in rustdoc, i'd assumed that settingsessopts.edition
would have done this...>_>
) This was "fixed" for doctests in #52385, but rather than patching in a call toset_default_edition
in all the places rustdoc sets up the compiler, i've instead moved the call in the driver to be farther in the process. This means that any use ofphase_1_parse_input
with the right session options will have the edition properly set without having to also remember to set libsyntax up separately.r? @rust-lang/compiler