Struct rustc_middle::hir::map::Map [−][src]
pub struct Map<'hir> {
pub(super) tcx: TyCtxt<'hir>,
}Fields
tcx: TyCtxt<'hir>Implementations
impl<'hir> Map<'hir>[src]
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 iter_local_def_id(&self) -> impl Iterator<Item = LocalDefId> + '_[src]
pub fn opt_def_kind(&self, local_def_id: LocalDefId) -> Option<DefKind>[src]
pub fn def_kind(&self, local_def_id: LocalDefId) -> DefKind[src]
pub fn find_parent_node(&self, id: HirId) -> Option<HirId>[src]
pub fn get_parent_node(&self, hir_id: HirId) -> HirId[src]
pub fn find(&self, id: HirId) -> Option<Node<'hir>>[src]
pub fn find(&self, id: HirId) -> Option<Node<'hir>>[src]Retrieves the Node corresponding to id, returning None if cannot be found.
pub fn get(&self, id: HirId) -> Node<'hir>[src]
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 item(&self, id: ItemId) -> &'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 foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'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) -> HirId[src]
pub fn body_owner(&self, _: 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]
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]
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]
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]
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 [LocalDefId]ⓘ[src]
pub fn krate_attrs(&self) -> &'hir [Attribute]ⓘ[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 visit_exported_macros_in_krate<V>(&self, visitor: &mut V) where
V: Visitor<'hir>, [src]
V: Visitor<'hir>,
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]
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]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 parent_owner_iter(
&self,
current_id: HirId
) -> ParentOwnerIterator<'_, 'hir>ⓘNotable traits for ParentOwnerIterator<'_, 'hir>
impl<'hir> Iterator for ParentOwnerIterator<'_, 'hir> type Item = (HirId, Node<'hir>);[src]
pub fn parent_owner_iter(
&self,
current_id: HirId
) -> ParentOwnerIterator<'_, 'hir>ⓘNotable traits for ParentOwnerIterator<'_, 'hir>
impl<'hir> Iterator for ParentOwnerIterator<'_, 'hir> type Item = (HirId, Node<'hir>);[src]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_inside_const_context(&self, hir_id: HirId) -> bool[src]
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]
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]
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]
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(super) fn get_module_parent_node(&self, hir_id: HirId) -> HirId[src]
pub(super) fn get_module_parent_node(&self, hir_id: HirId) -> HirId[src]Returns the HirId of id’s nearest module parent, or id itself if no
module parent is in this map.
pub fn get_if_cause(&self, hir_id: HirId) -> Option<&'hir Expr<'hir>>[src]
pub fn get_if_cause(&self, hir_id: HirId) -> Option<&'hir Expr<'hir>>[src]When on an if expression, a match arm tail expression or a match arm, give back
the enclosing if or match expression.
Used by error reporting when there’s a type error in an if or match arm caused by the expression needing to be unit.
pub fn get_enclosing_scope(&self, hir_id: HirId) -> Option<HirId>[src]
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]
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(&self, id: HirId) -> &'hir Variant<'hir>[src]
pub fn expect_foreign_item(&self, id: HirId) -> &'hir ForeignItem<'hir>[src]
pub fn expect_macro_def(&self, id: HirId) -> &'hir MacroDef<'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]
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]
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 opt_span(&self, hir_id: HirId) -> Option<Span>[src]
pub fn span_with_body(&self, hir_id: HirId) -> Span[src]
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]
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> Map<'hir> for Map<'hir>[src]
impl<'hir> Map<'hir> for Map<'hir>[src]fn find(&self, hir_id: HirId) -> Option<Node<'hir>>[src]
fn find(&self, hir_id: HirId) -> Option<Node<'hir>>[src]Retrieves the Node corresponding to id, returning None if cannot be found.
fn body(&self, id: BodyId) -> &'hir Body<'hir>[src]
fn item(&self, id: ItemId) -> &'hir Item<'hir>[src]
fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir>[src]
fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir>[src]
fn foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'hir>[src]
impl<'hir> Copy for Map<'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<'tcx, T> ArenaAllocatable<'tcx, ()> for T where
T: Copy, [src]
impl<'tcx, T> ArenaAllocatable<'tcx, ()> for T where
T: Copy, [src]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> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> MaybeResult<T> for T[src]
impl<T> MaybeResult<T> for T[src]impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn to_owned(&self) -> T[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)[src]
pub fn clone_into(&self, target: &mut T)[src]🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> WithConstness for T[src]
impl<T> WithConstness for T[src]fn with_constness(self, constness: Constness) -> ConstnessAnd<Self>[src]
fn with_const(self) -> ConstnessAnd<Self>[src]
fn without_const(self) -> ConstnessAnd<Self>[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,