Fix another crash from wrong binders

Basically, if we had something like `dyn Trait<T>` (where `T` is a type
parameter) in an impl we lowered that to `dyn Trait<^0.0>`, when it should be
`dyn Trait<^1.0>` because the `dyn` introduces a new binder. With one type
parameter, that's just wrong, with two, it'll lead to crashes.
This commit is contained in:
Florian Diebold
2020-04-17 22:48:29 +02:00
parent a4cda3efbb
commit d3cb9ea0bf
4 changed files with 92 additions and 27 deletions

View File

@@ -396,12 +396,12 @@ impl Substs {
}
/// Return Substs that replace each parameter by a bound variable.
pub(crate) fn bound_vars(generic_params: &Generics) -> Substs {
pub(crate) fn bound_vars(generic_params: &Generics, debruijn: DebruijnIndex) -> Substs {
Substs(
generic_params
.iter()
.enumerate()
.map(|(idx, _)| Ty::Bound(BoundVar::new(DebruijnIndex::INNERMOST, idx)))
.map(|(idx, _)| Ty::Bound(BoundVar::new(debruijn, idx)))
.collect(),
)
}