aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-06-05 16:41:58 +0100
committerFlorian Diebold <[email protected]>2020-06-05 16:41:58 +0100
commit0d2328f3eaf69c6a50fe6c1e946257bd3503d751 (patch)
treeae6cfd699840c47bc1e051a0b3c13d62babd5177 /crates/ra_hir_ty/src/tests
parent02962b374ecefd6f2a75956f4fb18806531d1d51 (diff)
Review fixes
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r--crates/ra_hir_ty/src/tests/traits.rs73
1 files changed, 58 insertions, 15 deletions
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs
index d83dc6d79..0c538a62d 100644
--- a/crates/ra_hir_ty/src/tests/traits.rs
+++ b/crates/ra_hir_ty/src/tests/traits.rs
@@ -1160,7 +1160,37 @@ fn test(x: impl Trait<u64>, y: &impl Trait<u64>) {
1160} 1160}
1161 1161
1162#[test] 1162#[test]
1163fn return_pos_impl_trait() { 1163fn simple_return_pos_impl_trait() {
1164 mark::check!(lower_rpit);
1165 assert_snapshot!(
1166 infer(r#"
1167trait Trait<T> {
1168 fn foo(&self) -> T;
1169}
1170fn bar() -> impl Trait<u64> { loop {} }
1171
1172fn test() {
1173 let a = bar();
1174 a.foo();
1175}
1176"#),
1177 @r###"
1178 30..34 'self': &Self
1179 72..83 '{ loop {} }': !
1180 74..81 'loop {}': !
1181 79..81 '{}': ()
1182 95..130 '{ ...o(); }': ()
1183 105..106 'a': impl Trait<u64>
1184 109..112 'bar': fn bar() -> impl Trait<u64>
1185 109..114 'bar()': impl Trait<u64>
1186 120..121 'a': impl Trait<u64>
1187 120..127 'a.foo()': u64
1188 "###
1189 );
1190}
1191
1192#[test]
1193fn more_return_pos_impl_trait() {
1164 assert_snapshot!( 1194 assert_snapshot!(
1165 infer(r#" 1195 infer(r#"
1166trait Iterator { 1196trait Iterator {
@@ -1174,12 +1204,12 @@ fn bar() -> (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>) { loop {} }
1174fn baz<T>(t: T) -> (impl Iterator<Item = impl Trait<T>>, impl Trait<T>) { loop {} } 1204fn baz<T>(t: T) -> (impl Iterator<Item = impl Trait<T>>, impl Trait<T>) { loop {} }
1175 1205
1176fn test() { 1206fn test() {
1177 // let (a, b) = bar(); 1207 let (a, b) = bar();
1178 // a.next().foo(); 1208 a.next().foo();
1179 // b.foo(); 1209 b.foo();
1180 let (c, d) = baz(1u128); 1210 let (c, d) = baz(1u128);
1181 c.next();//.foo(); 1211 c.next().foo();
1182 // d.foo(); 1212 d.foo();
1183} 1213}
1184"#), 1214"#),
1185 @r###" 1215 @r###"
@@ -1192,15 +1222,28 @@ fn test() {
1192 269..280 '{ loop {} }': ({unknown}, {unknown}) 1222 269..280 '{ loop {} }': ({unknown}, {unknown})
1193 271..278 'loop {}': ! 1223 271..278 'loop {}': !
1194 276..278 '{}': () 1224 276..278 '{}': ()
1195 292..429 '{ ...o(); }': () 1225 292..414 '{ ...o(); }': ()
1196 368..374 '(c, d)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>) 1226 302..308 '(a, b)': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
1197 369..370 'c': impl Iterator<Item = impl Trait<u128>> 1227 303..304 'a': impl Iterator<Item = impl Trait<u32>>
1198 372..373 'd': impl Trait<u128> 1228 306..307 'b': impl Trait<u64>
1199 377..380 'baz': fn baz<u128>(u128) -> (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>) 1229 311..314 'bar': fn bar() -> (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
1200 377..387 'baz(1u128)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>) 1230 311..316 'bar()': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
1201 381..386 '1u128': u128 1231 322..323 'a': impl Iterator<Item = impl Trait<u32>>
1202 393..394 'c': impl Iterator<Item = impl Trait<u128>> 1232 322..330 'a.next()': impl Trait<u32>
1203 393..401 'c.next()': impl Trait<u128> 1233 322..336 'a.next().foo()': u32
1234 342..343 'b': impl Trait<u64>
1235 342..349 'b.foo()': u64
1236 359..365 '(c, d)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
1237 360..361 'c': impl Iterator<Item = impl Trait<u128>>
1238 363..364 'd': impl Trait<u128>
1239 368..371 'baz': fn baz<u128>(u128) -> (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
1240 368..378 'baz(1u128)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
1241 372..377 '1u128': u128
1242 384..385 'c': impl Iterator<Item = impl Trait<u128>>
1243 384..392 'c.next()': impl Trait<u128>
1244 384..398 'c.next().foo()': u128
1245 404..405 'd': impl Trait<u128>
1246 404..411 'd.foo()': u128
1204 "### 1247 "###
1205 ); 1248 );
1206} 1249}