diff options
Diffstat (limited to 'crates/ra_hir_ty')
-rw-r--r-- | crates/ra_hir_ty/src/tests/traits.rs | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index e555c879a..9d32cbc7a 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs | |||
@@ -2055,7 +2055,7 @@ fn test<I: Iterator<Item: Iterator<Item = u32>>>() { | |||
2055 | #[test] | 2055 | #[test] |
2056 | fn proc_macro_server_types() { | 2056 | fn proc_macro_server_types() { |
2057 | assert_snapshot!( | 2057 | assert_snapshot!( |
2058 | infer_with_mismatches(r#" | 2058 | infer(r#" |
2059 | macro_rules! with_api { | 2059 | macro_rules! with_api { |
2060 | ($S:ident, $self:ident, $m:ident) => { | 2060 | ($S:ident, $self:ident, $m:ident) => { |
2061 | $m! { | 2061 | $m! { |
@@ -2069,9 +2069,9 @@ macro_rules! with_api { | |||
2069 | } | 2069 | } |
2070 | macro_rules! associated_item { | 2070 | macro_rules! associated_item { |
2071 | (type TokenStream) => | 2071 | (type TokenStream) => |
2072 | (type TokenStream: 'static + Clone;); | 2072 | (type TokenStream: 'static;); |
2073 | (type Group) => | 2073 | (type Group) => |
2074 | (type Group: 'static + Clone;); | 2074 | (type Group: 'static;); |
2075 | ($($item:tt)*) => ($($item)*;) | 2075 | ($($item:tt)*) => ($($item)*;) |
2076 | } | 2076 | } |
2077 | macro_rules! declare_server_traits { | 2077 | macro_rules! declare_server_traits { |
@@ -2083,21 +2083,23 @@ macro_rules! declare_server_traits { | |||
2083 | } | 2083 | } |
2084 | 2084 | ||
2085 | $(pub trait $name: Types { | 2085 | $(pub trait $name: Types { |
2086 | $(associated_item!(fn $method(&mut self, $($arg: $arg_ty),*) $(-> $ret_ty)?);)* | 2086 | $(associated_item!(fn $method($($arg: $arg_ty),*) $(-> $ret_ty)?);)* |
2087 | })* | 2087 | })* |
2088 | 2088 | ||
2089 | pub trait Server: Types $(+ $name)* {} | 2089 | pub trait Server: Types $(+ $name)* {} |
2090 | impl<S: Types $(+ $name)*> Server for S {} | 2090 | impl<S: Types $(+ $name)*> Server for S {} |
2091 | } | 2091 | } |
2092 | } | 2092 | } |
2093 | |||
2093 | with_api!(Self, self_, declare_server_traits); | 2094 | with_api!(Self, self_, declare_server_traits); |
2094 | struct Group {} | 2095 | struct G {} |
2095 | struct TokenStream {} | 2096 | struct T {} |
2096 | struct Rustc; | 2097 | struct Rustc; |
2097 | impl Types for Rustc { | 2098 | impl Types for Rustc { |
2098 | type TokenStream = TokenStream; | 2099 | type TokenStream = T; |
2099 | type Group = Group; | 2100 | type Group = G; |
2100 | } | 2101 | } |
2102 | |||
2101 | fn make<T>() -> T { loop {} } | 2103 | fn make<T>() -> T { loop {} } |
2102 | impl TokenStream for Rustc { | 2104 | impl TokenStream for Rustc { |
2103 | fn new() -> Self::TokenStream { | 2105 | fn new() -> Self::TokenStream { |
@@ -2105,17 +2107,17 @@ impl TokenStream for Rustc { | |||
2105 | make() | 2107 | make() |
2106 | } | 2108 | } |
2107 | } | 2109 | } |
2108 | "#, true), | 2110 | "#), |
2109 | @r###" | 2111 | @r###" |
2110 | 1115..1126 '{ loop {} }': T | 2112 | 1062..1073 '{ loop {} }': T |
2111 | 1117..1124 'loop {}': ! | 2113 | 1064..1071 'loop {}': ! |
2112 | 1122..1124 '{}': () | 2114 | 1069..1071 '{}': () |
2113 | 1190..1253 '{ ... }': {unknown} | 2115 | 1137..1200 '{ ... }': T |
2114 | 1204..1209 'group': {unknown} | 2116 | 1151..1156 'group': G |
2115 | 1225..1229 'make': fn make<{unknown}>() -> {unknown} | 2117 | 1172..1176 'make': fn make<G>() -> G |
2116 | 1225..1231 'make()': {unknown} | 2118 | 1172..1178 'make()': G |
2117 | 1241..1245 'make': fn make<{unknown}>() -> {unknown} | 2119 | 1188..1192 'make': fn make<T>() -> T |
2118 | 1241..1247 'make()': {unknown} | 2120 | 1188..1194 'make()': T |
2119 | "### | 2121 | "### |
2120 | ); | 2122 | ); |
2121 | } | 2123 | } |