Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Move placeholder error handling to before region inference #142623

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

Open
amandasystems wants to merge 3 commits into rust-lang:master
base: master
Choose a base branch
Loading
from amandasystems:early-placeholder-errors

Conversation

Copy link
Contributor

@amandasystems amandasystems commented Jun 17, 2025
edited
Loading

This PR breaks out yet another part of #130227. It prepares for the removal of precise placeholder tracking by colocating detecting placeholder errors for higher-ranked relations (placeholders outliving existentials that can't name them, other placeholders) with the preprocessing step that adds outlives-static constraints. This also relieves that step from the burden of ensuring these errors are detected via propagation, and fully splits the logic into one part that rewrites the constraint graph to add edges to 'static and one that detects hard errors.

For stepping-on-toes reasons it is currently based on #140737, but (削除) can be rebased on regular master and merged separately (削除ここまで) nope that's a terrible idea actually, it relies on some of the tracking introduced there.

This step also makes region errors more fine-grained, which is useful to simplify the error reporting pipeline, which is currently based on a very brittle method of reconstructing an error event after the fact to figure out what went wrong. Doing that is left as future work, though.

This changes the logic of error reporting slightly to not emit errors for placeholder/higher kinded constraints if there are other borrowck errors. This somewhat lessens the flood of errors and was described as if anything an improvement by @nikomatsakis in informal review.

r? lcnr

@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 Jun 17, 2025

This comment has been minimized.

Copy link
Contributor Author

Wow, a merge conflict with upstream for a commit I JUST PUSHED, that's record time!

apiraino and aureliomarcoag reacted with laugh emoji

@amandasystems amandasystems force-pushed the early-placeholder-errors branch 2 times, most recently from fd18095 to 199f961 Compare June 17, 2025 15:11
@amandasystems amandasystems changed the title (削除) [WIP] Move placeholder error handling to before region inference (削除ここまで) (追記) Move placeholder error handling to before region inference (追記ここまで) Jun 25, 2025
Copy link
Contributor

lcnr commented Jul 3, 2025

@rustbot blocked

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 3, 2025

This comment has been minimized.

This comment has been minimized.

Copy link
Collaborator

rustbot commented Aug 27, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

This comment has been minimized.

Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Aug 27, 2025
Comment on lines -26 to +25
= note: `Getter<'1>` would have to be implemented for the type `GetterImpl<'0, ConstructableImpl<'_>>`, for any two lifetimes `'0` and `'1`...
= note: `Getter<'_>` would have to be implemented for the type `GetterImpl<'0, ConstructableImpl<'1>>`, for any two lifetimes `'0` and `'1`...
Copy link
Contributor Author

@amandasystems amandasystems Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate this, but can't find a way around it. My gut feeling says it's another case of an order-dependent extraction procedure somewhere. For what it's worth, it wasn't in the earlier version of this code but it seems to have appeared after the recent changes to the base commit. Presumably the difference is from selecting smallest placeholder by rvid, etc. Help very much appreciated!

error_element
{
let adjusted_universe =
error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32());
Copy link
Contributor Author

@amandasystems amandasystems Sep 3, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the "checked sub" part is what really broke me here. Why are universes being adjusted? What's a base universe? And why can the subtraction sometimes overflow?!?!

Copy link
Contributor Author

@amandasystems amandasystems Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@amandasystems amandasystems Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, these are the only reads of base_universe on CanonicalTypeOpDeeplyNormalizeGoal, CanonicalTypeOpAscribeUserTypeGoal and InstantiateOpaqueType.

Copy link
Collaborator

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
 95 | | constraints.clone(),
 96 | | &universal_region_relations,
 97 | | infcx,
 98 | | );
 | |_____- argument #4 of type `&mut RegionErrors<'_>` is missing
 |
note: function defined here
 --> compiler/rustc_borrowck/src/handle_placeholders.rs:306:15
 |
306 | pub(crate) fn compute_sccs_applying_placeholder_outlives_constraints<'tcx>(
 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
310 | errors_buffer: &mut RegionErrors<'tcx>,
 | --------------------------------------
help: provide the argument
 |
 94 - let lowered_constraints = compute_sccs_applying_placeholder_outlives_constraints(
 95 - constraints.clone(),
 96 - &universal_region_relations,
 97 - infcx,
 98 - );
 94 + let lowered_constraints = compute_sccs_applying_placeholder_outlives_constraints(constraints.clone(), &universal_region_relations, infcx, /* &mut RegionErrors<'_> */);
 |
For more information about this error, try `rustc --explain E0061`.
[RUSTC-TIMING] rustc_borrowck test:false 4.470
error: could not compile `rustc_borrowck` (lib) due to 1 previous error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees

@lcnr lcnr

Labels
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.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /