@@ -87,7 +87,7 @@ Most of the time when you are working with the HIR, you will do so via
87
87
the ** HIR Map** , accessible in the tcx via [ ` tcx.hir() ` ] (and defined in
88
88
the [ ` hir::map ` ] module). The [ HIR map] contains a [ number of methods] to
89
89
convert between IDs of various kinds and to lookup data associated
90
- with an HIR node.
90
+ with a HIR node.
91
91
92
92
[ `tcx.hir()` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.hir
93
93
[ `hir::map` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/index.html
@@ -96,7 +96,7 @@ with an HIR node.
96
96
97
97
For example, if you have a [ ` DefId ` ] , and you would like to convert it
98
98
to 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
100
100
an ` Option<NodeId> ` – this will be ` None ` if the def-id refers to
101
101
something outside of the current crate (since then it has no HIR
102
102
node), but otherwise returns ` Some(n) ` where ` n ` is the node-id of the
@@ -105,13 +105,13 @@ definition.
105
105
[ `NodeId` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/node_id/struct.NodeId.html
106
106
[ as_local_node_id ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.as_local_node_id
107
107
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
109
109
[ ` NodeId ` ] . This returns a ` Option<Node<'tcx>> ` , where [ ` Node ` ] is an enum
110
110
defined in the map; by matching on this you can find out what sort of
111
111
node the node-id referred to and also get a pointer to the data
112
112
itself. Often, you know what sort of node ` n ` is – e.g. if you know
113
113
that ` 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
115
115
[ ` &hir::Expr ` ] [ Expr ] , panicking if ` n ` is not in fact an expression.
116
116
117
117
[ 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
120
120
[ Expr ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.Expr.html
121
121
122
122
Finally, 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 ] .
124
124
125
125
[ get_parent_node ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.get_parent_node
126
126
0 commit comments