From 559aeb2932368b40cda9ff8d3f7c4cf3aa065819 Mon Sep 17 00:00:00 2001 From: veetaha Date: Mon, 23 Mar 2020 02:01:07 +0200 Subject: ra_hir: add more privacy for Type --- crates/ra_hir/src/source_analyzer.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'crates/ra_hir/src/source_analyzer.rs') diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index e8afef328..10c12c910 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs @@ -17,7 +17,7 @@ use hir_def::{ AsMacroCall, DefWithBodyId, }; use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile}; -use hir_ty::{InEnvironment, InferenceResult, TraitEnvironment}; +use hir_ty::InferenceResult; use ra_syntax::{ ast::{self, AstNode}, SyntaxNode, SyntaxNodePtr, TextUnit, @@ -103,10 +103,6 @@ impl SourceAnalyzer { Some(res) } - fn trait_env(&self, db: &dyn HirDatabase) -> Arc { - TraitEnvironment::lower(db, &self.resolver) - } - pub(crate) fn type_of(&self, db: &dyn HirDatabase, expr: &ast::Expr) -> Option { let expr_id = match expr { ast::Expr::MacroCall(call) => { @@ -117,15 +113,13 @@ impl SourceAnalyzer { }?; let ty = self.infer.as_ref()?[expr_id].clone(); - let environment = self.trait_env(db); - Some(Type { krate: self.resolver.krate()?, ty: InEnvironment { value: ty, environment } }) + Type::new_with_resolver(db, &self.resolver, ty) } pub(crate) fn type_of_pat(&self, db: &dyn HirDatabase, pat: &ast::Pat) -> Option { let pat_id = self.pat_id(pat)?; let ty = self.infer.as_ref()?[pat_id].clone(); - let environment = self.trait_env(db); - Some(Type { krate: self.resolver.krate()?, ty: InEnvironment { value: ty, environment } }) + Type::new_with_resolver(db, &self.resolver, ty) } pub(crate) fn resolve_method_call(&self, call: &ast::MethodCallExpr) -> Option { -- cgit v1.2.3