From e6ee8a0d44fcedb583067bbaf36bcdf325029cdd Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 20 Jun 2019 15:00:31 +0300 Subject: rustc: produce AST instead of HIR from `hir::lowering::Resolver` methods. --- src/librustdoc/passes/collect_intra_doc_links.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/librustdoc') diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index e6f09927796..bb85fe898da 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -71,15 +71,16 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { }) }); - if let Ok(result) = result { + if let Ok((_, res)) = result { + let res = res.map_id(|_| panic!("unexpected node_id")); // In case this is a trait item, skip the // early return and try looking for the trait. - let value = match result.res { + let value = match res { Res::Def(DefKind::Method, _) | Res::Def(DefKind::AssocConst, _) => true, Res::Def(DefKind::AssocTy, _) => false, - Res::Def(DefKind::Variant, _) => return handle_variant(cx, result.res), + Res::Def(DefKind::Variant, _) => return handle_variant(cx, res), // Not a trait item; just return what we found. - _ => return Ok((result.res, None)) + _ => return Ok((res, None)) }; if value != (ns == ValueNS) { @@ -129,10 +130,11 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { // FIXME: `with_scope` requires the `NodeId` of a module. let node_id = cx.tcx.hir().hir_to_node_id(id); - let ty = cx.enter_resolver(|resolver| resolver.with_scope(node_id, |resolver| { + let (_, ty_res) = cx.enter_resolver(|resolver| resolver.with_scope(node_id, |resolver| { resolver.resolve_str_path_error(DUMMY_SP, &path, false) }))?; - match ty.res { + let ty_res = ty_res.map_id(|_| panic!("unexpected node_id")); + match ty_res { Res::Def(DefKind::Struct, did) | Res::Def(DefKind::Union, did) | Res::Def(DefKind::Enum, did) @@ -147,7 +149,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { ty::AssocKind::Const if ns == ValueNS => "associatedconstant", _ => return Err(()) }; - Ok((ty.res, Some(format!("{}.{}", out, item_name)))) + Ok((ty_res, Some(format!("{}.{}", out, item_name)))) } else { match cx.tcx.type_of(did).sty { ty::Adt(def, _) => { @@ -159,7 +161,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { .iter() .find(|item| item.ident.name == item_name) } { - Ok((ty.res, + Ok((ty_res, Some(format!("{}.{}", if def.is_enum() { "variant" @@ -193,7 +195,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { _ => return Err(()) }; - Ok((ty.res, Some(format!("{}.{}", kind, item_name)))) + Ok((ty_res, Some(format!("{}.{}", kind, item_name)))) } else { Err(()) } -- cgit 1.4.1-3-g733a5