Skip to content

Commit

Permalink
Rollup merge of #72777 - marmeladema:rustdoc-remove-local-def-id-from…
Browse files Browse the repository at this point in the history
…-node-id, r=petrochenkov

rustdoc: remove calls to `local_def_id_from_node_id`

rustdoc calls `local_def_id_from_node_id(CRATE_NODE_ID)` when it can just creates a top level `DefId` using `DefId::local(CRATE_DEF_INDEX)`.

cc #50928

r? @petrochenkov
  • Loading branch information
RalfJung authored May 30, 2020
2 parents b7f6a0b + 4b7e44f commit 581eafc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 2 additions & 6 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_ast::ast;
use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX};
use rustc_hir::Mutability;
use rustc_metadata::creader::LoadedMacro;
use rustc_middle::ty;
Expand Down Expand Up @@ -454,11 +454,7 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet<DefId>)
name: None,
attrs: clean::Attributes::default(),
source: clean::Span::empty(),
def_id: cx
.tcx
.hir()
.local_def_id_from_node_id(ast::CRATE_NODE_ID)
.to_def_id(),
def_id: DefId::local(CRATE_DEF_INDEX),
visibility: clean::Public,
stability: None,
deprecation: None,
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1549,11 +1549,11 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
ty::FnDef(..) | ty::FnPtr(_) => {
let ty = cx.tcx.lift(self).expect("FnPtr lift failed");
let sig = ty.fn_sig(cx.tcx);
let local_def_id = cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID);
let def_id = DefId::local(CRATE_DEF_INDEX);
BareFunction(box BareFunctionDecl {
unsafety: sig.unsafety(),
generic_params: Vec::new(),
decl: (local_def_id.to_def_id(), sig).clean(cx),
decl: (def_id, sig).clean(cx),
abi: sig.abi(),
})
}
Expand Down Expand Up @@ -2255,7 +2255,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
name: None,
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
def_id: cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID).to_def_id(),
def_id: DefId::local(CRATE_DEF_INDEX),
visibility: self.vis.clean(cx),
stability: None,
deprecation: None,
Expand Down

0 comments on commit 581eafc

Please sign in to comment.