diff options
| author | Michael Goulet <michael@errs.io> | 2023-05-12 02:08:39 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-05-12 02:08:43 +0000 |
| commit | 926e874fd1dccc208bf63db7a4288adf46caa3c3 (patch) | |
| tree | 8551ad41255e13879fa184c4d53140c9014e281d /compiler | |
| parent | 2a8221dbdfd180a2d56d4b0089f4f3952d8c2bcd (diff) | |
| download | rust-926e874fd1dccc208bf63db7a4288adf46caa3c3.tar.gz rust-926e874fd1dccc208bf63db7a4288adf46caa3c3.zip | |
Dont check `must_use` on nested `impl Future` from fn
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_lint/src/unused.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index eb175e96997..0fe140e08d2 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -103,8 +103,10 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { && let ty = cx.typeck_results().expr_ty(&await_expr) && let ty::Alias(ty::Opaque, ty::AliasTy { def_id: future_def_id, .. }) = ty.kind() && cx.tcx.ty_is_opaque_future(ty) - // FIXME: This also includes non-async fns that return `impl Future`. && let async_fn_def_id = cx.tcx.parent(*future_def_id) + && matches!(cx.tcx.def_kind(async_fn_def_id), DefKind::Fn | DefKind::AssocFn) + // Check that this `impl Future` actually comes from an `async fn` + && cx.tcx.asyncness(async_fn_def_id).is_async() && check_must_use_def( cx, async_fn_def_id, |
