Skip to content

Commit

Permalink
Auto merge of #55649 - scalexm:chalk-bound-ty, r=nikomatsakis
Browse files Browse the repository at this point in the history
Use bound types in `librustc_traits`

r? @nikomatsakis
see the tests which now move the higher-ranked binders to the left in implied bound rules!
  • Loading branch information
bors committed Nov 13, 2018
2 parents 485397e + 8d0b969 commit 5c9f7dc
Show file tree
Hide file tree
Showing 42 changed files with 1,179 additions and 657 deletions.
1 change: 1 addition & 0 deletions src/Cargo.lock
Expand Up @@ -2419,6 +2419,7 @@ dependencies = [
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_target 0.0.0",
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"syntax 0.0.0",
"syntax_pos 0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/canonical/substitute.rs
Expand Up @@ -80,6 +80,6 @@ where
}
};

tcx.replace_escaping_bound_vars(value, fld_r, fld_t)
tcx.replace_escaping_bound_vars(value, fld_r, fld_t).0
}
}
10 changes: 5 additions & 5 deletions src/librustc/infer/higher_ranked/mod.rs
Expand Up @@ -59,11 +59,11 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
// 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);
let (a_prime, _) = self.infcx.replace_bound_vars_with_fresh_vars(
span,
HigherRankedType,
a
);

debug!("a_prime={:?}", a_prime);
debug!("b_prime={:?}", b_prime);
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/infer/mod.rs
Expand Up @@ -1328,18 +1328,18 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
self.report_and_explain_type_error(trace, &err)
}

pub fn replace_late_bound_regions_with_fresh_var<T>(
pub fn replace_bound_vars_with_fresh_vars<T>(
&self,
span: Span,
lbrct: LateBoundRegionConversionTime,
value: &ty::Binder<T>,
value: &ty::Binder<T>
) -> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
where
T: TypeFoldable<'tcx>,
T: TypeFoldable<'tcx>
{
self.tcx.replace_late_bound_regions(value, |br| {
self.next_region_var(LateBoundRegion(span, br, lbrct))
})
let fld_r = |br| self.next_region_var(LateBoundRegion(span, br, lbrct));
let fld_t = |_| self.next_ty_var(TypeVariableOrigin::MiscVariable(span));
self.tcx.replace_bound_vars(value, fld_r, fld_t)
}

/// Given a higher-ranked projection predicate like:
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/traits/error_reporting.rs
Expand Up @@ -212,10 +212,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// cause I have no idea for a good error message.
if let ty::Predicate::Projection(ref data) = predicate {
let mut selcx = SelectionContext::new(self);
let (data, _) = self.replace_late_bound_regions_with_fresh_var(
let (data, _) = self.replace_bound_vars_with_fresh_vars(
obligation.cause.span,
infer::LateBoundRegionConversionTime::HigherRankedType,
data);
data
);
let mut obligations = vec![];
let normalized_ty = super::normalize_projection_type(
&mut selcx,
Expand Down

0 comments on commit 5c9f7dc

Please sign in to comment.