Skip to content
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

refactor(rustc_expand::mbe): Don't require full ExtCtxt when not necessary #128798

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

futile
Copy link
Contributor

@futile futile commented Aug 7, 2024

Refactor mbe::diagnostics::failed_to_match_macro() to not require a full ExtCtxt, but only a &ParseSess. It hard-required the ExtCtxt only for a call to cx.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 after failed_to_match_macro() was called, where before it was only called at the end of the main return path of the function. But since trace_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, but tests/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

@rustbot
Copy link
Collaborator

rustbot commented Aug 7, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 7, 2024
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Aug 7, 2024

📌 Commit a70c9e1 has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 7, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 8, 2024
Rollup of 7 pull requests

Successful merges:

 - rust-lang#128520 (Skip over args when determining if async-closure's inner coroutine consumes its upvars)
 - rust-lang#128552 (Emit an error for invalid use of the `#[no_sanitize]` attribute)
 - rust-lang#128691 (Update `compiler-builtins` to 0.1.117)
 - rust-lang#128702 (Add -Zmetrics-dir=PATH to save diagnostic metadata to disk)
 - rust-lang#128797 (Fuchsia Test Runner: enable ffx repository server)
 - rust-lang#128798 (refactor(rustc_expand::mbe): Don't require full ExtCtxt when not necessary)
 - rust-lang#128800 (Add tracking issue to core-pattern-type)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit fbbabb9 into rust-lang:master Aug 8, 2024
6 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Aug 8, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 8, 2024
Rollup merge of rust-lang#128798 - futile:refactor/mbe-diagnostics, r=petrochenkov

refactor(rustc_expand::mbe): Don't require full ExtCtxt when not necessary

Refactor `mbe::diagnostics::failed_to_match_macro()` to not require a full `ExtCtxt`, but only a `&ParseSess`. It hard-required the `ExtCtxt` only for a call to `cx.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 after `failed_to_match_macro()` was called, where before it was only called at the end of the main return path of the function. But since `trace_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, but `tests/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 rust-lang#128605 and rust-lang#128747, but is a standalone refactoring.

r? ``@petrochenkov``
@futile futile deleted the refactor/mbe-diagnostics branch August 8, 2024 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants