diff options
| author | csmoe <csmoe@msn.com> | 2019-09-23 17:13:11 +0000 |
|---|---|---|
| committer | csmoe <csmoe@msn.com> | 2019-09-24 06:17:54 +0000 |
| commit | a744fd04321f6307303a22ecc8880cbc7b6bcbda (patch) | |
| tree | a7bb0af98139ab607343c36bb96f40c893ac0b48 /src/librustc/ty | |
| parent | 726fe3b25573c8406a74e751d54f0bd3c663ea03 (diff) | |
| download | rust-a744fd04321f6307303a22ecc8880cbc7b6bcbda.tar.gz rust-a744fd04321f6307303a22ecc8880cbc7b6bcbda.zip | |
bug-out asyncness query on non-local funtions
Diffstat (limited to 'src/librustc/ty')
| -rw-r--r-- | src/librustc/ty/mod.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index dd36a452092..98fa64c265c 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -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() } |
