From ec2043a0820cc0fa0f7341f752342428aec6bde9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 18 Sep 2021 00:14:20 +0300 Subject: [PATCH] minor: parser cleanup --- crates/parser/src/grammar.rs | 5 +++-- crates/parser/src/grammar/items.rs | 36 ++++++++++++++---------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index 23f0cc0153..58e182d68c 100644 --- a/crates/parser/src/grammar.rs +++ b/crates/parser/src/grammar.rs @@ -183,6 +183,7 @@ fn opt_visibility(p: &mut Parser) -> bool { } } m.complete(p, VISIBILITY); + true } // test crate_keyword_vis // crate fn main() { } @@ -197,10 +198,10 @@ fn opt_visibility(p: &mut Parser) -> bool { let m = p.start(); p.bump(T![crate]); m.complete(p, VISIBILITY); + true } - _ => return false, + _ => false, } - true } fn opt_rename(p: &mut Parser) { diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs index e0b740a815..5fdffc4f96 100644 --- a/crates/parser/src/grammar/items.rs +++ b/crates/parser/src/grammar/items.rs @@ -135,27 +135,25 @@ pub(super) fn opt_item(p: &mut Parser, m: Marker) -> Result<(), Marker> { p.bump_remap(T![default]); has_mods = true; } - T![unsafe] => { - // test default_unsafe_item - // default unsafe impl T for Foo { - // default unsafe fn foo() {} - // } - if matches!(p.nth(2), T![impl] | T![fn]) { - p.bump_remap(T![default]); - p.bump(T![unsafe]); - has_mods = true; - } + // test default_unsafe_item + // default unsafe impl T for Foo { + // default unsafe fn foo() {} + // } + T![unsafe] if matches!(p.nth(2), T![impl] | T![fn]) => { + p.bump_remap(T![default]); + p.bump(T![unsafe]); + has_mods = true; } - T![async] => { - // test default_async_fn - // impl T for Foo { - // default async fn foo() {} - // } + // test default_async_fn + // impl T for Foo { + // default async fn foo() {} + // } - // test default_async_unsafe_fn - // impl T for Foo { - // default async unsafe fn foo() {} - // } + // test default_async_unsafe_fn + // impl T for Foo { + // default async unsafe fn foo() {} + // } + T![async] => { let mut maybe_fn = p.nth(2); let is_unsafe = if matches!(maybe_fn, T![unsafe]) { maybe_fn = p.nth(3);