aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests/simple.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/tests/simple.rs')
-rw-r--r--crates/ra_hir_ty/src/tests/simple.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs
index cd919466f..5e3f2bd3c 100644
--- a/crates/ra_hir_ty/src/tests/simple.rs
+++ b/crates/ra_hir_ty/src/tests/simple.rs
@@ -2152,3 +2152,48 @@ fn test() {
2152 "### 2152 "###
2153 ); 2153 );
2154} 2154}
2155
2156#[test]
2157fn generic_default_depending_on_other_type_arg() {
2158 assert_snapshot!(
2159 infer(r#"
2160struct Thing<T = u128, F = fn() -> T> { t: T }
2161
2162fn test(t1: Thing<u32>, t2: Thing) {
2163 t1;
2164 t2;
2165 Thing::<_> { t: 1u32 };
2166}
2167"#),
2168 // FIXME: the {unknown} is a bug
2169 @r###"
2170 56..58 't1': Thing<u32, fn() -> u32>
2171 72..74 't2': Thing<u128, fn() -> u128>
2172 83..130 '{ ...2 }; }': ()
2173 89..91 't1': Thing<u32, fn() -> u32>
2174 97..99 't2': Thing<u128, fn() -> u128>
2175 105..127 'Thing:...1u32 }': Thing<u32, fn() -> {unknown}>
2176 121..125 '1u32': u32
2177 "###
2178 );
2179}
2180
2181#[test]
2182fn generic_default_depending_on_other_type_arg_forward() {
2183 assert_snapshot!(
2184 infer(r#"
2185struct Thing<F = fn() -> T, T = u128> { t: T }
2186
2187fn test(t1: Thing) {
2188 t1;
2189}
2190"#),
2191 // the {unknown} here is intentional, as defaults are not allowed to
2192 // refer to type parameters coming later
2193 @r###"
2194 56..58 't1': Thing<fn() -> {unknown}, u128>
2195 67..78 '{ t1; }': ()
2196 73..75 't1': Thing<fn() -> {unknown}, u128>
2197 "###
2198 );
2199}