Skip to content

fix: parsing of ? opt-out trait bounds #12444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/parser/src/grammar/generic_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>() where T: ?for<> Sized {}
p.bump_any();
types::for_type(p, false)
}
current => {
match current {
T![?] => p.bump_any(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn f<T>() where T: ?for<> Sized {}