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.
I'm working on a rustc driver (Creusot) which needs to modify the MIR read by two queries,
mir_borrowckandcheck_liveness, in different ways for each query. Both of these queries usemir_promotedto read the MIR, which is immutable (until it is stolen).This adds an escape hatch so rustc drivers can mutate MIR for specific queries. And this removes
get_mutwhich is unused and also unusable now that there's no way to get a&mut Stealfrom the rustc API.Another approach may be to override the queries to modify the MIR after having read it from
mir_promoted. However the implementation of queries is largely hidden, so I can't just copy their code to then modify it. A solution would be to parameterize the queries with callbacks which get instantiated withmir_promotedby default, but that seems more involved and ad hoc. That's why I'm proposing this smaller change instead.