Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse leading vert in nested patterns #987

Merged
merged 1 commit into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?),
});
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions tests/repo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions tests/test_pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down