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
impl DefMap
sourcepub const ROOT: LocalModuleId = _
pub const ROOT: LocalModuleId = _
The module id of a crate or block root.
pub fn edition(&self) -> Edition
source§impl DefMap
impl DefMap
pub fn modules_for_file( &self, file_id: FileId, ) -> impl Iterator<Item = LocalModuleId> + '_
pub fn modules(&self) -> impl Iterator<Item = (LocalModuleId, &ModuleData)> + '_
pub fn derive_helpers_in_scope( &self, id: AstId<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) -> CrateId
pub fn module_id(&self, local_id: LocalModuleId) -> ModuleId
pub fn crate_root(&self) -> CrateRootModuleId
sourcepub fn root_module_id(&self) -> ModuleId
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.
sourcepub fn parent(&self) -> Option<ModuleId>
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).
sourcepub fn containing_module(&self, local_mod: LocalModuleId) -> Option<ModuleId>
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.
sourcepub fn diagnostics(&self) -> &[DefDiagnostic]
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§
source§impl Index<Idx<ModuleData>> for DefMap
impl Index<Idx<ModuleData>> for DefMap
source§type Output = ModuleData
type Output = ModuleData
source§fn index(&self, id: LocalModuleId) -> &ModuleData
fn index(&self, id: LocalModuleId) -> &ModuleData
container[index]
) operation. Read moreimpl 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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