1
Fork 0

Check projections are well-formed when using projection candidates

This commit is contained in:
Matthew Jasper 2020-06-28 12:41:46 +01:00
parent 87f2f42dc2
commit b3057f4d5f
13 changed files with 278 additions and 30 deletions

View file

@ -1269,7 +1269,11 @@ pub fn check_type_bounds<'tcx>(
// Finally, resolve all regions. This catches wily misuses of
// lifetime parameters.
let fcx = FnCtxt::new(&inh, param_env, impl_ty_hir_id);
fcx.regionck_item(impl_ty_hir_id, impl_ty_span, &[]);
let implied_bounds = match impl_ty.container {
ty::TraitContainer(_) => vec![],
ty::ImplContainer(def_id) => fcx.impl_implied_bounds(def_id, impl_ty_span),
};
fcx.regionck_item(impl_ty_hir_id, impl_ty_span, &implied_bounds);
Ok(())
})

View file

@ -1425,7 +1425,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.collect()
}
fn impl_implied_bounds(&self, impl_def_id: DefId, span: Span) -> Vec<Ty<'tcx>> {
pub(super) fn impl_implied_bounds(&self, impl_def_id: DefId, span: Span) -> Vec<Ty<'tcx>> {
match self.tcx.impl_trait_ref(impl_def_id) {
Some(ref trait_ref) => {
// Trait impl: take implied bounds from all types that