Skip to content

Commit cbef8f6

Browse files
committed
Add AST pretty-printer tests involving attr on binary operation
This test currently fails (as expected). --- stderr ------------------------------- Pretty-printer lost necessary parentheses BEFORE: #[attr] (1 + 1) AFTER: #[attr] 1 + 1 Pretty-printer lost necessary parentheses BEFORE: #[attr] (1 as T) AFTER: #[attr] 1 as T Pretty-printer lost necessary parentheses BEFORE: #[attr] (x = 1) AFTER: #[attr] x = 1 Pretty-printer lost necessary parentheses BEFORE: #[attr] (x += 1) AFTER: #[attr] x += 1 ------------------------------------------
1 parent 1ed0cbf commit cbef8f6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/ui-fulldeps/pprust-parenthesis-insertion.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ static EXPRS: &[&str] = &[
9292
"#[attr] loop {}.field",
9393
"(#[attr] loop {}).field",
9494
"loop { #![attr] }.field",
95+
// Attributes on a Binary, Cast, Assign, AssignOp, and Range expression
96+
// require parentheses. Without parentheses `#[attr] lo..hi` means
97+
// `(#[attr] lo)..hi`, and `#[attr] ..hi` is invalid syntax.
98+
"#[attr] (1 + 1)",
99+
"#[attr] (1 as T)",
100+
"#[attr] (x = 1)",
101+
"#[attr] (x += 1)",
102+
"#[attr] (lo..hi)",
103+
"#[attr] (..hi)",
95104
// Grammar restriction: break value starting with a labeled loop is not
96105
// allowed, except if the break is also labeled.
97106
"break 'outer 'inner: loop {} + 2",

0 commit comments

Comments
 (0)