mirror of
https://gitee.com/openharmony/third_party_rust_syn
synced 2025-02-18 14:40:40 +00:00
Parse labeled blocks as ExprVerbatim
This commit is contained in:
parent
8c81f628f3
commit
5d08ae619b
19
src/expr.rs
19
src/expr.rs
@ -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) >>
|
||||
|
@ -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" |
|
||||
|
Loading…
x
Reference in New Issue
Block a user