aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests/traits.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/tests/traits.rs')
-rw-r--r--crates/ra_hir_ty/src/tests/traits.rs47
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 22ae6ca90..53461bdbb 100644
--- a/crates/ra_hir_ty/src/tests/traits.rs
+++ b/crates/ra_hir_ty/src/tests/traits.rs
@@ -1924,6 +1924,53 @@ fn test<T, U>() where T: Trait<U::Item>, U: Trait<T::Item> {
1924} 1924}
1925 1925
1926#[test] 1926#[test]
1927fn inline_assoc_type_bounds_1() {
1928 let t = type_at(
1929 r#"
1930//- /main.rs
1931trait Iterator {
1932 type Item;
1933}
1934trait OtherTrait<T> {
1935 fn foo(&self) -> T;
1936}
1937
1938// workaround for Chalk assoc type normalization problems
1939pub struct S<T>;
1940impl<T: Iterator> Iterator for S<T> {
1941 type Item = <T as Iterator>::Item;
1942}
1943
1944fn test<I: Iterator<Item: OtherTrait<u32>>>() {
1945 let x: <S<I> as Iterator>::Item;
1946 x.foo()<|>;
1947}
1948"#,
1949 );
1950 assert_eq!(t, "u32");
1951}
1952
1953#[test]
1954fn inline_assoc_type_bounds_2() {
1955 let t = type_at(
1956 r#"
1957//- /main.rs
1958trait Iterator {
1959 type Item;
1960}
1961
1962fn test<I: Iterator<Item: Iterator<Item = u32>>>() {
1963 let x: <<I as Iterator>::Item as Iterator>::Item;
1964 x<|>;
1965}
1966"#,
1967 );
1968 // assert_eq!(t, "u32");
1969 // doesn't currently work, Chalk #234
1970 assert_eq!(t, "{unknown}");
1971}
1972
1973#[test]
1927fn unify_impl_trait() { 1974fn unify_impl_trait() {
1928 assert_snapshot!( 1975 assert_snapshot!(
1929 infer_with_mismatches(r#" 1976 infer_with_mismatches(r#"