-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
[WIP] Remove placeholders completely #130227
Open
amandasystems
wants to merge
10
commits into
rust-lang:master
Choose a base branch
from
amandasystems:remove-placeholders-completely
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[WIP] Remove placeholders completely #130227
amandasystems
wants to merge
10
commits into
rust-lang:master
from
amandasystems:remove-placeholders-completely
+457
−479
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This version is maximally naive, and currently unsound.
This update extends the SCC metadata tracking a lot and uses the extra information to add p: 'static for any placeholder that reaches another placeholder. It also inlines the few measly bits of `init_free_and_bound_regions()` that still remain as relevant. This increases the constructor for `RegionInferenceContext`s somewhat, but I still think it's readable. The documentation for `init_free_and_bound_regions()` was out of date, and the correct, up to date version is available in the various places where the logic was moved.
help the search for who is to blame.
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
Sep 11, 2024
r? nikomatsakis |
@rustbot author |
rustbot
added
S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Sep 11, 2024
This comment has been minimized.
This comment has been minimized.
This commit makes the search for blamable outlives constraints treat an added `x: 'static` edge as a redirect to figure out why it reached an invalid placeholder. As a drive-by it also refactors the blame search somewhat, renames a few methods, and allows iterating over outgoing constraints without the implied edges from 'static.
amandasystems
force-pushed
the
remove-placeholders-completely
branch
from
September 12, 2024 13:52
07b10ca
to
6ab45ce
Compare
This comment has been minimized.
This comment has been minimized.
I've switched to encoding our new outlives-static constraints with two extra parameters: the source and drain of a path in the original constraint graph that caused a placeholder issue. This handles all of the soundness issues, leaving 16 failing diagnostics.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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.
This PR does shotgun surgery on borrowck to remove all special handling of placeholders, completely replacing them with a preprocessing step that rewrites placeholder leaks into constraints, removing constraint propagation of placeholders and all logic used to detect placeholder violations during error reporting. This finishes what #123720 started.
The new method works like this:
r - (from: to_invalid) - > 'static
is added whenr
is the representative of an SCC andto_invalid
is the smallest-universed region it reaches), or if it reaches a region with a too large universe that isn't part of the SCC (in which caseto_invalid
is the region with a too large universe). In either case,from
is alsor
.reaches
inr
's SCC reaches another placeholder,reached
, in which case the added constraint isr -> (reaches: reached) 'static
. Through clever choice of defaults (chosing minimum elements),reached
will ber
if at all possible.When tracing errors for diagnostics one of these special constraints along a path are treated much like a HTTP redirect: if we are explaining
from: to
and reach an edge withreaches: invalid
we stop the search and start followingreaches: invalid
instead. When doing this the implicit edgesx: 'static
for every regionx
are ignored, since the search would otherwise be able to cheat by going through 'static and re-find the same edge again.A bunch of optimisations are possible:
There are a bunch of rather nice bonuses:
MirTypeckRegionConstraints
to the entire crate. The only entry point isplaceholder_region()
so correctness of the indices is now guaranteedfind_constraint_path_to()
isfind_sub_region_live_at()
, which may or may not be possible to work around.r? nikomatsakis