bug-out asyncness query on non-local funtions
This commit is contained in:
parent
726fe3b255
commit
a744fd0432
2 changed files with 13 additions and 11 deletions
|
|
@ -3351,16 +3351,17 @@ 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 {
|
||||
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()
|
||||
} else {
|
||||
hir::IsAsync::NotAsync
|
||||
}
|
||||
} else {
|
||||
hir::IsAsync::NotAsync
|
||||
}
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1212,7 +1212,8 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
match self.entry(id).kind {
|
||||
EntryKind::Fn(data) => data.decode(self).asyncness,
|
||||
EntryKind::Method(data) => data.decode(self).fn_data.asyncness,
|
||||
_ => hir::IsAsync::NotAsync,
|
||||
EntryKind::ForeignFn(data) => data.decode(self).asyncness,
|
||||
_ => bug!("asyncness: expect functions entry."),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue