mirror of https://github.com/rust-lang/rust.git
Rename `tt_prepend_space` as `space_between`.
And reorder the arguments. I find it easier to think about this way.
This commit is contained in:
parent
33aff5b152
commit
66c2b77a4a
|
@ -148,7 +148,7 @@ pub fn print_crate<'a>(
|
||||||
|
|
||||||
/// This makes printed token streams look slightly nicer,
|
/// This makes printed token streams look slightly nicer,
|
||||||
/// and also addresses some specific regressions described in #63896 and #73345.
|
/// 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 {
|
if let TokenTree::Token(token, _) = prev {
|
||||||
// No space after these tokens, e.g. `x.y`, `$e`
|
// No space after these tokens, e.g. `x.y`, `$e`
|
||||||
// (The carets point to `prev`.) ^ ^
|
// (The carets point to `prev`.) ^ ^
|
||||||
|
@ -159,9 +159,9 @@ fn tt_prepend_space(tt: &TokenTree, prev: &TokenTree) -> bool {
|
||||||
return comment_kind != CommentKind::Line;
|
return comment_kind != CommentKind::Line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match tt {
|
match curr {
|
||||||
// No space before these tokens, e.g. `foo,`, `println!`, `x.y`
|
// 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
|
// FIXME: having `Not` here works well for macro invocations like
|
||||||
// `println!()`, but is bad when `!` means "logical not" or "the never
|
// `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() {
|
while let Some(tt) = iter.next() {
|
||||||
self.print_tt(tt, convert_dollar_crate);
|
self.print_tt(tt, convert_dollar_crate);
|
||||||
if let Some(next) = iter.peek() {
|
if let Some(next) = iter.peek() {
|
||||||
if tt_prepend_space(next, tt) {
|
if space_between(tt, next) {
|
||||||
self.space();
|
self.space();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue