mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
minor: reduce duplication
This commit is contained in:
parent
7729473dd2
commit
25adc5e9f0
1 changed files with 5 additions and 21 deletions
|
@ -26,15 +26,16 @@ pub(super) fn opt_generic_arg_list(p: &mut Parser, colon_colon_required: bool) {
|
|||
// test type_arg
|
||||
// type A = B<'static, i32, 1, { 2 }, Item=u64, true, false>;
|
||||
fn generic_arg(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
match p.current() {
|
||||
LIFETIME_IDENT => {
|
||||
let m = p.start();
|
||||
lifetime(p);
|
||||
m.complete(p, LIFETIME_ARG);
|
||||
}
|
||||
// test associated_type_bounds
|
||||
// fn print_all<T: Iterator<Item, Item::Item, Item::<true>, Item: Display, Item<'a> = Item>>(printables: T) {}
|
||||
IDENT if [T![<], T![=], T![:]].contains(&p.nth(1)) => {
|
||||
let m = p.start();
|
||||
let path_ty = p.start();
|
||||
let path = p.start();
|
||||
let path_seg = p.start();
|
||||
|
@ -78,28 +79,12 @@ fn generic_arg(p: &mut Parser) {
|
|||
}
|
||||
}
|
||||
}
|
||||
T!['{'] => {
|
||||
expressions::block_expr(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
k if k.is_literal() => {
|
||||
expressions::literal(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
T![true] | T![false] => {
|
||||
expressions::literal(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
// test const_generic_negated_literal
|
||||
// fn f() { S::<-1> }
|
||||
T![-] => {
|
||||
let lm = p.start();
|
||||
p.bump(T![-]);
|
||||
expressions::literal(p);
|
||||
lm.complete(p, PREFIX_EXPR);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
T!['{'] | T![true] | T![false] | T![-] => const_arg(p),
|
||||
k if k.is_literal() => const_arg(p),
|
||||
_ => {
|
||||
let m = p.start();
|
||||
types::type_(p);
|
||||
m.complete(p, TYPE_ARG);
|
||||
}
|
||||
|
@ -108,7 +93,6 @@ fn generic_arg(p: &mut Parser) {
|
|||
|
||||
pub(super) fn const_arg(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
// FIXME: duplicates the code above
|
||||
match p.current() {
|
||||
T!['{'] => {
|
||||
expressions::block_expr(p);
|
||||
|
|
Loading…
Reference in a new issue