1
Fork 0

Modify as_local_hir_id to accept a LocalDefId instead of a DefId

This commit is contained in:
marmeladema 2020-04-12 13:45:41 +01:00
parent 92fb59d7f3
commit 6148db719f
86 changed files with 579 additions and 444 deletions

View file

@ -473,7 +473,9 @@ pub fn name_from_pat(p: &hir::Pat) -> String {
pub fn print_const(cx: &DocContext<'_>, n: &'tcx ty::Const<'_>) -> String {
match n.val {
ty::ConstKind::Unevaluated(def_id, _, promoted) => {
let mut s = if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(def_id) {
let mut s = if let Some(hir_id) =
def_id.as_local().map(|def_id| cx.tcx.hir().as_local_hir_id(def_id).unwrap())
{
print_const_expr(cx, cx.tcx.hir().body_owned_by(hir_id))
} else {
inline::print_inlined_const(cx, def_id)