Skip to content

Commit

Permalink
Merge pull request #1110 from dtolnay/attrletelse
Browse files Browse the repository at this point in the history
Preserve attributes on let-else stmt
  • Loading branch information
dtolnay authored Dec 23, 2021
2 parents b5834ab + 8d24d27 commit 47e1bc3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ast_struct! {
pub mod parsing {
use super::*;
use crate::parse::discouraged::Speculative;
use crate::parse::{Parse, ParseStream, Result};
use crate::parse::{Parse, ParseBuffer, ParseStream, Result};
use proc_macro2::TokenStream;

impl Block {
Expand Down Expand Up @@ -152,6 +152,7 @@ pub mod parsing {
}

fn parse_stmt(input: ParseStream, allow_nosemi: bool) -> Result<Stmt> {
let begin = input.fork();
let mut attrs = input.call(Attribute::parse_outer)?;

// brace-style macros; paren and bracket macros get parsed as
Expand All @@ -169,7 +170,7 @@ pub mod parsing {
}

if input.peek(Token![let]) {
stmt_local(input, attrs)
stmt_local(input, attrs, begin)
} else if input.peek(Token![pub])
|| input.peek(Token![crate]) && !input.peek2(Token![::])
|| input.peek(Token![extern])
Expand Down Expand Up @@ -222,9 +223,7 @@ pub mod parsing {
})))
}

fn stmt_local(input: ParseStream, attrs: Vec<Attribute>) -> Result<Stmt> {
let begin = input.fork();

fn stmt_local(input: ParseStream, attrs: Vec<Attribute>, begin: ParseBuffer) -> Result<Stmt> {
let let_token: Token![let] = input.parse()?;

let mut pat: Pat = pat::parsing::multi_pat_with_leading_vert(input)?;
Expand Down
3 changes: 0 additions & 3 deletions tests/repo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ const REVISION: &str = "e100ec5bc7cd768ec17d75448b29c9ab4a39272b";

#[rustfmt::skip]
static EXCLUDE: &[&str] = &[
// TODO: attributes on let-else stmt
"src/test/ui/let-else/let-else-allow-unused.rs",

// TODO: impl ~const T {}
// https://github.com/dtolnay/syn/issues/1051
"src/test/ui/rfc-2632-const-trait-impl/syntax.rs",
Expand Down

0 comments on commit 47e1bc3

Please sign in to comment.