Parse labeled blocks as ExprVerbatim

This commit is contained in:
David Tolnay 2018-08-01 00:08:48 -07:00
parent 8c81f628f3
commit 5d08ae619b
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 19 additions and 4 deletions

View File

@ -1614,6 +1614,8 @@ pub mod parsing {
|
cond_reduce!(allow_block, syn!(ExprBlock)) => { Expr::Block }
|
call!(unstable_labeled_block) => { Expr::Verbatim }
|
// NOTE: This is the prefix-form of range
call!(expr_range, allow_struct)
|
@ -1655,6 +1657,8 @@ pub mod parsing {
syn!(ExprUnsafe) => { Expr::Unsafe }
|
syn!(ExprBlock) => { Expr::Block }
|
call!(unstable_labeled_block) => { Expr::Verbatim }
) >>
// If the next token is a `.` or a `?` it is special-cased to parse
// as an expression instead of a blockexpression.
@ -2450,6 +2454,21 @@ pub mod parsing {
}
}
#[cfg(feature = "full")]
named!(unstable_labeled_block -> ExprVerbatim, do_parse!(
begin: call!(verbatim::grab_cursor) >>
many0!(Attribute::parse_outer) >>
option!(syn!(Label)) >>
braces!(tuple!(
many0!(Attribute::parse_inner),
call!(Block::parse_within),
)) >>
end: call!(verbatim::grab_cursor) >>
(ExprVerbatim {
tts: verbatim::token_range(begin..end),
})
));
#[cfg(feature = "full")]
named!(expr_range(allow_struct: bool) -> Expr, do_parse!(
limits: syn!(RangeLimits) >>

View File

@ -78,10 +78,6 @@ pub fn base_dir_filter(entry: &DirEntry) -> bool {
// https://github.com/dtolnay/syn/issues/390
"tests/rust/src/test/run-pass-fulldeps/proc-macro/macros-in-extern.rs" |
"tests/rust/src/test/run-pass/macros-in-extern.rs" |
// TODO feature(label_break_value)
//
// https://github.com/dtolnay/syn/issues/455
"tests/rust/src/test/run-pass/label_break_value.rs" |
// Deprecated placement syntax
"tests/rust/src/test/run-pass/new-box-syntax.rs" |
"tests/rust/src/test/ui/obsolete-in-place/bad.rs" |