-
Notifications
You must be signed in to change notification settings - Fork 70
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
Don't steal the resolver when lowering HIR; instead store an immutable resolver in TyCtxt #437
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed. cc @rust-lang/compiler @rust-lang/compiler-contributors |
Would this allow a user to perform resolution with just a |
It shouldn't IMO. Resolution is not tracked by incr comp. We are currently in the process of making all state that is not tracked by incr comp inaccessible from |
Vadim Petrochenkov and I talked this over and we have a plan for making this work without major changes to the resolver; he convinced me it will take a very long time for the resolver to be part of incremental, and I want to try and fix these issues without having to wait. |
Motivation
Currently, the resolver is stolen when lowering to HIR. This means that it cannot be used at all after creating a TyCtxt. In particular, rustdoc wants to use it afterwards for resolving intra-doc links. The current hack is to clone the whole resolver, and use the clone to look up links. This is causing numerous bugs; the most common is that the CStore of the clone is out of sync with the CStore of the TyCtxt, causing ICEs when looking up a DefId that's only present in the clone.
For more context, see rust-lang/rust#83761.
Proposal
Instead of cloning the resolver or requiring ownership: https://github.com/rust-lang/rust/blob/f434217aab9abf583ebc928b97ab4116921137aa/compiler/rustc_interface/src/passes.rs#L143-L148
Remove the
Steal
fromQueries::expansion
. Useexpansion().peek_mut()
when initially constructing the HIR, then never modify the resolver again. This can be enforced by using a trait that only allows immutable access:Previous discussion (copied from the linked issue):
I think as long as the TyCtxt doesn't have mutable access to the resolver it won't change things very much, it will only interact with DefIds and not NodeIds. I'm not suggesting that we make path resolution incremental as part of this change (although it may make it easier to do later).
Alternatives
Change rustdoc to do all path resolution before the TyCtxt is created. I do not think this is feasible, I spent a good two weeks on it with very little progress (see the history of jyn514/rust@8d3d43f). I am no longer willing to work on it and I highly doubt anyone else is.
Mentors or Reviewers
@petrochenkov
Process
The main points of the Major Change Process are as follows:
@rustbot second
.-C flag
, then full team check-off is required.@rfcbot fcp merge
on either the MCP or the PR.You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
The text was updated successfully, but these errors were encountered: