about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2021-08-03 17:28:51 +0200
committerLukas Wirth <lukastw97@gmail.com>2021-08-03 17:28:51 +0200
commitb96f1adf5cbfaaa0e0538bae63b20caa09484635 (patch)
treeaa349e69ce61b2f6003ed290b0e3093852bf8a33
parent8afa2722b22f941544c6883285b5bd630e6f510f (diff)
downloadrust-b96f1adf5cbfaaa0e0538bae63b20caa09484635.tar.gz
rust-b96f1adf5cbfaaa0e0538bae63b20caa09484635.zip
Give TypeInfo fields and methods more appropriate names
-rw-r--r--crates/hir/src/semantics.rs29
-rw-r--r--crates/ide/src/call_hierarchy.rs2
-rw-r--r--crates/ide/src/goto_type_definition.rs4
-rw-r--r--crates/ide/src/highlight_related.rs2
-rw-r--r--crates/ide/src/hover.rs22
-rw-r--r--crates/ide/src/inlay_hints.rs10
-rw-r--r--crates/ide/src/syntax_highlighting/highlight.rs4
-rw-r--r--crates/ide_assists/src/handlers/add_explicit_type.rs2
-rw-r--r--crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs2
-rw-r--r--crates/ide_assists/src/handlers/extract_function.rs6
-rw-r--r--crates/ide_assists/src/handlers/extract_variable.rs2
-rw-r--r--crates/ide_assists/src/handlers/fill_match_arms.rs4
-rw-r--r--crates/ide_assists/src/handlers/generate_function.rs5
-rw-r--r--crates/ide_assists/src/handlers/infer_function_return_type.rs2
-rw-r--r--crates/ide_assists/src/handlers/inline_call.rs2
-rw-r--r--crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs4
-rw-r--r--crates/ide_assists/src/handlers/replace_if_let_with_match.rs4
-rw-r--r--crates/ide_assists/src/handlers/replace_let_with_if_let.rs2
-rw-r--r--crates/ide_assists/src/utils.rs4
-rw-r--r--crates/ide_assists/src/utils/suggest_name.rs4
-rw-r--r--crates/ide_completion/src/completions/dot.rs2
-rw-r--r--crates/ide_completion/src/completions/flyimport.rs2
-rw-r--r--crates/ide_completion/src/completions/postfix.rs2
-rw-r--r--crates/ide_completion/src/completions/record.rs6
-rw-r--r--crates/ide_completion/src/context.rs12
-rw-r--r--crates/ide_db/src/call_info.rs2
-rw-r--r--crates/ide_db/src/helpers/import_assets.rs2
-rw-r--r--crates/ide_diagnostics/src/handlers/missing_ok_or_some_in_tail_expr.rs2
-rw-r--r--crates/ide_diagnostics/src/handlers/no_such_field.rs2
-rw-r--r--crates/ide_ssr/src/matching.rs2
30 files changed, 76 insertions, 74 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index f9cb043a7b5..ab3cb10b38f 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -90,22 +90,23 @@ impl PathResolution {
 #[derive(Debug)]
 pub struct TypeInfo {
     /// The original type of the expression or pattern.
-    pub ty: Type,
-    /// The coerced type, if a coercion happened.
-    pub coerced: Option<Type>,
+    pub original: Type,
+    /// The adjusted type, if an adjustment happened.
+    pub adjusted: Option<Type>,
 }
 
 impl TypeInfo {
-    pub fn ty(self) -> Type {
-        self.ty
+    pub fn original(self) -> Type {
+        self.original
     }
 
-    pub fn has_coercion(&self) -> bool {
-        self.coerced.is_some()
+    pub fn has_adjustment(&self) -> bool {
+        self.adjusted.is_some()
     }
 
-    pub fn coerced(self) -> Type {
-        self.coerced.unwrap_or(self.ty)
+    /// The adjusted type, or the original in case no adjustments occurred.
+    pub fn adjusted(self) -> Type {
+        self.adjusted.unwrap_or(self.original)
     }
 }
 
@@ -581,13 +582,13 @@ impl<'db> SemanticsImpl<'db> {
     fn type_of_expr(&self, expr: &ast::Expr) -> Option<TypeInfo> {
         self.analyze(expr.syntax())
             .type_of_expr(self.db, expr)
-            .map(|(ty, coerced)| TypeInfo { ty, coerced })
+            .map(|(ty, coerced)| TypeInfo { original: ty, adjusted: coerced })
     }
 
     fn type_of_pat(&self, pat: &ast::Pat) -> Option<TypeInfo> {
         self.analyze(pat.syntax())
             .type_of_pat(self.db, pat)
-            .map(|(ty, coerced)| TypeInfo { ty, coerced })
+            .map(|(ty, coerced)| TypeInfo { original: ty, adjusted: coerced })
     }
 
     fn type_of_self(&self, param: &ast::SelfParam) -> Option<Type> {
@@ -766,7 +767,7 @@ impl<'db> SemanticsImpl<'db> {
                     ast::Expr::FieldExpr(field_expr) => field_expr,
                     _ => return None,
                 };
-                let ty = self.type_of_expr(&field_expr.expr()?)?.ty;
+                let ty = self.type_of_expr(&field_expr.expr()?)?.original;
                 if !ty.is_packed(self.db) {
                     return None;
                 }
@@ -793,7 +794,7 @@ impl<'db> SemanticsImpl<'db> {
                 self.type_of_expr(&expr)
             })
             // Binding a reference to a packed type is possibly unsafe.
-            .map(|ty| ty.ty.is_packed(self.db))
+            .map(|ty| ty.original.is_packed(self.db))
             .unwrap_or(false)
 
         // FIXME This needs layout computation to be correct. It will highlight
@@ -839,7 +840,7 @@ impl<'db> SemanticsImpl<'db> {
                 }
             })
             // Binding a reference to a packed type is possibly unsafe.
-            .map(|ty| ty.ty.is_packed(self.db))
+            .map(|ty| ty.original.is_packed(self.db))
             .unwrap_or(false)
     }
 }
diff --git a/crates/ide/src/call_hierarchy.rs b/crates/ide/src/call_hierarchy.rs
index 428f3f1c6d6..f725247ccb4 100644
--- a/crates/ide/src/call_hierarchy.rs
+++ b/crates/ide/src/call_hierarchy.rs
@@ -86,7 +86,7 @@ pub(crate) fn outgoing_calls(db: &RootDatabase, position: FilePosition) -> Optio
             let name_ref = call_node.name_ref()?;
             let func_target = match call_node {
                 FnCallNode::CallExpr(expr) => {
-                    let callable = sema.type_of_expr(&expr.expr()?)?.ty.as_callable(db)?;
+                    let callable = sema.type_of_expr(&expr.expr()?)?.original.as_callable(db)?;
                     match callable.kind() {
                         hir::CallableKind::Function(it) => it.try_to_nav(db),
                         _ => None,
diff --git a/crates/ide/src/goto_type_definition.rs b/crates/ide/src/goto_type_definition.rs
index 3e9dfb8cb67..f8105790f4c 100644
--- a/crates/ide/src/goto_type_definition.rs
+++ b/crates/ide/src/goto_type_definition.rs
@@ -32,8 +32,8 @@ pub(crate) fn goto_type_definition(
     let (ty, node) = sema.token_ancestors_with_macros(token).find_map(|node| {
         let ty = match_ast! {
             match node {
-                ast::Expr(it) => sema.type_of_expr(&it)?.ty,
-                ast::Pat(it) => sema.type_of_pat(&it)?.ty,
+                ast::Expr(it) => sema.type_of_expr(&it)?.original,
+                ast::Pat(it) => sema.type_of_pat(&it)?.original,
                 ast::SelfParam(it) => sema.type_of_self(&it)?,
                 ast::Type(it) => sema.resolve_type(&it)?,
                 ast::RecordField(it) => sema.to_def(&it).map(|d| d.ty(db.upcast()))?,
diff --git a/crates/ide/src/highlight_related.rs b/crates/ide/src/highlight_related.rs
index a1c50c6364e..b4715b10a06 100644
--- a/crates/ide/src/highlight_related.rs
+++ b/crates/ide/src/highlight_related.rs
@@ -123,7 +123,7 @@ fn highlight_exit_points(
                 }
             }
             ast::Expr::MethodCallExpr(_) | ast::Expr::CallExpr(_) | ast::Expr::MacroCall(_) => {
-                if sema.type_of_expr(&expr).map_or(false, |ty| ty.ty.is_never()) {
+                if sema.type_of_expr(&expr).map_or(false, |ty| ty.original.is_never()) {
                     highlights
                         .push(HighlightedRange { access: None, range: expr.syntax().text_range() });
                 }
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 9ca20776b54..6789abfb0a7 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -225,29 +225,29 @@ fn hover_type_info(
     config: &HoverConfig,
     expr_or_pat: &Either<ast::Expr, ast::Pat>,
 ) -> Option<HoverResult> {
-    let TypeInfo { ty, coerced } = match expr_or_pat {
+    let TypeInfo { original, adjusted } = match expr_or_pat {
         Either::Left(expr) => sema.type_of_expr(expr)?,
         Either::Right(pat) => sema.type_of_pat(pat)?,
     };
 
     let mut res = HoverResult::default();
-    res.markup = if let Some(coerced_ty) = coerced {
-        let uncoerced = ty.display(sema.db).to_string();
-        let coerced = coerced_ty.display(sema.db).to_string();
+    res.markup = if let Some(adjusted_ty) = adjusted {
+        let original = original.display(sema.db).to_string();
+        let adjusted = adjusted_ty.display(sema.db).to_string();
         format!(
-            "```text\nType: {:>upad$}\nCoerced to: {:>cpad$}\n```\n",
-            uncoerced = uncoerced,
-            coerced = coerced,
+            "```text\nType: {:>apad$}\nCoerced to: {:>opad$}\n```\n",
+            uncoerced = original,
+            coerced = adjusted,
             // 6 base padding for static text prefix of each line
-            upad = 6 + coerced.len().max(uncoerced.len()),
-            cpad = uncoerced.len(),
+            apad = 6 + adjusted.len().max(original.len()),
+            opad = original.len(),
         )
         .into()
     } else {
         if config.markdown() {
-            Markup::fenced_block(&ty.display(sema.db))
+            Markup::fenced_block(&original.display(sema.db))
         } else {
-            ty.display(sema.db).to_string().into()
+            original.display(sema.db).to_string().into()
         }
     };
     Some(res)
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index 48c2f893aaf..3dc1bbf7dca 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -117,7 +117,7 @@ fn get_chaining_hints(
             next_next = tokens.next()?.kind();
         }
         if next_next == T![.] {
-            let ty = sema.type_of_expr(&expr)?.ty;
+            let ty = sema.type_of_expr(&expr)?.original;
             if ty.is_unknown() {
                 return None;
             }
@@ -189,7 +189,7 @@ fn get_bind_pat_hints(
     let krate = sema.scope(pat.syntax()).module().map(|it| it.krate());
     let famous_defs = FamousDefs(sema, krate);
 
-    let ty = sema.type_of_pat(&pat.clone().into())?.ty;
+    let ty = sema.type_of_pat(&pat.clone().into())?.original;
 
     if should_not_display_type_hint(sema, &pat, &ty) {
         return None;
@@ -308,7 +308,7 @@ fn should_not_display_type_hint(
                     return it.in_token().is_none() ||
                         it.iterable()
                             .and_then(|iterable_expr| sema.type_of_expr(&iterable_expr))
-                            .map(TypeInfo::ty)
+                            .map(TypeInfo::original)
                             .map_or(true, |iterable_ty| iterable_ty.is_unknown() || iterable_ty.is_unit())
                 },
                 _ => (),
@@ -394,7 +394,7 @@ fn is_enum_name_similar_to_param_name(
     argument: &ast::Expr,
     param_name: &str,
 ) -> bool {
-    match sema.type_of_expr(argument).and_then(|t| t.ty.as_adt()) {
+    match sema.type_of_expr(argument).and_then(|t| t.original.as_adt()) {
         Some(hir::Adt::Enum(e)) => to_lower_snake_case(&e.name(sema.db).to_string()) == param_name,
         _ => false,
     }
@@ -431,7 +431,7 @@ fn get_callable(
 ) -> Option<(hir::Callable, ast::ArgList)> {
     match expr {
         ast::Expr::CallExpr(expr) => {
-            sema.type_of_expr(&expr.expr()?)?.ty.as_callable(sema.db).zip(expr.arg_list())
+            sema.type_of_expr(&expr.expr()?)?.original.as_callable(sema.db).zip(expr.arg_list())
         }
         ast::Expr::MethodCallExpr(expr) => {
             sema.resolve_method_call_as_callable(expr).zip(expr.arg_list())
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs
index 9eab563ffff..3f61a856ddf 100644
--- a/crates/ide/src/syntax_highlighting/highlight.rs
+++ b/crates/ide/src/syntax_highlighting/highlight.rs
@@ -123,7 +123,7 @@ pub(super) fn element(
                 let prefix_expr = element.parent().and_then(ast::PrefixExpr::cast)?;
 
                 let expr = prefix_expr.expr()?;
-                let ty = sema.type_of_expr(&expr)?.ty;
+                let ty = sema.type_of_expr(&expr)?.original;
                 if ty.is_raw_ptr() {
                     HlTag::Operator(HlOperator::Other) | HlMod::Unsafe
                 } else if let Some(ast::PrefixOp::Deref) = prefix_expr.op_kind() {
@@ -555,7 +555,7 @@ fn highlight_method_call(
                 if let Some(receiver_ty) =
                     method_call.receiver().and_then(|it| sema.type_of_expr(&it))
                 {
-                    if !receiver_ty.coerced().is_copy(sema.db) {
+                    if !receiver_ty.adjusted().is_copy(sema.db) {
                         h |= HlMod::Consuming
                     }
                 }
diff --git a/crates/ide_assists/src/handlers/add_explicit_type.rs b/crates/ide_assists/src/handlers/add_explicit_type.rs
index 275ef53861e..a48729b45f0 100644
--- a/crates/ide_assists/src/handlers/add_explicit_type.rs
+++ b/crates/ide_assists/src/handlers/add_explicit_type.rs
@@ -57,7 +57,7 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio
         (ast::Pat::IdentPat(_), Some(expr)) => ctx.sema.type_of_expr(&expr)?,
         (pat, _) => ctx.sema.type_of_pat(&pat)?,
     }
-    .coerced();
+    .adjusted();
 
     // Unresolved or unnameable types can't be annotated
     if ty.contains_unknown() || ty.is_closure() {
diff --git a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs
index a24c9359cba..a7344572bae 100644
--- a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs
+++ b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs
@@ -86,7 +86,7 @@ fn validate_method_call_expr(
     let receiver = expr.receiver()?;
     let expr = ast::Expr::MethodCallExpr(expr);
 
-    let it_type = sema.type_of_expr(&receiver)?.coerced();
+    let it_type = sema.type_of_expr(&receiver)?.adjusted();
     let module = sema.scope(receiver.syntax()).module()?;
     let krate = module.krate();
 
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs
index a861755cbbb..25a66029cb9 100644
--- a/crates/ide_assists/src/handlers/extract_function.rs
+++ b/crates/ide_assists/src/handlers/extract_function.rs
@@ -345,7 +345,7 @@ impl FlowKind {
             FlowKind::Return(Some(expr))
             | FlowKind::Break(Some(expr))
             | FlowKind::TryReturn { expr, .. } => {
-                ctx.sema.type_of_expr(expr).map(TypeInfo::coerced)
+                ctx.sema.type_of_expr(expr).map(TypeInfo::adjusted)
             }
             FlowKind::Try { .. } => {
                 stdx::never!("try does not have defined expr_ty");
@@ -852,7 +852,7 @@ fn either_syntax(value: &Either<ast::IdentPat, ast::SelfParam>) -> &SyntaxNode {
 
 fn body_return_ty(ctx: &AssistContext, body: &FunctionBody) -> Option<RetType> {
     match body.tail_expr() {
-        Some(expr) => ctx.sema.type_of_expr(&expr).map(TypeInfo::ty).map(RetType::Expr),
+        Some(expr) => ctx.sema.type_of_expr(&expr).map(TypeInfo::original).map(RetType::Expr),
         None => Some(RetType::Stmt),
     }
 }
@@ -949,7 +949,7 @@ fn expr_err_kind(expr: &ast::Expr, ctx: &AssistContext) -> Option<TryKind> {
     let text = func_name.syntax().text();
 
     if text == "Err" {
-        Some(TryKind::Result { ty: ctx.sema.type_of_expr(expr).map(TypeInfo::ty)? })
+        Some(TryKind::Result { ty: ctx.sema.type_of_expr(expr).map(TypeInfo::original)? })
     } else if text == "None" {
         Some(TryKind::Option)
     } else {
diff --git a/crates/ide_assists/src/handlers/extract_variable.rs b/crates/ide_assists/src/handlers/extract_variable.rs
index c94fa127124..c72ed324237 100644
--- a/crates/ide_assists/src/handlers/extract_variable.rs
+++ b/crates/ide_assists/src/handlers/extract_variable.rs
@@ -40,7 +40,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option
         .take_while(|it| it.text_range().contains_range(ctx.frange.range))
         .find_map(valid_target_expr)?;
     if let Some(ty_info) = ctx.sema.type_of_expr(&to_extract) {
-        if ty_info.coerced().is_unit() {
+        if ty_info.adjusted().is_unit() {
             return None;
         }
     }
diff --git a/crates/ide_assists/src/handlers/fill_match_arms.rs b/crates/ide_assists/src/handlers/fill_match_arms.rs
index 52f0851295c..f71b9e3a3cb 100644
--- a/crates/ide_assists/src/handlers/fill_match_arms.rs
+++ b/crates/ide_assists/src/handlers/fill_match_arms.rs
@@ -223,7 +223,7 @@ impl ExtendedEnum {
 }
 
 fn resolve_enum_def(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<ExtendedEnum> {
-    sema.type_of_expr(expr)?.coerced().autoderef(sema.db).find_map(|ty| match ty.as_adt() {
+    sema.type_of_expr(expr)?.adjusted().autoderef(sema.db).find_map(|ty| match ty.as_adt() {
         Some(Adt::Enum(e)) => Some(ExtendedEnum::Enum(e)),
         _ => ty.is_bool().then(|| ExtendedEnum::Bool),
     })
@@ -234,7 +234,7 @@ fn resolve_tuple_of_enum_def(
     expr: &ast::Expr,
 ) -> Option<Vec<ExtendedEnum>> {
     sema.type_of_expr(expr)?
-        .coerced()
+        .adjusted()
         .tuple_fields(sema.db)
         .iter()
         .map(|ty| {
diff --git a/crates/ide_assists/src/handlers/generate_function.rs b/crates/ide_assists/src/handlers/generate_function.rs
index d22929206b3..255f9ae4ec2 100644
--- a/crates/ide_assists/src/handlers/generate_function.rs
+++ b/crates/ide_assists/src/handlers/generate_function.rs
@@ -153,7 +153,8 @@ impl FunctionBuilder {
         // type, but that the current state of their code doesn't allow that return type
         // to be accurately inferred.
         let (ret_ty, should_render_snippet) = {
-            match ctx.sema.type_of_expr(&ast::Expr::CallExpr(call.clone())).map(TypeInfo::ty) {
+            match ctx.sema.type_of_expr(&ast::Expr::CallExpr(call.clone())).map(TypeInfo::original)
+            {
                 Some(ty) if ty.is_unknown() || ty.is_unit() => (make::ty_unit(), true),
                 Some(ty) => {
                     let rendered = ty.display_source_code(ctx.db(), target_module.into());
@@ -331,7 +332,7 @@ fn fn_arg_type(
     target_module: hir::Module,
     fn_arg: &ast::Expr,
 ) -> Option<String> {
-    let ty = ctx.sema.type_of_expr(fn_arg)?.coerced();
+    let ty = ctx.sema.type_of_expr(fn_arg)?.adjusted();
     if ty.is_unknown() {
         return None;
     }
diff --git a/crates/ide_assists/src/handlers/infer_function_return_type.rs b/crates/ide_assists/src/handlers/infer_function_return_type.rs
index c4bb716071f..778ad21b08a 100644
--- a/crates/ide_assists/src/handlers/infer_function_return_type.rs
+++ b/crates/ide_assists/src/handlers/infer_function_return_type.rs
@@ -18,7 +18,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
 pub(crate) fn infer_function_return_type(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
     let (fn_type, tail_expr, builder_edit_pos) = extract_tail(ctx)?;
     let module = ctx.sema.scope(tail_expr.syntax()).module()?;
-    let ty = ctx.sema.type_of_expr(&tail_expr)?.coerced();
+    let ty = ctx.sema.type_of_expr(&tail_expr)?.adjusted();
     if ty.is_unit() {
         return None;
     }
diff --git a/crates/ide_assists/src/handlers/inline_call.rs b/crates/ide_assists/src/handlers/inline_call.rs
index 8bafae93f95..c60dd81eb06 100644
--- a/crates/ide_assists/src/handlers/inline_call.rs
+++ b/crates/ide_assists/src/handlers/inline_call.rs
@@ -190,7 +190,7 @@ pub(crate) fn inline_(
                         let ty = ctx
                             .sema
                             .type_of_expr(&expr)
-                            .filter(TypeInfo::has_coercion)
+                            .filter(TypeInfo::has_adjustment)
                             .and_then(|_| param_ty);
                         body.push_front(
                             make::let_stmt(pat, ty, Some(expr)).clone_for_update().into(),
diff --git a/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs b/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs
index 54c3f4a2a20..371223e79dc 100644
--- a/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs
+++ b/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs
@@ -80,7 +80,7 @@ fn is_ref_and_impls_iter_method(
     };
     let wanted_method = if ref_expr.mut_token().is_some() { known::iter_mut } else { known::iter };
     let expr_behind_ref = ref_expr.expr()?;
-    let ty = sema.type_of_expr(&expr_behind_ref)?.coerced();
+    let ty = sema.type_of_expr(&expr_behind_ref)?.adjusted();
     let scope = sema.scope(iterable.syntax());
     let krate = scope.module()?.krate();
     let traits_in_scope = scope.traits_in_scope();
@@ -110,7 +110,7 @@ fn is_ref_and_impls_iter_method(
 /// Whether iterable implements core::Iterator
 fn impls_core_iter(sema: &hir::Semantics<ide_db::RootDatabase>, iterable: &ast::Expr) -> bool {
     let it_typ = match sema.type_of_expr(iterable) {
-        Some(it) => it.coerced(),
+        Some(it) => it.adjusted(),
         None => return false,
     };
 
diff --git a/crates/ide_assists/src/handlers/replace_if_let_with_match.rs b/crates/ide_assists/src/handlers/replace_if_let_with_match.rs
index 45b3ce29909..323f58acbbe 100644
--- a/crates/ide_assists/src/handlers/replace_if_let_with_match.rs
+++ b/crates/ide_assists/src/handlers/replace_if_let_with_match.rs
@@ -127,7 +127,7 @@ fn make_else_arm(
         let pattern = if let [(Either::Left(pat), _)] = conditionals {
             ctx.sema
                 .type_of_pat(&pat)
-                .and_then(|ty| TryEnum::from_ty(&ctx.sema, &ty.coerced()))
+                .and_then(|ty| TryEnum::from_ty(&ctx.sema, &ty.adjusted()))
                 .zip(Some(pat))
         } else {
             None
@@ -268,7 +268,7 @@ fn binds_name(pat: &ast::Pat) -> bool {
 
 fn is_sad_pat(sema: &hir::Semantics<RootDatabase>, pat: &ast::Pat) -> bool {
     sema.type_of_pat(pat)
-        .and_then(|ty| TryEnum::from_ty(sema, &ty.coerced()))
+        .and_then(|ty| TryEnum::from_ty(sema, &ty.adjusted()))
         .map_or(false, |it| does_pat_match_variant(pat, &it.sad_pattern()))
 }
 
diff --git a/crates/ide_assists/src/handlers/replace_let_with_if_let.rs b/crates/ide_assists/src/handlers/replace_let_with_if_let.rs
index 190f302d5cd..19abb129efc 100644
--- a/crates/ide_assists/src/handlers/replace_let_with_if_let.rs
+++ b/crates/ide_assists/src/handlers/replace_let_with_if_let.rs
@@ -50,7 +50,7 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext) ->
         |edit| {
             let ty = ctx.sema.type_of_expr(&init);
             let happy_variant = ty
-                .and_then(|ty| TryEnum::from_ty(&ctx.sema, &ty.coerced()))
+                .and_then(|ty| TryEnum::from_ty(&ctx.sema, &ty.adjusted()))
                 .map(|it| it.happy_case());
             let pat = match happy_variant {
                 None => original_pat,
diff --git a/crates/ide_assists/src/utils.rs b/crates/ide_assists/src/utils.rs
index 1efac04db91..0bd89b51f8f 100644
--- a/crates/ide_assists/src/utils.rs
+++ b/crates/ide_assists/src/utils.rs
@@ -270,8 +270,8 @@ fn invert_special_case(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Opti
 
 fn bin_impls_ord(sema: &Semantics<RootDatabase>, bin: &ast::BinExpr) -> bool {
     match (
-        bin.lhs().and_then(|lhs| sema.type_of_expr(&lhs)).map(hir::TypeInfo::coerced),
-        bin.rhs().and_then(|rhs| sema.type_of_expr(&rhs)).map(hir::TypeInfo::coerced),
+        bin.lhs().and_then(|lhs| sema.type_of_expr(&lhs)).map(hir::TypeInfo::adjusted),
+        bin.rhs().and_then(|rhs| sema.type_of_expr(&rhs)).map(hir::TypeInfo::adjusted),
     ) {
         (Some(lhs_ty), Some(rhs_ty)) if lhs_ty == rhs_ty => {
             let krate = sema.scope(bin.syntax()).module().map(|it| it.krate());
diff --git a/crates/ide_assists/src/utils/suggest_name.rs b/crates/ide_assists/src/utils/suggest_name.rs
index 6a2f0863825..c1513f97dad 100644
--- a/crates/ide_assists/src/utils/suggest_name.rs
+++ b/crates/ide_assists/src/utils/suggest_name.rs
@@ -197,7 +197,7 @@ fn from_param(expr: &ast::Expr, sema: &Semantics<'_, RootDatabase>) -> Option<St
         match args_parent {
             ast::CallExpr(call) => {
                 let func = call.expr()?;
-                let func_ty = sema.type_of_expr(&func)?.coerced();
+                let func_ty = sema.type_of_expr(&func)?.adjusted();
                 func_ty.as_callable(sema.db)?
             },
             ast::MethodCallExpr(method) => sema.resolve_method_call_as_callable(&method)?,
@@ -225,7 +225,7 @@ fn var_name_from_pat(pat: &ast::Pat) -> Option<ast::Name> {
 }
 
 fn from_type(expr: &ast::Expr, sema: &Semantics<'_, RootDatabase>) -> Option<String> {
-    let ty = sema.type_of_expr(expr)?.coerced();
+    let ty = sema.type_of_expr(expr)?.adjusted();
     let ty = ty.remove_ref().unwrap_or(ty);
 
     name_of_type(&ty, sema.db)
diff --git a/crates/ide_completion/src/completions/dot.rs b/crates/ide_completion/src/completions/dot.rs
index 564f5f2eae4..fdd6e59ffe9 100644
--- a/crates/ide_completion/src/completions/dot.rs
+++ b/crates/ide_completion/src/completions/dot.rs
@@ -14,7 +14,7 @@ pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) {
     };
 
     let receiver_ty = match ctx.sema.type_of_expr(dot_receiver) {
-        Some(ty) => ty.ty,
+        Some(ty) => ty.original,
         _ => return,
     };
 
diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs
index e10eb269368..33b9b61a72d 100644
--- a/crates/ide_completion/src/completions/flyimport.rs
+++ b/crates/ide_completion/src/completions/flyimport.rs
@@ -180,7 +180,7 @@ fn import_assets(ctx: &CompletionContext, fuzzy_name: String) -> Option<ImportAs
     if let Some(dot_receiver) = ctx.dot_receiver() {
         ImportAssets::for_fuzzy_method_call(
             current_module,
-            ctx.sema.type_of_expr(dot_receiver)?.ty,
+            ctx.sema.type_of_expr(dot_receiver)?.original,
             fuzzy_name,
             dot_receiver.syntax().clone(),
         )
diff --git a/crates/ide_completion/src/completions/postfix.rs b/crates/ide_completion/src/completions/postfix.rs
index 7ec1f939c3e..b9eaccaf55c 100644
--- a/crates/ide_completion/src/completions/postfix.rs
+++ b/crates/ide_completion/src/completions/postfix.rs
@@ -38,7 +38,7 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
     let receiver_text = get_receiver_text(dot_receiver, receiver_is_ambiguous_float_literal);
 
     let receiver_ty = match ctx.sema.type_of_expr(dot_receiver) {
-        Some(it) => it.ty,
+        Some(it) => it.original,
         None => return,
     };
 
diff --git a/crates/ide_completion/src/completions/record.rs b/crates/ide_completion/src/completions/record.rs
index d15375634de..8ede825a622 100644
--- a/crates/ide_completion/src/completions/record.rs
+++ b/crates/ide_completion/src/completions/record.rs
@@ -12,9 +12,9 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) ->
         Some(ImmediateLocation::RecordExpr(record_expr)) => {
             let ty = ctx.sema.type_of_expr(&Expr::RecordExpr(record_expr.clone()));
             let default_trait = FamousDefs(&ctx.sema, ctx.krate).core_default_Default();
-            let impl_default_trait = default_trait
-                .zip(ty)
-                .map_or(false, |(default_trait, ty)| ty.ty.impls_trait(ctx.db, default_trait, &[]));
+            let impl_default_trait = default_trait.zip(ty).map_or(false, |(default_trait, ty)| {
+                ty.original.impls_trait(ctx.db, default_trait, &[])
+            });
 
             let missing_fields = ctx.sema.record_literal_missing_fields(record_expr);
             if impl_default_trait && !missing_fields.is_empty() {
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs
index 6922c203cea..ac5cd1ce8e3 100644
--- a/crates/ide_completion/src/context.rs
+++ b/crates/ide_completion/src/context.rs
@@ -454,7 +454,7 @@ impl<'a> CompletionContext<'a> {
                         let ty = it.pat()
                             .and_then(|pat| self.sema.type_of_pat(&pat))
                             .or_else(|| it.initializer().and_then(|it| self.sema.type_of_expr(&it)))
-                            .map(TypeInfo::ty);
+                            .map(TypeInfo::original);
                         let name = if let Some(ast::Pat::IdentPat(ident)) = it.pat() {
                             ident.name().map(NameOrNameRef::Name)
                         } else {
@@ -497,13 +497,13 @@ impl<'a> CompletionContext<'a> {
                     ast::RecordExprField(it) => {
                         cov_mark::hit!(expected_type_struct_field_with_leading_char);
                         (
-                            it.expr().as_ref().and_then(|e| self.sema.type_of_expr(e)).map(TypeInfo::ty),
+                            it.expr().as_ref().and_then(|e| self.sema.type_of_expr(e)).map(TypeInfo::original),
                             it.field_name().map(NameOrNameRef::NameRef),
                         )
                     },
                     ast::MatchExpr(it) => {
                         cov_mark::hit!(expected_type_match_arm_without_leading_char);
-                        let ty = it.expr().and_then(|e| self.sema.type_of_expr(&e)).map(TypeInfo::ty);
+                        let ty = it.expr().and_then(|e| self.sema.type_of_expr(&e)).map(TypeInfo::original);
                         (ty, None)
                     },
                     ast::IfExpr(it) => {
@@ -511,13 +511,13 @@ impl<'a> CompletionContext<'a> {
                         let ty = it.condition()
                             .and_then(|cond| cond.expr())
                             .and_then(|e| self.sema.type_of_expr(&e))
-                            .map(TypeInfo::ty);
+                            .map(TypeInfo::original);
                         (ty, None)
                     },
                     ast::IdentPat(it) => {
                         cov_mark::hit!(expected_type_if_let_with_leading_char);
                         cov_mark::hit!(expected_type_match_arm_with_leading_char);
-                        let ty = self.sema.type_of_pat(&ast::Pat::from(it)).map(TypeInfo::ty);
+                        let ty = self.sema.type_of_pat(&ast::Pat::from(it)).map(TypeInfo::original);
                         (ty, None)
                     },
                     ast::Fn(it) => {
@@ -528,7 +528,7 @@ impl<'a> CompletionContext<'a> {
                     },
                     ast::ClosureExpr(it) => {
                         let ty = self.sema.type_of_expr(&it.into());
-                        ty.and_then(|ty| ty.ty.as_callable(self.db))
+                        ty.and_then(|ty| ty.original.as_callable(self.db))
                             .map(|c| (Some(c.return_type()), None))
                             .unwrap_or((None, None))
                     },
diff --git a/crates/ide_db/src/call_info.rs b/crates/ide_db/src/call_info.rs
index a406e0d6f58..016b0014396 100644
--- a/crates/ide_db/src/call_info.rs
+++ b/crates/ide_db/src/call_info.rs
@@ -119,7 +119,7 @@ fn call_info_impl(
 
     let callable = match &calling_node {
         FnCallNode::CallExpr(call) => {
-            sema.type_of_expr(&call.expr()?)?.coerced().as_callable(sema.db)?
+            sema.type_of_expr(&call.expr()?)?.adjusted().as_callable(sema.db)?
         }
         FnCallNode::MethodCallExpr(call) => sema.resolve_method_call_as_callable(call)?,
     };
diff --git a/crates/ide_db/src/helpers/import_assets.rs b/crates/ide_db/src/helpers/import_assets.rs
index 52cd99ec910..3433398ebab 100644
--- a/crates/ide_db/src/helpers/import_assets.rs
+++ b/crates/ide_db/src/helpers/import_assets.rs
@@ -543,7 +543,7 @@ impl ImportCandidate {
         match sema.resolve_method_call(method_call) {
             Some(_) => None,
             None => Some(Self::TraitMethod(TraitImportCandidate {
-                receiver_ty: sema.type_of_expr(&method_call.receiver()?)?.coerced(),
+                receiver_ty: sema.type_of_expr(&method_call.receiver()?)?.adjusted(),
                 assoc_item_name: NameToImport::Exact(method_call.name_ref()?.to_string()),
             })),
         }
diff --git a/crates/ide_diagnostics/src/handlers/missing_ok_or_some_in_tail_expr.rs b/crates/ide_diagnostics/src/handlers/missing_ok_or_some_in_tail_expr.rs
index 06dc8dcd8ba..2e9bd2d3ddd 100644
--- a/crates/ide_diagnostics/src/handlers/missing_ok_or_some_in_tail_expr.rs
+++ b/crates/ide_diagnostics/src/handlers/missing_ok_or_some_in_tail_expr.rs
@@ -35,7 +35,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingOkOrSomeInTailExpr) -> Op
     let tail_expr_range = tail_expr.syntax().text_range();
     let mut builder = TextEdit::builder();
     for_each_tail_expr(&tail_expr, &mut |expr| {
-        if ctx.sema.type_of_expr(expr).map(TypeInfo::ty).as_ref() != Some(&d.expected) {
+        if ctx.sema.type_of_expr(expr).map(TypeInfo::original).as_ref() != Some(&d.expected) {
             builder.insert(expr.syntax().text_range().start(), format!("{}(", d.required));
             builder.insert(expr.syntax().text_range().end(), ")".to_string());
         }
diff --git a/crates/ide_diagnostics/src/handlers/no_such_field.rs b/crates/ide_diagnostics/src/handlers/no_such_field.rs
index 2518dd8bb69..667a550d1f9 100644
--- a/crates/ide_diagnostics/src/handlers/no_such_field.rs
+++ b/crates/ide_diagnostics/src/handlers/no_such_field.rs
@@ -62,7 +62,7 @@ fn missing_record_expr_field_fixes(
     };
     let def_file_id = def_file_id.original_file(sema.db);
 
-    let new_field_type = sema.type_of_expr(&record_expr_field.expr()?)?.coerced();
+    let new_field_type = sema.type_of_expr(&record_expr_field.expr()?)?.adjusted();
     if new_field_type.is_unknown() {
         return None;
     }
diff --git a/crates/ide_ssr/src/matching.rs b/crates/ide_ssr/src/matching.rs
index 6699d29f97b..55147674d25 100644
--- a/crates/ide_ssr/src/matching.rs
+++ b/crates/ide_ssr/src/matching.rs
@@ -615,7 +615,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
             .ok_or_else(|| {
                 match_error!("Failed to get receiver type for `{}`", expr.syntax().text())
             })?
-            .ty;
+            .original;
         // Temporary needed to make the borrow checker happy.
         let res = code_type
             .autoderef(self.sema.db)