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 .. pattern in pattern of let #1140

Merged
merged 2 commits into from Mar 14, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pat.rs
Expand Up @@ -654,7 +654,7 @@ pub mod parsing {
fn pat_lit_expr(input: ParseStream) -> Result<Option<Box<Expr>>> {
if input.is_empty()
|| input.peek(Token![|])
|| input.peek(Token![=>])
|| input.peek(Token![=])
|| input.peek(Token![:]) && !input.peek(Token![::])
|| input.peek(Token![,])
|| input.peek(Token![;])
Expand Down
17 changes: 17 additions & 0 deletions tests/test_stmt.rs
Expand Up @@ -4,6 +4,7 @@
mod macros;

use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
use quote::quote;
use std::iter::FromIterator;
use syn::Stmt;

Expand Down Expand Up @@ -74,3 +75,19 @@ fn test_none_group() {
})
"###);
}

#[test]
fn test_let_dot_dot() {
let tokens = quote! {
let .. = 10;
};

snapshot!(tokens as Stmt, @r###"
Local(Local {
pat: Pat::Rest,
init: Some(Expr::Lit {
lit: 10,
}),
})
"###);
}