51: G: for type r=matklad a=matklad

bors r+
This commit is contained in:
bors[bot] 2018-02-11 20:38:47 +00:00
commit 97c0258bc0
5 changed files with 45 additions and 0 deletions

View file

@ -111,6 +111,7 @@ Grammar(
"REFERENCE_TYPE",
"PLACEHOLDER_TYPE",
"FN_POINTER_TYPE",
"FOR_TYPE",
"EXTERN_BLOCK",
"ENUM_VARIANT",

View file

@ -9,6 +9,7 @@ pub(super) fn type_(p: &mut Parser) {
AMPERSAND => reference_type(p),
UNDERSCORE => placeholder_type(p),
FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p),
FOR_KW => for_type(p),
IDENT => path_type(p),
_ => {
p.error("expected type");
@ -166,6 +167,17 @@ fn fn_pointer_type(p: &mut Parser) {
m.complete(p, FN_POINTER_TYPE);
}
// test for_type
// type A = for<'a> fn() -> ();
fn for_type(p: &mut Parser) {
assert!(p.at(FOR_KW));
let m = p.start();
p.bump();
type_params::list(p);
type_(p);
m.complete(p, FOR_TYPE);
}
fn path_type(p: &mut Parser) {
assert!(p.at(IDENT));
let m = p.start();

View file

@ -109,6 +109,7 @@ pub enum SyntaxKind {
REFERENCE_TYPE,
PLACEHOLDER_TYPE,
FN_POINTER_TYPE,
FOR_TYPE,
EXTERN_BLOCK,
ENUM_VARIANT,
NAMED_FIELD,
@ -244,6 +245,7 @@ impl SyntaxKind {
REFERENCE_TYPE => &SyntaxInfo { name: "REFERENCE_TYPE" },
PLACEHOLDER_TYPE => &SyntaxInfo { name: "PLACEHOLDER_TYPE" },
FN_POINTER_TYPE => &SyntaxInfo { name: "FN_POINTER_TYPE" },
FOR_TYPE => &SyntaxInfo { name: "FOR_TYPE" },
EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" },
ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" },
NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" },

View file

@ -0,0 +1 @@
type A = for<'a> fn() -> ();

View file

@ -0,0 +1,29 @@
FILE@[0; 29)
TYPE_ITEM@[0; 29)
TYPE_KW@[0; 4)
NAME@[4; 7)
WHITESPACE@[4; 5)
IDENT@[5; 6) "A"
WHITESPACE@[6; 7)
EQ@[7; 8)
FOR_TYPE@[8; 27)
WHITESPACE@[8; 9)
FOR_KW@[9; 12)
TYPE_PARAM_LIST@[12; 17)
L_ANGLE@[12; 13)
LIFETIME_PARAM@[13; 15)
LIFETIME@[13; 15) "'a"
R_ANGLE@[15; 16)
WHITESPACE@[16; 17)
FN_POINTER_TYPE@[17; 27)
FN_KW@[17; 19)
L_PAREN@[19; 20)
R_PAREN@[20; 21)
WHITESPACE@[21; 22)
THIN_ARROW@[22; 24)
TUPLE_TYPE@[24; 27)
WHITESPACE@[24; 25)
L_PAREN@[25; 26)
R_PAREN@[26; 27)
SEMI@[27; 28)
WHITESPACE@[28; 29)