From b04d4a88d1ba7f04445e807b6a816930b1e9bbf2 Mon Sep 17 00:00:00 2001 From: roblabla Date: Sun, 22 Dec 2019 00:38:23 +0000 Subject: Parse const generics Fixes #1574 Fixes #2281 --- crates/ra_parser/src/grammar/type_params.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'crates/ra_parser/src/grammar/type_params.rs') diff --git a/crates/ra_parser/src/grammar/type_params.rs b/crates/ra_parser/src/grammar/type_params.rs index 34406b5bd..50e4900c3 100644 --- a/crates/ra_parser/src/grammar/type_params.rs +++ b/crates/ra_parser/src/grammar/type_params.rs @@ -25,6 +25,7 @@ fn type_param_list(p: &mut Parser) { match p.current() { LIFETIME => lifetime_param(p, m), IDENT => type_param(p, m), + CONST_KW => type_const_param(p, m), _ => { m.abandon(p); p.err_and_bump("expected type parameter") @@ -62,6 +63,16 @@ fn type_param(p: &mut Parser, m: Marker) { m.complete(p, TYPE_PARAM); } +// test const_param +// struct S; +fn type_const_param(p: &mut Parser, m: Marker) { + assert!(p.at(CONST_KW)); + p.bump(T![const]); + name(p); + types::ascription(p); + m.complete(p, CONST_PARAM); +} + // test type_param_bounds // struct S; pub(super) fn bounds(p: &mut Parser) { -- cgit v1.2.3