Skip to main content

ItemScope

Struct ItemScope 

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

Source

pub fn entries(&self) -> impl Iterator<Item = (&Name, PerNs)> + '_

Source

pub fn values( &self, ) -> impl Iterator<Item = (&Name, Item<ModuleDefId, ImportOrGlob>)> + '_

Source

pub fn types( &self, ) -> impl Iterator<Item = (&Name, Item<ModuleDefId, ImportOrExternCrate>)> + '_

Source

pub fn macros( &self, ) -> impl Iterator<Item = (&Name, Item<MacroId, ImportOrExternCrate>)> + '_

Source

pub fn imports(&self) -> impl Iterator<Item = ImportId> + '_

Source

pub fn fully_resolve_import( &self, db: &dyn SourceDatabase, import: ImportId, ) -> PerNs

Source

pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_

Source

pub fn extern_crate_decls( &self, ) -> impl ExactSizeIterator<Item = ExternCrateId> + '_

Source

pub fn extern_blocks(&self) -> impl Iterator<Item = ExternBlockId> + '_

Source

pub fn use_decls(&self) -> impl ExactSizeIterator<Item = UseId> + '_

Source

pub fn impls(&self) -> impl ExactSizeIterator<Item = ImplId> + '_

Source

pub fn trait_impls(&self) -> impl Iterator<Item = ImplId> + '_

Source

pub fn inherent_impls(&self) -> impl Iterator<Item = ImplId> + '_

Source

pub fn builtin_derive_impls( &self, ) -> impl ExactSizeIterator<Item = BuiltinDeriveImplId> + '_

Source

pub fn all_macro_calls(&self) -> impl Iterator<Item = MacroCallId> + '_

Source

pub(crate) fn modules_in_scope( &self, ) -> impl Iterator<Item = (ModuleId, Visibility)> + '_

Source

pub fn unnamed_consts(&self) -> impl Iterator<Item = ConstId> + '_

Source

pub fn legacy_macros(&self) -> impl Iterator<Item = (&Name, &[MacroId])> + '_

Iterate over all legacy textual scoped macros visible at the end of the module

Source

pub fn get(&self, name: &Name) -> PerNs

Get a name from current module scope, legacy macros are not included

Source

pub(crate) fn type_(&self, name: &Name) -> Option<(ModuleDefId, Visibility)>

Source

pub(crate) fn makro(&self, name: &Name) -> Option<MacroId>

Source

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.

Source

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.

Source

pub(crate) fn traits(&self) -> impl Iterator<Item = TraitId> + '_

Source

pub(crate) fn resolutions( &self, ) -> impl Iterator<Item = (Option<Name>, PerNs)> + '_

Source

pub fn macro_invoc(&self, call: AstId<MacroCall>) -> Option<MacroCallId>

Source

pub fn iter_macro_invoc( &self, ) -> impl Iterator<Item = (&AstId<MacroCall>, &MacroCallId)>

Source§

impl ItemScope

Source

pub(crate) fn declare(&mut self, def: ModuleDefId)

Source

pub(crate) fn remove_from_value_ns(&mut self, name: &Name, def: ModuleDefId)

Source

pub(crate) fn get_legacy_macro(&self, name: &Name) -> Option<&[MacroId]>

Source

pub(crate) fn define_impl(&mut self, imp: ImplId, is_trait_impl: bool)

Source

pub(crate) fn define_builtin_derive_impl(&mut self, imp: BuiltinDeriveImplId)

Source

pub(crate) fn define_extern_block(&mut self, extern_block: ExternBlockId)

Source

pub(crate) fn define_extern_crate_decl(&mut self, extern_crate: ExternCrateId)

Source

pub(crate) fn define_unnamed_const(&mut self, konst: ConstId)

Source

pub(crate) fn define_legacy_macro(&mut self, name: Name, mac: MacroId)

Source

pub(crate) fn add_attr_macro_invoc( &mut self, item: AstId<Item>, call: MacroCallId, )

Source

pub(crate) fn add_macro_invoc( &mut self, call: AstId<MacroCall>, call_id: MacroCallId, )

Source

pub fn attr_macro_invocs( &self, ) -> impl Iterator<Item = (AstId<Item>, MacroCallId)> + '_

Source

pub(crate) fn set_derive_macro_invoc( &mut self, adt: AstId<Adt>, call: Either<MacroCallId, BuiltinDeriveImplId>, id: AttrId, idx: usize, )

Source

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.

Source

pub fn derive_macro_invocs( &self, ) -> impl Iterator<Item = (AstId<Adt>, impl Iterator<Item = (AttrId, MacroCallId, &[Option<Either<MacroCallId, BuiltinDeriveImplId>>])>)> + '_

Source

pub fn derive_macro_invoc( &self, ast_id: AstId<Adt>, attr_id: AttrId, ) -> Option<MacroCallId>

Source

pub(crate) fn unnamed_trait_vis(&self, tr: TraitId) -> Option<Visibility>

Source

pub(crate) fn push_unnamed_trait( &mut self, tr: TraitId, vis: Visibility, import: Option<ImportId>, )

Source

pub(crate) fn push_res_with_import( &mut self, glob_imports: &mut PerNsGlobImports, lookup: (ModuleId, Name), def: PerNs, import: Option<ImportOrExternCrate>, ) -> bool

Source

pub(crate) fn censor_non_proc_macros(&mut self, krate: Crate)

Marks everything that is not a procedural macro as private to this_module.

Source

pub(crate) fn dump(&self, db: &dyn SourceDatabase, buf: &mut String)

Source

pub(crate) fn shrink_to_fit(&mut self)

Source§

impl ItemScope

Source

pub(crate) fn update_visibility_types(&mut self, name: &Name, vis: Visibility)

Source

pub(crate) fn update_visibility_values(&mut self, name: &Name, vis: Visibility)

Source

pub(crate) fn update_visibility_macros(&mut self, name: &Name, vis: Visibility)

Source

pub(crate) fn update_def_types( &mut self, name: &Name, def: ModuleDefId, vis: Visibility, )

Source

pub(crate) fn update_def_values( &mut self, name: &Name, def: ModuleDefId, vis: Visibility, )

Source

pub(crate) fn update_def_macros( &mut self, name: &Name, def: MacroId, vis: Visibility, )

Trait Implementations§

Source§

impl Debug for ItemScope

Source§

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

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

impl Default for ItemScope

Source§

fn default() -> ItemScope

Returns the “default value” for a type. Read more
Source§

impl Eq for ItemScope

Source§

impl PartialEq for ItemScope

Source§

fn eq(&self, other: &ItemScope) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ItemScope

Auto Trait Implementations§

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

Compare self to key and return true if they are equal.
§

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
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 + 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.
§

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> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

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
§

impl<T> Lookup<T> for T

§

fn into_owned(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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