erase late bound regions in get_vtable_methods()

Higher-ranked object types can otherwise cause late-bound regions to
sneak into the substs, leading to the false conclusion that some method
is unreachable.  The heart of this patch is from @arielb1.
This commit is contained in:
Niko Matsakis 2017-02-16 13:55:08 -05:00
parent ccd96c945f
commit f2d8a00191
3 changed files with 35 additions and 1 deletions

View file

@ -628,6 +628,11 @@ pub fn get_vtable_methods<'a, 'tcx>(
|_, _| tcx.mk_region(ty::ReErased),
|def, _| trait_ref.substs().type_for_def(def));
// the trait type may have higher-ranked lifetimes in it;
// so erase them if they appear, so that we get the type
// at some particular call site
let substs = tcx.erase_late_bound_regions_and_normalize(&ty::Binder(substs));
// It's possible that the method relies on where clauses that
// do not hold for this particular set of type parameters.
// Note that this method could then never be called, so we