Skip to content

-Zassumptions-on-binders: replace region vars with bound vars when handling alias outlives' - #164045

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
BoxyUwU:abby_s_region_vars_bound_vars
Oct 12, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
BoxyUwU:abby_s_region_vars_bound_vars

Conversation

@BoxyUwU

@BoxyUwU BoxyUwU commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

r? @khyperia

See added test. Previously when rewriting <T as Trait<'?x>>::Assoc: 'b we would just get ambiguity, we now produce for<'x> <T as Trait<'x>>::Assoc: 'b in the same way that we do when handling too-large-universe placeholders in alias outlives constraints

@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 Oct 9, 2026
@BoxyUwU
BoxyUwU force-pushed the abby_s_region_vars_bound_vars branch from 846785b to cde535f Compare October 10, 2026 09:29
@rustbot

rustbot commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main 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.

Comment on lines 985 to 990

@BoxyUwU BoxyUwU Oct 10, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the ambiguity would come from this line with a comment that lies to you because not handling region vars means you also get this to trigger from those rather than just non lifetime binders xd

before we added this logic it'd have just ICEd ig

View changes since the review

Comment thread compiler/rustc_type_ir/src/region_constraint.rs Outdated

@khyperia khyperia left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hell yea gamer, very readable straightforward PR, thanks ❤️

r=me unless you wanna respond to my yaps in some form

View changes since this review

// we dont equivalently elaborate the assumption into assumptions on the adt's components we just drop the
// assumptions
//
// so actually only `for<'a, 'b> Alias<'a>: 'b` and `for<'a> T: 'a` are assumptions we actually need to

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

for my own understanding: what is the difference between for<'a> T: 'a and T: 'static? I feel like they ought to imply each other, and we could (should?) "normalize" to one of them (probably T: 'static). Or is your thinking just, "special-casing is annoying, keep things in the form they are, they can be proven by T: 'static anyway no fuss"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There isn't a meaningful difference, if we had assumptions on the binders it would be, e.g. for<'a> where('b: 'a) T: 'a is different from T: 'static since T could be known to outlive some 'c which outlives 'b. But right now yeah no difference.

I don't know if we even get for<'a> T: 'a assumptions or not- when I originally wrote this comment is was more about the conceptual thing than actually what assumptions and representations we get in practice

self.cx.cx()
}

fn fold_region(&mut self, r: Region<I>) -> Region<I> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not in this PR, but, should we be folding types as well? for #![feature(non_lifetime_binders)]. tbh I don't know the state of non_lifetime_binders, if something like T::Alias<?x>: 'a -> for<NLB> T::Alias<NLB>: 'a is valid (in the sense of if it gets ICEy or not)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it doesn't get ICEy but we do just downgrade to ambiguity because we don't handle it. I have no idea what the right thing to do for non lifetime binders is lol that feature is not being actively developed rn tho

Region::new_bound(cx, self.current_index, *mapped_var)
}
RegionKind::ReVar(inf) => {
let u = self.cx.universe_of_region(inf).unwrap();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mostly a note for myself, I'm unfamiliar with phasing and when things are resolved/run, so I'm unsure if this is possible to ever be resolved and so universe_of_region returns None. Probably obvious once one knows how things work so a comment explaining why is probably not super worth it. Saw another comment that says it's only valid if eager_resolve_vars is run beforehand, but I don't see that here, but maybe we're working on the assumption that registered constraints have vars eagerly resolved?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think we just crash here sometimes yeah :3 Should actually be proper after #164103

for<'a> <T as Trait<'a>>::Assoc: 'b
{
forall<> {
exists<'a> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you know I'm realizing that I accidentally never actually tested exists, this is the first use of it in the test suite. whoops. glad it works!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

✨

for<'a> <T as Trait<'a>>::Assoc: 'b
}
} expect {
or { and {} }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is technically useless/not needed, right? just expect {} is fine. but being explicit is nice, shrug

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh yeah

@khyperia khyperia 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 Oct 12, 2026
@BoxyUwU
BoxyUwU force-pushed the abby_s_region_vars_bound_vars branch from cde535f to ecc137b Compare October 12, 2026 12:36
@BoxyUwU

BoxyUwU commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

@bors r=khyperia rollup

@rust-bors

rust-bors Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

📌 Commit ecc137b has been tentatively approved by khyperia

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 12, 2026
@BoxyUwU

BoxyUwU commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

renamed PlaceholderReplacer :>

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 12, 2026
…ars, r=khyperia

-Zassumptions-on-binders: replace region vars with bound vars when handling alias outlives'

r? @khyperia

See added test. Previously when rewriting `<T as Trait<'?x>>::Assoc: 'b` we would just get `ambiguity`, we now produce `for<'x> <T as Trait<'x>>::Assoc: 'b` in the same way that we do when handling too-large-universe placeholders in alias outlives constraints
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 12, 2026
…ars, r=khyperia

-Zassumptions-on-binders: replace region vars with bound vars when handling alias outlives'

r? @khyperia

See added test. Previously when rewriting `<T as Trait<'?x>>::Assoc: 'b` we would just get `ambiguity`, we now produce `for<'x> <T as Trait<'x>>::Assoc: 'b` in the same way that we do when handling too-large-universe placeholders in alias outlives constraints
rust-bors Bot pushed a commit that referenced this pull request Oct 12, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #164196 (`rust-analyzer` subtree update)
 - #164037 (Restrict application of optimization attributes from instance)
 - #164201 (Improve `--bless` output for `tests/debuginfo`)
 - #164202 ([rustdoc] Move the creation of `IndividualTestOptions` into the test runner closure to ensure the temporary folder is removed right after the test is done running)
 - #162140 (fn_addr_eq: we actually can guarantee basically nothing)
 - #163946 (Fix transmutability type mismatch bug)
 - #163978 (Copy over some methods from At to InferCtxt)
 - #164045 (-Zassumptions-on-binders: replace region vars with bound vars when handling alias outlives')
@rust-bors
rust-bors Bot merged commit 5bbae1e into rust-lang:main Oct 12, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 12, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 12, 2026
Rollup merge of #164045 - BoxyUwU:abby_s_region_vars_bound_vars, r=khyperia

-Zassumptions-on-binders: replace region vars with bound vars when handling alias outlives'

r? @khyperia

See added test. Previously when rewriting `<T as Trait<'?x>>::Assoc: 'b` we would just get `ambiguity`, we now produce `for<'x> <T as Trait<'x>>::Assoc: 'b` in the same way that we do when handling too-large-universe placeholders in alias outlives constraints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

3 participants