@@ -29,27 +29,29 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
29
29
30
30
let span = self . trace . cause . span ;
31
31
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) ;
35
36
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) ;
43
44
44
- debug ! ( "a_prime={:?}" , a_prime) ;
45
- debug ! ( "b_prime={:?}" , b_prime) ;
45
+ debug ! ( "a_prime={:?}" , a_prime) ;
46
+ debug ! ( "b_prime={:?}" , b_prime) ;
46
47
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) ?;
49
50
50
- debug ! ( "higher_ranked_sub: OK result={:?}" , result) ;
51
+ debug ! ( "higher_ranked_sub: OK result={:?}" , result) ;
51
52
52
- Ok ( ty:: Binder :: bind ( result) )
53
+ Ok ( ty:: Binder :: bind ( result) )
54
+ } ) ;
53
55
}
54
56
}
55
57
@@ -72,10 +74,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
72
74
/// [rustc guide]: https://rust-lang.github.io/rustc-guide/traits/hrtb.html
73
75
pub fn replace_bound_vars_with_placeholders < T > (
74
76
& self ,
75
- binder : & ty:: Binder < T >
77
+ binder : & ty:: Binder < T > ,
76
78
) -> ( T , PlaceholderMap < ' tcx > )
77
79
where
78
- T : TypeFoldable < ' tcx >
80
+ T : TypeFoldable < ' tcx > ,
79
81
{
80
82
let next_universe = self . create_next_universe ( ) ;
81
83
@@ -97,14 +99,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
97
99
98
100
debug ! (
99
101
"replace_bound_vars_with_placeholders(\
100
- next_universe={:?}, \
101
- binder={:?}, \
102
- result={:?}, \
103
- map={:?})",
104
- next_universe,
105
- binder,
106
- result,
107
- map,
102
+ next_universe={:?}, \
103
+ binder={:?}, \
104
+ result={:?}, \
105
+ map={:?})",
106
+ next_universe, binder, result, map,
108
107
) ;
109
108
110
109
( result, map)
0 commit comments