Skip to content
Open
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
1 change: 1 addition & 0 deletions src/gen/clone.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/gen/fold.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion src/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ast_struct! {
#[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct Local {
pub attrs: Vec<Attribute>,
pub super_token: Option<Token![super]>,
pub let_token: Token![let],
pub pat: Pat,
pub init: Option<LocalInit>,
Expand Down Expand Up @@ -217,7 +218,9 @@ pub(crate) mod parsing {
}
}

if input.peek(Token![let]) && !input.peek(token::Group) {
if (input.peek(Token![let]) || input.peek(Token![super]) && input.peek2(Token![let]))
&& !input.peek(token::Group)
{
stmt_local(input, attrs).map(Stmt::Local)
} else if input.peek(Token![pub])
|| input.peek(Token![crate]) && !input.peek2(Token![::])
Expand Down Expand Up @@ -281,6 +284,12 @@ pub(crate) mod parsing {
}

fn stmt_local(input: ParseStream, attrs: Vec<Attribute>) -> Result<Local> {
let super_token: Option<Token![super]> = if input.peek(Token![super]) {
Some(input.parse()?)
} else {
None
};

let let_token: Token![let] = input.parse()?;

let mut pat = Pat::parse_single(input)?;
Expand Down Expand Up @@ -324,6 +333,7 @@ pub(crate) mod parsing {

Ok(Local {
attrs,
super_token,
let_token,
pat,
init,
Expand Down Expand Up @@ -449,6 +459,9 @@ pub(crate) mod printing {
impl ToTokens for Local {
fn to_tokens(&self, tokens: &mut TokenStream) {
expr::printing::outer_attrs_to_tokens(&self.attrs, tokens);
if let Some(super_token) = &self.super_token {
super_token.to_tokens(tokens);
}
self.let_token.to_tokens(tokens);
self.pat.to_tokens(tokens);
if let Some(init) = &self.init {
Expand Down
4 changes: 0 additions & 4 deletions tests/repo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,6 @@ static EXCLUDE_FILES: &[&str] = &[
// https://github.com/dtolnay/syn/issues/1705
"src/tools/rustfmt/tests/target/cfg_attribute_in_where.rs",

// TODO: super let
// https://github.com/dtolnay/syn/issues/1889
"src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/let_stmt.rs",

// TODO: "ergonomic clones": `f(obj.use)`, `thread::spawn(use || f(obj))`, `async use`
// https://github.com/dtolnay/syn/issues/1802
"tests/codegen-llvm/ergonomic-clones/closure.rs",
Expand Down
Loading