From b0a104cbd1482d0d108217075fae85e0349b54af Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 10 Oct 2021 11:22:12 +0300 Subject: [PATCH] test formatting --- crates/hir_def/src/macro_expansion_tests.rs | 6 ++++-- crates/hir_def/src/macro_expansion_tests/mbe.rs | 4 ++-- .../src/macro_expansion_tests/mbe/tt_conversion.rs | 10 +++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/crates/hir_def/src/macro_expansion_tests.rs b/crates/hir_def/src/macro_expansion_tests.rs index 3cc3d34cb0..c3fb6fc647 100644 --- a/crates/hir_def/src/macro_expansion_tests.rs +++ b/crates/hir_def/src/macro_expansion_tests.rs @@ -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() => " ", _ => "", }; diff --git a/crates/hir_def/src/macro_expansion_tests/mbe.rs b/crates/hir_def/src/macro_expansion_tests/mbe.rs index d7ff87844c..9954544e91 100644 --- a/crates/hir_def/src/macro_expansion_tests/mbe.rs +++ b/crates/hir_def/src/macro_expansion_tests/mbe.rs @@ -816,7 +816,7 @@ macro_rules! m { fn bar() -> & 'a Baz {} -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); } "#]], ); diff --git a/crates/hir_def/src/macro_expansion_tests/mbe/tt_conversion.rs b/crates/hir_def/src/macro_expansion_tests/mbe/tt_conversion.rs index 3450cda3fd..291f99330f 100644 --- a/crates/hir_def/src/macro_expansion_tests/mbe/tt_conversion.rs +++ b/crates/hir_def/src/macro_expansion_tests/mbe/tt_conversion.rs @@ -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; } "#]], );