rename is_async_fn to asyncness

This commit is contained in:
csmoe 2019-09-21 03:17:57 +00:00
parent 9ffb1ce28c
commit a813cc1bf1
6 changed files with 13 additions and 21 deletions

View file

@ -244,7 +244,7 @@ rustc_queries! {
desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
}
query is_async_fn(key: DefId) -> bool {
query asyncness(key: DefId) -> hir::IsAsync {
desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) }
}

View file

@ -3349,16 +3349,17 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Ty<'_>> {
}
}
fn is_async_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
/// Check if a function is async.
fn asyncness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::IsAsync {
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
let node = tcx.hir().get(hir_id);
if let Some(fn_like) = hir::map::blocks::FnLikeNode::from_node(node) {
fn_like.asyncness() == hir::IsAsync::Async
fn_like.asyncness()
} else {
false
hir::IsAsync::NotAsync
}
} else {
false
hir::IsAsync::NotAsync
}
}
@ -3370,7 +3371,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
util::provide(providers);
constness::provide(providers);
*providers = ty::query::Providers {
is_async_fn,
asyncness,
associated_item,
associated_item_def_ids,
adt_sized_constraint,