mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 19:53:46 +00:00
Fix static async closure qualifier order
This commit is contained in:
parent
7b8303d479
commit
0b2fd9b132
@ -236,21 +236,21 @@ fn rewrite_closure_fn_decl(
|
|||||||
context: &RewriteContext<'_>,
|
context: &RewriteContext<'_>,
|
||||||
shape: Shape,
|
shape: Shape,
|
||||||
) -> Option<(String, usize)> {
|
) -> Option<(String, usize)> {
|
||||||
|
let immovable = if movability == ast::Movability::Static {
|
||||||
|
"static "
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
let is_async = if asyncness.is_async() { "async " } else { "" };
|
let is_async = if asyncness.is_async() { "async " } else { "" };
|
||||||
let mover = if capture == ast::CaptureBy::Value {
|
let mover = if capture == ast::CaptureBy::Value {
|
||||||
"move "
|
"move "
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
};
|
};
|
||||||
let immovable = if movability == ast::Movability::Static {
|
|
||||||
"static "
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
};
|
|
||||||
// 4 = "|| {".len(), which is overconservative when the closure consists of
|
// 4 = "|| {".len(), which is overconservative when the closure consists of
|
||||||
// a single expression.
|
// a single expression.
|
||||||
let nested_shape = shape
|
let nested_shape = shape
|
||||||
.shrink_left(is_async.len() + mover.len() + immovable.len())?
|
.shrink_left(immovable.len() + is_async.len() + mover.len())?
|
||||||
.sub_width(4)?;
|
.sub_width(4)?;
|
||||||
|
|
||||||
// 1 = |
|
// 1 = |
|
||||||
@ -288,7 +288,7 @@ fn rewrite_closure_fn_decl(
|
|||||||
.tactic(tactic)
|
.tactic(tactic)
|
||||||
.preserve_newline(true);
|
.preserve_newline(true);
|
||||||
let list_str = write_list(&item_vec, &fmt)?;
|
let list_str = write_list(&item_vec, &fmt)?;
|
||||||
let mut prefix = format!("{}{}{}|{}|", is_async, immovable, mover, list_str);
|
let mut prefix = format!("{}{}{}|{}|", immovable, is_async, mover, list_str);
|
||||||
|
|
||||||
if !ret_str.is_empty() {
|
if !ret_str.is_empty() {
|
||||||
if prefix.contains('\n') {
|
if prefix.contains('\n') {
|
||||||
|
@ -32,4 +32,20 @@ fn baz() {
|
|||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
spawn(
|
||||||
|
a,
|
||||||
|
static async || {
|
||||||
|
action();
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
spawn(
|
||||||
|
a,
|
||||||
|
static async move || {
|
||||||
|
action();
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -22,4 +22,14 @@ fn baz() {
|
|||||||
action();
|
action();
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
spawn(a, static async || {
|
||||||
|
action();
|
||||||
|
Ok(())
|
||||||
|
});
|
||||||
|
|
||||||
|
spawn(a, static async move || {
|
||||||
|
action();
|
||||||
|
Ok(())
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user