diff options
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r-- | crates/ra_hir_ty/src/tests/traits.rs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index d088bf309..81c5e6299 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs | |||
@@ -1948,6 +1948,53 @@ fn test<T, U>() where T: Trait<U::Item>, U: Trait<T::Item> { | |||
1948 | } | 1948 | } |
1949 | 1949 | ||
1950 | #[test] | 1950 | #[test] |
1951 | fn inline_assoc_type_bounds_1() { | ||
1952 | let t = type_at( | ||
1953 | r#" | ||
1954 | //- /main.rs | ||
1955 | trait Iterator { | ||
1956 | type Item; | ||
1957 | } | ||
1958 | trait OtherTrait<T> { | ||
1959 | fn foo(&self) -> T; | ||
1960 | } | ||
1961 | |||
1962 | // workaround for Chalk assoc type normalization problems | ||
1963 | pub struct S<T>; | ||
1964 | impl<T: Iterator> Iterator for S<T> { | ||
1965 | type Item = <T as Iterator>::Item; | ||
1966 | } | ||
1967 | |||
1968 | fn test<I: Iterator<Item: OtherTrait<u32>>>() { | ||
1969 | let x: <S<I> as Iterator>::Item; | ||
1970 | x.foo()<|>; | ||
1971 | } | ||
1972 | "#, | ||
1973 | ); | ||
1974 | assert_eq!(t, "u32"); | ||
1975 | } | ||
1976 | |||
1977 | #[test] | ||
1978 | fn inline_assoc_type_bounds_2() { | ||
1979 | let t = type_at( | ||
1980 | r#" | ||
1981 | //- /main.rs | ||
1982 | trait Iterator { | ||
1983 | type Item; | ||
1984 | } | ||
1985 | |||
1986 | fn test<I: Iterator<Item: Iterator<Item = u32>>>() { | ||
1987 | let x: <<I as Iterator>::Item as Iterator>::Item; | ||
1988 | x<|>; | ||
1989 | } | ||
1990 | "#, | ||
1991 | ); | ||
1992 | // assert_eq!(t, "u32"); | ||
1993 | // doesn't currently work, Chalk #234 | ||
1994 | assert_eq!(t, "{unknown}"); | ||
1995 | } | ||
1996 | |||
1997 | #[test] | ||
1951 | fn unify_impl_trait() { | 1998 | fn unify_impl_trait() { |
1952 | assert_snapshot!( | 1999 | assert_snapshot!( |
1953 | infer_with_mismatches(r#" | 2000 | infer_with_mismatches(r#" |