Skip to content

Commit 24e14dd

Browse files
Only check predicates for late-bound non-lifetime vars in object candidate assembly
1 parent fb61292 commit 24e14dd

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Diff for: compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
628628
}
629629

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

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// check-pass
2+
3+
trait Foo {
4+
type Bar<T>
5+
where
6+
dyn Send + 'static: Send;
7+
}
8+
9+
impl Foo for () {
10+
type Bar<T> = i32;
11+
// We take `<() as Foo>::Bar<T>: Sized` and normalize it under the where clause
12+
// of `for<S> <() as Foo>::Bar<S> = i32`. This gives us back `i32: Send` with
13+
// the nested obligation `(dyn Send + 'static): Send`. However, during candidate
14+
// assembly for object types, we disqualify any obligations that has non-region
15+
// late-bound vars in the param env(!), rather than just the predicate. This causes
16+
// the where clause to not hold even though it trivially should.
17+
}
18+
19+
fn main() {}

0 commit comments

Comments
 (0)