Skip to content

Commit f947cf7

Browse files
authored
Merge pull request #2085 from A4-Tacks/break-label-abs-path
Fix parse abs path expr in labeled break
2 parents 9cb6556 + 0cce166 commit f947cf7

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎src/expr.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2833,7 +2833,7 @@ pub(crate) mod parsing {
28332833
let ahead = input.fork();
28342834
let label_begin = ahead.cursor();
28352835
let label = Lifetime::parse_optional_any(&ahead);
2836-
if label.is_some() && ahead.peek(Token![:]) {
2836+
if label.is_some() && ahead.peek(Token![:]) && !ahead.peek(Token![::]) {
28372837
// Not allowed: `break 'label: loop {...}`
28382838
// Parentheses are required. `break ('label: loop {...})`
28392839
let _: Expr = input.parse()?;

‎tests/test_expr.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,9 @@ fn test_ambiguous_label() {
588588
quote! {
589589
break 'outer 'inner: loop { break 'inner 42; };
590590
},
591+
quote! {
592+
break 'outer ::lib::foo();
593+
},
591594
] {
592595
syn::parse2::<Stmt>(stmt).unwrap();
593596
}

0 commit comments

Comments
 (0)