@@ -87,7 +87,7 @@ Most of the time when you are working with the HIR, you will do so via
8787the ** HIR Map** , accessible in the tcx via [ ` tcx.hir() ` ] (and defined in
8888the [ ` hir::map ` ] module). The [ HIR map] contains a [ number of methods] to
8989convert between IDs of various kinds and to lookup data associated
90- with an HIR node.
90+ with a HIR node.
9191
9292[ `tcx.hir()` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.hir
9393[ `hir::map` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/index.html
@@ -96,7 +96,7 @@ with an HIR node.
9696
9797For example, if you have a [ ` DefId ` ] , and you would like to convert it
9898to a [ ` NodeId ` ] , you can use
99- [ ` tcx.hir.as_local_node_id(def_id) ` ] [ as_local_node_id ] . This returns
99+ [ ` tcx.hir() .as_local_node_id(def_id) ` ] [ as_local_node_id ] . This returns
100100an ` Option<NodeId> ` – this will be ` None ` if the def-id refers to
101101something outside of the current crate (since then it has no HIR
102102node), but otherwise returns ` Some(n) ` where ` n ` is the node-id of the
@@ -105,13 +105,13 @@ definition.
105105[ `NodeId` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/node_id/struct.NodeId.html
106106[ as_local_node_id ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.as_local_node_id
107107
108- Similarly, you can use [ ` tcx.hir.find(n) ` ] [ find ] to lookup the node for a
108+ Similarly, you can use [ ` tcx.hir() .find(n) ` ] [ find ] to lookup the node for a
109109[ ` NodeId ` ] . This returns a ` Option<Node<'tcx>> ` , where [ ` Node ` ] is an enum
110110defined in the map; by matching on this you can find out what sort of
111111node the node-id referred to and also get a pointer to the data
112112itself. Often, you know what sort of node ` n ` is – e.g. if you know
113113that ` n ` must be some HIR expression, you can do
114- [ ` tcx.hir.expect_expr(n) ` ] [ expect_expr ] , which will extract and return the
114+ [ ` tcx.hir() .expect_expr(n) ` ] [ expect_expr ] , which will extract and return the
115115[ ` &hir::Expr ` ] [ Expr ] , panicking if ` n ` is not in fact an expression.
116116
117117[ find ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.find
@@ -120,7 +120,7 @@ that `n` must be some HIR expression, you can do
120120[ Expr ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.Expr.html
121121
122122Finally, you can use the HIR map to find the parents of nodes, via
123- calls like [ ` tcx.hir.get_parent_node(n) ` ] [ get_parent_node ] .
123+ calls like [ ` tcx.hir() .get_parent_node(n) ` ] [ get_parent_node ] .
124124
125125[ get_parent_node ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.get_parent_node
126126
0 commit comments