refactor(rustc_expand::mbe): Don't require full ExtCtxt when not necessary #128798
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.
Refactor
mbe::diagnostics::failed_to_match_macro()
to not require a fullExtCtxt
, but only a&ParseSess
. It hard-required theExtCtxt
only for a call tocx.trace_macros_diag()
, which we move instead to the only call-site of the function.Note: This could be a potential change in observed behavior, because a call to
cx.trace_macros_diag()
now always happens afterfailed_to_match_macro()
was called, where before it was only called at the end of the main return path of the function. But sincetrace_macros_diag()
"flushes" out any not-yet-reported errors, it should be ok to call it for all paths, since there shouldn't be any on the non-main paths I think. However, I don't know the rest of the codebase well enough to say that with 100% confidence, buttests/ui
still pass, which gives at least some confidence in the change.Also concretize the return type from
Box<dyn MacResult>
to(Span, ErrorGuaranteed)
, because this function will always return an error, and never any other kind of result.Was part of #128605 and #128747, but is a standalone refactoring.
r? @petrochenkov