Add regression test of pattern inside None group

This commit is contained in:
David Tolnay 2020-10-10 15:48:27 -07:00
parent 4f547c9aad
commit 915ca09e50
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -1,4 +1,9 @@
#[macro_use]
mod macros;
use proc_macro2::{Delimiter, Group, TokenStream, TokenTree};
use quote::quote;
use std::iter::FromIterator;
use syn::{Item, Pat, Stmt};
#[test]
@ -36,3 +41,27 @@ fn test_leading_vert() {
syn::parse_str::<Stmt>("let NS { f: | A }: NS;").unwrap_err();
syn::parse_str::<Stmt>("let NS { f: || A }: NS;").unwrap_err();
}
#[test]
fn test_group() {
let group = Group::new(Delimiter::None, quote!(Some(_)));
let tokens = TokenStream::from_iter(vec![TokenTree::Group(group)]);
snapshot!(tokens as Pat, @r###"
Pat::TupleStruct {
path: Path {
segments: [
PathSegment {
ident: "Some",
arguments: None,
},
],
},
pat: PatTuple {
elems: [
Pat::Wild,
],
},
}
"###);
}