Skip to content

Commit a813cc1

Browse files
committed
rename is_async_fn to asyncness
1 parent 9ffb1ce commit a813cc1

File tree

6 files changed

+13
-21
lines changed

6 files changed

+13
-21
lines changed

src/librustc/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ rustc_queries! {
244244
desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
245245
}
246246

247-
query is_async_fn(key: DefId) -> bool {
247+
query asyncness(key: DefId) -> hir::IsAsync {
248248
desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) }
249249
}
250250

src/librustc/ty/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -3349,16 +3349,17 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Ty<'_>> {
33493349
}
33503350
}
33513351

3352-
fn is_async_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
3352+
/// Check if a function is async.
3353+
fn asyncness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::IsAsync {
33533354
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
33543355
let node = tcx.hir().get(hir_id);
33553356
if let Some(fn_like) = hir::map::blocks::FnLikeNode::from_node(node) {
3356-
fn_like.asyncness() == hir::IsAsync::Async
3357+
fn_like.asyncness()
33573358
} else {
3358-
false
3359+
hir::IsAsync::NotAsync
33593360
}
33603361
} else {
3361-
false
3362+
hir::IsAsync::NotAsync
33623363
}
33633364
}
33643365

@@ -3370,7 +3371,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
33703371
util::provide(providers);
33713372
constness::provide(providers);
33723373
*providers = ty::query::Providers {
3373-
is_async_fn,
3374+
asyncness,
33743375
associated_item,
33753376
associated_item_def_ids,
33763377
adt_sized_constraint,

src/librustc_metadata/cstore_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
133133
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
134134
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
135135
is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) }
136-
is_async_fn => { cdata.is_async_fn(def_id.index) }
136+
asyncness => { cdata.asyncness(def_id.index) }
137137
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
138138
static_mutability => { cdata.static_mutability(def_id.index) }
139139
def_kind => { cdata.def_kind(def_id.index) }

src/librustc_metadata/decoder.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1208,13 +1208,12 @@ impl<'a, 'tcx> CrateMetadata {
12081208
constness == hir::Constness::Const
12091209
}
12101210

1211-
pub fn is_async_fn(&self, id: DefIndex) -> bool {
1212-
let asyncness = match self.entry(id).kind {
1211+
pub fn asyncness(&self, id: DefIndex) -> hir::IsAsync {
1212+
match self.entry(id).kind {
12131213
EntryKind::Fn(data) => data.decode(self).asyncness,
12141214
EntryKind::Method(data) => data.decode(self).fn_data.asyncness,
12151215
_ => hir::IsAsync::NotAsync,
1216-
};
1217-
asyncness == hir::IsAsync::Async
1216+
}
12181217
}
12191218

12201219
pub fn is_foreign_item(&self, id: DefIndex) -> bool {

src/librustdoc/clean/inline.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,7 @@ fn build_external_function(cx: &DocContext<'_>, did: DefId) -> clean::Function {
217217
} else {
218218
hir::Constness::NotConst
219219
};
220-
let asyncness = if cx.tcx.is_async_fn(did) {
221-
hir::IsAsync::Async
222-
} else {
223-
hir::IsAsync::NotAsync
224-
};
220+
let asyncness = cx.tcx.asyncness(did);
225221
let predicates = cx.tcx.predicates_of(did);
226222
let (generics, decl) = clean::enter_impl_trait(cx, || {
227223
((cx.tcx.generics_of(did), &predicates).clean(cx), (did, sig).clean(cx))

src/librustdoc/clean/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -2403,11 +2403,7 @@ impl Clean<Item> for ty::AssocItem {
24032403
} else {
24042404
hir::Constness::NotConst
24052405
};
2406-
let asyncness = if cx.tcx.is_async_fn(self.def_id) {
2407-
hir::IsAsync::Async
2408-
} else {
2409-
hir::IsAsync::NotAsync
2410-
};
2406+
let asyncness = cx.tcx.asyncness(self.def_id);
24112407
let defaultness = match self.container {
24122408
ty::ImplContainer(_) => Some(self.defaultness),
24132409
ty::TraitContainer(_) => None,

0 commit comments

Comments
 (0)