diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 6f8d8fa49..59c85daed 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -2536,6 +2536,22 @@ fn test() { (&S).foo()<|>; } | |||
2536 | } | 2536 | } |
2537 | 2537 | ||
2538 | #[test] | 2538 | #[test] |
2539 | fn method_resolution_where_clause_inline_not_met() { | ||
2540 | // The blanket impl shouldn't apply because we can't prove S: Clone | ||
2541 | let t = type_at( | ||
2542 | r#" | ||
2543 | //- /main.rs | ||
2544 | trait Clone {} | ||
2545 | trait Trait { fn foo(self) -> u128; } | ||
2546 | struct S; | ||
2547 | impl<T: Clone> Trait for T {} | ||
2548 | fn test() { (&S).foo()<|>; } | ||
2549 | "#, | ||
2550 | ); | ||
2551 | assert_eq!(t, "{unknown}"); | ||
2552 | } | ||
2553 | |||
2554 | #[test] | ||
2539 | fn method_resolution_where_clause_1() { | 2555 | fn method_resolution_where_clause_1() { |
2540 | let t = type_at( | 2556 | let t = type_at( |
2541 | r#" | 2557 | r#" |
@@ -2569,6 +2585,23 @@ fn test() { S2.into()<|>; } | |||
2569 | } | 2585 | } |
2570 | 2586 | ||
2571 | #[test] | 2587 | #[test] |
2588 | fn method_resolution_where_clause_inline() { | ||
2589 | let t = type_at( | ||
2590 | r#" | ||
2591 | //- /main.rs | ||
2592 | trait Into<T> { fn into(self) -> T; } | ||
2593 | trait From<T> { fn from(other: T) -> Self; } | ||
2594 | struct S1; | ||
2595 | struct S2; | ||
2596 | impl From<S2> for S1 {}; | ||
2597 | impl<T, U: From<T>> Into<U> for T {} | ||
2598 | fn test() { S2.into()<|>; } | ||
2599 | "#, | ||
2600 | ); | ||
2601 | assert_eq!(t, "S1"); | ||
2602 | } | ||
2603 | |||
2604 | #[test] | ||
2572 | fn method_resolution_encountering_fn_type() { | 2605 | fn method_resolution_encountering_fn_type() { |
2573 | covers!(trait_resolution_on_fn_type); | 2606 | covers!(trait_resolution_on_fn_type); |
2574 | type_at( | 2607 | type_at( |