Skip to content

Commit

Permalink
Auto merge of rust-lang#12444 - XFFXFF:fix_12442, r=Veykril
Browse files Browse the repository at this point in the history
fix: parsing of `?` opt-out trait bounds

fixes rust-lang#12442
  • Loading branch information
bors committed Jun 2, 2022
2 parents 2f0814e + df67bbd commit 88024c7
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
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 {}

0 comments on commit 88024c7

Please sign in to comment.