aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/grammar
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-23 23:19:38 +0100
committerAleksey Kladov <[email protected]>2018-08-23 23:19:38 +0100
commitdc40f1298a8d4dcb7a26d5af38c4fb7ef3d6c5df (patch)
tree618354b471933003577ff2a5616c27bd272f62f3 /crates/libsyntax2/src/grammar
parentcf7d4a2a243cac1975b9b28d47ed91a6bd01b34f (diff)
better self-types
Diffstat (limited to 'crates/libsyntax2/src/grammar')
-rw-r--r--crates/libsyntax2/src/grammar/items/mod.rs2
-rw-r--r--crates/libsyntax2/src/grammar/items/use_item.rs2
-rw-r--r--crates/libsyntax2/src/grammar/mod.rs8
-rw-r--r--crates/libsyntax2/src/grammar/params.rs8
4 files changed, 11 insertions, 9 deletions
diff --git a/crates/libsyntax2/src/grammar/items/mod.rs b/crates/libsyntax2/src/grammar/items/mod.rs
index c74266133..d460612b4 100644
--- a/crates/libsyntax2/src/grammar/items/mod.rs
+++ b/crates/libsyntax2/src/grammar/items/mod.rs
@@ -208,7 +208,7 @@ fn extern_crate_item(p: &mut Parser) {
208 assert!(p.at(CRATE_KW)); 208 assert!(p.at(CRATE_KW));
209 p.bump(); 209 p.bump();
210 name(p); 210 name(p);
211 alias(p); 211 opt_alias(p);
212 p.expect(SEMI); 212 p.expect(SEMI);
213} 213}
214 214
diff --git a/crates/libsyntax2/src/grammar/items/use_item.rs b/crates/libsyntax2/src/grammar/items/use_item.rs
index a3f7f0da8..3da40a629 100644
--- a/crates/libsyntax2/src/grammar/items/use_item.rs
+++ b/crates/libsyntax2/src/grammar/items/use_item.rs
@@ -26,7 +26,7 @@ fn use_tree(p: &mut Parser) {
26 paths::use_path(p); 26 paths::use_path(p);
27 match p.current() { 27 match p.current() {
28 AS_KW => { 28 AS_KW => {
29 alias(p); 29 opt_alias(p);
30 } 30 }
31 COLONCOLON => { 31 COLONCOLON => {
32 p.bump(); 32 p.bump();
diff --git a/crates/libsyntax2/src/grammar/mod.rs b/crates/libsyntax2/src/grammar/mod.rs
index bbdc4f807..d09a9dc9c 100644
--- a/crates/libsyntax2/src/grammar/mod.rs
+++ b/crates/libsyntax2/src/grammar/mod.rs
@@ -92,14 +92,14 @@ fn opt_visibility(p: &mut Parser) {
92 _ => (), 92 _ => (),
93 } 93 }
94} 94}
95fn alias(p: &mut Parser) -> bool { 95
96fn opt_alias(p: &mut Parser) {
96 if p.at(AS_KW) { 97 if p.at(AS_KW) {
97 let alias = p.start(); 98 let m = p.start();
98 p.bump(); 99 p.bump();
99 name(p); 100 name(p);
100 alias.complete(p, ALIAS); 101 m.complete(p, ALIAS);
101 } 102 }
102 true //FIXME: return false if three are errors
103} 103}
104 104
105fn abi(p: &mut Parser) { 105fn abi(p: &mut Parser) {
diff --git a/crates/libsyntax2/src/grammar/params.rs b/crates/libsyntax2/src/grammar/params.rs
index 7e58e8713..47567ec8a 100644
--- a/crates/libsyntax2/src/grammar/params.rs
+++ b/crates/libsyntax2/src/grammar/params.rs
@@ -92,16 +92,18 @@ fn value_parameter(p: &mut Parser, flavor: Flavor) {
92// fn b(&self,) {} 92// fn b(&self,) {}
93// fn c(&'a self,) {} 93// fn c(&'a self,) {}
94// fn d(&'a mut self, x: i32) {} 94// fn d(&'a mut self, x: i32) {}
95// fn e(mut self) {}
95// } 96// }
96fn self_param(p: &mut Parser) { 97fn self_param(p: &mut Parser) {
97 let m; 98 let m;
98 if p.at(SELF_KW) { 99 if p.at(SELF_KW) || p.at(MUT_KW) && p.nth(1) == SELF_KW {
99 m = p.start(); 100 m = p.start();
100 p.bump(); 101 p.eat(MUT_KW);
102 p.eat(SELF_KW);
101 // test arb_self_types 103 // test arb_self_types
102 // impl S { 104 // impl S {
103 // fn a(self: &Self) {} 105 // fn a(self: &Self) {}
104 // fn b(self: Box<Self>) {} 106 // fn b(mut self: Box<Self>) {}
105 // } 107 // }
106 if p.at(COLON) { 108 if p.at(COLON) {
107 types::ascription(p); 109 types::ascription(p);