Struct hir_def::nameres::DefMap

source ·
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§

source§

impl DefMap

source

pub const ROOT: LocalModuleId = _

The module id of a crate or block root.

source§

impl DefMap

source

pub fn modules_for_file( &self, file_id: FileId ) -> impl Iterator<Item = LocalModuleId> + '_

source

pub fn modules(&self) -> impl Iterator<Item = (LocalModuleId, &ModuleData)> + '_

source

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

source

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

source

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

source

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

source

pub fn is_rustc_coherence_is_core(&self) -> bool

source

pub fn is_no_std(&self) -> bool

source

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

source

pub fn proc_macro_loading_error(&self) -> Option<&str>

source

pub fn krate(&self) -> CrateId

source

pub fn module_id(&self, local_id: LocalModuleId) -> ModuleId

source

pub fn crate_root(&self) -> CrateRootModuleId

source

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.

source

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).

source

pub fn containing_module(&self, local_mod: LocalModuleId) -> 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.

source

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

Get a reference to the def map’s diagnostics.

source

pub fn recursion_limit(&self) -> u32

source

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

source

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

Trait Implementations§

source§

impl Debug for DefMap

source§

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

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

impl Index<Idx<ModuleData>> for DefMap

§

type Output = ModuleData

The returned type after indexing.
source§

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

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

impl PartialEq for DefMap

source§

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

source§

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