aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-05-11 15:49:55 +0100
committerFlorian Diebold <[email protected]>2019-05-11 15:56:36 +0100
commitcbe75676b90d93e5b0ac461dce2d916cef4c0476 (patch)
tree50999df2191aa13204ca05f255ebe2b2105a1832 /crates/ra_hir/src/ty
parentd6dc75f9f22b73faf8c526be69ca43e52d6db1bf (diff)
Add support for inline bounds
E.g. impl<T: Clone> Foo for T.
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/tests.rs33
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]
2539fn 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
2544trait Clone {}
2545trait Trait { fn foo(self) -> u128; }
2546struct S;
2547impl<T: Clone> Trait for T {}
2548fn test() { (&S).foo()<|>; }
2549"#,
2550 );
2551 assert_eq!(t, "{unknown}");
2552}
2553
2554#[test]
2539fn method_resolution_where_clause_1() { 2555fn 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]
2588fn method_resolution_where_clause_inline() {
2589 let t = type_at(
2590 r#"
2591//- /main.rs
2592trait Into<T> { fn into(self) -> T; }
2593trait From<T> { fn from(other: T) -> Self; }
2594struct S1;
2595struct S2;
2596impl From<S2> for S1 {};
2597impl<T, U: From<T>> Into<U> for T {}
2598fn test() { S2.into()<|>; }
2599"#,
2600 );
2601 assert_eq!(t, "S1");
2602}
2603
2604#[test]
2572fn method_resolution_encountering_fn_type() { 2605fn 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(