diff options
author | Aleksey Kladov <[email protected]> | 2018-08-13 15:42:43 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-13 15:42:43 +0100 |
commit | d1eceefeb8b683da3f64b89446f04f01803962e1 (patch) | |
tree | b5e80856cadc70dbc5f9a8e2cbe6cbf751e5f716 /crates/libsyntax2/src/grammar/types.rs | |
parent | 5a56ac4b72e7f57fb20d49bcf531611f144cc0e0 (diff) |
dyn type
Diffstat (limited to 'crates/libsyntax2/src/grammar/types.rs')
-rw-r--r-- | crates/libsyntax2/src/grammar/types.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/libsyntax2/src/grammar/types.rs b/crates/libsyntax2/src/grammar/types.rs index 0d8c6bfba..5ba3fcca0 100644 --- a/crates/libsyntax2/src/grammar/types.rs +++ b/crates/libsyntax2/src/grammar/types.rs | |||
@@ -11,9 +11,10 @@ pub(super) fn type_(p: &mut Parser) { | |||
11 | FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), | 11 | FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), |
12 | FOR_KW => for_type(p), | 12 | FOR_KW => for_type(p), |
13 | IMPL_KW => impl_trait_type(p), | 13 | IMPL_KW => impl_trait_type(p), |
14 | DYN_KW => dyn_trait_type(p), | ||
14 | _ if paths::is_path_start(p) => path_type(p), | 15 | _ if paths::is_path_start(p) => path_type(p), |
15 | _ => { | 16 | _ => { |
16 | p.error("expected type"); | 17 | p.err_and_bump("expected type"); |
17 | } | 18 | } |
18 | } | 19 | } |
19 | } | 20 | } |
@@ -194,6 +195,16 @@ fn impl_trait_type(p: &mut Parser) { | |||
194 | m.complete(p, IMPL_TRAIT_TYPE); | 195 | m.complete(p, IMPL_TRAIT_TYPE); |
195 | } | 196 | } |
196 | 197 | ||
198 | // test dyn_trait_type | ||
199 | // type A = dyn Iterator<Item=Foo<'a>> + 'a; | ||
200 | fn dyn_trait_type(p: &mut Parser) { | ||
201 | assert!(p.at(DYN_KW)); | ||
202 | let m = p.start(); | ||
203 | p.bump(); | ||
204 | type_params::bounds_without_colon(p); | ||
205 | m.complete(p, DYN_TRAIT_TYPE); | ||
206 | } | ||
207 | |||
197 | // test path_type | 208 | // test path_type |
198 | // type A = Foo; | 209 | // type A = Foo; |
199 | // type B = ::Foo; | 210 | // type B = ::Foo; |