diff options
author | Florian Diebold <[email protected]> | 2019-12-15 17:56:38 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-12-15 17:56:38 +0000 |
commit | 6e1c2d0df89a390be33c81b6e03a5ad352763593 (patch) | |
tree | f3ba344e185e17e6e62ce650462fd63af9eddd26 /crates/ra_hir_ty/src/tests | |
parent | ac961b261458bfeb23f7d4e896d5f957b0854a3a (diff) |
Handle impl Trait more correctly
When calling a function, argument-position impl Trait is transparent; same for
return-position impl Trait when inside the function. So in these cases, we need
to represent that type not by `Ty::Opaque`, but by a type variable that can be
unified with whatever flows into there.
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r-- | crates/ra_hir_ty/src/tests/traits.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index a926d01e5..d8673c90d 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs | |||
@@ -1509,6 +1509,37 @@ fn test() -> impl Trait<i32> { | |||
1509 | } | 1509 | } |
1510 | "#, true), | 1510 | "#, true), |
1511 | @r###" | 1511 | @r###" |
1512 | [27; 28) 'x': impl Trait<u32> | ||
1513 | [47; 58) '{ loop {} }': () | ||
1514 | [49; 56) 'loop {}': ! | ||
1515 | [54; 56) '{}': () | ||
1516 | [69; 70) 'x': impl Trait<T> | ||
1517 | [92; 103) '{ loop {} }': T | ||
1518 | [94; 101) 'loop {}': ! | ||
1519 | [99; 101) '{}': () | ||
1520 | [172; 183) '{ loop {} }': T | ||
1521 | [174; 181) 'loop {}': ! | ||
1522 | [179; 181) '{}': () | ||
1523 | [214; 310) '{ ...t()) }': S<i32> | ||
1524 | [224; 226) 's1': S<u32> | ||
1525 | [229; 230) 'S': S<u32>(T) -> S<T> | ||
1526 | [229; 241) 'S(default())': S<u32> | ||
1527 | [231; 238) 'default': fn default<u32>() -> T | ||
1528 | [231; 240) 'default()': u32 | ||
1529 | [247; 250) 'foo': fn foo(impl Trait<u32>) -> () | ||
1530 | [247; 254) 'foo(s1)': () | ||
1531 | [251; 253) 's1': S<u32> | ||
1532 | [264; 265) 'x': i32 | ||
1533 | [273; 276) 'bar': fn bar<i32>(impl Trait<T>) -> T | ||
1534 | [273; 290) 'bar(S(...lt()))': i32 | ||
1535 | [277; 278) 'S': S<i32>(T) -> S<T> | ||
1536 | [277; 289) 'S(default())': S<i32> | ||
1537 | [279; 286) 'default': fn default<i32>() -> T | ||
1538 | [279; 288) 'default()': i32 | ||
1539 | [296; 297) 'S': S<i32>(T) -> S<T> | ||
1540 | [296; 308) 'S(default())': S<i32> | ||
1541 | [298; 305) 'default': fn default<i32>() -> T | ||
1542 | [298; 307) 'default()': i32 | ||
1512 | "### | 1543 | "### |
1513 | ); | 1544 | ); |
1514 | } | 1545 | } |