Skip to content

Commit 581eafc

Browse files
authored
Rollup merge of rust-lang#72777 - marmeladema:rustdoc-remove-local-def-id-from-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 rust-lang#50928 r? @petrochenkov
2 parents b7f6a0b + 4b7e44f commit 581eafc

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/librustdoc/clean/inline.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_ast::ast;
66
use rustc_data_structures::fx::FxHashSet;
77
use rustc_hir as hir;
88
use rustc_hir::def::{CtorKind, DefKind, Res};
9-
use rustc_hir::def_id::DefId;
9+
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX};
1010
use rustc_hir::Mutability;
1111
use rustc_metadata::creader::LoadedMacro;
1212
use rustc_middle::ty;
@@ -454,11 +454,7 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet<DefId>)
454454
name: None,
455455
attrs: clean::Attributes::default(),
456456
source: clean::Span::empty(),
457-
def_id: cx
458-
.tcx
459-
.hir()
460-
.local_def_id_from_node_id(ast::CRATE_NODE_ID)
461-
.to_def_id(),
457+
def_id: DefId::local(CRATE_DEF_INDEX),
462458
visibility: clean::Public,
463459
stability: None,
464460
deprecation: None,

src/librustdoc/clean/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1549,11 +1549,11 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
15491549
ty::FnDef(..) | ty::FnPtr(_) => {
15501550
let ty = cx.tcx.lift(self).expect("FnPtr lift failed");
15511551
let sig = ty.fn_sig(cx.tcx);
1552-
let local_def_id = cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID);
1552+
let def_id = DefId::local(CRATE_DEF_INDEX);
15531553
BareFunction(box BareFunctionDecl {
15541554
unsafety: sig.unsafety(),
15551555
generic_params: Vec::new(),
1556-
decl: (local_def_id.to_def_id(), sig).clean(cx),
1556+
decl: (def_id, sig).clean(cx),
15571557
abi: sig.abi(),
15581558
})
15591559
}
@@ -2255,7 +2255,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
22552255
name: None,
22562256
attrs: self.attrs.clean(cx),
22572257
source: self.whence.clean(cx),
2258-
def_id: cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID).to_def_id(),
2258+
def_id: DefId::local(CRATE_DEF_INDEX),
22592259
visibility: self.vis.clean(cx),
22602260
stability: None,
22612261
deprecation: None,

0 commit comments

Comments
 (0)