Skip to content

Commit 5f87884

Browse files
committed
Use more async closures
1 parent 4b18678 commit 5f87884

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

compiler/base/orchestrator/src/coordinator.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ where
947947
use versions_error::*;
948948

949949
let [stable, beta, nightly] =
950-
[Channel::Stable, Channel::Beta, Channel::Nightly].map(|c| async move {
950+
[Channel::Stable, Channel::Beta, Channel::Nightly].map(async |c| {
951951
let c = self.select_channel(c).await?;
952952
c.versions().await.map_err(VersionsChannelError::from)
953953
});
@@ -1144,11 +1144,9 @@ where
11441144
let token = mem::take(token);
11451145
token.cancel();
11461146

1147-
let channels = [stable, beta, nightly].map(|c| async {
1148-
match c.take() {
1149-
Some(c) => c.shutdown().await,
1150-
_ => Ok(()),
1151-
}
1147+
let channels = [stable, beta, nightly].map(async |c| match c.take() {
1148+
Some(c) => c.shutdown().await,
1149+
_ => Ok(()),
11521150
});
11531151

11541152
let [stable, beta, nightly] = channels;
@@ -3081,7 +3079,7 @@ mod tests {
30813079
(Mode::Release, "[optimized]"),
30823080
];
30833081

3084-
let tests = params.into_iter().map(|(mode, expected)| async move {
3082+
let tests = params.into_iter().map(async |(mode, expected)| {
30853083
let coordinator = new_coordinator();
30863084

30873085
let request = ExecuteRequest {
@@ -3116,8 +3114,10 @@ mod tests {
31163114
];
31173115

31183116
let tests = params.into_iter().flat_map(|(code, works_in)| {
3119-
Edition::ALL.into_iter().zip(works_in).map(
3120-
move |(edition, expected_to_work)| async move {
3117+
Edition::ALL
3118+
.into_iter()
3119+
.zip(works_in)
3120+
.map(async |(edition, expected_to_work)| {
31213121
let coordinator = new_coordinator();
31223122

31233123
let request = ExecuteRequest {
@@ -3137,8 +3137,7 @@ mod tests {
31373137
coordinator.shutdown().await?;
31383138

31393139
Ok::<_, Error>(())
3140-
},
3141-
)
3140+
})
31423141
});
31433142

31443143
try_join_all(tests).with_timeout().await?;
@@ -3157,7 +3156,7 @@ mod tests {
31573156
),
31583157
];
31593158

3160-
let tests = params.into_iter().map(|(crate_type, expected)| async move {
3159+
let tests = params.into_iter().map(async |(crate_type, expected)| {
31613160
let coordinator = new_coordinator();
31623161

31633162
let request = ExecuteRequest {
@@ -3190,7 +3189,7 @@ mod tests {
31903189

31913190
let params = [(false, "Running `"), (true, "Running unittests")];
31923191

3193-
let tests = params.into_iter().map(|(tests, expected)| async move {
3192+
let tests = params.into_iter().map(async |(tests, expected)| {
31943193
let coordinator = new_coordinator();
31953194

31963195
let request = ExecuteRequest {
@@ -3223,7 +3222,7 @@ mod tests {
32233222
(true, "stack backtrace:"),
32243223
];
32253224

3226-
let tests = params.into_iter().map(|(backtrace, expected)| async move {
3225+
let tests = params.into_iter().map(async |(backtrace, expected)| {
32273226
let coordinator = new_coordinator();
32283227

32293228
let request = ExecuteRequest {

ui/src/server_axum.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ async fn evaluate(
230230
Extension(db): Extension<Handle>,
231231
Json(req): Json<api::EvaluateRequest>,
232232
) -> Result<Json<api::EvaluateResponse>> {
233-
attempt_record_request(db, req, |req| async {
233+
attempt_record_request(db, req, async |req| {
234234
with_coordinator(&factory.0, req, async |c, req| {
235235
c.execute(req).context(EvaluateSnafu).await
236236
})
@@ -245,7 +245,7 @@ async fn compile(
245245
Extension(db): Extension<Handle>,
246246
Json(req): Json<api::CompileRequest>,
247247
) -> Result<Json<api::CompileResponse>> {
248-
attempt_record_request(db, req, |req| async {
248+
attempt_record_request(db, req, async |req| {
249249
with_coordinator(&factory.0, req, async |c, req| {
250250
c.compile(req).context(CompileSnafu).await
251251
})
@@ -260,7 +260,7 @@ async fn execute(
260260
Extension(db): Extension<Handle>,
261261
Json(req): Json<api::ExecuteRequest>,
262262
) -> Result<Json<api::ExecuteResponse>> {
263-
attempt_record_request(db, req, |req| async {
263+
attempt_record_request(db, req, async |req| {
264264
with_coordinator(&factory.0, req, async |c, req| {
265265
c.execute(req).context(ExecuteSnafu).await
266266
})
@@ -275,7 +275,7 @@ async fn format(
275275
Extension(db): Extension<Handle>,
276276
Json(req): Json<api::FormatRequest>,
277277
) -> Result<Json<api::FormatResponse>> {
278-
attempt_record_request(db, req, |req| async {
278+
attempt_record_request(db, req, async |req| {
279279
with_coordinator(&factory.0, req, async |c, req| {
280280
c.format(req).context(FormatSnafu).await
281281
})
@@ -290,7 +290,7 @@ async fn clippy(
290290
Extension(db): Extension<Handle>,
291291
Json(req): Json<api::ClippyRequest>,
292292
) -> Result<Json<api::ClippyResponse>> {
293-
attempt_record_request(db, req, |req| async {
293+
attempt_record_request(db, req, async |req| {
294294
with_coordinator(&factory.0, req, async |c, req| {
295295
c.clippy(req).context(ClippySnafu).await
296296
})
@@ -305,7 +305,7 @@ async fn miri(
305305
Extension(db): Extension<Handle>,
306306
Json(req): Json<api::MiriRequest>,
307307
) -> Result<Json<api::MiriResponse>> {
308-
attempt_record_request(db, req, |req| async {
308+
attempt_record_request(db, req, async |req| {
309309
with_coordinator(&factory.0, req, async |c, req| {
310310
c.miri(req).context(MiriSnafu).await
311311
})
@@ -320,7 +320,7 @@ async fn macro_expansion(
320320
Extension(db): Extension<Handle>,
321321
Json(req): Json<api::MacroExpansionRequest>,
322322
) -> Result<Json<api::MacroExpansionResponse>> {
323-
attempt_record_request(db, req, |req| async {
323+
attempt_record_request(db, req, async |req| {
324324
with_coordinator(&factory.0, req, async |c, req| {
325325
c.macro_expansion(req).context(MacroExpansionSnafu).await
326326
})

ui/src/server_axum/websocket.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ async fn handle_msg(
568568
.spawn({
569569
let tx = tx.clone();
570570
let meta = meta.clone();
571-
|coordinator| async {
571+
async |coordinator| {
572572
let r = handle_execute(
573573
token,
574574
execution_rx,
@@ -706,13 +706,13 @@ async fn handle_execute_inner(
706706

707707
let mut stdin_tx = Some(stdin_tx);
708708

709-
let send_stdout = |payload| async {
709+
let send_stdout = async |payload| {
710710
let meta = meta.clone();
711711
tx.send(Ok(MessageResponse::ExecuteStdout { payload, meta }))
712712
.await
713713
};
714714

715-
let send_stderr = |payload| async {
715+
let send_stderr = async |payload| {
716716
let meta = meta.clone();
717717
tx.send(Ok(MessageResponse::ExecuteStderr { payload, meta }))
718718
.await

0 commit comments

Comments
 (0)