Skip to content

Commit 12c55fd

Browse files
committed
doc: some HirIdification
1 parent 3b97954 commit 12c55fd

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ enum PathKind {
4949

5050
struct LinkCollector<'a, 'tcx: 'a, 'rcx: 'a> {
5151
cx: &'a DocContext<'a, 'tcx, 'rcx>,
52-
mod_ids: Vec<ast::NodeId>,
52+
mod_ids: Vec<hir::HirId>,
5353
is_nightly_build: bool,
5454
}
5555

@@ -69,7 +69,7 @@ impl<'a, 'tcx, 'rcx> LinkCollector<'a, 'tcx, 'rcx> {
6969
path_str: &str,
7070
is_val: bool,
7171
current_item: &Option<String>,
72-
parent_id: Option<ast::NodeId>)
72+
parent_id: Option<hir::HirId>)
7373
-> Result<(Def, Option<String>), ()>
7474
{
7575
let cx = self.cx;
@@ -232,11 +232,11 @@ impl<'a, 'tcx, 'rcx> DocFolder for LinkCollector<'a, 'tcx, 'rcx> {
232232
};
233233

234234
// FIXME: get the resolver to work with non-local resolve scopes.
235-
let parent_node = self.cx.as_local_node_id(item.def_id).and_then(|node_id| {
235+
let parent_node = self.cx.as_local_hir_id(item.def_id).and_then(|hir_id| {
236236
// FIXME: this fails hard for impls in non-module scope, but is necessary for the
237237
// current `resolve()` implementation.
238-
match self.cx.tcx.hir().get_module_parent_node(node_id) {
239-
id if id != node_id => Some(id),
238+
match self.cx.tcx.hir().get_module_parent_node(hir_id) {
239+
id if id != hir_id => Some(id),
240240
_ => None,
241241
}
242242
});
@@ -255,9 +255,9 @@ impl<'a, 'tcx, 'rcx> DocFolder for LinkCollector<'a, 'tcx, 'rcx> {
255255
}
256256
} else {
257257
match parent_node.or(self.mod_ids.last().cloned()) {
258-
Some(parent) if parent != ast::CRATE_NODE_ID => {
258+
Some(parent) if parent != hir::CRATE_HIR_ID => {
259259
// FIXME: can we pull the parent module's name from elsewhere?
260-
Some(self.cx.tcx.hir().name(parent).to_string())
260+
Some(self.cx.tcx.hir().name_by_hir_id(parent).to_string())
261261
}
262262
_ => None,
263263
}
@@ -274,7 +274,7 @@ impl<'a, 'tcx, 'rcx> DocFolder for LinkCollector<'a, 'tcx, 'rcx> {
274274
};
275275

276276
if item.is_mod() && item.attrs.inner_docs {
277-
self.mod_ids.push(self.cx.tcx.hir().hir_to_node_id(item_hir_id.unwrap()));
277+
self.mod_ids.push(item_hir_id.unwrap());
278278
}
279279

280280
let cx = self.cx;
@@ -421,7 +421,7 @@ impl<'a, 'tcx, 'rcx> DocFolder for LinkCollector<'a, 'tcx, 'rcx> {
421421
}
422422

423423
if item.is_mod() && !item.attrs.inner_docs {
424-
self.mod_ids.push(self.cx.tcx.hir().hir_to_node_id(item_hir_id.unwrap()));
424+
self.mod_ids.push(item_hir_id.unwrap());
425425
}
426426

427427
if item.is_mod() {

src/librustdoc/visit_ast.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct RustdocVisitor<'a, 'tcx: 'a, 'rcx: 'a> {
3131
pub module: Module,
3232
pub attrs: hir::HirVec<ast::Attribute>,
3333
pub cx: &'a core::DocContext<'a, 'tcx, 'rcx>,
34-
view_item_stack: FxHashSet<ast::NodeId>,
34+
view_item_stack: FxHashSet<hir::HirId>,
3535
inlining: bool,
3636
/// Are the current module and all of its parents public?
3737
inside_public_path: bool,
@@ -44,7 +44,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
4444
) -> RustdocVisitor<'a, 'tcx, 'rcx> {
4545
// If the root is re-exported, terminate all recursion.
4646
let mut stack = FxHashSet::default();
47-
stack.insert(ast::CRATE_NODE_ID);
47+
stack.insert(hir::CRATE_HIR_ID);
4848
RustdocVisitor {
4949
module: Module::new(None),
5050
attrs: hir::HirVec::new(),
@@ -269,13 +269,13 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
269269
om: &mut Module,
270270
please_inline: bool) -> bool {
271271

272-
fn inherits_doc_hidden(cx: &core::DocContext<'_, '_, '_>, mut node: ast::NodeId) -> bool {
272+
fn inherits_doc_hidden(cx: &core::DocContext<'_, '_, '_>, mut node: hir::HirId) -> bool {
273273
while let Some(id) = cx.tcx.hir().get_enclosing_scope(node) {
274274
node = id;
275275
if cx.tcx.hir().attrs(node).lists("doc").has_word("hidden") {
276276
return true;
277277
}
278-
if node == ast::CRATE_NODE_ID {
278+
if node == hir::CRATE_HIR_ID {
279279
break;
280280
}
281281
}
@@ -324,21 +324,21 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
324324
return false
325325
}
326326

327-
let def_node_id = match tcx.hir().as_local_node_id(def_did) {
327+
let def_hir_id = match tcx.hir().as_local_hir_id(def_did) {
328328
Some(n) => n, None => return false
329329
};
330330

331331
let is_private = !self.cx.renderinfo.borrow().access_levels.is_public(def_did);
332-
let is_hidden = inherits_doc_hidden(self.cx, def_node_id);
332+
let is_hidden = inherits_doc_hidden(self.cx, def_hir_id);
333333

334334
// Only inline if requested or if the item would otherwise be stripped.
335335
if (!please_inline && !is_private && !is_hidden) || is_no_inline {
336336
return false
337337
}
338338

339-
if !self.view_item_stack.insert(def_node_id) { return false }
339+
if !self.view_item_stack.insert(def_hir_id) { return false }
340340

341-
let ret = match tcx.hir().get(def_node_id) {
341+
let ret = match tcx.hir().get_by_hir_id(def_hir_id) {
342342
Node::Item(&hir::Item { node: hir::ItemKind::Mod(ref m), .. }) if glob => {
343343
let prev = mem::replace(&mut self.inlining, true);
344344
for i in &m.item_ids {
@@ -371,7 +371,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
371371
}
372372
_ => false,
373373
};
374-
self.view_item_stack.remove(&def_node_id);
374+
self.view_item_stack.remove(&def_hir_id);
375375
ret
376376
}
377377

0 commit comments

Comments
 (0)