Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add some parenthesization test cases with operators that are not left…
…-associative
  • Loading branch information
dtolnay committed Dec 21, 2024
commit d748d1d9533bac2a29371b8154acebebaf588ca1
8 changes: 8 additions & 0 deletions tests/ui-fulldeps/pprust-parenthesis-insertion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ static EXPRS: &[&str] = &[
"(2 + 2) * 2",
"2 * (2 + 2)",
"2 + 2 + 2",
// Right-associative operator.
"2 += 2 += 2",
"(2 += 2) += 2",
// Return has lower precedence than a binary operator.
"(return 2) + 2",
"2 + (return 2)", // FIXME: no parenthesis needed.
Expand Down Expand Up @@ -89,6 +92,11 @@ static EXPRS: &[&str] = &[
// allowed, except if the break is also labeled.
"break 'outer 'inner: loop {} + 2",
"break ('inner: loop {} + 2)",
// Grammar restriction: ranges cannot be the endpoint of another range.
"(2..2)..2",
"2..(2..2)",
"(2..2)..",
"..(2..2)",
// Grammar restriction: the value in let-else is not allowed to end in a
// curly brace.
"{ let _ = 1 + 1 else {}; }",
Expand Down