diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-10-12 08:50:42 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-10-12 08:50:42 +1100 |
| commit | 66c2b77a4a3d0b46c1abd2d90007b28e5de1b93d (patch) | |
| tree | 66e3bf80d904a1e32dbe797858951ef6cc766ecd | |
| parent | 33aff5b1523b64052ae580f9bb6c7a7de94f16c5 (diff) | |
Rename `tt_prepend_space` as `space_between`.
And reorder the arguments. I find it easier to think about this way.
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 8b7e91882fc..e71f421659e 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -148,7 +148,7 @@ pub fn print_crate<'a>( /// This makes printed token streams look slightly nicer, /// and also addresses some specific regressions described in #63896 and #73345. -fn tt_prepend_space(tt: &TokenTree, prev: &TokenTree) -> bool { +fn space_between(prev: &TokenTree, curr: &TokenTree) -> bool { if let TokenTree::Token(token, _) = prev { // No space after these tokens, e.g. `x.y`, `$e` // (The carets point to `prev`.) ^ ^ @@ -159,9 +159,9 @@ fn tt_prepend_space(tt: &TokenTree, prev: &TokenTree) -> bool { return comment_kind != CommentKind::Line; } } - match tt { + match curr { // No space before these tokens, e.g. `foo,`, `println!`, `x.y` - // (The carets point to `token`.) ^ ^ ^ + // (The carets point to `curr`.) ^ ^ ^ // // FIXME: having `Not` here works well for macro invocations like // `println!()`, but is bad when `!` means "logical not" or "the never @@ -575,7 +575,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere while let Some(tt) = iter.next() { self.print_tt(tt, convert_dollar_crate); if let Some(next) = iter.peek() { - if tt_prepend_space(next, tt) { + if space_between(tt, next) { self.space(); } } |
