pub struct Resolver<'db> {
pub data: ResolverData,
pub macro_call_data: Option<ResolverMacroData>,
pub suppress_modifiers_diagnostics: bool,
pub owning_crate_id: CrateId,
pub settings: CrateSettings,
/* private fields */
}
Expand description
Resolves paths semantically.
Fields§
§data: ResolverData
§macro_call_data: Option<ResolverMacroData>
The resolving context for macro related resolving. Should be Some
only if the current
code is an expansion of a macro.
suppress_modifiers_diagnostics: bool
If true, suppresses diagnostics for missing resolver modifiers ($defsite
or $callsite
).
Should be true only within plugin macros generated code.
owning_crate_id: CrateId
§settings: CrateSettings
Implementations§
Source§impl Resolver<'_>
impl Resolver<'_>
Sourcepub fn set_feature_config(
&mut self,
element_id: &impl LanguageElementId,
syntax: &impl QueryAttrs,
diagnostics: &mut SemanticDiagnostics,
)
pub fn set_feature_config( &mut self, element_id: &impl LanguageElementId, syntax: &impl QueryAttrs, diagnostics: &mut SemanticDiagnostics, )
Extracts the allowed node from the syntax, and sets it as the allowed features of the resolver.
Source§impl<'db> Resolver<'db>
impl<'db> Resolver<'db>
pub fn new( db: &'db dyn SemanticGroup, module_file_id: ModuleFileId, inference_id: InferenceId, ) -> Self
pub fn with_data(db: &'db dyn SemanticGroup, data: ResolverData) -> Self
pub fn inference(&mut self) -> Inference<'_>
Sourcepub fn add_generic_param(&mut self, generic_param_id: GenericParamId)
pub fn add_generic_param(&mut self, generic_param_id: GenericParamId)
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_suppress_modifiers_diagnostics( &mut self, suppress_modifiers_diagnostics: bool, )
Sourcepub fn active_module_file_id(
&self,
macro_context_modifier: MacroContextModifier,
) -> ModuleFileId
pub fn active_module_file_id( &self, macro_context_modifier: MacroContextModifier, ) -> ModuleFileId
Return the module_file_id, with respect to the macro context modifier, see
MacroContextModifier
.
Sourcepub fn active_owning_crate_id(
&self,
macro_context_modifier: MacroContextModifier,
) -> CrateId
pub fn active_owning_crate_id( &self, macro_context_modifier: MacroContextModifier, ) -> CrateId
Returns the owning crate id of the active module file id, with respect to the macro context
modifier, see MacroContextModifier
.
Sourcepub fn active_settings(
&self,
macro_context_modifier: MacroContextModifier,
) -> CrateSettings
pub fn active_settings( &self, macro_context_modifier: MacroContextModifier, ) -> CrateSettings
Returns the active settings of the owning crate, with respect to the macro context
modifier, see MacroContextModifier
.
Sourcepub fn resolve_concrete_path(
&mut self,
diagnostics: &mut SemanticDiagnostics,
path: impl AsSegments,
item_type: NotFoundItemType,
) -> Maybe<ResolvedConcreteItem>
pub fn resolve_concrete_path( &mut self, diagnostics: &mut SemanticDiagnostics, path: impl AsSegments, item_type: NotFoundItemType, ) -> Maybe<ResolvedConcreteItem>
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,
path: impl AsSegments,
item_type: NotFoundItemType,
ctx: ResolutionContext<'_>,
) -> Maybe<ResolvedConcreteItem>
pub fn resolve_concrete_path_ex( &mut self, diagnostics: &mut SemanticDiagnostics, path: impl AsSegments, item_type: NotFoundItemType, ctx: ResolutionContext<'_>, ) -> Maybe<ResolvedConcreteItem>
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,
path: impl AsSegments,
item_type: NotFoundItemType,
ctx: ResolutionContext<'_>,
) -> Maybe<ResolvedGenericItem>
pub fn resolve_generic_path( &mut self, diagnostics: &mut SemanticDiagnostics, path: impl AsSegments, item_type: NotFoundItemType, ctx: ResolutionContext<'_>, ) -> Maybe<ResolvedGenericItem>
Resolves a generic item, given a path. Guaranteed to result in at most one diagnostic.
Sourcepub fn resolve_generic_path_with_args(
&mut self,
diagnostics: &mut SemanticDiagnostics,
path: impl AsSegments,
item_type: NotFoundItemType,
ctx: ResolutionContext<'_>,
) -> Maybe<ResolvedGenericItem>
pub fn resolve_generic_path_with_args( &mut self, diagnostics: &mut SemanticDiagnostics, path: impl AsSegments, item_type: NotFoundItemType, ctx: ResolutionContext<'_>, ) -> Maybe<ResolvedGenericItem>
Resolves a generic item, given a concrete item path, while ignoring the generic args. Guaranteed to result in at most one diagnostic.
pub fn prelude_submodule(&self) -> ModuleId
Sourcepub fn prelude_submodule_ex(
&self,
macro_context_modifier: MacroContextModifier,
) -> ModuleId
pub fn prelude_submodule_ex( &self, macro_context_modifier: MacroContextModifier, ) -> ModuleId
Returns the crate’s prelude
submodule.
Sourcepub fn specialize_function(
&mut self,
diagnostics: &mut SemanticDiagnostics,
stable_ptr: SyntaxStablePtrId,
generic_function: GenericFunctionId,
generic_args: &[GenericArg],
) -> Maybe<FunctionId>
pub fn specialize_function( &mut self, diagnostics: &mut SemanticDiagnostics, stable_ptr: SyntaxStablePtrId, generic_function: GenericFunctionId, generic_args: &[GenericArg], ) -> Maybe<FunctionId>
Specializes a generic function.
Sourcepub fn specialize_type(
&mut self,
diagnostics: &mut SemanticDiagnostics,
stable_ptr: SyntaxStablePtrId,
generic_type: GenericTypeId,
generic_args: &[GenericArg],
) -> Maybe<TypeId>
pub fn specialize_type( &mut self, diagnostics: &mut SemanticDiagnostics, stable_ptr: SyntaxStablePtrId, generic_type: GenericTypeId, generic_args: &[GenericArg], ) -> Maybe<TypeId>
Specializes a generic type.
Sourcepub fn impl_lookup_context(&self) -> ImplLookupContext
pub fn impl_lookup_context(&self) -> ImplLookupContext
Returns the current impl lookup context.
Sourcepub fn impl_lookup_context_ex(
&self,
macro_context_modifier: MacroContextModifier,
) -> ImplLookupContext
pub fn impl_lookup_context_ex( &self, macro_context_modifier: MacroContextModifier, ) -> ImplLookupContext
Returns the current impl lookup context, with respect to the macro context modifier,
see MacroContextModifier
.
Sourcepub fn resolve_generic_args(
&mut self,
diagnostics: &mut SemanticDiagnostics,
substitution: GenericSubstitution,
generic_params: &[GenericParam],
generic_args_syntax: &[GenericArg],
stable_ptr: SyntaxStablePtrId,
) -> Maybe<Vec<GenericArgumentId>>
pub fn resolve_generic_args( &mut self, diagnostics: &mut SemanticDiagnostics, substitution: GenericSubstitution, generic_params: &[GenericParam], generic_args_syntax: &[GenericArg], stable_ptr: SyntaxStablePtrId, ) -> Maybe<Vec<GenericArgumentId>>
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 ignore_visibility_checks(&self, module_id: ModuleId) -> bool
pub fn ignore_visibility_checks(&self, module_id: ModuleId) -> bool
Should visibility checks not actually happen for lookups in this module.
Sourcepub fn ignore_visibility_checks_ex(
&self,
module_id: ModuleId,
macro_context_modifier: MacroContextModifier,
) -> bool
pub fn ignore_visibility_checks_ex( &self, module_id: ModuleId, macro_context_modifier: MacroContextModifier, ) -> bool
Same as [self.ignore_visibility_checks
], but takes into account the current macro context
modifier.
Sourcepub fn validate_feature_constraints<T: HasFeatureKind>(
&self,
diagnostics: &mut SemanticDiagnostics,
identifier: &TerminalIdentifier,
item_info: &T,
)
pub fn validate_feature_constraints<T: HasFeatureKind>( &self, diagnostics: &mut SemanticDiagnostics, identifier: &TerminalIdentifier, 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,
item_info: &ModuleItemInfo,
user_module: ModuleId,
) -> bool
pub fn is_item_visible( &self, containing_module_id: ModuleId, item_info: &ModuleItemInfo, user_module: ModuleId, ) -> bool
Checks if an item is visible from the current module.
Sourcepub fn is_item_visible_ex(
&self,
containing_module_id: ModuleId,
item_info: &ModuleItemInfo,
user_module: ModuleId,
macro_context_modifier: MacroContextModifier,
) -> bool
pub fn is_item_visible_ex( &self, containing_module_id: ModuleId, item_info: &ModuleItemInfo, user_module: ModuleId, macro_context_modifier: MacroContextModifier, ) -> bool
Same as [self.is_item_visible
], but takes into account the current macro context
modifier.
Sourcepub fn insert_used_use(&mut self, item_id: ModuleItemId)
pub fn insert_used_use(&mut self, item_id: ModuleItemId)
Inserts an item into the used uses set, if it is indeed a use.
Methods from Deref<Target = ResolverData>§
pub fn clone_with_inference_id( &self, db: &dyn SemanticGroup, inference_id: InferenceId, ) -> 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<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