From 6502bd2c966d57bdb8fbba7f43da9ddd004d87d3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 5 Nov 2018 11:39:35 +0300 Subject: reduce code duplication --- crates/ra_syntax/src/grammar/types.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'crates/ra_syntax/src/grammar/types.rs') diff --git a/crates/ra_syntax/src/grammar/types.rs b/crates/ra_syntax/src/grammar/types.rs index f308aef89..ed2718e73 100644 --- a/crates/ra_syntax/src/grammar/types.rs +++ b/crates/ra_syntax/src/grammar/types.rs @@ -188,13 +188,22 @@ fn fn_pointer_type(p: &mut Parser) { m.complete(p, FN_POINTER_TYPE); } +pub(super) fn for_binder(p: &mut Parser) { + assert!(p.at(FOR_KW)); + p.bump(); + if p.at(L_ANGLE) { + type_params::opt_type_param_list(p); + } else { + p.error("expected `<`"); + } +} + // test for_type // type A = for<'a> fn() -> (); pub(super) fn for_type(p: &mut Parser) { assert!(p.at(FOR_KW)); let m = p.start(); - p.bump(); - type_params::opt_type_param_list(p); + for_binder(p); match p.current() { FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), _ if paths::is_path_start(p) => path_type_(p, false), -- cgit v1.2.3