1
Fork 0

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,

View file

@ -133,7 +133,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) }
is_async_fn => { cdata.is_async_fn(def_id.index) }
asyncness => { cdata.asyncness(def_id.index) }
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
static_mutability => { cdata.static_mutability(def_id.index) }
def_kind => { cdata.def_kind(def_id.index) }

View file

@ -1208,13 +1208,12 @@ impl<'a, 'tcx> CrateMetadata {
constness == hir::Constness::Const
}
pub fn is_async_fn(&self, id: DefIndex) -> bool {
let asyncness = match self.entry(id).kind {
pub fn asyncness(&self, id: DefIndex) -> hir::IsAsync {
match self.entry(id).kind {
EntryKind::Fn(data) => data.decode(self).asyncness,
EntryKind::Method(data) => data.decode(self).fn_data.asyncness,
_ => hir::IsAsync::NotAsync,
};
asyncness == hir::IsAsync::Async
}
}
pub fn is_foreign_item(&self, id: DefIndex) -> bool {

View file

@ -217,11 +217,7 @@ fn build_external_function(cx: &DocContext<'_>, did: DefId) -> clean::Function {
} else {
hir::Constness::NotConst
};
let asyncness = if cx.tcx.is_async_fn(did) {
hir::IsAsync::Async
} else {
hir::IsAsync::NotAsync
};
let asyncness = cx.tcx.asyncness(did);
let predicates = cx.tcx.predicates_of(did);
let (generics, decl) = clean::enter_impl_trait(cx, || {
((cx.tcx.generics_of(did), &predicates).clean(cx), (did, sig).clean(cx))

View file

@ -2403,11 +2403,7 @@ impl Clean<Item> for ty::AssocItem {
} else {
hir::Constness::NotConst
};
let asyncness = if cx.tcx.is_async_fn(self.def_id) {
hir::IsAsync::Async
} else {
hir::IsAsync::NotAsync
};
let asyncness = cx.tcx.asyncness(self.def_id);
let defaultness = match self.container {
ty::ImplContainer(_) => Some(self.defaultness),
ty::TraitContainer(_) => None,