Skip to content

Commit 8009ccc

Browse files
committed
minor: improve readability
1 parent 25adc5e commit 8009ccc

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

crates/parser/src/grammar/generic_args.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ pub(super) fn opt_generic_arg_list(p: &mut Parser, colon_colon_required: bool) {
2727
// type A = B<'static, i32, 1, { 2 }, Item=u64, true, false>;
2828
fn generic_arg(p: &mut Parser) {
2929
match p.current() {
30-
LIFETIME_IDENT => {
31-
let m = p.start();
32-
lifetime(p);
33-
m.complete(p, LIFETIME_ARG);
34-
}
30+
LIFETIME_IDENT => lifetime_arg(p),
3531
// test associated_type_bounds
3632
// fn print_all<T: Iterator<Item, Item::Item, Item::<true>, Item: Display, Item<'a> = Item>>(printables: T) {}
3733
IDENT if [T![<], T![=], T![:]].contains(&p.nth(1)) => {
@@ -83,14 +79,16 @@ fn generic_arg(p: &mut Parser) {
8379
// fn f() { S::<-1> }
8480
T!['{'] | T![true] | T![false] | T![-] => const_arg(p),
8581
k if k.is_literal() => const_arg(p),
86-
_ => {
87-
let m = p.start();
88-
types::type_(p);
89-
m.complete(p, TYPE_ARG);
90-
}
82+
_ => type_arg(p),
9183
}
9284
}
9385

86+
fn lifetime_arg(p: &mut Parser) {
87+
let m = p.start();
88+
lifetime(p);
89+
m.complete(p, LIFETIME_ARG);
90+
}
91+
9492
pub(super) fn const_arg(p: &mut Parser) {
9593
let m = p.start();
9694
match p.current() {
@@ -121,3 +119,9 @@ pub(super) fn const_arg(p: &mut Parser) {
121119
}
122120
}
123121
}
122+
123+
fn type_arg(p: &mut Parser) {
124+
let m = p.start();
125+
types::type_(p);
126+
m.complete(p, TYPE_ARG);
127+
}

0 commit comments

Comments
 (0)