Parse leading vert in nested patterns

This commit is contained in:
David Tolnay 2021-03-26 01:48:40 -04:00
parent ab13815dfe
commit a82f5fafcd
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
3 changed files with 8 additions and 12 deletions

View File

@ -523,7 +523,7 @@ pub mod parsing {
attrs,
member,
colon_token: input.parse()?,
pat: Box::new(multi_pat(input)?),
pat: Box::new(multi_pat_with_leading_vert(input)?),
});
}
@ -602,7 +602,7 @@ pub mod parsing {
let mut elems = Punctuated::new();
while !content.is_empty() {
let value = multi_pat(&content)?;
let value = multi_pat_with_leading_vert(&content)?;
elems.push_value(value);
if content.is_empty() {
break;
@ -701,7 +701,7 @@ pub mod parsing {
let mut elems = Punctuated::new();
while !content.is_empty() {
let value = multi_pat(&content)?;
let value = multi_pat_with_leading_vert(&content)?;
elems.push_value(value);
if content.is_empty() {
break;

View File

@ -27,10 +27,6 @@ static EXCLUDE: &[&str] = &[
"src/test/ui/const-generics/defaults/pretty-printing-ast.rs",
"src/test/ui/const-generics/min_const_generics/type_and_const_defaults.rs",
// TODO: leading vert in or-pattern
// https://github.com/dtolnay/syn/issues/982
"src/test/ui/or-patterns/or-patterns-syntactic-pass.rs",
// TODO: static with omitted type
// https://github.com/dtolnay/syn/issues/983
// TODO: placeholder type in type parameter position

View File

@ -31,14 +31,14 @@ fn test_leading_vert() {
syn::parse_str::<Item>("fn fun2(|| A: E) {}").unwrap_err();
syn::parse_str::<Stmt>("let | () = ();").unwrap();
syn::parse_str::<Stmt>("let (| A): E;").unwrap_err();
syn::parse_str::<Stmt>("let (| A): E;").unwrap();
syn::parse_str::<Stmt>("let (|| A): (E);").unwrap_err();
syn::parse_str::<Stmt>("let (| A,): (E,);").unwrap_err();
syn::parse_str::<Stmt>("let [| A]: [E; 1];").unwrap_err();
syn::parse_str::<Stmt>("let (| A,): (E,);").unwrap();
syn::parse_str::<Stmt>("let [| A]: [E; 1];").unwrap();
syn::parse_str::<Stmt>("let [|| A]: [E; 1];").unwrap_err();
syn::parse_str::<Stmt>("let TS(| A): TS;").unwrap_err();
syn::parse_str::<Stmt>("let TS(| A): TS;").unwrap();
syn::parse_str::<Stmt>("let TS(|| A): TS;").unwrap_err();
syn::parse_str::<Stmt>("let NS { f: | A }: NS;").unwrap_err();
syn::parse_str::<Stmt>("let NS { f: | A }: NS;").unwrap();
syn::parse_str::<Stmt>("let NS { f: || A }: NS;").unwrap_err();
}