minor: improve readability

This commit is contained in:
Aleksey Kladov 2021-09-18 15:56:26 +03:00
parent ed84717869
commit c0556bd8c1
3 changed files with 17 additions and 15 deletions

View file

@ -14,21 +14,7 @@ fn generic_param_list(p: &mut Parser) {
p.bump(T![<]);
while !p.at(EOF) && !p.at(T![>]) {
let m = p.start();
// test generic_param_list_param_attribute
// fn foo<#[lt_attr] 'a, #[t_attr] T>() {}
attributes::outer_attrs(p);
match p.current() {
LIFETIME_IDENT => lifetime_param(p, m),
IDENT => type_param(p, m),
T![const] => const_param(p, m),
_ => {
m.abandon(p);
p.err_and_bump("expected type parameter")
}
}
generic_param(p);
if !p.at(T![>]) && !p.expect(T![,]) {
break;
}
@ -37,6 +23,22 @@ fn generic_param_list(p: &mut Parser) {
m.complete(p, GENERIC_PARAM_LIST);
}
fn generic_param(p: &mut Parser) {
let m = p.start();
// test generic_param_attribute
// fn foo<#[lt_attr] 'a, #[t_attr] T>() {}
attributes::outer_attrs(p);
match p.current() {
LIFETIME_IDENT => lifetime_param(p, m),
IDENT => type_param(p, m),
T![const] => const_param(p, m),
_ => {
m.abandon(p);
p.err_and_bump("expected type parameter")
}
}
}
// test lifetime_param
// fn f<'a: 'b>() {}
fn lifetime_param(p: &mut Parser, m: Marker) {