aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/grammar/paths.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-13 21:54:00 +0100
committerAleksey Kladov <[email protected]>2018-08-13 21:54:00 +0100
commit49ab44102496ac8c4a05b00c584adecf583f4d87 (patch)
tree853718de93f4c713a084fe728ee5035e57be2a40 /crates/libsyntax2/src/grammar/paths.rs
parentd9e86e574ad936f03a64c38dc7b7f39ddcc4eebd (diff)
Qualified paths
Diffstat (limited to 'crates/libsyntax2/src/grammar/paths.rs')
-rw-r--r--crates/libsyntax2/src/grammar/paths.rs44
1 files changed, 28 insertions, 16 deletions
diff --git a/crates/libsyntax2/src/grammar/paths.rs b/crates/libsyntax2/src/grammar/paths.rs
index aa5ecf4b8..97ab1880b 100644
--- a/crates/libsyntax2/src/grammar/paths.rs
+++ b/crates/libsyntax2/src/grammar/paths.rs
@@ -27,9 +27,6 @@ enum Mode {
27} 27}
28 28
29fn path(p: &mut Parser, mode: Mode) { 29fn path(p: &mut Parser, mode: Mode) {
30 if !is_path_start(p) {
31 return;
32 }
33 let path = p.start(); 30 let path = p.start();
34 path_segment(p, mode, true); 31 path_segment(p, mode, true);
35 let mut qual = path.complete(p, PATH); 32 let mut qual = path.complete(p, PATH);
@@ -51,21 +48,36 @@ fn path(p: &mut Parser, mode: Mode) {
51} 48}
52 49
53fn path_segment(p: &mut Parser, mode: Mode, first: bool) { 50fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
54 let segment = p.start(); 51 let m = p.start();
55 if first { 52 // test qual_paths
56 p.eat(COLONCOLON); 53 // type X = <A as B>::Output;
57 } 54 // fn foo() { <usize as Default>::default(); }
58 match p.current() { 55 if first && p.eat(L_ANGLE) {
59 IDENT => { 56 types::type_(p);
60 name_ref(p); 57 if p.eat(AS_KW) {
61 path_generic_args(p, mode); 58 if is_path_start(p) {
59 types::path_type(p);
60 } else {
61 p.error("expected a trait");
62 }
62 } 63 }
63 SELF_KW | SUPER_KW => p.bump(), 64 p.expect(R_ANGLE);
64 _ => { 65 } else {
65 p.err_and_bump("expected identifier"); 66 if first {
67 p.eat(COLONCOLON);
66 } 68 }
67 }; 69 match p.current() {
68 segment.complete(p, PATH_SEGMENT); 70 IDENT => {
71 name_ref(p);
72 path_generic_args(p, mode);
73 }
74 SELF_KW | SUPER_KW => p.bump(),
75 _ => {
76 p.err_and_bump("expected identifier");
77 }
78 };
79 }
80 m.complete(p, PATH_SEGMENT);
69} 81}
70 82
71fn path_generic_args(p: &mut Parser, mode: Mode) { 83fn path_generic_args(p: &mut Parser, mode: Mode) {