Simplify checking for GeneratorKind::Async
Adds a helper method around `generator_kind` that makes matching async constructs simpler.
This commit is contained in:
parent
8a09420ac4
commit
2db0dc3297
5 changed files with 10 additions and 22 deletions
|
@ -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)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue