diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index cacfe9eb2f107..958bf1c58cf58 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -248,8 +248,9 @@ impl<'a> State<'a> { }; self.print_expr_maybe_paren(lhs, left_prec); - self.space(); - self.word_space(op.node.to_string()); + self.nbsp(); + self.word(op.node.to_string()); + self.nbsp(); self.print_expr_maybe_paren(rhs, right_prec) } diff --git a/tests/ui/macros/issue-108341.rs b/tests/ui/macros/issue-108341.rs new file mode 100644 index 0000000000000..de576f9fdbf51 --- /dev/null +++ b/tests/ui/macros/issue-108341.rs @@ -0,0 +1,12 @@ +// run-fail +// error-pattern: assertion failed: +// error-pattern: 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 == 1 + +fn main() { + assert!( + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + == 1 + ); +}