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,
    pub types: TypesMap,
    /* 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.

§types: TypesMap

Implementations§

source§

impl Body

source

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

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, edition: Edition, ) -> String

source

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

source

pub fn pretty_print_pat( &self, db: &dyn DefDatabase, owner: DefWithBodyId, pat: PatId, oneline: bool, edition: Edition, ) -> 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

source

pub fn walk_child_exprs(&self, expr_id: ExprId, f: impl FnMut(ExprId))

source

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

source

pub fn expr_path_hygiene(&self, expr: ExprId) -> HygieneId

source

pub fn pat_path_hygiene(&self, pat: PatId) -> HygieneId

source

pub fn expr_or_pat_path_hygiene(&self, id: ExprOrPatId) -> HygieneId

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

source§

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

source§

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

source§

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

source§

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 Index<Idx<TypeRef>> for Body

source§

type Output = TypeRef

The returned type after indexing.
source§

fn index(&self, b: TypeRefId) -> &TypeRef

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

impl PartialEq for Body

source§

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

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

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

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 + Sync + Send> for T
where T: Any + Send + Sync,

§

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

Convert self into the appropriate boxed form.
source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

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

source§

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>,

source§

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