Skip to content

Commit

Permalink
Merge pull request #1140 from dtolnay/letdotdot
Browse files Browse the repository at this point in the history
Parse `..` pattern in pattern of let
  • Loading branch information
dtolnay authored Mar 14, 2022
2 parents 1a0cf9d + c708999 commit 5d1cd93
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pat.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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,
}),
})
"###);
}

0 comments on commit 5d1cd93

Please sign in to comment.