test formatting

This commit is contained in:
Aleksey Kladov 2021-10-10 11:22:12 +03:00
parent 2510eaa9b2
commit b0a104cbd1
3 changed files with 11 additions and 9 deletions

View file

@ -20,7 +20,7 @@ use stdx::format_to;
use syntax::{
ast::{self, edit::IndentLevel},
AstNode,
SyntaxKind::{self, IDENT, LIFETIME_IDENT},
SyntaxKind::{EOF, IDENT, LIFETIME_IDENT},
SyntaxNode, T,
};
@ -109,7 +109,7 @@ fn reindent(indent: IndentLevel, pp: String) -> String {
fn pretty_print_macro_expansion(expn: SyntaxNode) -> String {
let mut res = String::new();
let mut prev_kind = SyntaxKind::EOF;
let mut prev_kind = EOF;
let mut indent_level = 0;
for token in iter::successors(expn.first_token(), |t| t.next_token()) {
let curr_kind = token.kind();
@ -129,6 +129,8 @@ fn pretty_print_macro_expansion(expn: SyntaxNode) -> String {
(T![->], _) | (_, T![->]) => " ",
(T![&&], _) | (_, T![&&]) => " ",
(T![,], _) => " ",
(T![fn], T!['(']) => "",
_ if prev_kind.is_keyword() => " ",
_ => "",
};

View file

@ -816,7 +816,7 @@ macro_rules! m {
fn bar() -> & 'a Baz<u8> {}
fn bar() -> extern"Rust"fn() -> Ret {}
fn bar() -> extern "Rust"fn() -> Ret {}
"#]],
);
}
@ -835,7 +835,7 @@ macro_rules! m {
($p:pat) => { fn foo() { let $p; } }
}
fn foo() {
let(a, b);
let (a, b);
}
"#]],
);

View file

@ -53,11 +53,11 @@ macro_rules! m {
}
}
fn f() {
let_ = 'c';
let_ = 1000;
let_ = 12E+99_f64;
let_ = "rust1";
let_ = -92;
let _ = 'c';
let _ = 1000;
let _ = 12E+99_f64;
let _ = "rust1";
let _ = -92;
}
"#]],
);