From 0623bb4d71725d6b07e8cef5665094581f951fc0 Mon Sep 17 00:00:00 2001 From: Florian Diebold <flodiebold@gmail.com> Date: Sat, 20 Mar 2021 15:26:42 +0100 Subject: Test for a Salsa bug --- crates/hir_ty/src/tests/traits.rs | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'crates/hir_ty/src/tests') diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index 8f2bdffc0..1bb6dff95 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs @@ -2271,6 +2271,57 @@ fn test<T, U>() where T: Trait<U::Item>, U: Trait<T::Item> { ); } +#[test] +fn unselected_projection_in_trait_env_cycle_3() { + // this is a cycle, although it would be possible to handle if we didn't go + // into bindings when looking for traits + check_types( + r#" +//- /main.rs +trait Trait { + type Item; + type OtherItem; +} + +fn test<T>() where T: Trait<OtherItem = T::Item> { + let x: T::Item = no_matter; +} //^ {unknown} +"#, + ); +} + +#[test] +fn unselected_projection_in_trait_env_no_cycle() { + // this is not a cycle + check_types( + r#" +//- /main.rs +trait Index { + type Output; +} + +type Key<S: UnificationStoreBase> = <S as UnificationStoreBase>::Key; + +pub trait UnificationStoreBase: Index<Output = Key<Self>> { + type Key; + + fn len(&self) -> usize; +} + +pub trait UnificationStoreMut: UnificationStoreBase { + fn push(&mut self, value: Self::Key); +} + +fn test<T>(t: T) where T: UnificationStoreMut { + let x; + t.push(x); + let y: Key<T>; + (x, y); +} //^ (UnificationStoreBase::Key<T>, UnificationStoreBase::Key<T>) +"#, + ); +} + #[test] fn inline_assoc_type_bounds_1() { check_types( -- cgit v1.2.3