Skip to content

rework GAT borrowck limitation error #145041

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
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Aug 7, 2025

The old one depends on the ConstraintCategory of the constraint which meant we did not emit this note if we had to prove the higher ranked trait bound due to e.g. normalization.

This made it annoying brittle and caused MIR borrowck errors to be order dependent, fixes the issue in #140737 (comment).

r? types cc @amandasystems

@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, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 7, 2025

This PR modifies tests/ui/issues/. If this PR is adding new tests to tests/ui/issues/,
please refrain from doing so, and instead add it to more descriptive subdirectories.

&& let ConstraintCategory::Predicate(span) = constraint.category
&& let NllRegionVariableOrigin::Placeholder(placeholder) = origin.origin
&& let Some(id) = placeholder.bound.kind.get_id()
&& let Some(placeholder_id) = id.as_local()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This lint should ideally also work for placeholders from foreign crates by looking at the bound vars and span from the parent predicates_of.

Changing that is annoying and I did not do it in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

This logic will probably help a lot with various order-dependent things I introduce in my PRs, since selection of the correct placeholder is a lot less sensitive now! Thanks!

note: due to current limitations in the borrow checker, this implies a `'static` lifetime
--> $DIR/implementation-not-general-enough-ice-133252.rs:16:18
|
LL | fn force_send<T: Send>(_: T) {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The fact that this note worked and was also applicable here feels somewhat incidental to me. It's caused by incorrectly handling the existential regions in opaque types. This is an instantiation of #110338 for opaque types instead of coroutines

@lcnr lcnr force-pushed the borrowck-limitations-error branch from 5a3ddbc to ba8fa8f Compare August 7, 2025 09:49
@lcnr lcnr force-pushed the borrowck-limitations-error branch from 07a0562 to da17a53 Compare August 13, 2025 12:09
@BoxyUwU
Copy link
Member

BoxyUwU commented Aug 13, 2025

r? BoxyUwU

@rustbot rustbot assigned BoxyUwU and unassigned spastorino Aug 13, 2025
@BoxyUwU
Copy link
Member

BoxyUwU commented Aug 14, 2025

r=me after comment or not

@BoxyUwU BoxyUwU 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 Aug 14, 2025
@lcnr lcnr force-pushed the borrowck-limitations-error branch from da17a53 to 3ebf611 Compare August 14, 2025 15:43
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants