Repository navigation
-Zassumptions-on-binders: replace region vars with bound vars when handling alias outlives' - #164045
Conversation
846785b to
cde535f
Compare
|
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. |
There was a problem hiding this comment.
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
| // 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 |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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!
| for<'a> <T as Trait<'a>>::Assoc: 'b | ||
| } | ||
| } expect { | ||
| or { and {} } |
There was a problem hiding this comment.
this is technically useless/not needed, right? just expect {} is fine. but being explicit is nice, shrug
cde535f to
ecc137b
Compare
|
@bors r=khyperia rollup |
|
renamed |
…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
…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
…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')
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
r? @khyperia
See added test. Previously when rewriting
<T as Trait<'?x>>::Assoc: 'bwe would just getambiguity, we now producefor<'x> <T as Trait<'x>>::Assoc: 'bin the same way that we do when handling too-large-universe placeholders in alias outlives constraints