Skip to content

Only instantiate binder during dyn's built-in trait candidate probe once #117610

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

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Only check predicates for late-bound non-lifetime vars in object cand…
…idate assembly
  • Loading branch information
compiler-errors committed Nov 6, 2023
commit 24e14dd8b40a2434fc2343342c30d8d5748d1c5a
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() {}