Skip to content

Commit

Permalink
Only check predicates for late-bound non-lifetime vars in object cand…
Browse files Browse the repository at this point in the history
…idate assembly
  • Loading branch information
compiler-errors committed Nov 6, 2023
1 parent fb61292 commit 24e14dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}

self.infcx.probe(|_snapshot| {
if obligation.has_non_region_late_bound() {
// FIXME(non_lifetime_binders): Really, we care only to check that we don't
// have any non-region *escaping* bound vars, but that's hard to check and
// we shouldn't really ever encounter those anyways.
if obligation.self_ty().has_non_region_late_bound() {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// check-pass

trait Foo {
type Bar<T>
where
dyn Send + 'static: Send;
}

impl Foo for () {
type Bar<T> = i32;
// We take `<() as Foo>::Bar<T>: Sized` and normalize it under the where clause
// of `for<S> <() as Foo>::Bar<S> = i32`. This gives us back `i32: Send` with
// the nested obligation `(dyn Send + 'static): Send`. However, during candidate
// assembly for object types, we disqualify any obligations that has non-region
// late-bound vars in the param env(!), rather than just the predicate. This causes
// the where clause to not hold even though it trivially should.
}

fn main() {}

0 comments on commit 24e14dd

Please sign in to comment.