Skip to content

Commit

Permalink
Add test of parenthesizing break value by AST pretty-printer
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jun 24, 2024
1 parent bcf94de commit 5f37433
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/ui/unpretty/expanded-interpolation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@ macro_rules! stmt {
($stmt:stmt) => { $stmt };
}

fn break_labeled_loop() {
let no_paren = 'outer: loop {
break 'outer expr!('inner: loop { break 'inner 1; } + 1);
};

let paren_around_break_value = 'outer: loop {
break expr!('inner: loop { break 'inner 1; } + 1);
};

macro_rules! breaking {
($value:expr) => {
break $value
};
}

let paren_around_break_value = loop {
breaking!('inner: loop { break 'inner 1; } + 1);
};
}

fn if_let() {
macro_rules! if_let {
($pat:pat, $expr:expr) => {
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/unpretty/expanded-interpolation.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ macro_rules! expr { ($expr:expr) => { $expr }; }

macro_rules! stmt { ($stmt:stmt) => { $stmt }; }

fn break_labeled_loop() {
let no_paren =
'outer: loop { break 'outer 'inner: loop { break 'inner 1; } + 1; };

let paren_around_break_value =
'outer: loop { break 'inner: loop { break 'inner 1; } + 1; };

macro_rules! breaking { ($value:expr) => { break $value }; }

let paren_around_break_value =
loop { break 'inner: loop { break 'inner 1; } + 1; };
}

fn if_let() {
macro_rules! if_let {
($pat:pat, $expr:expr) => { if let $pat = $expr {} };
Expand Down

0 comments on commit 5f37433

Please sign in to comment.