Hide labeled blocks from precedence test

This commit is contained in:
David Tolnay 2018-08-01 00:28:36 -07:00
parent 5d08ae619b
commit 61e15e53b4
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 7 additions and 1 deletions

View File

@ -2458,7 +2458,7 @@ pub mod parsing {
named!(unstable_labeled_block -> ExprVerbatim, do_parse!(
begin: call!(verbatim::grab_cursor) >>
many0!(Attribute::parse_outer) >>
option!(syn!(Label)) >>
syn!(Label) >>
braces!(tuple!(
many0!(Attribute::parse_inner),
call!(Block::parse_within),

View File

@ -220,6 +220,12 @@ fn libsyntax_brackets(libsyntax_expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
impl Folder for BracketsFolder {
fn fold_expr(&mut self, e: P<Expr>) -> P<Expr> {
e.map(|e| match e.node {
ExprKind::Block(_, label) if label.is_some() => Expr {
id: ast::DUMMY_NODE_ID,
node: ExprKind::Paren(P(e)),
span: DUMMY_SP,
attrs: ThinVec::new(),
},
ExprKind::If(..) | ExprKind::Block(..) | ExprKind::IfLet(..) => {
fold::noop_fold_expr(e, self)
}