From d1eceefeb8b683da3f64b89446f04f01803962e1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 13 Aug 2018 17:42:43 +0300 Subject: dyn type --- crates/libsyntax2/src/grammar/types.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'crates/libsyntax2/src/grammar/types.rs') 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) { FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), FOR_KW => for_type(p), IMPL_KW => impl_trait_type(p), + DYN_KW => dyn_trait_type(p), _ if paths::is_path_start(p) => path_type(p), _ => { - p.error("expected type"); + p.err_and_bump("expected type"); } } } @@ -194,6 +195,16 @@ fn impl_trait_type(p: &mut Parser) { m.complete(p, IMPL_TRAIT_TYPE); } +// test dyn_trait_type +// type A = dyn Iterator> + 'a; +fn dyn_trait_type(p: &mut Parser) { + assert!(p.at(DYN_KW)); + let m = p.start(); + p.bump(); + type_params::bounds_without_colon(p); + m.complete(p, DYN_TRAIT_TYPE); +} + // test path_type // type A = Foo; // type B = ::Foo; -- cgit v1.2.3