Struct rustc_middle::hir::map::Map[][src]

pub struct Map<'hir> {
    pub(super) tcx: TyCtxt<'hir>,
}

Fields

tcx: TyCtxt<'hir>

Implementations

Retrieves the Node corresponding to id, returning None if cannot be found.

Retrieves the Node corresponding to id, panicking if it cannot be found.

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.

Given a HirId, returns the BodyId associated with it, if the node is a body owner, otherwise returns None.

Given a body owner’s id, returns the BodyId associated with it.

Returns the BodyOwnerKind of this LocalDefId.

Panics if LocalDefId does not have an associated body.

Returns the ConstContext of the body associated with this LocalDefId.

Panics if LocalDefId does not have an associated body.

This should only be used for determining the context of a body, a return value of Some does not always suggest that the owner of the body is const.

Returns an iterator of the DefIds for all body-owners in this crate. If you would prefer to iterate over the bodies themselves, you can do self.hir().krate().body_ids.iter().

Gets the attributes on the crate. This is preferable to invoking krate.attrs because it registers a tighter dep-graph access.

Walks the contents of a crate. See also Crate::visit_all_items.

Walks the attributes in a crate.

Visits all items in the crate in some deterministic (but unspecified) order. If you just need to process every item, but don’t care about nesting, this method is the best choice.

If you do care about nesting – usually because your algorithm follows lexical scoping rules – then you want a different approach. You should override visit_nested_item in your visitor and then call intravisit::walk_crate instead.

A parallel version of visit_all_item_likes.

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.

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.

Checks if the node is left-hand side of an assignment.

Whether the expression pointed at by hir_id belongs to a const evaluation context. Used exclusively for diagnostics, to avoid suggestion function calls.

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
}

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.

Returns the HirId of id’s nearest module parent, or id itself if no module parent is in this map.

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.

Returns the nearest enclosing scope. A scope is roughly an item or block.

Returns the defining scope for an opaque type definition.

Given a node ID, gets a list of attributes associated with the AST corresponding to the node-ID.

Gets the span of the definition of the specified HIR node. This is used by tcx.get_span

Like hir.span(), but includes the body of function items (instead of just the function header)

Get a representation of this id for debugging purposes. NOTE: Do NOT use this in diagnostics!

Returns the HirId of N in struct Foo<const N: usize = { ... }> when called with the HirId for the { ... } anon const

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Retrieves the Node corresponding to id, returning None if cannot be found.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Layout

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 8 bytes