pub struct Resolver { /* private fields */ }
Implementations§
source§impl Resolver
impl Resolver
sourcepub fn resolve_known_trait(
&self,
db: &dyn DefDatabase,
path: &ModPath,
) -> Option<TraitId>
pub fn resolve_known_trait( &self, db: &dyn DefDatabase, path: &ModPath, ) -> Option<TraitId>
Resolve known trait from std, like std::futures::Future
sourcepub fn resolve_known_struct(
&self,
db: &dyn DefDatabase,
path: &ModPath,
) -> Option<StructId>
pub fn resolve_known_struct( &self, db: &dyn DefDatabase, path: &ModPath, ) -> Option<StructId>
Resolve known struct from std, like std::boxed::Box
sourcepub fn resolve_known_enum(
&self,
db: &dyn DefDatabase,
path: &ModPath,
) -> Option<EnumId>
pub fn resolve_known_enum( &self, db: &dyn DefDatabase, path: &ModPath, ) -> Option<EnumId>
Resolve known enum from std, like std::result::Result
pub fn resolve_module_path_in_items( &self, db: &dyn DefDatabase, path: &ModPath, ) -> PerNs
pub fn resolve_path_in_type_ns( &self, db: &dyn DefDatabase, path: &Path, ) -> Option<(TypeNs, Option<usize>, Option<ImportOrExternCrate>)>
pub fn resolve_path_in_type_ns_fully_with_imports( &self, db: &dyn DefDatabase, path: &Path, ) -> Option<(TypeNs, Option<ImportOrExternCrate>)>
pub fn resolve_path_in_type_ns_fully( &self, db: &dyn DefDatabase, path: &Path, ) -> Option<TypeNs>
pub fn resolve_visibility( &self, db: &dyn DefDatabase, visibility: &RawVisibility, ) -> Option<Visibility>
pub fn resolve_path_in_value_ns( &self, db: &dyn DefDatabase, path: &Path, hygiene_id: HygieneId, ) -> Option<ResolveValueResult>
pub fn resolve_path_in_value_ns_fully( &self, db: &dyn DefDatabase, path: &Path, hygiene: HygieneId, ) -> Option<ValueNs>
pub fn resolve_path_as_macro( &self, db: &dyn DefDatabase, path: &ModPath, expected_macro_kind: Option<MacroSubNs>, ) -> Option<(MacroId, Option<ImportId>)>
pub fn resolve_path_as_macro_def( &self, db: &dyn DefDatabase, path: &ModPath, expected_macro_kind: Option<MacroSubNs>, ) -> Option<MacroDefId>
pub fn resolve_lifetime(&self, lifetime: &LifetimeRef) -> Option<LifetimeNs>
sourcepub fn names_in_scope(
&self,
db: &dyn DefDatabase,
) -> IndexMap<Name, SmallVec<[ScopeDef; 1]>, BuildHasherDefault<FxHasher>>
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.
pub fn extern_crate_decls_in_scope<'a>( &'a self, db: &'a dyn DefDatabase, ) -> impl Iterator<Item = Name> + 'a
pub fn extern_crates_in_scope( &self, ) -> impl Iterator<Item = (Name, ModuleId)> + '_
pub fn traits_in_scope(&self, db: &dyn DefDatabase) -> FxHashSet<TraitId>
pub fn traits_in_scope_from_block_scopes( &self, ) -> impl Iterator<Item = TraitId> + '_
pub fn module(&self) -> ModuleId
pub fn krate(&self) -> CrateId
pub fn def_map(&self) -> &DefMap
pub fn where_predicates_in_scope( &self, ) -> impl Iterator<Item = (&WherePredicate, (&GenericDefId, &TypesMap))>
pub fn generic_def(&self) -> Option<GenericDefId>
pub fn generic_params(&self) -> Option<&Arc<GenericParams>>
pub fn all_generic_params( &self, ) -> impl Iterator<Item = (&GenericParams, &GenericDefId)>
pub fn body_owner(&self) -> Option<DefWithBodyId>
pub fn type_owner(&self) -> Option<TypeOwnerId>
pub fn impl_def(&self) -> Option<ImplId>
sourcepub fn update_to_inner_scope(
&mut self,
db: &dyn DefDatabase,
owner: DefWithBodyId,
expr_id: ExprId,
) -> UpdateGuard
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
pub fn reset_to_guard(&mut self, UpdateGuard: UpdateGuard)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Resolver
impl RefUnwindSafe for Resolver
impl Send for Resolver
impl Sync for Resolver
impl Unpin for Resolver
impl UnwindSafe for Resolver
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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