Skip to content

Commit

Permalink
Merge pull request #1127 from dtolnay/staticasync
Browse files Browse the repository at this point in the history
Fix static async closure keyword order
  • Loading branch information
dtolnay authored Jan 20, 2022
2 parents 6a8bf28 + 5aeec41 commit 2468457
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 38 deletions.
12 changes: 4 additions & 8 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ ast_struct! {
#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ExprClosure #full {
pub attrs: Vec<Attribute>,
pub asyncness: Option<Token![async]>,
pub movability: Option<Token![static]>,
pub asyncness: Option<Token![async]>,
pub capture: Option<Token![move]>,
pub or1_token: Token![|],
pub inputs: Punctuated<Pat, Token![,]>,
Expand Down Expand Up @@ -2397,12 +2397,8 @@ pub(crate) mod parsing {

#[cfg(feature = "full")]
fn expr_closure(input: ParseStream, allow_struct: AllowStruct) -> Result<ExprClosure> {
let movability: Option<Token![static]> = input.parse()?;
let asyncness: Option<Token![async]> = input.parse()?;
let movability: Option<Token![static]> = if asyncness.is_none() {
input.parse()?
} else {
None
};
let capture: Option<Token![move]> = input.parse()?;
let or1_token: Token![|] = input.parse()?;

Expand Down Expand Up @@ -2440,8 +2436,8 @@ pub(crate) mod parsing {

Ok(ExprClosure {
attrs: Vec::new(),
asyncness,
movability,
asyncness,
capture,
or1_token,
inputs,
Expand Down Expand Up @@ -3223,8 +3219,8 @@ pub(crate) mod printing {
impl ToTokens for ExprClosure {
fn to_tokens(&self, tokens: &mut TokenStream) {
outer_attrs_to_tokens(&self.attrs, tokens);
self.asyncness.to_tokens(tokens);
self.movability.to_tokens(tokens);
self.asyncness.to_tokens(tokens);
self.capture.to_tokens(tokens);
self.or1_token.to_tokens(tokens);
self.inputs.to_tokens(tokens);
Expand Down
2 changes: 1 addition & 1 deletion src/gen/clone.rs

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

2 changes: 1 addition & 1 deletion src/gen/debug.rs

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

4 changes: 2 additions & 2 deletions src/gen/eq.rs

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

2 changes: 1 addition & 1 deletion src/gen/fold.rs

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

2 changes: 1 addition & 1 deletion src/gen/hash.rs

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

4 changes: 2 additions & 2 deletions src/gen/visit.rs

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

4 changes: 2 additions & 2 deletions src/gen/visit_mut.rs

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

8 changes: 4 additions & 4 deletions syn.json
Original file line number Diff line number Diff line change
Expand Up @@ -1087,14 +1087,14 @@
"syn": "Attribute"
}
},
"asyncness": {
"movability": {
"option": {
"token": "Async"
"token": "Static"
}
},
"movability": {
"asyncness": {
"option": {
"token": "Static"
"token": "Async"
}
},
"capture": {
Expand Down
24 changes: 12 additions & 12 deletions tests/debug/gen.rs

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

4 changes: 0 additions & 4 deletions tests/repo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ static EXCLUDE: &[&str] = &[
"src/test/ui/rfc-2497-if-let-chains/issue-90722.rs",
"src/test/ui/rfc-2497-if-let-chains/then-else-blocks.rs",

// TODO: static async closure keyword order
"src/tools/rustfmt/tests/source/async_block.rs",
"src/tools/rustfmt/tests/target/async_block.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 2468457

Please sign in to comment.