Skip to content

Commit

Permalink
Fix static async closure keyword order
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 20, 2022
1 parent 6a8bf28 commit fc0c370
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 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
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 fc0c370

Please sign in to comment.