diff options
author | Florian Diebold <[email protected]> | 2021-03-20 14:26:42 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-03-21 12:33:06 +0000 |
commit | 0623bb4d71725d6b07e8cef5665094581f951fc0 (patch) | |
tree | 748724d956efcb09be31d299dcecb90e1830142b /crates/hir_ty/src/tests | |
parent | 0d40ff5e623b3670ce3e0e324ecbab3e5197aaeb (diff) |
Test for a Salsa bug
Diffstat (limited to 'crates/hir_ty/src/tests')
-rw-r--r-- | crates/hir_ty/src/tests/traits.rs | 51 |
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] |
2275 | fn 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 | ||
2281 | trait Trait { | ||
2282 | type Item; | ||
2283 | type OtherItem; | ||
2284 | } | ||
2285 | |||
2286 | fn test<T>() where T: Trait<OtherItem = T::Item> { | ||
2287 | let x: T::Item = no_matter; | ||
2288 | } //^ {unknown} | ||
2289 | "#, | ||
2290 | ); | ||
2291 | } | ||
2292 | |||
2293 | #[test] | ||
2294 | fn unselected_projection_in_trait_env_no_cycle() { | ||
2295 | // this is not a cycle | ||
2296 | check_types( | ||
2297 | r#" | ||
2298 | //- /main.rs | ||
2299 | trait Index { | ||
2300 | type Output; | ||
2301 | } | ||
2302 | |||
2303 | type Key<S: UnificationStoreBase> = <S as UnificationStoreBase>::Key; | ||
2304 | |||
2305 | pub trait UnificationStoreBase: Index<Output = Key<Self>> { | ||
2306 | type Key; | ||
2307 | |||
2308 | fn len(&self) -> usize; | ||
2309 | } | ||
2310 | |||
2311 | pub trait UnificationStoreMut: UnificationStoreBase { | ||
2312 | fn push(&mut self, value: Self::Key); | ||
2313 | } | ||
2314 | |||
2315 | fn 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] | ||
2275 | fn inline_assoc_type_bounds_1() { | 2326 | fn inline_assoc_type_bounds_1() { |
2276 | check_types( | 2327 | check_types( |
2277 | r#" | 2328 | r#" |