reorder the placeholders and inference variables in hr::sub

This commit is contained in:
Niko Matsakis 2018-09-07 10:00:01 -04:00
parent 4cd4eae435
commit f8dd084ef1

View File

@ -51,19 +51,21 @@ pub fn higher_ranked_sub<T>(&mut self, a: &Binder<T>, b: &Binder<T>, a_is_expect
return self.infcx.commit_if_ok(|snapshot| {
let span = self.trace.cause.span;
// First, we instantiate each bound region in the subtype with a fresh
// region variable.
// First, we instantiate each bound region in the supertype with a
// fresh placeholder region.
let (b_prime, placeholder_map) =
self.infcx.replace_late_bound_regions_with_placeholders(b);
// Next, we instantiate each bound region in the subtype
// with a fresh region variable. These region variables --
// but no other pre-existing region variables -- can name
// the placeholders.
let (a_prime, _) =
self.infcx.replace_late_bound_regions_with_fresh_var(
span,
HigherRankedType,
a);
// Second, we instantiate each bound region in the supertype with a
// fresh concrete region.
let (b_prime, placeholder_map) =
self.infcx.replace_late_bound_regions_with_placeholders(b);
debug!("a_prime={:?}", a_prime);
debug!("b_prime={:?}", b_prime);