From 367487fe88dca78cffad5138673d5259f7f7ba6b Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 28 May 2020 21:42:22 +0200 Subject: Support raw_ref_op's raw reference operator --- crates/ra_parser/src/grammar/expressions.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'crates/ra_parser') diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index 34f039768..d6e8df32a 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs @@ -325,13 +325,27 @@ fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> let kind = match p.current() { // test ref_expr // fn foo() { + // // reference operator // let _ = &1; // let _ = &mut &f(); + // let _ = &raw; + // let _ = &raw.0; + // // raw reference operator + // let _ = &raw mut foo; + // let _ = &raw const foo; // } T![&] => { m = p.start(); p.bump(T![&]); - p.eat(T![mut]); + if p.at(IDENT) + && p.at_contextual_kw("raw") + && (p.nth_at(1, T![mut]) || p.nth_at(1, T![const])) + { + p.bump_remap(T![raw]); + p.bump_any(); + } else { + p.eat(T![mut]); + } REF_EXPR } // test unary_expr -- cgit v1.2.3