pub struct ItemScope {Show 19 fields
types: IndexMap<Name, TypesItem, FxBuildHasher>,
values: IndexMap<Name, ValuesItem, FxBuildHasher>,
macros: IndexMap<Name, MacrosItem, FxBuildHasher>,
unresolved: FxHashSet<Name>,
declarations: ThinVec<ModuleDefId>,
impls: ThinVec<(ImplId, bool)>,
builtin_derive_impls: ThinVec<BuiltinDeriveImplId>,
extern_blocks: ThinVec<ExternBlockId>,
unnamed_consts: ThinVec<ConstId>,
unnamed_trait_imports: ThinVec<(TraitId, Item<()>)>,
use_imports_types: FxHashMap<ImportOrExternCrate, ImportOrDef>,
use_imports_values: FxHashMap<ImportOrGlob, ImportOrDef>,
use_imports_macros: FxHashMap<ImportOrExternCrate, ImportOrDef>,
use_decls: ThinVec<UseId>,
extern_crate_decls: ThinVec<ExternCrateId>,
legacy_macros: FxHashMap<Name, SmallVec<[MacroId; 1]>>,
attr_macros: FxHashMap<AstId<Item>, MacroCallId>,
macro_invocations: FxHashMap<AstId<MacroCall>, MacroCallId>,
derive_macros: FxHashMap<AstId<Adt>, SmallVec<[DeriveMacroInvocation; 1]>>,
}Fields§
§types: IndexMap<Name, TypesItem, FxBuildHasher>Defs visible in this scope. This includes declarations, but also
imports. The imports belong to this module and can be resolved by using them on
the use_imports_* fields.
values: IndexMap<Name, ValuesItem, FxBuildHasher>§macros: IndexMap<Name, MacrosItem, FxBuildHasher>§unresolved: FxHashSet<Name>§declarations: ThinVec<ModuleDefId>The defs declared in this scope. Each def has a single scope where it is declared.
impls: ThinVec<(ImplId, bool)>§builtin_derive_impls: ThinVec<BuiltinDeriveImplId>§extern_blocks: ThinVec<ExternBlockId>§unnamed_consts: ThinVec<ConstId>§unnamed_trait_imports: ThinVec<(TraitId, Item<()>)>Traits imported via use Trait as _;.
use_imports_types: FxHashMap<ImportOrExternCrate, ImportOrDef>§use_imports_values: FxHashMap<ImportOrGlob, ImportOrDef>§use_imports_macros: FxHashMap<ImportOrExternCrate, ImportOrDef>§use_decls: ThinVec<UseId>§extern_crate_decls: ThinVec<ExternCrateId>§legacy_macros: FxHashMap<Name, SmallVec<[MacroId; 1]>>Macros visible in current module in legacy textual scope
For macros invoked by an unqualified identifier like bar!(), legacy_macros will be searched in first.
If it yields no result, then it turns to module scoped macros.
It macros with name qualified with a path like crate::foo::bar!(), legacy_macros will be skipped,
and only normal scoped macros will be searched in.
Note that this automatically inherit macros defined textually before the definition of module itself.
Module scoped macros will be inserted into items instead of here.
attr_macros: FxHashMap<AstId<Item>, MacroCallId>The attribute macro invocations in this scope.
macro_invocations: FxHashMap<AstId<MacroCall>, MacroCallId>The macro invocations in this scope.
derive_macros: FxHashMap<AstId<Adt>, SmallVec<[DeriveMacroInvocation; 1]>>The derive macro invocations in this scope, keyed by the owner item over the actual derive attributes paired with the derive macro invocations for the specific attribute.
Implementations§
Source§impl ItemScope
Legacy macros can only be accessed through special methods like get_legacy_macros.
Other methods will only resolve values, types and module scoped macros only.
impl ItemScope
Legacy macros can only be accessed through special methods like get_legacy_macros.
Other methods will only resolve values, types and module scoped macros only.
pub fn entries(&self) -> impl Iterator<Item = (&Name, PerNs)> + '_
pub fn values( &self, ) -> impl Iterator<Item = (&Name, Item<ModuleDefId, ImportOrGlob>)> + '_
pub fn types( &self, ) -> impl Iterator<Item = (&Name, Item<ModuleDefId, ImportOrExternCrate>)> + '_
pub fn macros( &self, ) -> impl Iterator<Item = (&Name, Item<MacroId, ImportOrExternCrate>)> + '_
pub fn imports(&self) -> impl Iterator<Item = ImportId> + '_
pub fn fully_resolve_import( &self, db: &dyn SourceDatabase, import: ImportId, ) -> PerNs
pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_
pub fn extern_crate_decls( &self, ) -> impl ExactSizeIterator<Item = ExternCrateId> + '_
pub fn extern_blocks(&self) -> impl Iterator<Item = ExternBlockId> + '_
pub fn use_decls(&self) -> impl ExactSizeIterator<Item = UseId> + '_
pub fn impls(&self) -> impl ExactSizeIterator<Item = ImplId> + '_
pub fn trait_impls(&self) -> impl Iterator<Item = ImplId> + '_
pub fn inherent_impls(&self) -> impl Iterator<Item = ImplId> + '_
pub fn builtin_derive_impls( &self, ) -> impl ExactSizeIterator<Item = BuiltinDeriveImplId> + '_
pub fn all_macro_calls(&self) -> impl Iterator<Item = MacroCallId> + '_
pub(crate) fn modules_in_scope( &self, ) -> impl Iterator<Item = (ModuleId, Visibility)> + '_
pub fn unnamed_consts(&self) -> impl Iterator<Item = ConstId> + '_
Sourcepub fn legacy_macros(&self) -> impl Iterator<Item = (&Name, &[MacroId])> + '_
pub fn legacy_macros(&self) -> impl Iterator<Item = (&Name, &[MacroId])> + '_
Iterate over all legacy textual scoped macros visible at the end of the module
Sourcepub fn get(&self, name: &Name) -> PerNs
pub fn get(&self, name: &Name) -> PerNs
Get a name from current module scope, legacy macros are not included
pub(crate) fn type_(&self, name: &Name) -> Option<(ModuleDefId, Visibility)>
pub(crate) fn makro(&self, name: &Name) -> Option<MacroId>
Sourcepub(crate) fn name_of(
&self,
item: ItemInNs,
) -> Option<(&Name, Visibility, bool)>
pub(crate) fn name_of( &self, item: ItemInNs, ) -> Option<(&Name, Visibility, bool)>
XXX: this is O(N) rather than O(1), try to not introduce new usages.
Sourcepub(crate) fn names_of<T>(
&self,
item: ItemInNs,
cb: impl FnMut(&Name, Visibility, bool) -> Option<T>,
) -> Option<T>
pub(crate) fn names_of<T>( &self, item: ItemInNs, cb: impl FnMut(&Name, Visibility, bool) -> Option<T>, ) -> Option<T>
XXX: this is O(N) rather than O(1), try to not introduce new usages.
pub(crate) fn traits(&self) -> impl Iterator<Item = TraitId> + '_
pub(crate) fn resolutions( &self, ) -> impl Iterator<Item = (Option<Name>, PerNs)> + '_
pub fn macro_invoc(&self, call: AstId<MacroCall>) -> Option<MacroCallId>
pub fn iter_macro_invoc( &self, ) -> impl Iterator<Item = (&AstId<MacroCall>, &MacroCallId)>
Source§impl ItemScope
impl ItemScope
pub(crate) fn declare(&mut self, def: ModuleDefId)
pub(crate) fn remove_from_value_ns(&mut self, name: &Name, def: ModuleDefId)
pub(crate) fn get_legacy_macro(&self, name: &Name) -> Option<&[MacroId]>
pub(crate) fn define_impl(&mut self, imp: ImplId, is_trait_impl: bool)
pub(crate) fn define_builtin_derive_impl(&mut self, imp: BuiltinDeriveImplId)
pub(crate) fn define_extern_block(&mut self, extern_block: ExternBlockId)
pub(crate) fn define_extern_crate_decl(&mut self, extern_crate: ExternCrateId)
pub(crate) fn define_unnamed_const(&mut self, konst: ConstId)
pub(crate) fn define_legacy_macro(&mut self, name: Name, mac: MacroId)
pub(crate) fn add_attr_macro_invoc( &mut self, item: AstId<Item>, call: MacroCallId, )
pub(crate) fn add_macro_invoc( &mut self, call: AstId<MacroCall>, call_id: MacroCallId, )
pub fn attr_macro_invocs( &self, ) -> impl Iterator<Item = (AstId<Item>, MacroCallId)> + '_
pub(crate) fn set_derive_macro_invoc( &mut self, adt: AstId<Adt>, call: Either<MacroCallId, BuiltinDeriveImplId>, id: AttrId, idx: usize, )
Sourcepub(crate) fn init_derive_attribute(
&mut self,
adt: AstId<Adt>,
attr_id: AttrId,
attr_call_id: MacroCallId,
derive_call_ids: SmallVec<[Option<Either<MacroCallId, BuiltinDeriveImplId>>; 4]>,
)
pub(crate) fn init_derive_attribute( &mut self, adt: AstId<Adt>, attr_id: AttrId, attr_call_id: MacroCallId, derive_call_ids: SmallVec<[Option<Either<MacroCallId, BuiltinDeriveImplId>>; 4]>, )
We are required to set this up front as derive invocation recording happens out of order due to the fixed pointer iteration loop being able to record some derives later than others independent of their indices.
pub fn derive_macro_invocs( &self, ) -> impl Iterator<Item = (AstId<Adt>, impl Iterator<Item = (AttrId, MacroCallId, &[Option<Either<MacroCallId, BuiltinDeriveImplId>>])>)> + '_
pub fn derive_macro_invoc( &self, ast_id: AstId<Adt>, attr_id: AttrId, ) -> Option<MacroCallId>
pub(crate) fn unnamed_trait_vis(&self, tr: TraitId) -> Option<Visibility>
pub(crate) fn push_unnamed_trait( &mut self, tr: TraitId, vis: Visibility, import: Option<ImportId>, )
pub(crate) fn push_res_with_import( &mut self, glob_imports: &mut PerNsGlobImports, lookup: (ModuleId, Name), def: PerNs, import: Option<ImportOrExternCrate>, ) -> bool
Sourcepub(crate) fn censor_non_proc_macros(&mut self, krate: Crate)
pub(crate) fn censor_non_proc_macros(&mut self, krate: Crate)
Marks everything that is not a procedural macro as private to this_module.
pub(crate) fn dump(&self, db: &dyn SourceDatabase, buf: &mut String)
pub(crate) fn shrink_to_fit(&mut self)
Source§impl ItemScope
impl ItemScope
pub(crate) fn update_visibility_types(&mut self, name: &Name, vis: Visibility)
pub(crate) fn update_visibility_values(&mut self, name: &Name, vis: Visibility)
pub(crate) fn update_visibility_macros(&mut self, name: &Name, vis: Visibility)
pub(crate) fn update_def_types( &mut self, name: &Name, def: ModuleDefId, vis: Visibility, )
pub(crate) fn update_def_values( &mut self, name: &Name, def: ModuleDefId, vis: Visibility, )
pub(crate) fn update_def_macros( &mut self, name: &Name, def: MacroId, vis: Visibility, )
Trait Implementations§
impl Eq for ItemScope
impl StructuralPartialEq for ItemScope
Auto Trait Implementations§
impl Freeze for ItemScope
impl RefUnwindSafe for ItemScope
impl Send for ItemScope
impl Sync for ItemScope
impl Unpin for ItemScope
impl UnsafeUnpin for ItemScope
impl UnwindSafe for ItemScope
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
key and return true if they are equal.§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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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