mirror of
https://gitee.com/openharmony/third_party_rust_syn
synced 2024-11-23 16:00:10 +00:00
Merge pull request #842 from dtolnay/group
Parse Expr::Struct containing None-delimited ident name
This commit is contained in:
commit
7a81558977
@ -1691,7 +1691,11 @@ pub(crate) mod parsing {
|
||||
// interactions, as they are fully contained.
|
||||
#[cfg(feature = "full")]
|
||||
fn atom_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
|
||||
if input.peek(token::Group) && !input.peek2(Token![::]) && !input.peek2(Token![!]) {
|
||||
if input.peek(token::Group)
|
||||
&& !input.peek2(Token![::])
|
||||
&& !input.peek2(Token![!])
|
||||
&& !input.peek2(token::Brace)
|
||||
{
|
||||
input.call(expr_group).map(Expr::Group)
|
||||
} else if input.peek(Lit) {
|
||||
input.parse().map(Expr::Lit)
|
||||
|
@ -142,3 +142,25 @@ fn test_macro_variable_macro() {
|
||||
}
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_macro_variable_struct() {
|
||||
// mimics the token stream corresponding to `$struct {}`
|
||||
let tokens = TokenStream::from_iter(vec![
|
||||
TokenTree::Group(Group::new(Delimiter::None, quote! { S })),
|
||||
TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())),
|
||||
]);
|
||||
|
||||
snapshot!(tokens as Expr, @r###"
|
||||
Expr::Struct {
|
||||
path: Path {
|
||||
segments: [
|
||||
PathSegment {
|
||||
ident: "S",
|
||||
arguments: None,
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
"###);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user