From 236ac630f6ffc403257d4c77e6187819432956cf Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Mon, 6 Apr 2020 17:24:08 +0200 Subject: Fix Chalk panic Fixes #3865. Basically I forgot to shift 'back' when we got `dyn Trait`s back from Chalk, so after going through Chalk a few times, the panic happened. --- crates/ra_hir_ty/src/tests/traits.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'crates/ra_hir_ty/src/tests/traits.rs') diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index 081aa943a..22ae6ca90 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, "()"); +} -- cgit v1.2.3