From 272a8dce4f603b38e7755bcd2dc8abb6437e6e64 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 8 Apr 2021 23:34:05 +0200 Subject: Fix crash on syn involving lifetimes returned by Chalk If we get lifetime variables back in autoderef, just immediately replace them by static lifetimes for now. Method resolution doesn't really deal correctly with new variables being introduced (this needs to be fixed more properly). This fixes `rust-analyzer analysis-stats --with-deps` crashing in the RA repo. --- crates/hir_ty/src/tests/regression.rs | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'crates/hir_ty/src/tests/regression.rs') diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index b69f86050..9cd9f473d 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs @@ -974,3 +974,41 @@ fn param_overrides_fn() { "#, ) } + +#[test] +fn lifetime_from_chalk_during_deref() { + check_types( + r#" + #[lang = "deref"] + pub trait Deref { + type Target; + } + + struct Box {} + impl Deref for Box { + type Target = T; + + fn deref(&self) -> &Self::Target { + loop {} + } + } + + trait Iterator { + type Item; + } + + pub struct Iter<'a, T: 'a> { + inner: Box + 'a>, + } + + trait IterTrait<'a, T: 'a>: Iterator { + fn clone_box(&self); + } + + fn clone_iter(s: Iter) { + s.inner.clone_box(); + //^^^^^^^^^^^^^^^^^^^ () + } + "#, + ) +} -- cgit v1.2.3