diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-02-17 13:27:54 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-02-17 13:27:54 +0000 |
commit | 8c4c5b5b802a204bfeef52e215358ae838900f1f (patch) | |
tree | 8dfe6cab5e91be9d6acaf91aee767b19ec93d3c9 | |
parent | 94681450f82c7cf6b034548aebd0cc0279fd09ad (diff) | |
parent | 1c4e05ec2f177dd82c85b015f611650430b2f020 (diff) |
Merge #53
53: More correct path type r=matklad a=matklad
bors r+
-rw-r--r-- | src/parser/grammar/types.rs | 9 | ||||
-rw-r--r-- | tests/data/parser/inline/0032_path_type.rs | 4 | ||||
-rw-r--r-- | tests/data/parser/inline/0032_path_type.txt | 70 |
3 files changed, 81 insertions, 2 deletions
diff --git a/src/parser/grammar/types.rs b/src/parser/grammar/types.rs index c25517a51..bcdc3ef97 100644 --- a/src/parser/grammar/types.rs +++ b/src/parser/grammar/types.rs | |||
@@ -10,7 +10,7 @@ pub(super) fn type_(p: &mut Parser) { | |||
10 | UNDERSCORE => placeholder_type(p), | 10 | UNDERSCORE => placeholder_type(p), |
11 | FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), | 11 | FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), |
12 | FOR_KW => for_type(p), | 12 | FOR_KW => for_type(p), |
13 | IDENT => path_type(p), | 13 | _ if paths::is_path_start(p) => path_type(p), |
14 | _ => { | 14 | _ => { |
15 | p.error("expected type"); | 15 | p.error("expected type"); |
16 | } | 16 | } |
@@ -178,8 +178,13 @@ fn for_type(p: &mut Parser) { | |||
178 | m.complete(p, FOR_TYPE); | 178 | m.complete(p, FOR_TYPE); |
179 | } | 179 | } |
180 | 180 | ||
181 | // test path_type | ||
182 | // type A = Foo; | ||
183 | // type B = ::Foo; | ||
184 | // type C = self::Foo; | ||
185 | // type D = super::Foo; | ||
181 | fn path_type(p: &mut Parser) { | 186 | fn path_type(p: &mut Parser) { |
182 | assert!(p.at(IDENT)); | 187 | assert!(paths::is_path_start(p)); |
183 | let m = p.start(); | 188 | let m = p.start(); |
184 | paths::type_path(p); | 189 | paths::type_path(p); |
185 | m.complete(p, PATH_TYPE); | 190 | m.complete(p, PATH_TYPE); |
diff --git a/tests/data/parser/inline/0032_path_type.rs b/tests/data/parser/inline/0032_path_type.rs new file mode 100644 index 000000000..bf94f32e1 --- /dev/null +++ b/tests/data/parser/inline/0032_path_type.rs | |||
@@ -0,0 +1,4 @@ | |||
1 | type A = Foo; | ||
2 | type B = ::Foo; | ||
3 | type C = self::Foo; | ||
4 | type D = super::Foo; | ||
diff --git a/tests/data/parser/inline/0032_path_type.txt b/tests/data/parser/inline/0032_path_type.txt new file mode 100644 index 000000000..1441b8c13 --- /dev/null +++ b/tests/data/parser/inline/0032_path_type.txt | |||
@@ -0,0 +1,70 @@ | |||
1 | FILE@[0; 71) | ||
2 | TYPE_ITEM@[0; 14) | ||
3 | TYPE_KW@[0; 4) | ||
4 | NAME@[4; 7) | ||
5 | WHITESPACE@[4; 5) | ||
6 | IDENT@[5; 6) "A" | ||
7 | WHITESPACE@[6; 7) | ||
8 | EQ@[7; 8) | ||
9 | PATH_TYPE@[8; 12) | ||
10 | PATH@[8; 12) | ||
11 | PATH_SEGMENT@[8; 12) | ||
12 | NAME_REF@[8; 12) | ||
13 | WHITESPACE@[8; 9) | ||
14 | IDENT@[9; 12) "Foo" | ||
15 | SEMI@[12; 13) | ||
16 | WHITESPACE@[13; 14) | ||
17 | TYPE_ITEM@[14; 30) | ||
18 | TYPE_KW@[14; 18) | ||
19 | NAME@[18; 21) | ||
20 | WHITESPACE@[18; 19) | ||
21 | IDENT@[19; 20) "B" | ||
22 | WHITESPACE@[20; 21) | ||
23 | EQ@[21; 22) | ||
24 | PATH_TYPE@[22; 28) | ||
25 | PATH@[22; 28) | ||
26 | PATH_SEGMENT@[22; 28) | ||
27 | WHITESPACE@[22; 23) | ||
28 | COLONCOLON@[23; 25) | ||
29 | NAME_REF@[25; 28) | ||
30 | IDENT@[25; 28) "Foo" | ||
31 | SEMI@[28; 29) | ||
32 | WHITESPACE@[29; 30) | ||
33 | TYPE_ITEM@[30; 50) | ||
34 | TYPE_KW@[30; 34) | ||
35 | NAME@[34; 37) | ||
36 | WHITESPACE@[34; 35) | ||
37 | IDENT@[35; 36) "C" | ||
38 | WHITESPACE@[36; 37) | ||
39 | EQ@[37; 38) | ||
40 | PATH_TYPE@[38; 48) | ||
41 | PATH@[38; 48) | ||
42 | PATH@[38; 43) | ||
43 | PATH_SEGMENT@[38; 43) | ||
44 | WHITESPACE@[38; 39) | ||
45 | SELF_KW@[39; 43) | ||
46 | COLONCOLON@[43; 45) | ||
47 | PATH_SEGMENT@[45; 48) | ||
48 | NAME_REF@[45; 48) | ||
49 | IDENT@[45; 48) "Foo" | ||
50 | SEMI@[48; 49) | ||
51 | WHITESPACE@[49; 50) | ||
52 | TYPE_ITEM@[50; 71) | ||
53 | TYPE_KW@[50; 54) | ||
54 | NAME@[54; 57) | ||
55 | WHITESPACE@[54; 55) | ||
56 | IDENT@[55; 56) "D" | ||
57 | WHITESPACE@[56; 57) | ||
58 | EQ@[57; 58) | ||
59 | PATH_TYPE@[58; 69) | ||
60 | PATH@[58; 69) | ||
61 | PATH@[58; 64) | ||
62 | PATH_SEGMENT@[58; 64) | ||
63 | WHITESPACE@[58; 59) | ||
64 | SUPER_KW@[59; 64) | ||
65 | COLONCOLON@[64; 66) | ||
66 | PATH_SEGMENT@[66; 69) | ||
67 | NAME_REF@[66; 69) | ||
68 | IDENT@[66; 69) "Foo" | ||
69 | SEMI@[69; 70) | ||
70 | WHITESPACE@[70; 71) | ||