@@ -628,18 +628,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
628
628
}
629
629
630
630
self . infcx . probe ( |_snapshot| {
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 ( ) {
635
- return ;
636
- }
631
+ let poly_trait_predicate = self . infcx . resolve_vars_if_possible ( obligation. predicate ) ;
632
+ let placeholder_trait_predicate =
633
+ self . infcx . instantiate_binder_with_placeholders ( poly_trait_predicate) ;
637
634
638
- // The code below doesn't care about regions, and the
639
- // self-ty here doesn't escape this probe, so just erase
640
- // any LBR.
641
- let self_ty = self . tcx ( ) . erase_late_bound_regions ( obligation. self_ty ( ) ) ;
642
- let poly_trait_ref = match self_ty. kind ( ) {
635
+ let self_ty = placeholder_trait_predicate. self_ty ( ) ;
636
+ let principal_trait_ref = match self_ty. kind ( ) {
643
637
ty:: Dynamic ( ref data, ..) => {
644
638
if data. auto_traits ( ) . any ( |did| did == obligation. predicate . def_id ( ) ) {
645
639
debug ! (
@@ -671,18 +665,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
671
665
_ => return ,
672
666
} ;
673
667
674
- debug ! ( ?poly_trait_ref, "assemble_candidates_from_object_ty" ) ;
675
-
676
- let poly_trait_predicate = self . infcx . resolve_vars_if_possible ( obligation. predicate ) ;
677
- let placeholder_trait_predicate =
678
- self . infcx . instantiate_binder_with_placeholders ( poly_trait_predicate) ;
668
+ debug ! ( ?principal_trait_ref, "assemble_candidates_from_object_ty" ) ;
679
669
680
670
// Count only those upcast versions that match the trait-ref
681
671
// we are looking for. Specifically, do not only check for the
682
672
// correct trait, but also the correct type parameters.
683
673
// For example, we may be trying to upcast `Foo` to `Bar<i32>`,
684
674
// but `Foo` is declared as `trait Foo: Bar<u32>`.
685
- let candidate_supertraits = util:: supertraits ( self . tcx ( ) , poly_trait_ref )
675
+ let candidate_supertraits = util:: supertraits ( self . tcx ( ) , principal_trait_ref )
686
676
. enumerate ( )
687
677
. filter ( |& ( _, upcast_trait_ref) | {
688
678
self . infcx . probe ( |_| {
0 commit comments