diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 9d61bba402..717399b6de 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -860,7 +860,8 @@ pub trait TypeWalk { ); self } - // /// Shifts up debruijn indices of `Ty::Bound` vars by `n`. + + /// Shifts up debruijn indices of `Ty::Bound` vars by `n`. fn shift_bound_vars(self, n: DebruijnIndex) -> Self where Self: Sized, diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index 081aa943a4..22ae6ca909 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs @@ -2021,3 +2021,28 @@ fn main() { "### ); } + +#[test] +fn dyn_trait_through_chalk() { + let t = type_at( + r#" +//- /main.rs +struct Box {} +#[lang = "deref"] +trait Deref { + type Target; +} +impl Deref for Box { + type Target = T; +} +trait Trait { + fn foo(&self); +} + +fn test(x: Box) { + x.foo()<|>; +} +"#, + ); + assert_eq!(t, "()"); +} diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 53ce362ea2..1bc0f07135 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs @@ -427,7 +427,12 @@ impl ToChalk for GenericPredicate { db: &dyn HirDatabase, where_clause: chalk_ir::QuantifiedWhereClause, ) -> GenericPredicate { - match where_clause.value { + // we don't produce any where clauses with binders and can't currently deal with them + match where_clause + .value + .shifted_out(&Interner) + .expect("unexpected bound vars in where clause") + { chalk_ir::WhereClause::Implemented(tr) => { GenericPredicate::Implemented(from_chalk(db, tr)) }