Simplify checking for GeneratorKind::Async

Adds a helper method around `generator_kind` that makes matching async constructs simpler.
This commit is contained in:
Arpad Borsos
2022-11-26 21:33:12 +01:00
parent 8a09420ac4
commit 2db0dc3297
5 changed files with 10 additions and 22 deletions

View File

@@ -1360,6 +1360,11 @@ impl<'tcx> TyCtxt<'tcx> {
self.diagnostic_items(did.krate).name_to_id.get(&name) == Some(&did)
}
/// Returns `true` if the node pointed to by `def_id` is a generator for an async construct.
pub fn generator_is_async(self, def_id: DefId) -> bool {
matches!(self.generator_kind(def_id), Some(hir::GeneratorKind::Async(_)))
}
pub fn stability(self) -> &'tcx stability::Index {
self.stability_index(())
}