Struct hir_def::resolver::Resolver

source ·
pub struct Resolver { /* private fields */ }

Implementations§

source§

impl Resolver

source

pub fn resolve_known_trait( &self, db: &dyn DefDatabase, path: &ModPath, ) -> Option<TraitId>

Resolve known trait from std, like std::futures::Future

source

pub fn resolve_known_struct( &self, db: &dyn DefDatabase, path: &ModPath, ) -> Option<StructId>

Resolve known struct from std, like std::boxed::Box

source

pub fn resolve_known_enum( &self, db: &dyn DefDatabase, path: &ModPath, ) -> Option<EnumId>

Resolve known enum from std, like std::result::Result

source

pub fn resolve_module_path_in_items( &self, db: &dyn DefDatabase, path: &ModPath, ) -> PerNs

source

pub fn resolve_path_in_type_ns( &self, db: &dyn DefDatabase, path: &Path, ) -> Option<(TypeNs, Option<usize>, Option<ImportOrExternCrate>)>

source

pub fn resolve_path_in_type_ns_fully_with_imports( &self, db: &dyn DefDatabase, path: &Path, ) -> Option<(TypeNs, Option<ImportOrExternCrate>)>

source

pub fn resolve_path_in_type_ns_fully( &self, db: &dyn DefDatabase, path: &Path, ) -> Option<TypeNs>

source

pub fn resolve_visibility( &self, db: &dyn DefDatabase, visibility: &RawVisibility, ) -> Option<Visibility>

source

pub fn resolve_path_in_value_ns( &self, db: &dyn DefDatabase, path: &Path, hygiene_id: HygieneId, ) -> Option<ResolveValueResult>

source

pub fn resolve_path_in_value_ns_fully( &self, db: &dyn DefDatabase, path: &Path, hygiene: HygieneId, ) -> Option<ValueNs>

source

pub fn resolve_path_as_macro( &self, db: &dyn DefDatabase, path: &ModPath, expected_macro_kind: Option<MacroSubNs>, ) -> Option<(MacroId, Option<ImportId>)>

source

pub fn resolve_path_as_macro_def( &self, db: &dyn DefDatabase, path: &ModPath, expected_macro_kind: Option<MacroSubNs>, ) -> Option<MacroDefId>

source

pub fn resolve_lifetime(&self, lifetime: &LifetimeRef) -> Option<LifetimeNs>

source

pub fn names_in_scope( &self, db: &dyn DefDatabase, ) -> IndexMap<Name, SmallVec<[ScopeDef; 1]>, BuildHasherDefault<FxHasher>>

Returns a set of names available in the current scope.

Note that this is a somewhat fuzzy concept – internally, the compiler doesn’t necessary follow a strict scoping discipline. Rather, it just tells for each ident what it resolves to.

A good example is something like str::from_utf8. From scopes point of view, this code is erroneous – both str module and str type occupy the same type namespace.

We don’t try to model that super-correctly – this functionality is primarily exposed for completions.

Note that in Rust one name can be bound to several items:

macro_rules! t { () => (()) }
type t = t!();
const t: t = t!()

That’s why we return a multimap.

The shadowing is accounted for: in

let it = 92;
{
    let it = 92;
    $0
}

there will be only one entry for it in the result.

The result is ordered roughly from the innermost scope to the outermost: when the name is introduced in two namespaces in two scopes, we use the position of the first scope.

source

pub fn extern_crate_decls_in_scope<'a>( &'a self, db: &'a dyn DefDatabase, ) -> impl Iterator<Item = Name> + 'a

source

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

source

pub fn traits_in_scope(&self, db: &dyn DefDatabase) -> FxHashSet<TraitId>

source

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

source

pub fn module(&self) -> ModuleId

source

pub fn krate(&self) -> CrateId

source

pub fn def_map(&self) -> &DefMap

source

pub fn where_predicates_in_scope( &self, ) -> impl Iterator<Item = (&WherePredicate, (&GenericDefId, &TypesMap))>

source

pub fn generic_def(&self) -> Option<GenericDefId>

source

pub fn generic_params(&self) -> Option<&Arc<GenericParams>>

source

pub fn all_generic_params( &self, ) -> impl Iterator<Item = (&GenericParams, &GenericDefId)>

source

pub fn body_owner(&self) -> Option<DefWithBodyId>

source

pub fn type_owner(&self) -> Option<TypeOwnerId>

source

pub fn impl_def(&self) -> Option<ImplId>

source

pub fn update_to_inner_scope( &mut self, db: &dyn DefDatabase, owner: DefWithBodyId, expr_id: ExprId, ) -> UpdateGuard

expr_id is required to be an expression id that comes after the top level expression scope in the given resolver

source

pub fn reset_to_guard(&mut self, UpdateGuard: UpdateGuard)

Trait Implementations§

source§

impl Clone for Resolver

source§

fn clone(&self) -> Resolver

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Resolver

source§

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

Formats the value using the given formatter. Read more

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

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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 + Sync + Send> for T
where T: Any + Send + Sync,

§

fn into_box(self) -> Box<dyn Any + Sync + Send>

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

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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