mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-28 04:45:05 +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
|
// test type_arg
|
||||||
// type A = B<'static, i32, 1, { 2 }, Item=u64, true, false>;
|
// type A = B<'static, i32, 1, { 2 }, Item=u64, true, false>;
|
||||||
fn generic_arg(p: &mut Parser) {
|
fn generic_arg(p: &mut Parser) {
|
||||||
let m = p.start();
|
|
||||||
match p.current() {
|
match p.current() {
|
||||||
LIFETIME_IDENT => {
|
LIFETIME_IDENT => {
|
||||||
|
let m = p.start();
|
||||||
lifetime(p);
|
lifetime(p);
|
||||||
m.complete(p, LIFETIME_ARG);
|
m.complete(p, LIFETIME_ARG);
|
||||||
}
|
}
|
||||||
// test associated_type_bounds
|
// test associated_type_bounds
|
||||||
// fn print_all<T: Iterator<Item, Item::Item, Item::<true>, Item: Display, Item<'a> = Item>>(printables: T) {}
|
// 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)) => {
|
IDENT if [T![<], T![=], T![:]].contains(&p.nth(1)) => {
|
||||||
|
let m = p.start();
|
||||||
let path_ty = p.start();
|
let path_ty = p.start();
|
||||||
let path = p.start();
|
let path = p.start();
|
||||||
let path_seg = 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
|
// test const_generic_negated_literal
|
||||||
// fn f() { S::<-1> }
|
// fn f() { S::<-1> }
|
||||||
T![-] => {
|
T!['{'] | T![true] | T![false] | T![-] => const_arg(p),
|
||||||
let lm = p.start();
|
k if k.is_literal() => const_arg(p),
|
||||||
p.bump(T![-]);
|
|
||||||
expressions::literal(p);
|
|
||||||
lm.complete(p, PREFIX_EXPR);
|
|
||||||
m.complete(p, CONST_ARG);
|
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
|
let m = p.start();
|
||||||
types::type_(p);
|
types::type_(p);
|
||||||
m.complete(p, TYPE_ARG);
|
m.complete(p, TYPE_ARG);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +93,6 @@ fn generic_arg(p: &mut Parser) {
|
||||||
|
|
||||||
pub(super) fn const_arg(p: &mut Parser) {
|
pub(super) fn const_arg(p: &mut Parser) {
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
// FIXME: duplicates the code above
|
|
||||||
match p.current() {
|
match p.current() {
|
||||||
T!['{'] => {
|
T!['{'] => {
|
||||||
expressions::block_expr(p);
|
expressions::block_expr(p);
|
||||||
|
|
Loading…
Reference in a new issue