Skip to content

Commit

Permalink
Add test of let expr surrounded in None-delimited group
Browse files Browse the repository at this point in the history
Currently fails with:

    ---- test_none_group stdout ----
    thread 'test_none_group' panicked at tests/test_stmt.rs:87:52:
    called `Result::unwrap()` on an `Err` value: Error("expected `;`")
  • Loading branch information
dtolnay committed Dec 11, 2023
1 parent 0ddfc27 commit 5325b6d
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions tests/test_stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
mod macros;

use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
use quote::quote;
use quote::{quote, ToTokens as _};
use syn::parse::Parser as _;
use syn::{Block, Stmt};

Expand Down Expand Up @@ -68,7 +68,6 @@ fn test_none_group() {
TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())),
]),
))]);

snapshot!(tokens as Stmt, @r###"
Stmt::Item(Item::Fn {
vis: Visibility::Inherited,
Expand All @@ -83,6 +82,33 @@ fn test_none_group() {
},
})
"###);

let tokens = Group::new(Delimiter::None, quote!(let None = None)).to_token_stream();
let stmts = Block::parse_within.parse2(tokens).unwrap();
// FIXME
snapshot!(stmts, @r###"
[
Stmt::Expr(
Expr::Group {
expr: Expr::Let {
pat: Pat::Ident {
ident: "None",
},
expr: Expr::Path {
path: Path {
segments: [
PathSegment {
ident: "None",
},
],
},
},
},
},
None,
),
]
"###);
}

#[test]
Expand Down

0 comments on commit 5325b6d

Please sign in to comment.