]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/ty/mod.rs
Rollup merge of #64599 - csmoe:doc_async_reexport, r=nikomatsakis
[rust.git] / src / librustc / ty / mod.rs
index 8bb9648e031ef5e98c4979fd8c234ded1303939d..89afbbaf4d402749dc907c5c078d037e24cd5289 100644 (file)
@@ -3353,6 +3353,22 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Ty<'_>> {
     }
 }
 
+/// Check if a function is async.
+fn asyncness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::IsAsync {
+    let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap_or_else(|| {
+        bug!("asyncness: expected local `DefId`, got `{:?}`", def_id)
+    });
+
+    let node = tcx.hir().get(hir_id);
+
+    let fn_like = hir::map::blocks::FnLikeNode::from_node(node).unwrap_or_else(|| {
+        bug!("asyncness: expected fn-like node but got `{:?}`", def_id);
+    });
+
+    fn_like.asyncness()
+}
+
+
 pub fn provide(providers: &mut ty::query::Providers<'_>) {
     context::provide(providers);
     erase_regions::provide(providers);
@@ -3360,6 +3376,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
     util::provide(providers);
     constness::provide(providers);
     *providers = ty::query::Providers {
+        asyncness,
         associated_item,
         associated_item_def_ids,
         adt_sized_constraint,