mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
minor: simplify
This commit is contained in:
parent
0005678649
commit
09531b703d
2 changed files with 7 additions and 20 deletions
|
@ -32,9 +32,6 @@ fn generic_arg(p: &mut Parser) {
|
|||
// 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();
|
||||
name_ref(p);
|
||||
opt_generic_arg_list(p, false);
|
||||
match p.current() {
|
||||
|
@ -42,27 +39,17 @@ fn generic_arg(p: &mut Parser) {
|
|||
T![=] => {
|
||||
p.bump_any();
|
||||
types::type_(p);
|
||||
|
||||
path_seg.abandon(p);
|
||||
path.abandon(p);
|
||||
path_ty.abandon(p);
|
||||
m.complete(p, ASSOC_TYPE_ARG);
|
||||
}
|
||||
// NameRef<...>:
|
||||
T![:] if !p.at(T![::]) => {
|
||||
generic_params::bounds(p);
|
||||
|
||||
path_seg.abandon(p);
|
||||
path.abandon(p);
|
||||
path_ty.abandon(p);
|
||||
m.complete(p, ASSOC_TYPE_ARG);
|
||||
}
|
||||
_ => {
|
||||
path_seg.complete(p, PATH_SEGMENT);
|
||||
let qual = path.complete(p, PATH);
|
||||
paths::type_path_for_qualifier(p, qual);
|
||||
path_ty.complete(p, PATH_TYPE);
|
||||
m.complete(p, TYPE_ARG);
|
||||
let m = m.complete(p, PATH_SEGMENT).precede(p).complete(p, PATH);
|
||||
let m = paths::type_path_for_qualifier(p, m);
|
||||
m.precede(p).complete(p, PATH_TYPE).precede(p).complete(p, TYPE_ARG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ pub(super) fn expr_path(p: &mut Parser) {
|
|||
path(p, Mode::Expr)
|
||||
}
|
||||
|
||||
pub(crate) fn type_path_for_qualifier(p: &mut Parser, qual: CompletedMarker) {
|
||||
pub(crate) fn type_path_for_qualifier(p: &mut Parser, qual: CompletedMarker) -> CompletedMarker {
|
||||
path_for_qualifier(p, Mode::Type, qual)
|
||||
}
|
||||
|
||||
|
@ -42,10 +42,10 @@ fn path(p: &mut Parser, mode: Mode) {
|
|||
let path = p.start();
|
||||
path_segment(p, mode, true);
|
||||
let qual = path.complete(p, PATH);
|
||||
path_for_qualifier(p, mode, qual)
|
||||
path_for_qualifier(p, mode, qual);
|
||||
}
|
||||
|
||||
fn path_for_qualifier(p: &mut Parser, mode: Mode, mut qual: CompletedMarker) {
|
||||
fn path_for_qualifier(p: &mut Parser, mode: Mode, mut qual: CompletedMarker) -> CompletedMarker {
|
||||
loop {
|
||||
let use_tree = matches!(p.nth(2), T![*] | T!['{']);
|
||||
if p.at(T![::]) && !use_tree {
|
||||
|
@ -55,7 +55,7 @@ fn path_for_qualifier(p: &mut Parser, mode: Mode, mut qual: CompletedMarker) {
|
|||
let path = path.complete(p, PATH);
|
||||
qual = path;
|
||||
} else {
|
||||
break;
|
||||
return qual;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue