mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
update parser to support associated const equality
This commit is contained in:
parent
bdecd9374e
commit
6580d75308
@ -40,11 +40,19 @@ fn generic_arg(p: &mut Parser) {
|
||||
name_ref(p);
|
||||
opt_generic_arg_list(p, false);
|
||||
match p.current() {
|
||||
// test assoc_type_eq
|
||||
// type T = StreamingIterator<Item<'a> = &'a T>;
|
||||
T![=] => {
|
||||
p.bump_any();
|
||||
types::type_(p);
|
||||
if types::TYPE_FIRST.contains(p.current()) {
|
||||
// test assoc_type_eq
|
||||
// type T = StreamingIterator<Item<'a> = &'a T>;
|
||||
types::type_(p);
|
||||
} else {
|
||||
// test assoc_const_eq
|
||||
// fn foo<F: Foo<N=3>>() {}
|
||||
// const TEST: usize = 3;
|
||||
// fn bar<F: Foo<N={TEST}>>() {}
|
||||
const_arg(p);
|
||||
}
|
||||
m.complete(p, ASSOC_TYPE_ARG);
|
||||
}
|
||||
// test assoc_type_bound
|
||||
|
@ -0,0 +1,105 @@
|
||||
SOURCE_FILE
|
||||
FN
|
||||
FN_KW "fn"
|
||||
WHITESPACE " "
|
||||
NAME
|
||||
IDENT "foo"
|
||||
GENERIC_PARAM_LIST
|
||||
L_ANGLE "<"
|
||||
TYPE_PARAM
|
||||
NAME
|
||||
IDENT "F"
|
||||
COLON ":"
|
||||
WHITESPACE " "
|
||||
TYPE_BOUND_LIST
|
||||
TYPE_BOUND
|
||||
PATH_TYPE
|
||||
PATH
|
||||
PATH_SEGMENT
|
||||
NAME_REF
|
||||
IDENT "Foo"
|
||||
GENERIC_ARG_LIST
|
||||
L_ANGLE "<"
|
||||
ASSOC_TYPE_ARG
|
||||
NAME_REF
|
||||
IDENT "N"
|
||||
EQ "="
|
||||
CONST_ARG
|
||||
LITERAL
|
||||
INT_NUMBER "3"
|
||||
R_ANGLE ">"
|
||||
R_ANGLE ">"
|
||||
PARAM_LIST
|
||||
L_PAREN "("
|
||||
R_PAREN ")"
|
||||
WHITESPACE " "
|
||||
BLOCK_EXPR
|
||||
STMT_LIST
|
||||
L_CURLY "{"
|
||||
R_CURLY "}"
|
||||
WHITESPACE "\n"
|
||||
CONST
|
||||
CONST_KW "const"
|
||||
WHITESPACE " "
|
||||
NAME
|
||||
IDENT "TEST"
|
||||
COLON ":"
|
||||
WHITESPACE " "
|
||||
PATH_TYPE
|
||||
PATH
|
||||
PATH_SEGMENT
|
||||
NAME_REF
|
||||
IDENT "usize"
|
||||
WHITESPACE " "
|
||||
EQ "="
|
||||
WHITESPACE " "
|
||||
LITERAL
|
||||
INT_NUMBER "3"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n"
|
||||
FN
|
||||
FN_KW "fn"
|
||||
WHITESPACE " "
|
||||
NAME
|
||||
IDENT "bar"
|
||||
GENERIC_PARAM_LIST
|
||||
L_ANGLE "<"
|
||||
TYPE_PARAM
|
||||
NAME
|
||||
IDENT "F"
|
||||
COLON ":"
|
||||
WHITESPACE " "
|
||||
TYPE_BOUND_LIST
|
||||
TYPE_BOUND
|
||||
PATH_TYPE
|
||||
PATH
|
||||
PATH_SEGMENT
|
||||
NAME_REF
|
||||
IDENT "Foo"
|
||||
GENERIC_ARG_LIST
|
||||
L_ANGLE "<"
|
||||
ASSOC_TYPE_ARG
|
||||
NAME_REF
|
||||
IDENT "N"
|
||||
EQ "="
|
||||
CONST_ARG
|
||||
BLOCK_EXPR
|
||||
STMT_LIST
|
||||
L_CURLY "{"
|
||||
PATH_EXPR
|
||||
PATH
|
||||
PATH_SEGMENT
|
||||
NAME_REF
|
||||
IDENT "TEST"
|
||||
R_CURLY "}"
|
||||
R_ANGLE ">"
|
||||
R_ANGLE ">"
|
||||
PARAM_LIST
|
||||
L_PAREN "("
|
||||
R_PAREN ")"
|
||||
WHITESPACE " "
|
||||
BLOCK_EXPR
|
||||
STMT_LIST
|
||||
L_CURLY "{"
|
||||
R_CURLY "}"
|
||||
WHITESPACE "\n"
|
@ -0,0 +1,3 @@
|
||||
fn foo<F: Foo<N=3>>() {}
|
||||
const TEST: usize = 3;
|
||||
fn bar<F: Foo<N={TEST}>>() {}
|
Loading…
Reference in New Issue
Block a user