diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index c97b547946e..43ced8ee5b1 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -209,9 +209,8 @@ impl CodegenCx<'ll, 'tcx> { debug!("get_static: sym={} instance={:?}", sym, instance); - let g = if let Some(id) = - def_id.as_local().map(|def_id| self.tcx.hir().as_local_hir_id(def_id)) - { + let g = if let Some(def_id) = def_id.as_local() { + let id = self.tcx.hir().as_local_hir_id(def_id); let llty = self.layout_of(ty).llvm_type(self); let (g, attrs) = match self.tcx.hir().get(id) { Node::Item(&hir::Item { attrs, span, kind: hir::ItemKind::Static(..), .. }) => { diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/find_anon_type.rs index e02a90c7b5f..190a2dcc556 100644 --- a/src/librustc_infer/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc_infer/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -29,9 +29,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { ) -> Option<(&hir::Ty<'_>, &hir::FnDecl<'_>)> { if let Some(anon_reg) = self.tcx().is_suitable_region(region) { let def_id = anon_reg.def_id; - if let Some(hir_id) = - def_id.as_local().map(|def_id| self.tcx().hir().as_local_hir_id(def_id)) - { + if let Some(def_id) = def_id.as_local() { + let hir_id = self.tcx().hir().as_local_hir_id(def_id); let fndecl = match self.tcx().hir().get(hir_id) { Node::Item(&hir::Item { kind: hir::ItemKind::Fn(ref m, ..), .. }) | Node::TraitItem(&hir::TraitItem { diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/outlives_closure.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/outlives_closure.rs index ca051cecbb8..fc858a49759 100644 --- a/src/librustc_infer/infer/error_reporting/nice_region_error/outlives_closure.rs +++ b/src/librustc_infer/infer/error_reporting/nice_region_error/outlives_closure.rs @@ -46,9 +46,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { ) = (&sub_origin, sup_region) { let hir = &self.tcx().hir(); - if let Some(hir_id) = - free_region.scope.as_local().map(|def_id| hir.as_local_hir_id(def_id)) - { + if let Some(def_id) = free_region.scope.as_local() { + let hir_id = hir.as_local_hir_id(def_id); if let Node::Expr(Expr { kind: Closure(_, _, _, closure_span, None), .. }) = hir.get(hir_id) { diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 5b25204f21b..cad6a312521 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -436,9 +436,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { // If the trait is private, add the impl items to `private_traits` so they don't get // reported for missing docs. let real_trait = trait_ref.path.res.def_id(); - if let Some(hir_id) = - real_trait.as_local().map(|def_id| cx.tcx.hir().as_local_hir_id(def_id)) - { + if let Some(def_id) = real_trait.as_local() { + let hir_id = cx.tcx.hir().as_local_hir_id(def_id); if let Some(Node::Item(item)) = cx.tcx.hir().find(hir_id) { if let hir::VisibilityKind::Inherited = item.vis.node { for impl_item_ref in items { @@ -611,10 +610,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations { let mut impls = HirIdSet::default(); cx.tcx.for_each_impl(debug, |d| { if let Some(ty_def) = cx.tcx.type_of(d).ty_adt_def() { - if let Some(hir_id) = - ty_def.did.as_local().map(|def_id| cx.tcx.hir().as_local_hir_id(def_id)) - { - impls.insert(hir_id); + if let Some(def_id) = ty_def.did.as_local() { + impls.insert(cx.tcx.hir().as_local_hir_id(def_id)); } } }); diff --git a/src/librustc_middle/hir/map/mod.rs b/src/librustc_middle/hir/map/mod.rs index 8860fe7ff97..aee80b6e14e 100644 --- a/src/librustc_middle/hir/map/mod.rs +++ b/src/librustc_middle/hir/map/mod.rs @@ -482,7 +482,7 @@ impl<'hir> Map<'hir> { } pub fn get_if_local(&self, id: DefId) -> Option> { - if let Some(id) = id.as_local() { Some(self.get(self.as_local_hir_id(id))) } else { None } + id.as_local().map(|id| self.get(self.as_local_hir_id(id))) } pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics<'hir>> { @@ -883,7 +883,7 @@ impl<'hir> Map<'hir> { } pub fn span_if_local(&self, id: DefId) -> Option { - if let Some(id) = id.as_local() { Some(self.span(self.as_local_hir_id(id))) } else { None } + id.as_local().map(|id| self.span(self.as_local_hir_id(id))) } pub fn res_span(&self, res: Res) -> Option { @@ -1082,11 +1082,6 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId) -> String { } pub fn provide(providers: &mut Providers<'_>) { - providers.def_kind = |tcx, def_id| { - if let Some(def_id) = def_id.as_local() { - tcx.hir().def_kind(tcx.hir().as_local_hir_id(def_id)) - } else { - bug!("calling local def_kind query provider for upstream DefId: {:?}", def_id); - } - }; + providers.def_kind = + |tcx, def_id| tcx.hir().def_kind(tcx.hir().as_local_hir_id(def_id.expect_local())); } diff --git a/src/librustc_middle/mir/mod.rs b/src/librustc_middle/mir/mod.rs index 93b031c5d88..d3fcf9c64f8 100644 --- a/src/librustc_middle/mir/mod.rs +++ b/src/librustc_middle/mir/mod.rs @@ -2338,14 +2338,13 @@ impl<'tcx> Debug for Rvalue<'tcx> { } AggregateKind::Closure(def_id, substs) => ty::tls::with(|tcx| { - if let Some(hir_id) = - def_id.as_local().map(|def_id| tcx.hir().as_local_hir_id(def_id)) - { + if let Some(def_id) = def_id.as_local() { + let hir_id = tcx.hir().as_local_hir_id(def_id); let name = if tcx.sess.opts.debugging_opts.span_free_formats { let substs = tcx.lift(&substs).unwrap(); format!( "[closure@{}]", - tcx.def_path_str_with_substs(def_id, substs), + tcx.def_path_str_with_substs(def_id.to_def_id(), substs), ) } else { format!("[closure@{:?}]", tcx.hir().span(hir_id)) @@ -2366,9 +2365,8 @@ impl<'tcx> Debug for Rvalue<'tcx> { }), AggregateKind::Generator(def_id, _, _) => ty::tls::with(|tcx| { - if let Some(hir_id) = - def_id.as_local().map(|def_id| tcx.hir().as_local_hir_id(def_id)) - { + if let Some(def_id) = def_id.as_local() { + let hir_id = tcx.hir().as_local_hir_id(def_id); let name = format!("[generator@{:?}]", tcx.hir().span(hir_id)); let mut struct_fmt = fmt.debug_struct(&name); diff --git a/src/librustc_middle/ty/print/pretty.rs b/src/librustc_middle/ty/print/pretty.rs index 200ccf42c01..828f7f6a767 100644 --- a/src/librustc_middle/ty/print/pretty.rs +++ b/src/librustc_middle/ty/print/pretty.rs @@ -608,9 +608,8 @@ pub trait PrettyPrinter<'tcx>: } // FIXME(eddyb) should use `def_span`. - if let Some(hir_id) = - did.as_local().map(|did| self.tcx().hir().as_local_hir_id(did)) - { + if let Some(did) = did.as_local() { + let hir_id = self.tcx().hir().as_local_hir_id(did); p!(write("@{:?}", self.tcx().hir().span(hir_id))); if substs.as_generator().is_valid() { @@ -654,11 +653,10 @@ pub trait PrettyPrinter<'tcx>: p!(write("[closure")); // FIXME(eddyb) should use `def_span`. - if let Some(hir_id) = - did.as_local().map(|did| self.tcx().hir().as_local_hir_id(did)) - { + if let Some(did) = did.as_local() { + let hir_id = self.tcx().hir().as_local_hir_id(did); if self.tcx().sess.opts.debugging_opts.span_free_formats { - p!(write("@"), print_def_path(did, substs)); + p!(write("@"), print_def_path(did.to_def_id(), substs)); } else { p!(write("@{:?}", self.tcx().hir().span(hir_id))); } diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index ef66e96381f..6cc4ee432a5 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -864,11 +864,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { format!("`{}` would have to be valid for `{}`...", name, region_name), ); - if let Some(fn_hir_id) = self - .mir_def_id - .as_local() - .map(|def_id| self.infcx.tcx.hir().as_local_hir_id(def_id)) - { + if let Some(def_id) = self.mir_def_id.as_local() { + let fn_hir_id = self.infcx.tcx.hir().as_local_hir_id(def_id); err.span_label( drop_span, format!( diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 802b8897bb9..6d1984fd20f 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -430,7 +430,8 @@ fn check_recursion_limit<'tcx>( // infinite expansion. if adjusted_recursion_depth > *tcx.sess.recursion_limit.get() { let error = format!("reached the recursion limit while instantiating `{}`", instance); - if let Some(hir_id) = def_id.as_local().map(|def_id| tcx.hir().as_local_hir_id(def_id)) { + if let Some(def_id) = def_id.as_local() { + let hir_id = tcx.hir().as_local_hir_id(def_id); tcx.sess.span_fatal(tcx.hir().span(hir_id), &error); } else { tcx.sess.fatal(&error); diff --git a/src/librustc_passes/dead.rs b/src/librustc_passes/dead.rs index 261386f70d9..6d1fbd6c868 100644 --- a/src/librustc_passes/dead.rs +++ b/src/librustc_passes/dead.rs @@ -537,9 +537,8 @@ impl DeadVisitor<'tcx> { let inherent_impls = self.tcx.inherent_impls(def_id); for &impl_did in inherent_impls.iter() { for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] { - if let Some(item_hir_id) = - item_did.as_local().map(|did| self.tcx.hir().as_local_hir_id(did)) - { + if let Some(did) = item_did.as_local() { + let item_hir_id = self.tcx.hir().as_local_hir_id(did); if self.live_symbols.contains(&item_hir_id) { return true; } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 7e1a53d4c3f..b1fbba7e1a7 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -445,9 +445,8 @@ impl VisibilityLike for Option { const SHALLOW: bool = true; fn new_min(find: &FindMin<'_, '_, Self>, def_id: DefId) -> Self { cmp::min( - if let Some(hir_id) = - def_id.as_local().map(|def_id| find.tcx.hir().as_local_hir_id(def_id)) - { + if let Some(def_id) = def_id.as_local() { + let hir_id = find.tcx.hir().as_local_hir_id(def_id); find.access_levels.map.get(&hir_id).cloned() } else { Self::MAX @@ -549,9 +548,8 @@ impl EmbargoVisitor<'tcx> { if export.vis.is_accessible_from(defining_mod, self.tcx) { if let Res::Def(def_kind, def_id) = export.res { let vis = def_id_visibility(self.tcx, def_id).0; - if let Some(hir_id) = - def_id.as_local().map(|def_id| self.tcx.hir().as_local_hir_id(def_id)) - { + if let Some(def_id) = def_id.as_local() { + let hir_id = self.tcx.hir().as_local_hir_id(def_id); self.update_macro_reachable_def(hir_id, def_kind, vis, defining_mod); } } @@ -914,10 +912,8 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> { for export in exports.iter() { if export.vis == ty::Visibility::Public { if let Some(def_id) = export.res.opt_def_id() { - if let Some(hir_id) = def_id - .as_local() - .map(|def_id| self.tcx.hir().as_local_hir_id(def_id)) - { + if let Some(def_id) = def_id.as_local() { + let hir_id = self.tcx.hir().as_local_hir_id(def_id); self.update(hir_id, Some(AccessLevel::Exported)); } } diff --git a/src/librustc_resolve/late/lifetimes.rs b/src/librustc_resolve/late/lifetimes.rs index 8d9110f9a57..a988c5829b5 100644 --- a/src/librustc_resolve/late/lifetimes.rs +++ b/src/librustc_resolve/late/lifetimes.rs @@ -596,10 +596,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { // In the future, this should be fixed and this error should be removed. let def = self.map.defs.get(&lifetime.hir_id).cloned(); if let Some(Region::LateBound(_, def_id, _)) = def { - if let Some(hir_id) = def_id - .as_local() - .map(|def_id| self.tcx.hir().as_local_hir_id(def_id)) - { + if let Some(def_id) = def_id.as_local() { + let hir_id = self.tcx.hir().as_local_hir_id(def_id); // Ensure that the parent of the def is an item, not HRTB let parent_id = self.tcx.hir().get_parent_node(hir_id); let parent_impl_id = hir::ImplItemId { hir_id: parent_id }; @@ -1559,10 +1557,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } if let Some(parent_def_id) = self.tcx.parent(def_id) { - if let Some(parent_hir_id) = parent_def_id - .as_local() - .map(|def_id| self.tcx.hir().as_local_hir_id(def_id)) - { + if let Some(def_id) = parent_def_id.as_local() { + let parent_hir_id = self.tcx.hir().as_local_hir_id(def_id); // lifetimes in `derive` expansions don't count (Issue #53738) if self .tcx @@ -1959,9 +1955,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { }; let map = &self.map; - let unsubst = if let Some(id) = - def_id.as_local().map(|def_id| self.tcx.hir().as_local_hir_id(def_id)) - { + let unsubst = if let Some(def_id) = def_id.as_local() { + let id = self.tcx.hir().as_local_hir_id(def_id); &map.object_lifetime_defaults[&id] } else { let tcx = self.tcx; diff --git a/src/librustc_trait_selection/opaque_types.rs b/src/librustc_trait_selection/opaque_types.rs index 8af9d7ea904..8ff8f5734c9 100644 --- a/src/librustc_trait_selection/opaque_types.rs +++ b/src/librustc_trait_selection/opaque_types.rs @@ -1036,9 +1036,8 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> { // let x = || foo(); // returns the Opaque assoc with `foo` // } // ``` - if let Some(opaque_hir_id) = - def_id.as_local().map(|def_id| tcx.hir().as_local_hir_id(def_id)) - { + if let Some(def_id) = def_id.as_local() { + let opaque_hir_id = tcx.hir().as_local_hir_id(def_id); let parent_def_id = self.parent_def_id; let def_scope_default = || { let opaque_parent_hir_id = tcx.hir().get_parent_item(opaque_hir_id); @@ -1085,7 +1084,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> { ), }; if in_definition_scope { - return self.fold_opaque_ty(ty, def_id, substs, origin); + return self.fold_opaque_ty(ty, def_id.to_def_id(), substs, origin); } debug!( diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index f834f74d5df..590726ce8ed 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -409,9 +409,8 @@ fn extract_spans_for_error_reporting<'a, 'tcx>( match *terr { TypeError::Mutability => { - if let Some(trait_m_hir_id) = - trait_m.def_id.as_local().map(|def_id| tcx.hir().as_local_hir_id(def_id)) - { + if let Some(def_id) = trait_m.def_id.as_local() { + let trait_m_hir_id = tcx.hir().as_local_hir_id(def_id); let trait_m_iter = match tcx.hir().expect_trait_item(trait_m_hir_id).kind { TraitItemKind::Fn(ref trait_m_sig, _) => trait_m_sig.decl.inputs.iter(), _ => bug!("{:?} is not a TraitItemKind::Fn", trait_m), @@ -438,9 +437,8 @@ fn extract_spans_for_error_reporting<'a, 'tcx>( } } TypeError::Sorts(ExpectedFound { .. }) => { - if let Some(trait_m_hir_id) = - trait_m.def_id.as_local().map(|def_id| tcx.hir().as_local_hir_id(def_id)) - { + if let Some(def_id) = trait_m.def_id.as_local() { + let trait_m_hir_id = tcx.hir().as_local_hir_id(def_id); let (trait_m_output, trait_m_iter) = match tcx.hir().expect_trait_item(trait_m_hir_id).kind { TraitItemKind::Fn(ref trait_m_sig, _) => { @@ -591,9 +589,8 @@ fn compare_number_of_generics<'tcx>( if impl_count != trait_count { err_occurred = true; - let (trait_spans, impl_trait_spans) = if let Some(trait_hir_id) = - trait_.def_id.as_local().map(|def_id| tcx.hir().as_local_hir_id(def_id)) - { + let (trait_spans, impl_trait_spans) = if let Some(def_id) = trait_.def_id.as_local() { + let trait_hir_id = tcx.hir().as_local_hir_id(def_id); let trait_item = tcx.hir().expect_trait_item(trait_hir_id); if trait_item.generics.params.is_empty() { (Some(vec![trait_item.generics.span]), vec![]) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index dc94a57882d..228c40ac853 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -1052,9 +1052,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let generics = self.tcx.generics_of(table_owner.to_def_id()); let type_param = generics.type_param(param, self.tcx); let hir = &self.tcx.hir(); - if let Some(id) = - type_param.def_id.as_local().map(|def_id| hir.as_local_hir_id(def_id)) - { + if let Some(def_id) = type_param.def_id.as_local() { + let id = hir.as_local_hir_id(def_id); // Get the `hir::Param` to verify whether it already has any bounds. // We do this to avoid suggesting code that ends up as `T: FooBar`, // instead we suggest `T: Foo + Bar` in that case. diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 3ec3ef2f30c..01d077d47f0 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -377,9 +377,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { return; } - let (local, remote) = if let Some(id) = - def_id.as_local().map(|def_id| self.tcx().hir().as_local_hir_id(def_id)) - { + let (local, remote) = if let Some(def_id) = def_id.as_local() { + let id = self.tcx().hir().as_local_hir_id(def_id); (Some(self.terms_cx.inferred_starts[&id]), None) } else { (None, Some(self.tcx().variances_of(def_id))) diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 7a25f07bfe9..6208c147101 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -340,7 +340,8 @@ pub fn build_impl( } } - let for_ = if let Some(hir_id) = did.as_local().map(|did| tcx.hir().as_local_hir_id(did)) { + let for_ = if let Some(did) = did.as_local() { + let hir_id = tcx.hir().as_local_hir_id(did); match tcx.hir().expect_item(hir_id).kind { hir::ItemKind::Impl { self_ty, .. } => self_ty.clean(cx), _ => panic!("did given to build_impl was not an impl"), @@ -360,9 +361,8 @@ pub fn build_impl( } let predicates = tcx.explicit_predicates_of(did); - let (trait_items, generics) = if let Some(hir_id) = - did.as_local().map(|did| tcx.hir().as_local_hir_id(did)) - { + let (trait_items, generics) = if let Some(did) = did.as_local() { + let hir_id = tcx.hir().as_local_hir_id(did); match tcx.hir().expect_item(hir_id).kind { hir::ItemKind::Impl { ref generics, ref items, .. } => ( items.iter().map(|item| tcx.hir().impl_item(item.id).clean(cx)).collect::>(), @@ -488,7 +488,8 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet) } pub fn print_inlined_const(cx: &DocContext<'_>, did: DefId) -> String { - if let Some(hir_id) = did.as_local().map(|did| cx.tcx.hir().as_local_hir_id(did)) { + if let Some(did) = did.as_local() { + let hir_id = cx.tcx.hir().as_local_hir_id(did); rustc_hir_pretty::id_to_string(&cx.tcx.hir(), hir_id) } else { cx.tcx.rendered_const(did) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index a685b4a73cd..4d03bb21cb3 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1379,10 +1379,9 @@ impl Clean for hir::Ty<'_> { let mut alias = None; if let Res::Def(DefKind::TyAlias, def_id) = path.res { // Substitute private type aliases - if let Some(hir_id) = - def_id.as_local().map(|def_id| cx.tcx.hir().as_local_hir_id(def_id)) - { - if !cx.renderinfo.borrow().access_levels.is_exported(def_id) { + if let Some(def_id) = def_id.as_local() { + let hir_id = cx.tcx.hir().as_local_hir_id(def_id); + if !cx.renderinfo.borrow().access_levels.is_exported(def_id.to_def_id()) { alias = Some(&cx.tcx.hir().expect_item(hir_id).kind); } } diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index de101a20fc5..ec5ac48ffe4 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -473,9 +473,8 @@ 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) = - def_id.as_local().map(|def_id| cx.tcx.hir().as_local_hir_id(def_id)) - { + let mut s = if let Some(def_id) = def_id.as_local() { + let hir_id = cx.tcx.hir().as_local_hir_id(def_id); print_const_expr(cx, cx.tcx.hir().body_owned_by(hir_id)) } else { inline::print_inlined_const(cx, def_id) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 2f10171e616..43b641c7fe6 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -335,10 +335,8 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { fn fold_item(&mut self, mut item: Item) -> Option { let item_hir_id = if item.is_mod() { - if let Some(id) = - item.def_id.as_local().map(|def_id| self.cx.tcx.hir().as_local_hir_id(def_id)) - { - Some(id) + if let Some(def_id) = item.def_id.as_local() { + Some(self.cx.tcx.hir().as_local_hir_id(def_id)) } else { debug!("attempting to fold on a non-local item: {:?}", item); return self.fold_item_recur(item);