aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/grammar
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/src/grammar')
-rw-r--r--crates/libsyntax2/src/grammar/params.rs39
1 files changed, 26 insertions, 13 deletions
diff --git a/crates/libsyntax2/src/grammar/params.rs b/crates/libsyntax2/src/grammar/params.rs
index 32e905cb2..7e58e8713 100644
--- a/crates/libsyntax2/src/grammar/params.rs
+++ b/crates/libsyntax2/src/grammar/params.rs
@@ -94,20 +94,33 @@ fn value_parameter(p: &mut Parser, flavor: Flavor) {
94// fn d(&'a mut self, x: i32) {} 94// fn d(&'a mut self, x: i32) {}
95// } 95// }
96fn self_param(p: &mut Parser) { 96fn self_param(p: &mut Parser) {
97 let la1 = p.nth(1); 97 let m;
98 let la2 = p.nth(2); 98 if p.at(SELF_KW) {
99 let la3 = p.nth(3); 99 m = p.start();
100 let n_toks = match (p.current(), la1, la2, la3) {
101 (SELF_KW, _, _, _) => 1,
102 (AMP, SELF_KW, _, _) => 2,
103 (AMP, MUT_KW, SELF_KW, _) => 3,
104 (AMP, LIFETIME, SELF_KW, _) => 3,
105 (AMP, LIFETIME, MUT_KW, SELF_KW) => 4,
106 _ => return,
107 };
108 let m = p.start();
109 for _ in 0..n_toks {
110 p.bump(); 100 p.bump();
101 // test arb_self_types
102 // impl S {
103 // fn a(self: &Self) {}
104 // fn b(self: Box<Self>) {}
105 // }
106 if p.at(COLON) {
107 types::ascription(p);
108 }
109 } else {
110 let la1 = p.nth(1);
111 let la2 = p.nth(2);
112 let la3 = p.nth(3);
113 let n_toks = match (p.current(), la1, la2, la3) {
114 (AMP, SELF_KW, _, _) => 2,
115 (AMP, MUT_KW, SELF_KW, _) => 3,
116 (AMP, LIFETIME, SELF_KW, _) => 3,
117 (AMP, LIFETIME, MUT_KW, SELF_KW) => 4,
118 _ => return,
119 };
120 m = p.start();
121 for _ in 0..n_toks {
122 p.bump();
123 }
111 } 124 }
112 m.complete(p, SELF_PARAM); 125 m.complete(p, SELF_PARAM);
113 if !p.at(R_PAREN) { 126 if !p.at(R_PAREN) {