Skip to content

Commit 6cb4ffb

Browse files
committed
reintroduce commit_if_ok call into higher_ranked_sub
1 parent 3cd286b commit 6cb4ffb

File tree

1 file changed

+25
-26
lines changed
  • src/librustc/infer/higher_ranked

1 file changed

+25
-26
lines changed

src/librustc/infer/higher_ranked/mod.rs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -97,14 +99,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
9799

98100
debug!(
99101
"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,
108107
);
109108

110109
(result, map)

0 commit comments

Comments
 (0)