aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer/expr.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-03-01 12:57:26 +0000
committerGitHub <[email protected]>2021-03-01 12:57:26 +0000
commitcda13d54613006c7985da0489878605300ba05b8 (patch)
tree81a8fc4b890192c41f00f7731929e781c3cb790a /crates/hir_ty/src/infer/expr.rs
parent1c7b2b8c0748c9548500d0dc08c8da1d1a36c81a (diff)
parent4b7fc693150f333cefe0e69d93271807f32741c4 (diff)
Merge #7823
7823: Being Ty::InferenceVar closer to chalk equivalent r=flodiebold a=Veykril Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/infer/expr.rs')
-rw-r--r--crates/hir_ty/src/infer/expr.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs
index 23d4ac8ef..928ad37a3 100644
--- a/crates/hir_ty/src/infer/expr.rs
+++ b/crates/hir_ty/src/infer/expr.rs
@@ -3,6 +3,7 @@
3use std::iter::{repeat, repeat_with}; 3use std::iter::{repeat, repeat_with};
4use std::{mem, sync::Arc}; 4use std::{mem, sync::Arc};
5 5
6use chalk_ir::TyVariableKind;
6use hir_def::{ 7use hir_def::{
7 expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, 8 expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp},
8 path::{GenericArg, GenericArgs}, 9 path::{GenericArg, GenericArgs},
@@ -18,8 +19,8 @@ use crate::{
18 primitive::{self, UintTy}, 19 primitive::{self, UintTy},
19 traits::{FnTrait, InEnvironment}, 20 traits::{FnTrait, InEnvironment},
20 utils::{generics, variant_data, Generics}, 21 utils::{generics, variant_data, Generics},
21 Binders, CallableDefId, FnPointer, FnSig, InferTy, Mutability, Obligation, OpaqueTyId, Rawness, 22 Binders, CallableDefId, FnPointer, FnSig, Mutability, Obligation, OpaqueTyId, Rawness, Scalar,
22 Scalar, Substs, TraitRef, Ty, 23 Substs, TraitRef, Ty,
23}; 24};
24 25
25use super::{ 26use super::{
@@ -527,8 +528,8 @@ impl<'a> InferenceContext<'a> {
527 Ty::Scalar(Scalar::Int(_)) 528 Ty::Scalar(Scalar::Int(_))
528 | Ty::Scalar(Scalar::Uint(_)) 529 | Ty::Scalar(Scalar::Uint(_))
529 | Ty::Scalar(Scalar::Float(_)) 530 | Ty::Scalar(Scalar::Float(_))
530 | Ty::Infer(InferTy::IntVar(..)) 531 | Ty::InferenceVar(_, TyVariableKind::Integer)
531 | Ty::Infer(InferTy::FloatVar(..)) => inner_ty, 532 | Ty::InferenceVar(_, TyVariableKind::Float) => inner_ty,
532 // Otherwise we resolve via the std::ops::Neg trait 533 // Otherwise we resolve via the std::ops::Neg trait
533 _ => self 534 _ => self
534 .resolve_associated_type(inner_ty, self.resolve_ops_neg_output()), 535 .resolve_associated_type(inner_ty, self.resolve_ops_neg_output()),
@@ -540,7 +541,7 @@ impl<'a> InferenceContext<'a> {
540 Ty::Scalar(Scalar::Bool) 541 Ty::Scalar(Scalar::Bool)
541 | Ty::Scalar(Scalar::Int(_)) 542 | Ty::Scalar(Scalar::Int(_))
542 | Ty::Scalar(Scalar::Uint(_)) 543 | Ty::Scalar(Scalar::Uint(_))
543 | Ty::Infer(InferTy::IntVar(..)) => inner_ty, 544 | Ty::InferenceVar(_, TyVariableKind::Integer) => inner_ty,
544 // Otherwise we resolve via the std::ops::Not trait 545 // Otherwise we resolve via the std::ops::Not trait
545 _ => self 546 _ => self
546 .resolve_associated_type(inner_ty, self.resolve_ops_not_output()), 547 .resolve_associated_type(inner_ty, self.resolve_ops_not_output()),
@@ -761,7 +762,7 @@ impl<'a> InferenceContext<'a> {
761 // `!`). 762 // `!`).
762 if self.diverges.is_always() { 763 if self.diverges.is_always() {
763 // we don't even make an attempt at coercion 764 // we don't even make an attempt at coercion
764 self.table.new_maybe_never_type_var() 765 self.table.new_maybe_never_var()
765 } else { 766 } else {
766 self.coerce(&Ty::unit(), expected.coercion_target()); 767 self.coerce(&Ty::unit(), expected.coercion_target());
767 Ty::unit() 768 Ty::unit()