minor: parser cleanup

This commit is contained in:
Aleksey Kladov 2021-09-18 00:14:20 +03:00
parent c72a30af63
commit ec2043a082
2 changed files with 20 additions and 21 deletions

View file

@ -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) {

View file

@ -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);