From cbe75676b90d93e5b0ac461dce2d916cef4c0476 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 11 May 2019 16:49:55 +0200 Subject: Add support for inline bounds E.g. impl Foo for T. --- crates/ra_hir/src/ty/tests.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'crates/ra_hir/src/ty') 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 @@ -2535,6 +2535,22 @@ fn test() { (&S).foo()<|>; } assert_eq!(t, "{unknown}"); } +#[test] +fn method_resolution_where_clause_inline_not_met() { + // The blanket impl shouldn't apply because we can't prove S: Clone + let t = type_at( + r#" +//- /main.rs +trait Clone {} +trait Trait { fn foo(self) -> u128; } +struct S; +impl Trait for T {} +fn test() { (&S).foo()<|>; } +"#, + ); + assert_eq!(t, "{unknown}"); +} + #[test] fn method_resolution_where_clause_1() { let t = type_at( @@ -2568,6 +2584,23 @@ fn test() { S2.into()<|>; } assert_eq!(t, "S1"); } +#[test] +fn method_resolution_where_clause_inline() { + let t = type_at( + r#" +//- /main.rs +trait Into { fn into(self) -> T; } +trait From { fn from(other: T) -> Self; } +struct S1; +struct S2; +impl From for S1 {}; +impl> Into for T {} +fn test() { S2.into()<|>; } +"#, + ); + assert_eq!(t, "S1"); +} + #[test] fn method_resolution_encountering_fn_type() { covers!(trait_resolution_on_fn_type); -- cgit v1.2.3