From b7aaa083d6dec5c780beb1327f711448ad4081be Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 13 Mar 2022 23:10:59 -0700 Subject: [PATCH 1/2] Add test of let dot dot Currently fails: ---- test_let_dot_dot stdout ---- thread 'test_let_dot_dot' panicked at 'called `Result::unwrap()` on an `Err` value: Error("expected one of: literal, identifier, `::`, `<`, `self`, `Self`, `super`, `crate`, `const`")', tests/test_stmt.rs:85:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace --- tests/test_stmt.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_stmt.rs b/tests/test_stmt.rs index dbe1c76589..0bca62b048 100644 --- a/tests/test_stmt.rs +++ b/tests/test_stmt.rs @@ -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; @@ -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, + }), + }) + "###); +} From c708999ca934ab319caec652e517d23d43dc0ce0 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 13 Mar 2022 23:07:40 -0700 Subject: [PATCH 2/2] Parse `..` pattern in pattern of let --- src/pat.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pat.rs b/src/pat.rs index bfabfe667a..cce95a6b9e 100644 --- a/src/pat.rs +++ b/src/pat.rs @@ -654,7 +654,7 @@ pub mod parsing { fn pat_lit_expr(input: ParseStream) -> Result>> { 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![;])