aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-03-20 14:26:42 +0000
committerFlorian Diebold <[email protected]>2021-03-21 12:33:06 +0000
commit0623bb4d71725d6b07e8cef5665094581f951fc0 (patch)
tree748724d956efcb09be31d299dcecb90e1830142b /crates/hir_ty/src/tests
parent0d40ff5e623b3670ce3e0e324ecbab3e5197aaeb (diff)
Test for a Salsa bug
Diffstat (limited to 'crates/hir_ty/src/tests')
-rw-r--r--crates/hir_ty/src/tests/traits.rs51
1 files changed, 51 insertions, 0 deletions
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
@@ -2272,6 +2272,57 @@ fn test<T, U>() where T: Trait<U::Item>, U: Trait<T::Item> {
2272} 2272}
2273 2273
2274#[test] 2274#[test]
2275fn unselected_projection_in_trait_env_cycle_3() {
2276 // this is a cycle, although it would be possible to handle if we didn't go
2277 // into bindings when looking for traits
2278 check_types(
2279 r#"
2280//- /main.rs
2281trait Trait {
2282 type Item;
2283 type OtherItem;
2284}
2285
2286fn test<T>() where T: Trait<OtherItem = T::Item> {
2287 let x: T::Item = no_matter;
2288} //^ {unknown}
2289"#,
2290 );
2291}
2292
2293#[test]
2294fn unselected_projection_in_trait_env_no_cycle() {
2295 // this is not a cycle
2296 check_types(
2297 r#"
2298//- /main.rs
2299trait Index {
2300 type Output;
2301}
2302
2303type Key<S: UnificationStoreBase> = <S as UnificationStoreBase>::Key;
2304
2305pub trait UnificationStoreBase: Index<Output = Key<Self>> {
2306 type Key;
2307
2308 fn len(&self) -> usize;
2309}
2310
2311pub trait UnificationStoreMut: UnificationStoreBase {
2312 fn push(&mut self, value: Self::Key);
2313}
2314
2315fn test<T>(t: T) where T: UnificationStoreMut {
2316 let x;
2317 t.push(x);
2318 let y: Key<T>;
2319 (x, y);
2320} //^ (UnificationStoreBase::Key<T>, UnificationStoreBase::Key<T>)
2321"#,
2322 );
2323}
2324
2325#[test]
2275fn inline_assoc_type_bounds_1() { 2326fn inline_assoc_type_bounds_1() {
2276 check_types( 2327 check_types(
2277 r#" 2328 r#"