pub struct Resolver<'db> {
pub data: ResolverData<'db>,
pub macro_call_data: Option<Arc<ResolverMacroData<'db>>>,
pub default_module_allowed: bool,
pub owning_crate_id: CrateId<'db>,
pub settings: CrateSettings,
/* private fields */
}Expand description
Resolves paths semantically.
Fields§
§data: ResolverData<'db>§macro_call_data: Option<Arc<ResolverMacroData<'db>>>The resolving context for macro related resolving. Should be Some only if the current
code is an expansion of a macro.
default_module_allowed: boolIf true, allow resolution of path through the module definition, without a modifier. Should be true only within plugin macros generated code, or item macro call generated code.
owning_crate_id: CrateId<'db>§settings: CrateSettingsImplementations§
Source§impl<'db> Resolver<'db>
impl<'db> Resolver<'db>
Sourcepub fn set_feature_config(
&mut self,
element_id: &impl LanguageElementId<'db>,
syntax: &impl QueryAttrs<'db>,
diagnostics: &mut SemanticDiagnostics<'db>,
)
pub fn set_feature_config( &mut self, element_id: &impl LanguageElementId<'db>, syntax: &impl QueryAttrs<'db>, diagnostics: &mut SemanticDiagnostics<'db>, )
Extracts the allowed node from the syntax, and sets it as the allowed features of the resolver.
Sourcepub fn extend_feature_config_from_item(
&mut self,
db: &'db dyn Database,
crate_id: CrateId<'db>,
diagnostics: &mut SemanticDiagnostics<'db>,
item: &impl QueryAttrs<'db>,
) -> FeatureConfigRestore<'db>
pub fn extend_feature_config_from_item( &mut self, db: &'db dyn Database, crate_id: CrateId<'db>, diagnostics: &mut SemanticDiagnostics<'db>, item: &impl QueryAttrs<'db>, ) -> FeatureConfigRestore<'db>
Extends the current feature config with the contents of those extracted from the given item,
returns the original feature config for restoring it later.
IMPORTANT: don’t forget to call restore_feature_config!
Sourcepub fn restore_feature_config(&mut self, restore: FeatureConfigRestore<'db>)
pub fn restore_feature_config(&mut self, restore: FeatureConfigRestore<'db>)
Restores the feature config to its state before Self::extend_feature_config_from_item, using the restoration state returned by that method.
Source§impl<'db> Resolver<'db>
impl<'db> Resolver<'db>
pub fn new( db: &'db dyn Database, module_id: ModuleId<'db>, inference_id: InferenceId<'db>, ) -> Self
pub fn with_data(db: &'db dyn Database, data: ResolverData<'db>) -> Self
pub fn inference(&mut self) -> Inference<'db, '_>
Sourcepub fn add_generic_param(&mut self, generic_param_id: GenericParamId<'db>)
pub fn add_generic_param(&mut self, generic_param_id: GenericParamId<'db>)
Adds a generic param to an existing resolver. This is required since a resolver needs to exist before resolving the generic params, and thus, they are added to the Resolver only after they are resolved.
pub fn set_default_module_allowed(&mut self, default_module_allowed: bool)
Sourcepub fn resolve_concrete_path(
&mut self,
diagnostics: &mut SemanticDiagnostics<'db>,
path: impl AsSegments<'db>,
item_type: NotFoundItemType,
) -> Maybe<ResolvedConcreteItem<'db>>
pub fn resolve_concrete_path( &mut self, diagnostics: &mut SemanticDiagnostics<'db>, path: impl AsSegments<'db>, item_type: NotFoundItemType, ) -> Maybe<ResolvedConcreteItem<'db>>
Resolves a concrete item, given a path. Guaranteed to result in at most one diagnostic. Item not inside a statement.
Sourcepub fn resolve_concrete_path_ex(
&mut self,
diagnostics: &mut SemanticDiagnostics<'db>,
path: impl AsSegments<'db>,
item_type: NotFoundItemType,
ctx: ResolutionContext<'db, '_>,
) -> Maybe<ResolvedConcreteItem<'db>>
pub fn resolve_concrete_path_ex( &mut self, diagnostics: &mut SemanticDiagnostics<'db>, path: impl AsSegments<'db>, item_type: NotFoundItemType, ctx: ResolutionContext<'db, '_>, ) -> Maybe<ResolvedConcreteItem<'db>>
Resolves a concrete item, given a path. Guaranteed to result in at most one diagnostic.
Sourcepub fn resolve_generic_path(
&mut self,
diagnostics: &mut SemanticDiagnostics<'db>,
path: impl AsSegments<'db>,
item_type: NotFoundItemType,
ctx: ResolutionContext<'db, '_>,
) -> Maybe<ResolvedGenericItem<'db>>
pub fn resolve_generic_path( &mut self, diagnostics: &mut SemanticDiagnostics<'db>, path: impl AsSegments<'db>, item_type: NotFoundItemType, ctx: ResolutionContext<'db, '_>, ) -> Maybe<ResolvedGenericItem<'db>>
Resolves a generic item, given a path. Guaranteed to result in at most one diagnostic.
Sourcepub fn resolve_use_path(
&mut self,
diagnostics: &mut SemanticDiagnostics<'db>,
use_path: UsePath<'db>,
ctx: ResolutionContext<'db, '_>,
) -> Maybe<ResolvedGenericItem<'db>>
pub fn resolve_use_path( &mut self, diagnostics: &mut SemanticDiagnostics<'db>, use_path: UsePath<'db>, ctx: ResolutionContext<'db, '_>, ) -> Maybe<ResolvedGenericItem<'db>>
Resolves a generic item from a use statement path.
Useful for resolving paths from use items and statements.
Sourcepub fn resolve_generic_path_with_args(
&mut self,
diagnostics: &mut SemanticDiagnostics<'db>,
path: impl AsSegments<'db>,
item_type: NotFoundItemType,
ctx: ResolutionContext<'db, '_>,
) -> Maybe<ResolvedGenericItem<'db>>
pub fn resolve_generic_path_with_args( &mut self, diagnostics: &mut SemanticDiagnostics<'db>, path: impl AsSegments<'db>, item_type: NotFoundItemType, ctx: ResolutionContext<'db, '_>, ) -> Maybe<ResolvedGenericItem<'db>>
Resolves a generic item, given a concrete item path, while ignoring the generic args. Guaranteed to result in at most one diagnostic.
Sourcepub fn determine_base_item_in_local_scope(
&mut self,
identifier: &TerminalIdentifier<'db>,
) -> Option<ResolvedConcreteItem<'db>>
pub fn determine_base_item_in_local_scope( &mut self, identifier: &TerminalIdentifier<'db>, ) -> Option<ResolvedConcreteItem<'db>>
Determines whether the first identifier of a path is a local item.
pub fn prelude_submodule(&self) -> ModuleId<'db>
Sourcepub fn specialize_function(
&mut self,
diagnostics: &mut SemanticDiagnostics<'db>,
stable_ptr: SyntaxStablePtrId<'db>,
generic_function: GenericFunctionId<'db>,
generic_args: &[GenericArg<'db>],
) -> Maybe<FunctionId<'db>>
pub fn specialize_function( &mut self, diagnostics: &mut SemanticDiagnostics<'db>, stable_ptr: SyntaxStablePtrId<'db>, generic_function: GenericFunctionId<'db>, generic_args: &[GenericArg<'db>], ) -> Maybe<FunctionId<'db>>
Specializes a generic function.
Sourcepub fn specialize_type(
&mut self,
diagnostics: &mut SemanticDiagnostics<'db>,
stable_ptr: SyntaxStablePtrId<'db>,
generic_type: GenericTypeId<'db>,
generic_args: &[GenericArg<'db>],
) -> Maybe<TypeId<'db>>
pub fn specialize_type( &mut self, diagnostics: &mut SemanticDiagnostics<'db>, stable_ptr: SyntaxStablePtrId<'db>, generic_type: GenericTypeId<'db>, generic_args: &[GenericArg<'db>], ) -> Maybe<TypeId<'db>>
Specializes a generic type.
Sourcepub fn impl_lookup_context(&self) -> ImplLookupContextId<'db>
pub fn impl_lookup_context(&self) -> ImplLookupContextId<'db>
Returns the current impl lookup context.
Sourcepub fn resolve_generic_args(
&mut self,
diagnostics: &mut SemanticDiagnostics<'db>,
substitution: GenericSubstitution<'db>,
generic_params: &[GenericParam<'db>],
generic_args_syntax: &[GenericArg<'db>],
stable_ptr: SyntaxStablePtrId<'db>,
) -> Maybe<Vec<GenericArgumentId<'db>>>
pub fn resolve_generic_args( &mut self, diagnostics: &mut SemanticDiagnostics<'db>, substitution: GenericSubstitution<'db>, generic_params: &[GenericParam<'db>], generic_args_syntax: &[GenericArg<'db>], stable_ptr: SyntaxStablePtrId<'db>, ) -> Maybe<Vec<GenericArgumentId<'db>>>
Resolves generic arguments. For each generic argument, if the syntax is provided, it will be resolved by the inference. Otherwise, resolved by type.
Sourcepub fn get_arg_syntax_per_param(
&self,
diagnostics: &mut SemanticDiagnostics<'db>,
generic_params: &[GenericParamId<'db>],
generic_args_syntax: &[GenericArg<'db>],
) -> Maybe<UnorderedHashMap<GenericParamId<'db>, GenericArgValue<'db>>>
pub fn get_arg_syntax_per_param( &self, diagnostics: &mut SemanticDiagnostics<'db>, generic_params: &[GenericParamId<'db>], generic_args_syntax: &[GenericArg<'db>], ) -> Maybe<UnorderedHashMap<GenericParamId<'db>, GenericArgValue<'db>>>
Returns a map of generic param id -> its assigned arg syntax.
Sourcepub fn ignore_visibility_checks(&self, module_id: ModuleId<'db>) -> bool
pub fn ignore_visibility_checks(&self, module_id: ModuleId<'db>) -> bool
Should visibility checks not actually happen for lookups in this module.
Sourcepub fn validate_feature_constraints<T: HasFeatureKind<'db>>(
&self,
diagnostics: &mut SemanticDiagnostics<'db>,
identifier: &TerminalIdentifier<'db>,
item_info: &T,
)
pub fn validate_feature_constraints<T: HasFeatureKind<'db>>( &self, diagnostics: &mut SemanticDiagnostics<'db>, identifier: &TerminalIdentifier<'db>, item_info: &T, )
Validates whether a given item is allowed based on its feature kind. This function checks if the item’s feature kind is allowed in the current configuration. If the item uses an unstable, deprecated, or internal feature that is not permitted, a corresponding diagnostic error is reported.
Sourcepub fn is_item_visible(
&self,
containing_module_id: ModuleId<'db>,
item_info: &ModuleItemInfo<'db>,
user_module: ModuleId<'db>,
) -> bool
pub fn is_item_visible( &self, containing_module_id: ModuleId<'db>, item_info: &ModuleItemInfo<'db>, user_module: ModuleId<'db>, ) -> bool
Checks if an item is visible from the current module.
Sourcepub fn insert_used_use(&mut self, item_id: ModuleItemId<'db>)
pub fn insert_used_use(&mut self, item_id: ModuleItemId<'db>)
Inserts an item into the used uses set, if it is indeed a use.
Methods from Deref<Target = ResolverData<'db>>§
pub fn clone_with_inference_id( &self, db: &'db dyn Database, inference_id: InferenceId<'db>, ) -> Self
Trait Implementations§
Auto Trait Implementations§
impl<'db> Freeze for Resolver<'db>
impl<'db> !RefUnwindSafe for Resolver<'db>
impl<'db> !Send for Resolver<'db>
impl<'db> !Sync for Resolver<'db>
impl<'db> Unpin for Resolver<'db>
impl<'db> !UnwindSafe for Resolver<'db>
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<'db, T> DebugDbUpcast<'db, T> for Twhere
T: ?Sized,
impl<'db, T> DebugDbUpcast<'db, T> for Twhere
T: ?Sized,
fn debug_db_upcast(&'db self) -> &'db T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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