From 4a91453409aaf58eba0a91e4b62a35f49814b394 Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Tue, 23 Jul 2024 22:32:23 +0100 Subject: [PATCH] fix: move `use` parsing to outer match arm --- crates/parser/src/grammar/generic_params.rs | 12 ++++----- .../parser/inline/ok/precise_capturing.rast | 25 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/crates/parser/src/grammar/generic_params.rs b/crates/parser/src/grammar/generic_params.rs index b653d8e060..cf80a535ac 100644 --- a/crates/parser/src/grammar/generic_params.rs +++ b/crates/parser/src/grammar/generic_params.rs @@ -144,6 +144,12 @@ fn type_bound(p: &mut Parser<'_>) -> bool { match p.current() { LIFETIME_IDENT => lifetime(p), T![for] => types::for_type(p, false), + // test precise_capturing + // fn captures<'a: 'a, 'b: 'b, T>() -> impl Sized + use<'b, T> {} + T![use] => { + p.bump_any(); + generic_param_list(p) + } T![?] if p.nth_at(1, T![for]) => { // test question_for_type_trait_bound // fn f() where T: ?for<> Sized {} @@ -167,12 +173,6 @@ fn type_bound(p: &mut Parser<'_>) -> bool { T![async] => { p.bump_any(); } - // test precise_capturing - // fn captures<'a: 'a, 'b: 'b, T>() -> impl Sized + use<'b, T> {} - T![use] => { - p.bump_any(); - generic_param_list(p); - } _ => (), } if paths::is_use_path_start(p) { diff --git a/crates/parser/test_data/parser/inline/ok/precise_capturing.rast b/crates/parser/test_data/parser/inline/ok/precise_capturing.rast index 5a482384f8..cf52f1e479 100644 --- a/crates/parser/test_data/parser/inline/ok/precise_capturing.rast +++ b/crates/parser/test_data/parser/inline/ok/precise_capturing.rast @@ -48,18 +48,19 @@ SOURCE_FILE WHITESPACE " " PLUS "+" WHITESPACE " " - USE_KW "use" - GENERIC_PARAM_LIST - L_ANGLE "<" - LIFETIME_PARAM - LIFETIME - LIFETIME_IDENT "'b" - COMMA "," - WHITESPACE " " - TYPE_PARAM - NAME - IDENT "T" - R_ANGLE ">" + TYPE_BOUND + USE_KW "use" + GENERIC_PARAM_LIST + L_ANGLE "<" + LIFETIME_PARAM + LIFETIME + LIFETIME_IDENT "'b" + COMMA "," + WHITESPACE " " + TYPE_PARAM + NAME + IDENT "T" + R_ANGLE ">" WHITESPACE " " BLOCK_EXPR STMT_LIST