@@ -29,27 +29,29 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
2929
3030 let span = self . trace . cause . span ;
3131
32- // First, we instantiate each bound region in the supertype with a
33- // fresh placeholder region.
34- let ( b_prime, _) = self . infcx . replace_bound_vars_with_placeholders ( b) ;
32+ return self . infcx . commit_if_ok ( |_snapshot| {
33+ // First, we instantiate each bound region in the supertype with a
34+ // fresh placeholder region.
35+ let ( b_prime, _) = self . infcx . replace_bound_vars_with_placeholders ( b) ;
3536
36- // Next, we instantiate each bound region in the subtype
37- // with a fresh region variable. These region variables --
38- // but no other pre-existing region variables -- can name
39- // the placeholders.
40- let ( a_prime, _) =
41- self . infcx
42- . replace_bound_vars_with_fresh_vars ( span, HigherRankedType , a) ;
37+ // Next, we instantiate each bound region in the subtype
38+ // with a fresh region variable. These region variables --
39+ // but no other pre-existing region variables -- can name
40+ // the placeholders.
41+ let ( a_prime, _) =
42+ self . infcx
43+ . replace_bound_vars_with_fresh_vars ( span, HigherRankedType , a) ;
4344
44- debug ! ( "a_prime={:?}" , a_prime) ;
45- debug ! ( "b_prime={:?}" , b_prime) ;
45+ debug ! ( "a_prime={:?}" , a_prime) ;
46+ debug ! ( "b_prime={:?}" , b_prime) ;
4647
47- // Compare types now that bound regions have been replaced.
48- let result = self . sub ( a_is_expected) . relate ( & a_prime, & b_prime) ?;
48+ // Compare types now that bound regions have been replaced.
49+ let result = self . sub ( a_is_expected) . relate ( & a_prime, & b_prime) ?;
4950
50- debug ! ( "higher_ranked_sub: OK result={:?}" , result) ;
51+ debug ! ( "higher_ranked_sub: OK result={:?}" , result) ;
5152
52- Ok ( ty:: Binder :: bind ( result) )
53+ Ok ( ty:: Binder :: bind ( result) )
54+ } ) ;
5355 }
5456}
5557
@@ -72,10 +74,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
7274 /// [rustc guide]: https://rust-lang.github.io/rustc-guide/traits/hrtb.html
7375 pub fn replace_bound_vars_with_placeholders < T > (
7476 & self ,
75- binder : & ty:: Binder < T >
77+ binder : & ty:: Binder < T > ,
7678 ) -> ( T , PlaceholderMap < ' tcx > )
7779 where
78- T : TypeFoldable < ' tcx >
80+ T : TypeFoldable < ' tcx > ,
7981 {
8082 let next_universe = self . create_next_universe ( ) ;
8183
@@ -96,10 +98,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
9698 let ( result, map) = self . tcx . replace_bound_vars ( binder, fld_r, fld_t) ;
9799
98100 debug ! (
99- "replace_bound_vars_with_placeholders(binder={:?}, result={:?}, map={:?})" ,
101+ "replace_bound_vars_with_placeholders(\
102+ next_universe={:?}, \
103+ binder={:?}, \
104+ result={:?}, \
105+ map={:?})",
106+ next_universe,
100107 binder,
101108 result,
102- map
109+ map,
103110 ) ;
104111
105112 ( result, map)
0 commit comments