Struct hir::DefMap

pub struct DefMap {
    pub modules: Arena<ModuleData>,
    /* private fields */
}
Expand description

Contains the results of (early) name resolution.

A DefMap stores the module tree and the definitions that are in scope in every module after item-level macros have been expanded.

Every crate has a primary DefMap whose root is the crate’s main file (main.rs/lib.rs), computed by the crate_def_map query. Additionally, every block expression introduces the opportunity to write arbitrary item and module hierarchies, and thus gets its own DefMap that is computed by the block_def_map query.

Fields§

§modules: Arena<ModuleData>

The modules and their data declared in this crate.

Implementations§

§

impl DefMap

pub const ROOT: Idx<ModuleData> = _

The module id of a crate or block root.

pub fn edition(&self) -> Edition

§

impl DefMap

pub fn modules_for_file( &self, file_id: FileId, ) -> impl Iterator<Item = Idx<ModuleData>>

pub fn modules(&self) -> impl Iterator<Item = (Idx<ModuleData>, &ModuleData)>

pub fn derive_helpers_in_scope( &self, id: InFileWrapper<HirFileId, FileAstId<Adt>>, ) -> Option<&[(Name, MacroId, MacroCallId)]>

pub fn registered_tools(&self) -> &[Symbol]

pub fn registered_attrs(&self) -> &[Symbol]

pub fn is_unstable_feature_enabled(&self, feature: &Symbol) -> bool

pub fn is_rustc_coherence_is_core(&self) -> bool

pub fn is_no_std(&self) -> bool

pub fn fn_as_proc_macro(&self, id: FunctionId) -> Option<ProcMacroId>

pub fn krate(&self) -> Idx<CrateData>

pub fn module_id(&self, local_id: Idx<ModuleData>) -> ModuleId

pub fn crate_root(&self) -> CrateRootModuleId

pub fn root_module_id(&self) -> ModuleId

This is the same as Self::crate_root for crate def maps, but for block def maps, it returns the root block module.

pub fn parent(&self) -> Option<ModuleId>

If this DefMap is for a block expression, returns the module containing the block (which might again be a block, or a module inside a block).

pub fn containing_module(&self, local_mod: Idx<ModuleData>) -> Option<ModuleId>

Returns the module containing local_mod, either the parent mod, or the module (or block) containing the block, if self corresponds to a block expression.

pub fn diagnostics(&self) -> &[DefDiagnostic]

Get a reference to the def map’s diagnostics.

pub fn recursion_limit(&self) -> u32

pub fn dump(&self, db: &dyn DefDatabase) -> String

pub fn dump_block_scopes(&self, db: &dyn DefDatabase) -> String

Trait Implementations§

§

impl Debug for DefMap

§

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

Formats the value using the given formatter. Read more
§

impl Index<Idx<ModuleData>> for DefMap

§

type Output = ModuleData

The returned type after indexing.
§

fn index(&self, id: Idx<ModuleData>) -> &ModuleData

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

impl PartialEq for DefMap

§

fn eq(&self, other: &DefMap) -> 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.
§

impl Eq for DefMap

§

impl StructuralPartialEq for DefMap

Auto Trait Implementations§

§

impl Freeze for DefMap

§

impl RefUnwindSafe for DefMap

§

impl Send for DefMap

§

impl Sync for DefMap

§

impl Unpin for DefMap

§

impl UnwindSafe for DefMap

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<T> Cast for T

§

fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U
where Self: CastTo<U>, U: HasInterner,

Cast a value to type U using CastTo.
§

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
§

impl<'a, T> Captures<'a> for T
where T: ?Sized,