diff --git a/crates/parser/src/grammar/generic_params.rs b/crates/parser/src/grammar/generic_params.rs index fbd514078d4f0..78a75fad1cb69 100644 --- a/crates/parser/src/grammar/generic_params.rs +++ b/crates/parser/src/grammar/generic_params.rs @@ -133,6 +133,12 @@ fn type_bound(p: &mut Parser) -> bool { match p.current() { LIFETIME_IDENT => lifetime(p), T![for] => types::for_type(p, false), + T![?] if p.nth_at(1, T![for]) => { + // test question_for_type_trait_bound + // fn f() where T: ?for<> Sized {} + p.bump_any(); + types::for_type(p, false) + } current => { match current { T![?] => p.bump_any(), diff --git a/crates/parser/test_data/parser/inline/ok/0201_question_for_type_trait_bound.rast b/crates/parser/test_data/parser/inline/ok/0201_question_for_type_trait_bound.rast new file mode 100644 index 0000000000000..56e2d1095d29b --- /dev/null +++ b/crates/parser/test_data/parser/inline/ok/0201_question_for_type_trait_bound.rast @@ -0,0 +1,47 @@ +SOURCE_FILE + FN + FN_KW "fn" + WHITESPACE " " + NAME + IDENT "f" + GENERIC_PARAM_LIST + L_ANGLE "<" + TYPE_PARAM + NAME + IDENT "T" + R_ANGLE ">" + PARAM_LIST + L_PAREN "(" + R_PAREN ")" + WHITESPACE " " + WHERE_CLAUSE + WHERE_KW "where" + WHITESPACE " " + WHERE_PRED + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + IDENT "T" + COLON ":" + WHITESPACE " " + TYPE_BOUND_LIST + TYPE_BOUND + QUESTION "?" + FOR_TYPE + FOR_KW "for" + GENERIC_PARAM_LIST + L_ANGLE "<" + R_ANGLE ">" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + IDENT "Sized" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + R_CURLY "}" + WHITESPACE "\n" diff --git a/crates/parser/test_data/parser/inline/ok/0201_question_for_type_trait_bound.rs b/crates/parser/test_data/parser/inline/ok/0201_question_for_type_trait_bound.rs new file mode 100644 index 0000000000000..f80dd90d446c5 --- /dev/null +++ b/crates/parser/test_data/parser/inline/ok/0201_question_for_type_trait_bound.rs @@ -0,0 +1 @@ +fn f() where T: ?for<> Sized {}