@@ -34,31 +34,27 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
3434 T : Relate < ' tcx > ,
3535 {
3636 let span = self . trace . cause . span ;
37+ // First, we instantiate each bound region in the supertype with a
38+ // fresh placeholder region. Note that this automatically creates
39+ // a new universe if needed.
40+ let sup_prime = self . infcx . replace_bound_vars_with_placeholders ( sup) ;
3741
38- self . infcx . commit_if_ok ( |_| {
39- // First, we instantiate each bound region in the supertype with a
40- // fresh placeholder region. Note that this automatically creates
41- // a new universe if needed .
42- let sup_prime = self . infcx . replace_bound_vars_with_placeholders ( sup ) ;
42+ // Next, we instantiate each bound region in the subtype
43+ // with a fresh region variable. These region variables --
44+ // but no other pre-existing region variables -- can name
45+ // the placeholders .
46+ let sub_prime = self . infcx . replace_bound_vars_with_fresh_vars ( span , HigherRankedType , sub ) ;
4347
44- // Next, we instantiate each bound region in the subtype
45- // with a fresh region variable. These region variables --
46- // but no other pre-existing region variables -- can name
47- // the placeholders.
48- let sub_prime =
49- self . infcx . replace_bound_vars_with_fresh_vars ( span, HigherRankedType , sub) ;
48+ debug ! ( "a_prime={:?}" , sub_prime) ;
49+ debug ! ( "b_prime={:?}" , sup_prime) ;
5050
51- debug ! ( "a_prime={:?}" , sub_prime ) ;
52- debug ! ( "b_prime={:?}" , sup_prime) ;
51+ // Compare types now that bound regions have been replaced.
52+ let result = self . sub ( sub_is_expected ) . relate ( sub_prime , sup_prime) ? ;
5353
54- // Compare types now that bound regions have been replaced.
55- let result = self . sub ( sub_is_expected) . relate ( sub_prime, sup_prime) ?;
56-
57- debug ! ( "higher_ranked_sub: OK result={result:?}" ) ;
58- // NOTE: returning the result here would be dangerous as it contains
59- // placeholders which **must not** be named afterwards.
60- Ok ( ( ) )
61- } )
54+ debug ! ( "OK result={result:?}" ) ;
55+ // NOTE: returning the result here would be dangerous as it contains
56+ // placeholders which **must not** be named afterwards.
57+ Ok ( ( ) )
6258 }
6359}
6460
0 commit comments