1
Fork 0

Rollup merge of #104951 - Swatinem:async-kind, r=compiler-errors

Simplify checking for `GeneratorKind::Async`

Adds a helper method around `generator_kind` that makes matching async constructs simpler.
This commit is contained in:
Matthias Krüger 2022-11-29 05:24:21 +01:00 committed by GitHub
commit c81605ca91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 22 deletions

View file

@ -322,10 +322,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
ty::Closure(..) => Some(MustUsePath::Closure(span)),
ty::Generator(def_id, ..) => {
// async fn should be treated as "implementor of `Future`"
let must_use = if matches!(
cx.tcx.generator_kind(def_id),
Some(hir::GeneratorKind::Async(..))
) {
let must_use = if cx.tcx.generator_is_async(def_id) {
let def_id = cx.tcx.lang_items().future_trait().unwrap();
is_def_must_use(cx, def_id, span)
.map(|inner| MustUsePath::Opaque(Box::new(inner)))