Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir/src/semantics.rs')
-rw-r--r--crates/hir/src/semantics.rs34
1 files changed, 28 insertions, 6 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index b896cda9dd..17b670f6a4 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -49,10 +49,10 @@ use crate::{
semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx},
source_analyzer::{name_hygiene, resolve_hir_path, SourceAnalyzer},
Access, Adjust, Adjustment, Adt, AutoBorrow, BindingMode, BuiltinAttr, Callable, Const,
- ConstParam, Crate, DeriveHelper, Enum, Field, Function, HasSource, HirFileId, Impl, InFile,
- InlineAsmOperand, ItemInNs, Label, LifetimeParam, Local, Macro, Module, ModuleDef, Name,
- OverloadedDeref, Path, ScopeDef, Static, Struct, ToolModule, Trait, TraitAlias, TupleField,
- Type, TypeAlias, TypeParam, Union, Variant, VariantDef,
+ ConstParam, Crate, DeriveHelper, Enum, Field, Function, GenericSubstitution, HasSource,
+ HirFileId, Impl, InFile, InlineAsmOperand, ItemInNs, Label, LifetimeParam, Local, Macro,
+ Module, ModuleDef, Name, OverloadedDeref, Path, ScopeDef, Static, Struct, ToolModule, Trait,
+ TraitAlias, TupleField, Type, TypeAlias, TypeParam, Union, Variant, VariantDef,
};
const CONTINUE_NO_BREAKS: ControlFlow<Infallible, ()> = ControlFlow::Continue(());
@@ -1415,7 +1415,7 @@ impl<'db> SemanticsImpl<'db> {
pub fn resolve_method_call_fallback(
&self,
call: &ast::MethodCallExpr,
- ) -> Option<Either<Function, Field>> {
+ ) -> Option<(Either<Function, Field>, Option<GenericSubstitution>)> {
self.analyze(call.syntax())?.resolve_method_call_fallback(self.db, call)
}
@@ -1458,7 +1458,7 @@ impl<'db> SemanticsImpl<'db> {
pub fn resolve_field_fallback(
&self,
field: &ast::FieldExpr,
- ) -> Option<Either<Either<Field, TupleField>, Function>> {
+ ) -> Option<(Either<Either<Field, TupleField>, Function>, Option<GenericSubstitution>)> {
self.analyze(field.syntax())?.resolve_field_fallback(self.db, field)
}
@@ -1466,10 +1466,25 @@ impl<'db> SemanticsImpl<'db> {
&self,
field: &ast::RecordExprField,
) -> Option<(Field, Option<Local>, Type)> {
+ self.resolve_record_field_with_substitution(field)
+ .map(|(field, local, ty, _)| (field, local, ty))
+ }
+
+ pub fn resolve_record_field_with_substitution(
+ &self,
+ field: &ast::RecordExprField,
+ ) -> Option<(Field, Option<Local>, Type, GenericSubstitution)> {
self.analyze(field.syntax())?.resolve_record_field(self.db, field)
}
pub fn resolve_record_pat_field(&self, field: &ast::RecordPatField) -> Option<(Field, Type)> {
+ self.resolve_record_pat_field_with_subst(field).map(|(field, ty, _)| (field, ty))
+ }
+
+ pub fn resolve_record_pat_field_with_subst(
+ &self,
+ field: &ast::RecordPatField,
+ ) -> Option<(Field, Type, GenericSubstitution)> {
self.analyze(field.syntax())?.resolve_record_pat_field(self.db, field)
}
@@ -1525,6 +1540,13 @@ impl<'db> SemanticsImpl<'db> {
}
pub fn resolve_path(&self, path: &ast::Path) -> Option<PathResolution> {
+ self.resolve_path_with_subst(path).map(|(it, _)| it)
+ }
+
+ pub fn resolve_path_with_subst(
+ &self,
+ path: &ast::Path,
+ ) -> Option<(PathResolution, Option<GenericSubstitution>)> {
self.analyze(path.syntax())?.resolve_path(self.db, path)
}