Skip to content

Commit

Permalink
rename is_async_fn to asyncness
Browse files Browse the repository at this point in the history
  • Loading branch information
csmoe committed Sep 21, 2019
1 parent 9ffb1ce commit a813cc1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}

Expand Down
11 changes: 6 additions & 5 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 1 addition & 5 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 1 addition & 5 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a813cc1

Please sign in to comment.