Struct hir_def::body::Body

source ·
pub struct Body {
    pub exprs: Arena<Expr>,
    pub pats: Arena<Pat>,
    pub bindings: Arena<Binding>,
    pub labels: Arena<Label>,
    pub binding_owners: FxHashMap<BindingId, ExprId>,
    pub params: Box<[PatId]>,
    pub self_param: Option<BindingId>,
    pub body_expr: ExprId,
    /* private fields */
}
Expand description

The body of an item (function, const etc.).

Fields§

§exprs: Arena<Expr>§pats: Arena<Pat>§bindings: Arena<Binding>§labels: Arena<Label>§binding_owners: FxHashMap<BindingId, ExprId>

Id of the closure/coroutine that owns the corresponding binding. If a binding is owned by the top level expression, it will not be listed in here.

§params: Box<[PatId]>

The patterns for the function’s parameters. While the parameter types are part of the function signature, the patterns are not (they don’t change the external type of the function).

If this Body is for the body of a constant, this will just be empty.

§self_param: Option<BindingId>§body_expr: ExprId

The ExprId of the actual body expression.

Implementations§

source§

impl Body

source

pub fn blocks<'a>( &'a self, db: &'a dyn DefDatabase ) -> impl Iterator<Item = (BlockId, Arc<DefMap>)> + '_

Returns an iterator over all block expressions in this body that define inner items.

source

pub fn pretty_print(&self, db: &dyn DefDatabase, owner: DefWithBodyId) -> String

source

pub fn pretty_print_expr( &self, db: &dyn DefDatabase, owner: DefWithBodyId, expr: ExprId ) -> String

source

pub fn walk_bindings_in_pat(&self, pat_id: PatId, f: impl FnMut(BindingId))

source

pub fn walk_pats_shallow(&self, pat_id: PatId, f: impl FnMut(PatId))

source

pub fn walk_pats(&self, pat_id: PatId, f: &mut impl FnMut(PatId))

source

pub fn is_binding_upvar(&self, binding: BindingId, relative_to: ExprId) -> bool

Trait Implementations§

source§

impl Debug for Body

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Body

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Index<Idx<Binding>> for Body

§

type Output = Binding

The returned type after indexing.
source§

fn index(&self, b: BindingId) -> &Binding

Performs the indexing (container[index]) operation. Read more
source§

impl Index<Idx<Expr>> for Body

§

type Output = Expr

The returned type after indexing.
source§

fn index(&self, expr: ExprId) -> &Expr

Performs the indexing (container[index]) operation. Read more
source§

impl Index<Idx<Label>> for Body

§

type Output = Label

The returned type after indexing.
source§

fn index(&self, label: LabelId) -> &Label

Performs the indexing (container[index]) operation. Read more
source§

impl Index<Idx<Pat>> for Body

§

type Output = Pat

The returned type after indexing.
source§

fn index(&self, pat: PatId) -> &Pat

Performs the indexing (container[index]) operation. Read more
source§

impl PartialEq for Body

source§

fn eq(&self, other: &Body) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Body

source§

impl StructuralPartialEq for Body

Auto Trait Implementations§

§

impl Freeze for Body

§

impl RefUnwindSafe for Body

§

impl Send for Body

§

impl Sync for Body

§

impl Unpin for Body

§

impl UnwindSafe for Body

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send> for T
where T: Any + Send,

§

fn into_box(self) -> Box<dyn Any + Send>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send + Sync> for T
where T: Any + Send + Sync,

§

fn into_box(self) -> Box<dyn Any + Send + Sync>

Convert self into the appropriate boxed form.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more