Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
926e874
Dont check `must_use` on nested `impl Future` from fn
compiler-errors May 12, 2023
d371b80
Bump `cc` for `bootstrap`
r-value May 18, 2023
f0f9d88
Add Iterator::map_windows
frank-king May 10, 2023
e6a7fde
Give a more useful location for where a span_bug was delayed
jyn514 May 18, 2023
f577cc4
Fix doc comment for `ConstParamTy` derive
juntyr May 18, 2023
30c0e4e
Add more tests for the offset_of!() macro
est31 May 17, 2023
3e4ed61
do not overwrite obligations
lcnr May 18, 2023
0426562
very minor cleanups
jyn514 May 15, 2023
ad5955b
Migrate GUI colors test to original CSS color format
GuillaumeGomez May 18, 2023
1551495
Fix an ICE in CGU dumping code.
nnethercote May 18, 2023
1bb957e
Improve CGU partitioning debug output.
nnethercote May 18, 2023
4c03da9
Rollup merge of #94667 - frank-king:feature/iter_map_windows, r=Mark-…
GuillaumeGomez May 19, 2023
477cc24
Rollup merge of #111491 - compiler-errors:nested-fut-must-use, r=wesl…
GuillaumeGomez May 19, 2023
f410a76
Rollup merge of #111606 - jyn514:nightly-diagnostics, r=lcnr
GuillaumeGomez May 19, 2023
3d86765
Rollup merge of #111665 - est31:offset_of_tests, r=WaffleLapkin
GuillaumeGomez May 19, 2023
c00e88a
Rollup merge of #111701 - r-value:patch-1, r=jyn514
GuillaumeGomez May 19, 2023
98989f3
Rollup merge of #111708 - jyn514:delay-span-bug-msg, r=compiler-errors
GuillaumeGomez May 19, 2023
af26f19
Rollup merge of #111715 - juntyr:const-param-ty-derive-fix, r=Nilstrieb
GuillaumeGomez May 19, 2023
3b393c1
Rollup merge of #111723 - lcnr:overwrite-obligations, r=compiler-errors
GuillaumeGomez May 19, 2023
1123c72
Rollup merge of #111726 - GuillaumeGomez:gui-test-migrate-color, r=no…
GuillaumeGomez May 19, 2023
807f36a
Rollup merge of #111743 - nnethercote:improve-cgu-merging-debug-outpu…
GuillaumeGomez May 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/lint/unused/auxiliary/must-use-foreign.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// edition:2021

use std::future::Future;

pub struct Manager;

impl Manager {
#[must_use]
pub async fn new() -> (Self, impl Future<Output = ()>) {
(Manager, async {})
}
}
15 changes: 15 additions & 0 deletions tests/ui/lint/unused/must-use-foreign.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// edition:2021
// aux-build:must-use-foreign.rs
// check-pass

extern crate must_use_foreign;

use must_use_foreign::Manager;

async fn async_main() {
Manager::new().await.1.await;
}

fn main() {
let _ = async_main();
}
2 changes: 1 addition & 1 deletion tests/ui/lint/unused/unused-async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async fn test() {
foo().await; //~ ERROR unused output of future returned by `foo` that must be used
bar(); //~ ERROR unused return value of `bar` that must be used
//~^ ERROR unused implementer of `Future` that must be used
bar().await; //~ ERROR unused output of future returned by `bar` that must be used
bar().await; // ok, it's not an async fn
baz(); //~ ERROR unused implementer of `Future` that must be used
baz().await; // ok
}
Expand Down
13 changes: 1 addition & 12 deletions tests/ui/lint/unused/unused-async.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ help: use `let _ = ...` to ignore the resulting value
LL | let _ = bar();
| +++++++

error: unused output of future returned by `bar` that must be used
--> $DIR/unused-async.rs:36:5
|
LL | bar().await;
| ^^^^^^^^^^^
|
help: use `let _ = ...` to ignore the resulting value
|
LL | let _ = bar().await;
| +++++++

error: unused implementer of `Future` that must be used
--> $DIR/unused-async.rs:37:5
|
Expand All @@ -71,5 +60,5 @@ LL | baz();
|
= note: futures do nothing unless you `.await` or poll them

error: aborting due to 7 previous errors
error: aborting due to 6 previous errors