Struct ra_ap_hir_def::nameres::DefMap
source · pub struct DefMap { /* 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.
Implementations§
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) -> &[SmolStr]
pub fn registered_attrs(&self) -> &[SmolStr]
pub fn is_unstable_feature_enabled(&self, feature: &str) -> bool
pub fn root(&self) -> LocalModuleId
pub fn fn_as_proc_macro(&self, id: FunctionId) -> Option<ProcMacroId>
pub fn proc_macro_loading_error(&self) -> Option<&str>
pub fn module_id(&self, local_id: LocalModuleId) -> ModuleId
sourcepub fn with_ancestor_maps<T>(
&self,
db: &dyn DefDatabase,
local_mod: LocalModuleId,
f: &mut dyn FnMut(&DefMap, LocalModuleId) -> Option<T>
) -> Option<T>
pub fn with_ancestor_maps<T>(
&self,
db: &dyn DefDatabase,
local_mod: LocalModuleId,
f: &mut dyn FnMut(&DefMap, LocalModuleId) -> Option<T>
) -> Option<T>
Ascends the DefMap
hierarchy and calls f
with every DefMap
and containing module.
If f
returns Some(val)
, iteration is stopped and Some(val)
is returned. If f
returns
None
, iteration continues.
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 containing
the block, if self
corresponds to a block expression.
pub fn dump(&self, db: &dyn DefDatabase) -> String
pub fn dump_block_scopes(&self, db: &dyn DefDatabase) -> String
sourcepub fn diagnostics(&self) -> &[DefDiagnostic]
pub fn diagnostics(&self) -> &[DefDiagnostic]
Get a reference to the def map’s diagnostics.
pub fn recursion_limit(&self) -> Option<u32>
Trait Implementations§
source§impl Index<Idx<ModuleData>> for DefMap
impl Index<Idx<ModuleData>> for DefMap
§type Output = ModuleData
type Output = ModuleData
source§fn index(&self, id: LocalModuleId) -> &ModuleData
fn index(&self, id: LocalModuleId) -> &ModuleData
container[index]
) operation. Read moresource§impl PartialEq<DefMap> for DefMap
impl PartialEq<DefMap> for DefMap
impl Eq for DefMap
impl StructuralEq for DefMap
impl StructuralPartialEq for DefMap
Auto Trait Implementations§
impl RefUnwindSafe for DefMap
impl Send for DefMap
impl Sync for DefMap
impl Unpin for DefMap
impl UnwindSafe for DefMap
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.