Struct rustc::hir::map::Map
[−]
[src]
pub struct Map<'hir> { pub forest: &'hir Forest, pub dep_graph: DepGraph, // some fields omitted }
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Represents a mapping from Node IDs to AST elements and their parent Node IDs
Fields
forest: &'hir Forest
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
The backing storage for all the AST nodes.
dep_graph: DepGraph
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Same as the dep_graph in forest, just available with one fewer deref. This is a gratuitous micro-optimization.
Methods
impl<'hir> Map<'hir>
[src]
pub fn read(&self, id: NodeId)
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Registers a read in the dependency graph of the AST node with
the given id
. This needs to be called each time a public
function returns the HIR for a node -- in other words, when it
"reveals" the content of a node to the caller (who might not
otherwise have had access to those contents, and hence needs a
read recorded). If the function just returns a DefId or
NodeId, no actual content was returned, so no read is needed.
pub fn definitions(&self) -> &'hir Definitions
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn def_key(&self, def_id: DefId) -> DefKey
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn def_path_from_id(&self, id: NodeId) -> Option<DefPath>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn def_path(&self, def_id: DefId) -> DefPath
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn local_def_id(&self, node: NodeId) -> DefId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn opt_local_def_id(&self, node: NodeId) -> Option<DefId>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn as_local_node_id(&self, def_id: DefId) -> Option<NodeId>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn hir_to_node_id(&self, hir_id: HirId) -> NodeId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn node_to_hir_id(&self, node_id: NodeId) -> HirId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn def_index_to_hir_id(&self, def_index: DefIndex) -> HirId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn def_index_to_node_id(&self, def_index: DefIndex) -> NodeId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn local_def_id_to_hir_id(&self, def_id: LocalDefId) -> HirId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn local_def_id_to_node_id(&self, def_id: LocalDefId) -> NodeId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn krate(&self) -> &'hir Crate
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn body(&self, id: BodyId) -> &'hir Body
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn body_owner(&self, BodyId { node_id: node_id }: BodyId) -> NodeId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Returns the NodeId
that corresponds to the definition of
which this is the body of, i.e. a fn
, const
or static
item (possibly associated), or a closure, or the body itself
for embedded constant expressions (e.g. N
in [T; N]
).
pub fn body_owner_def_id(&self, id: BodyId) -> DefId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn maybe_body_owned_by(&self, id: NodeId) -> Option<BodyId>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Given a node id, returns the BodyId
associated with it,
if the node is a body owner, otherwise returns None
.
pub fn body_owned_by(&self, id: NodeId) -> BodyId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Given a body owner's id, returns the BodyId
associated with it.
pub fn body_owner_kind(&self, id: NodeId) -> BodyOwnerKind
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn ty_param_owner(&self, id: NodeId) -> NodeId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn ty_param_name(&self, id: NodeId) -> Name
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn trait_impls(&self, trait_did: DefId) -> &'hir [NodeId]
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn trait_auto_impl(&self, trait_did: DefId) -> Option<NodeId>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn trait_is_auto(&self, trait_did: DefId) -> bool
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn krate_attrs(&self) -> &'hir [Attribute]
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Get the attributes on the krate. This is preferable to
invoking krate.attrs
because it registers a tighter
dep-graph access.
pub fn get(&self, id: NodeId) -> Node<'hir>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Retrieve the Node corresponding to id
, panicking if it cannot
be found.
pub fn get_if_local(&self, id: DefId) -> Option<Node<'hir>>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn find(&self, id: NodeId) -> Option<Node<'hir>>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Retrieve the Node corresponding to id
, returning None if
cannot be found.
pub fn get_parent_node(&self, id: NodeId) -> NodeId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Similar to get_parent, returns the parent node id or id if there is no parent. Note that the parent may be CRATE_NODE_ID, which is not itself present in the map -- so passing the return value of get_parent_node to get may actually panic. This function returns the immediate parent in the AST, whereas get_parent returns the enclosing item. Note that this might not be the actual parent node in the AST - some kinds of nodes are not in the map and these will never appear as the parent_node. So you can always walk the parent_nodes from a node to the root of the ast (unless you get the same id back here that can happen if the id is not in the map itself or is just weird).
pub fn is_argument(&self, id: NodeId) -> bool
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Check if the node is an argument. An argument is a local variable whose immediate parent is an item or a closure.
pub fn get_return_block(&self, id: NodeId) -> Option<NodeId>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Retrieve the NodeId for id
's enclosing method, unless there's a
while
or loop
before reaching it, as block tail returns are not
available in them.
fn foo(x: usize) -> bool { if x == 1 { true // `get_return_block` gets passed the `id` corresponding } else { // to this, it will return `foo`'s `NodeId`. false } }
fn foo(x: usize) -> bool { loop { true // `get_return_block` gets passed the `id` corresponding } // to this, it will return `None`. false }
pub fn get_parent(&self, id: NodeId) -> NodeId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Retrieve the NodeId for id
's parent item, or id
itself if no
parent item is in this map. The "parent item" is the closest parent node
in the AST which is recorded by the map and is an item, either an item
in a module, trait, or impl.
pub fn get_module_parent(&self, id: NodeId) -> DefId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Returns the NodeId of id
's nearest module parent, or id
itself if no
module parent is in this map.
pub fn get_enclosing_scope(&self, id: NodeId) -> Option<NodeId>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Returns the nearest enclosing scope. A scope is an item or block. FIXME it is not clear to me that all items qualify as scopes - statics and associated types probably shouldn't, for example. Behavior in this regard should be expected to be highly unstable.
pub fn get_parent_did(&self, id: NodeId) -> DefId
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn get_foreign_abi(&self, id: NodeId) -> Abi
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn expect_item(&self, id: NodeId) -> &'hir Item
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn expect_impl_item(&self, id: NodeId) -> &'hir ImplItem
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn expect_trait_item(&self, id: NodeId) -> &'hir TraitItem
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn expect_variant_data(&self, id: NodeId) -> &'hir VariantData
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn expect_variant(&self, id: NodeId) -> &'hir Variant
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn expect_foreign_item(&self, id: NodeId) -> &'hir ForeignItem
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn expect_expr(&self, id: NodeId) -> &'hir Expr
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn get_inlined_body_untracked(&self, def_id: DefId) -> Option<&'hir Body>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn intern_inlined_body(&self, def_id: DefId, body: Body) -> &'hir Body
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn name(&self, id: NodeId) -> Name
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Returns the name associated with the given NodeId's AST.
pub fn attrs(&self, id: NodeId) -> &'hir [Attribute]
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Given a node ID, get a list of attributes associated with the AST corresponding to the Node ID
ⓘImportant traits for NodesMatchingSuffix<'a, 'hir>pub fn nodes_matching_suffix<'a>(
&'a self,
parts: &'a [String]
) -> NodesMatchingSuffix<'a, 'hir>
[src]
&'a self,
parts: &'a [String]
) -> NodesMatchingSuffix<'a, 'hir>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Returns an iterator that yields the node id's with paths that
match parts
. (Requires parts
is non-empty.)
For example, if given parts
equal to ["bar", "quux"]
, then
the iterator will produce node id's for items with paths
such as foo::bar::quux
, bar::quux
, other::bar::quux
, and
any other such items it can find in the map.
pub fn span(&self, id: NodeId) -> Span
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn span_if_local(&self, id: DefId) -> Option<Span>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn node_to_string(&self, id: NodeId) -> String
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn node_to_user_string(&self, id: NodeId) -> String
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn node_to_pretty_string(&self, id: NodeId) -> String
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Trait Implementations
impl<'hir> Clone for Map<'hir>
[src]
fn clone(&self) -> Map<'hir>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'hir> PpAnn for Map<'hir>
[src]
Identical to the PpAnn
implementation for hir::Crate
,
except it avoids creating a dependency on the whole crate.
fn nested(&self, state: &mut State, nested: Nested) -> Result<()>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn pre(&self, _state: &mut State, _node: AnnNode) -> Result<()>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn post(&self, _state: &mut State, _node: AnnNode) -> Result<()>
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?