Skip to content

Commit 8bd8484

Browse files
committed
review comments
1 parent 243496e commit 8bd8484

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

compiler/rustc_lint/src/unused.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,17 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
9595

9696
if let hir::ExprKind::Match(await_expr, _arms, hir::MatchSource::AwaitDesugar) = expr.kind
9797
&& let ty = cx.typeck_results().expr_ty(&await_expr)
98-
&& let ty::Opaque(def_id, _) = ty.kind()
98+
&& let ty::Opaque(future_def_id, _) = ty.kind()
9999
&& cx.tcx.ty_is_opaque_future(ty)
100-
&& let parent = cx.tcx.parent(*def_id)
101-
&& check_must_use_def(cx, parent, expr.span, "awaited future returned by ", "")
100+
// FIXME: This also includes non-async fns that return `impl Future`.
101+
&& let async_fn_def_id = cx.tcx.parent(*future_def_id)
102+
&& check_must_use_def(
103+
cx,
104+
async_fn_def_id,
105+
expr.span,
106+
"output of future returned by ",
107+
"",
108+
)
102109
{
103110
// We have a bare `foo().await;` on an opaque type from an async function that was
104111
// annotated with `#[must_use]`.

src/test/ui/lint/unused/unused-async.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ impl Wowee {
3030
async fn test() {
3131
foo(); //~ ERROR unused return value of `foo` that must be used
3232
//~^ ERROR unused implementer of `Future` that must be used
33-
foo().await; //~ ERROR unused awaited future returned by `foo` that must be used
33+
foo().await; //~ ERROR unused output of future returned by `foo` that must be used
3434
bar(); //~ ERROR unused return value of `bar` that must be used
3535
//~^ ERROR unused implementer of `Future` that must be used
36-
bar().await; //~ ERROR unused awaited future returned by `bar` that must be used
36+
bar().await; //~ ERROR unused output of future returned by `bar` that must be used
3737
baz(); //~ ERROR unused implementer of `Future` that must be used
3838
baz().await; // ok
3939
}

src/test/ui/lint/unused/unused-async.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ error: unused return value of `foo` that must be used
1717
LL | foo();
1818
| ^^^^^
1919

20-
error: unused awaited future returned by `foo` that must be used
20+
error: unused output of future returned by `foo` that must be used
2121
--> $DIR/unused-async.rs:33:5
2222
|
2323
LL | foo().await;
@@ -37,7 +37,7 @@ error: unused return value of `bar` that must be used
3737
LL | bar();
3838
| ^^^^^
3939

40-
error: unused awaited future returned by `bar` that must be used
40+
error: unused output of future returned by `bar` that must be used
4141
--> $DIR/unused-async.rs:36:5
4242
|
4343
LL | bar().await;

0 commit comments

Comments
 (0)