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.rs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index d887dae99c..48661ec4eb 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -30,9 +30,9 @@ use crate::{ db::HirDatabase, semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, source_analyzer::{resolve_hir_path, SourceAnalyzer}, - Access, BuiltinAttr, Callable, ConstParam, Crate, Field, Function, HasSource, HirFileId, Impl, - InFile, Label, LifetimeParam, Local, Macro, Module, ModuleDef, Name, Path, ScopeDef, - ToolModule, Trait, Type, TypeAlias, TypeParam, VariantDef, + Access, BindingMode, BuiltinAttr, Callable, ConstParam, Crate, Field, Function, HasSource, + HirFileId, Impl, InFile, Label, LifetimeParam, Local, Macro, Module, ModuleDef, Name, Path, + ScopeDef, ToolModule, Trait, Type, TypeAlias, TypeParam, VariantDef, }; #[derive(Debug, Clone, PartialEq, Eq)] @@ -336,6 +336,14 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { self.imp.type_of_self(param) } + pub fn pattern_adjustments(&self, pat: &ast::Pat) -> SmallVec<[Type; 1]> { + self.imp.pattern_adjustments(pat) + } + + pub fn binding_mode_of_pat(&self, pat: &ast::IdentPat) -> Option<BindingMode> { + self.imp.binding_mode_of_pat(pat) + } + pub fn resolve_method_call(&self, call: &ast::MethodCallExpr) -> Option<Function> { self.imp.resolve_method_call(call).map(Function::from) } @@ -951,6 +959,16 @@ impl<'db> SemanticsImpl<'db> { self.analyze(param.syntax())?.type_of_self(self.db, param) } + fn pattern_adjustments(&self, pat: &ast::Pat) -> SmallVec<[Type; 1]> { + self.analyze(pat.syntax()) + .and_then(|it| it.pattern_adjustments(self.db, pat)) + .unwrap_or_default() + } + + fn binding_mode_of_pat(&self, pat: &ast::IdentPat) -> Option<BindingMode> { + self.analyze(pat.syntax())?.binding_mode_of_pat(self.db, pat) + } + fn resolve_method_call(&self, call: &ast::MethodCallExpr) -> Option<FunctionId> { self.analyze(call.syntax())?.resolve_method_call(self.db, call).map(|(id, _)| id) } |