[−][src]Struct rustc_middle::hir::map::Map
Fields
tcx: TyCtxt<'hir>Implementations
impl<'hir> Map<'hir>[src]
pub fn krate(&self) -> &'hir Crate<'hir>[src]
pub fn definitions(&self) -> &'hir Definitions[src]
pub fn def_key(&self, def_id: LocalDefId) -> DefKey[src]
pub fn def_path_from_hir_id(&self, id: HirId) -> Option<DefPath>[src]
pub fn def_path(&self, def_id: LocalDefId) -> DefPath[src]
pub fn local_def_id(&self, hir_id: HirId) -> LocalDefId[src]
pub fn opt_local_def_id(&self, hir_id: HirId) -> Option<LocalDefId>[src]
pub fn local_def_id_to_hir_id(&self, def_id: LocalDefId) -> HirId[src]
pub fn opt_local_def_id_to_hir_id(&self, def_id: LocalDefId) -> Option<HirId>[src]
pub fn def_kind(&self, local_def_id: LocalDefId) -> DefKind[src]
pub(in hir::map) fn find_entry(
&self,
id: HirId
) -> Option<Entry<'hir>>[src]
&self,
id: HirId
) -> Option<Entry<'hir>>
pub(in hir::map) fn get_entry(
&self,
id: HirId
) -> Entry<'hir>[src]
&self,
id: HirId
) -> Entry<'hir>
pub fn item(&self, id: HirId) -> &'hir Item<'hir>[src]
pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir>[src]
pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir>[src]
pub fn body(&self, id: BodyId) -> &'hir Body<'hir>[src]
pub fn fn_decl_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnDecl<'hir>>[src]
pub fn fn_sig_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnSig<'hir>>[src]
pub fn enclosing_body_owner(&self, hir_id: HirId) -> HirId[src]
pub fn body_owner(&self, BodyId { hir_id: hir_id }: BodyId) -> HirId[src]
Returns the HirId that corresponds to the definition of
which this is the body of, i.e., a fn, const or static
item (possibly associated), a closure, or a hir::AnonConst.
pub fn body_owner_def_id(&self, id: BodyId) -> LocalDefId[src]
pub fn maybe_body_owned_by(&self, hir_id: HirId) -> Option<BodyId>[src]
Given a HirId, returns the BodyId associated with it,
if the node is a body owner, otherwise returns None.
pub fn body_owned_by(&self, id: HirId) -> BodyId[src]
Given a body owner's id, returns the BodyId associated with it.
pub fn body_param_names(&self, id: BodyId) -> impl Iterator<Item = Ident> + 'hir[src]
pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind[src]
Returns the BodyOwnerKind of this LocalDefId.
Panics if LocalDefId does not have an associated body.
pub fn body_const_context(&self, did: LocalDefId) -> Option<ConstContext>[src]
Returns the ConstContext of the body associated with this LocalDefId.
Panics if LocalDefId does not have an associated body.
pub fn ty_param_owner(&self, id: HirId) -> HirId[src]
pub fn ty_param_name(&self, id: HirId) -> Symbol[src]
pub fn trait_impls(&self, trait_did: DefId) -> &'hir [HirId][src]
pub fn krate_attrs(&self) -> &'hir [Attribute][src]
Gets the attributes on the crate. This is preferable to
invoking krate.attrs because it registers a tighter
dep-graph access.
pub fn get_module(&self, module: LocalDefId) -> (&'hir Mod<'hir>, Span, HirId)[src]
pub fn visit_item_likes_in_module<V>(&self, module: LocalDefId, visitor: &mut V) where
V: ItemLikeVisitor<'hir>, [src]
V: ItemLikeVisitor<'hir>,
pub fn get(&self, id: HirId) -> Node<'hir>[src]
Retrieves the Node corresponding to id, panicking if it cannot be found.
pub fn get_if_local(&self, id: DefId) -> Option<Node<'hir>>[src]
pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics<'hir>>[src]
pub fn find(&self, hir_id: HirId) -> Option<Node<'hir>>[src]
Retrieves the Node corresponding to id, returning None if cannot be found.
pub fn get_parent_node(&self, hir_id: HirId) -> HirId[src]
Similar to get_parent; returns the parent HIR Id, or just hir_id if there
is no parent. Note that the parent may be CRATE_HIR_ID, which is not itself
present in the map, so passing the return value of get_parent_node to
get may in fact panic.
This function returns the immediate parent in the HIR, whereas get_parent
returns the enclosing item. Note that this might not be the actual parent
node in the HIR -- some kinds of nodes are not in the map and these will
never appear as the parent node. Thus, you can always walk the parent nodes
from a node to the root of the HIR (unless you get back the same ID here,
which can happen if the ID is not in the map itself or is just weird).
pub fn parent_iter(&self, current_id: HirId) -> ParentHirIterator<'_, 'hir>ⓘNotable traits for ParentHirIterator<'_, 'hir>
impl<'hir, '_> Iterator for ParentHirIterator<'_, 'hir> type Item = (HirId, Node<'hir>);[src]
Notable traits for ParentHirIterator<'_, 'hir>
impl<'hir, '_> Iterator for ParentHirIterator<'_, 'hir> type Item = (HirId, Node<'hir>);Returns an iterator for the nodes in the ancestor tree of the current_id
until the crate root is reached. Prefer this over your own loop using get_parent_node.
pub fn is_argument(&self, id: HirId) -> bool[src]
Checks if the node is an argument. An argument is a local variable whose immediate parent is an item or a closure.
pub fn is_inside_const_context(&self, hir_id: HirId) -> bool[src]
Whether the expression pointed at by hir_id belongs to a const evaluation context.
Used exclusively for diagnostics, to avoid suggestion function calls.
pub fn is_hir_id_module(&self, hir_id: HirId) -> bool[src]
Whether hir_id corresponds to a mod or a crate.
pub fn get_return_block(&self, id: HirId) -> Option<HirId>[src]
Retrieves the HirId 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 // If `get_return_block` gets passed the `id` corresponding } else { // to this, it will return `foo`'s `HirId`. false } }
fn foo(x: usize) -> bool { loop { true // If `get_return_block` gets passed the `id` corresponding } // to this, it will return `None`. false }
pub fn get_parent_item(&self, hir_id: HirId) -> HirId[src]
Retrieves the HirId 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 HIR which is recorded by the map and is an item, either an item
in a module, trait, or impl.
pub(in hir) fn get_module_parent_node(
&self,
hir_id: HirId
) -> HirId[src]
&self,
hir_id: HirId
) -> HirId
Returns the HirId of id's nearest module parent, or id itself if no
module parent is in this map.
pub fn get_match_if_cause(&self, hir_id: HirId) -> Option<&'hir Expr<'hir>>[src]
When on a match arm tail expression or on a match arm, give back the enclosing match
expression.
Used by error reporting when there's a type error in a match arm caused by the match
expression needing to be unit.
pub fn get_enclosing_scope(&self, hir_id: HirId) -> Option<HirId>[src]
Returns the nearest enclosing scope. A scope is roughly an item or block.
pub fn get_defining_scope(&self, id: HirId) -> HirId[src]
Returns the defining scope for an opaque type definition.
pub fn get_parent_did(&self, id: HirId) -> LocalDefId[src]
pub fn get_foreign_abi(&self, hir_id: HirId) -> Abi[src]
pub fn expect_item(&self, id: HirId) -> &'hir Item<'hir>[src]
pub fn expect_impl_item(&self, id: HirId) -> &'hir ImplItem<'hir>[src]
pub fn expect_trait_item(&self, id: HirId) -> &'hir TraitItem<'hir>[src]
pub fn expect_variant_data(&self, id: HirId) -> &'hir VariantData<'hir>[src]
pub fn expect_variant(&self, id: HirId) -> &'hir Variant<'hir>[src]
pub fn expect_foreign_item(&self, id: HirId) -> &'hir ForeignItem<'hir>[src]
pub fn expect_expr(&self, id: HirId) -> &'hir Expr<'hir>[src]
pub fn opt_name(&self, id: HirId) -> Option<Symbol>[src]
pub fn name(&self, id: HirId) -> Symbol[src]
pub fn attrs(&self, id: HirId) -> &'hir [Attribute][src]
Given a node ID, gets a list of attributes associated with the AST corresponding to the node-ID.
pub fn span(&self, hir_id: HirId) -> Span[src]
Gets the span of the definition of the specified HIR node.
This is used by tcx.get_span
pub fn span_with_body(&self, hir_id: HirId) -> Span[src]
Like hir.span(), but includes the body of function items
(instead of just the function header)
pub fn span_if_local(&self, id: DefId) -> Option<Span>[src]
pub fn res_span(&self, res: Res) -> Option<Span>[src]
pub fn node_to_string(&self, id: HirId) -> String[src]
Get a representation of this id for debugging purposes.
NOTE: Do NOT use this in diagnostics!
Trait Implementations
impl<'hir> Clone for Map<'hir>[src]
impl<'hir> Copy for Map<'hir>[src]
impl<'hir> Map<'hir> for Map<'hir>[src]
pub fn find(&self, hir_id: HirId) -> Option<Node<'hir>>[src]
pub fn body(&self, id: BodyId) -> &'hir Body<'hir>[src]
pub fn item(&self, id: HirId) -> &'hir Item<'hir>[src]
pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir>[src]
pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir>[src]
Auto Trait Implementations
impl<'hir> !RefUnwindSafe for Map<'hir>
impl<'hir> !Send for Map<'hir>
impl<'hir> !Sync for Map<'hir>
impl<'hir> Unpin for Map<'hir>
impl<'hir> !UnwindSafe for Map<'hir>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<'tcx, T> ArenaAllocatable<'tcx, ()> for T where
T: Copy, [src]
T: Copy,
pub fn allocate_on(Self, &'a Arena<'tcx>) -> &'a mut T[src]
pub fn allocate_from_iter(
&'a Arena<'tcx>,
impl IntoIterator<Item = T>
) -> &'a mut [T][src]
&'a Arena<'tcx>,
impl IntoIterator<Item = T>
) -> &'a mut [T]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> MaybeResult<T> for T[src]
type Error = !
pub fn from(Result<T, <T as MaybeResult<T>>::Error>) -> T[src]
pub fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.