From f4c106f86a4fbb91f36aac59a6a98fff9d3c5c40 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 31 Jul 2018 20:48:45 +0300 Subject: Lifetimes in self param --- src/parser/grammar/mod.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/parser') diff --git a/src/parser/grammar/mod.rs b/src/parser/grammar/mod.rs index b8847fb68..53ef28181 100644 --- a/src/parser/grammar/mod.rs +++ b/src/parser/grammar/mod.rs @@ -126,15 +126,19 @@ fn fn_value_parameters(p: &mut Parser) { // impl S { // fn a(self) {} // fn b(&self,) {} - // fn c(&mut self, x: i32) {} + // fn c(&'a self,) {} + // fn d(&'a mut self, x: i32) {} // } fn self_param(p: &mut Parser) { let la1 = p.nth(1); let la2 = p.nth(2); - let n_toks = match (p.current(), la1, la2) { - (SELF_KW, _, _) => 1, - (AMPERSAND, SELF_KW, _) => 2, - (AMPERSAND, MUT_KW, SELF_KW) => 3, + let la3 = p.nth(3); + let n_toks = match (p.current(), la1, la2, la3) { + (SELF_KW, _, _, _) => 1, + (AMPERSAND, SELF_KW, _, _) => 2, + (AMPERSAND, MUT_KW, SELF_KW, _) => 3, + (AMPERSAND, LIFETIME, SELF_KW, _) => 3, + (AMPERSAND, LIFETIME, MUT_KW, SELF_KW) => 4, _ => return, }; let m = p.start(); -- cgit v1.2.3