@@ -628,18 +628,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
628628        } 
629629
630630        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) ; 
637634
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 ( )  { 
643637                ty:: Dynamic ( ref  data,  ..)  => { 
644638                    if  data. auto_traits ( ) . any ( |did| did == obligation. predicate . def_id ( ) )  { 
645639                        debug ! ( 
@@ -671,18 +665,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
671665                _ => return , 
672666            } ; 
673667
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" ) ; 
679669
680670            // Count only those upcast versions that match the trait-ref 
681671            // we are looking for. Specifically, do not only check for the 
682672            // correct trait, but also the correct type parameters. 
683673            // For example, we may be trying to upcast `Foo` to `Bar<i32>`, 
684674            // 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 ) 
686676                . enumerate ( ) 
687677                . filter ( |& ( _,  upcast_trait_ref) | { 
688678                    self . infcx . probe ( |_| { 
0 commit comments