mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
format
This commit is contained in:
parent
8105c14454
commit
904a832b7c
@ -5,9 +5,9 @@ extern crate libsyntax2;
|
||||
extern crate tools;
|
||||
|
||||
use clap::{App, Arg, SubCommand};
|
||||
use std::time::Instant;
|
||||
use std::{fs, io::Read, path::Path};
|
||||
use tools::collect_tests;
|
||||
use std::time::Instant;
|
||||
|
||||
type Result<T> = ::std::result::Result<T, failure::Error>;
|
||||
|
||||
|
@ -34,12 +34,11 @@ pub(super) fn expr(p: &mut Parser) {
|
||||
loop {
|
||||
lhs = match p.current() {
|
||||
L_PAREN => call_expr(p, lhs),
|
||||
DOT if p.nth(1) == IDENT =>
|
||||
if p.nth(2) == L_PAREN {
|
||||
method_call_expr(p, lhs)
|
||||
} else {
|
||||
field_expr(p, lhs)
|
||||
}
|
||||
DOT if p.nth(1) == IDENT => if p.nth(2) == L_PAREN {
|
||||
method_call_expr(p, lhs)
|
||||
} else {
|
||||
field_expr(p, lhs)
|
||||
},
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
@ -193,11 +192,11 @@ fn struct_lit(p: &mut Parser) {
|
||||
expr(p);
|
||||
}
|
||||
m.complete(p, STRUCT_LIT_FIELD);
|
||||
},
|
||||
}
|
||||
DOTDOT => {
|
||||
p.bump();
|
||||
expr(p);
|
||||
},
|
||||
}
|
||||
_ => p.err_and_bump("expected identifier"),
|
||||
}
|
||||
if !p.at(R_CURLY) {
|
||||
|
@ -142,7 +142,9 @@ fn fn_value_parameters(p: &mut Parser) {
|
||||
_ => return,
|
||||
};
|
||||
let m = p.start();
|
||||
for _ in 0..n_toks { p.bump(); }
|
||||
for _ in 0..n_toks {
|
||||
p.bump();
|
||||
}
|
||||
m.complete(p, SELF_PARAM);
|
||||
if !p.at(R_PAREN) {
|
||||
p.expect(COMMA);
|
||||
|
@ -33,16 +33,16 @@ fn type_arg(p: &mut Parser) {
|
||||
LIFETIME => {
|
||||
p.bump();
|
||||
m.complete(p, LIFETIME_ARG);
|
||||
},
|
||||
}
|
||||
IDENT if p.nth(1) == EQ => {
|
||||
name_ref(p);
|
||||
p.bump();
|
||||
types::type_(p);
|
||||
m.complete(p, ASSOC_TYPE_ARG);
|
||||
},
|
||||
}
|
||||
_ => {
|
||||
types::type_(p);
|
||||
m.complete(p, TYPE_ARG);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::{fmt::Write};
|
||||
use std::fmt::Write;
|
||||
use {
|
||||
algo::walk::{walk, WalkEvent},
|
||||
SyntaxNode,
|
||||
algo::walk::{WalkEvent, walk},
|
||||
};
|
||||
|
||||
/// Parse a file and create a string representation of the resulting parse tree.
|
||||
@ -34,13 +34,13 @@ pub fn dump_tree(syntax: &SyntaxNode) -> String {
|
||||
}
|
||||
}
|
||||
level += 1;
|
||||
},
|
||||
}
|
||||
WalkEvent::Exit(_) => level -= 1,
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(level, 0);
|
||||
for err in errors[err_pos..].iter() {
|
||||
for err in errors[err_pos..].iter() {
|
||||
writeln!(buf, "err: `{}`", err.message).unwrap();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user