Skip to content

Commit

Permalink
Address code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
eholk committed Dec 4, 2023
1 parent 13d284d commit f114bb4
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,10 @@ fn rewrite_closure_fn_decl(
} else {
""
};
let (is_async, is_gen) = if let Some(coro_kind) = coro_kind {
let is_async = if coro_kind.is_async() { "async " } else { "" };
let is_gen = if coro_kind.is_gen() { "gen " } else { "" };
(is_async, is_gen)
} else {
("", "")
let coro = match coro_kind {
Some(ast::CoroutineKind::Async { .. }) => "async ",
Some(ast::CoroutineKind::Gen { .. }) => "gen ",
None => "",
};
let mover = if matches!(capture, ast::CaptureBy::Value { .. }) {
"move "
Expand All @@ -278,14 +276,7 @@ fn rewrite_closure_fn_decl(
// 4 = "|| {".len(), which is overconservative when the closure consists of
// a single expression.
let nested_shape = shape
.shrink_left(
binder.len()
+ const_.len()
+ immovable.len()
+ is_async.len()
+ is_gen.len()
+ mover.len(),
)?
.shrink_left(binder.len() + const_.len() + immovable.len() + coro.len() + mover.len())?
.sub_width(4)?;

// 1 = |
Expand Down Expand Up @@ -323,7 +314,7 @@ fn rewrite_closure_fn_decl(
.tactic(tactic)
.preserve_newline(true);
let list_str = write_list(&item_vec, &fmt)?;
let mut prefix = format!("{binder}{const_}{immovable}{is_async}{is_gen}{mover}|{list_str}|");
let mut prefix = format!("{binder}{const_}{immovable}{coro}{mover}|{list_str}|");

if !ret_str.is_empty() {
if prefix.contains('\n') {
Expand Down

0 comments on commit f114bb4

Please sign in to comment.