diff options
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 48 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 78 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 36 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/op.rs | 20 |
6 files changed, 95 insertions, 95 deletions
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 6219402d4..5926b5758 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -53,7 +53,7 @@ pub use self::{ | |||
53 | name::Name, | 53 | name::Name, |
54 | ids::{HirFileId, MacroCallId, MacroCallLoc, HirInterner}, | 54 | ids::{HirFileId, MacroCallId, MacroCallLoc, HirInterner}, |
55 | nameres::{PerNs, Namespace}, | 55 | nameres::{PerNs, Namespace}, |
56 | ty::{Ty, ApplicationTy, TypeName, Substs, display::HirDisplay}, | 56 | ty::{Ty, ApplicationTy, TypeCtor, Substs, display::HirDisplay}, |
57 | impl_block::{ImplBlock, ImplItem}, | 57 | impl_block::{ImplBlock, ImplItem}, |
58 | docs::{Docs, Documentation}, | 58 | docs::{Docs, Documentation}, |
59 | adt::AdtDef, | 59 | adt::AdtDef, |
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 0bb716569..1d9e7b76c 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -21,7 +21,7 @@ pub(crate) use infer::{infer, InferenceResult, InferTy}; | |||
21 | use display::{HirDisplay, HirFormatter}; | 21 | use display::{HirDisplay, HirFormatter}; |
22 | 22 | ||
23 | #[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] | 23 | #[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] |
24 | pub enum TypeName { | 24 | pub enum TypeCtor { |
25 | /// The primitive boolean type. Written as `bool`. | 25 | /// The primitive boolean type. Written as `bool`. |
26 | Bool, | 26 | Bool, |
27 | 27 | ||
@@ -87,7 +87,7 @@ pub enum TypeName { | |||
87 | 87 | ||
88 | #[derive(Clone, PartialEq, Eq, Debug)] | 88 | #[derive(Clone, PartialEq, Eq, Debug)] |
89 | pub struct ApplicationTy { | 89 | pub struct ApplicationTy { |
90 | pub name: TypeName, | 90 | pub name: TypeCtor, |
91 | pub parameters: Substs, | 91 | pub parameters: Substs, |
92 | } | 92 | } |
93 | 93 | ||
@@ -191,17 +191,17 @@ impl FnSig { | |||
191 | } | 191 | } |
192 | 192 | ||
193 | impl Ty { | 193 | impl Ty { |
194 | pub fn simple(name: TypeName) -> Ty { | 194 | pub fn simple(name: TypeCtor) -> Ty { |
195 | Ty::Apply(ApplicationTy { name, parameters: Substs::empty() }) | 195 | Ty::Apply(ApplicationTy { name, parameters: Substs::empty() }) |
196 | } | 196 | } |
197 | pub fn apply_one(name: TypeName, param: Ty) -> Ty { | 197 | pub fn apply_one(name: TypeCtor, param: Ty) -> Ty { |
198 | Ty::Apply(ApplicationTy { name, parameters: Substs::single(param) }) | 198 | Ty::Apply(ApplicationTy { name, parameters: Substs::single(param) }) |
199 | } | 199 | } |
200 | pub fn apply(name: TypeName, parameters: Substs) -> Ty { | 200 | pub fn apply(name: TypeCtor, parameters: Substs) -> Ty { |
201 | Ty::Apply(ApplicationTy { name, parameters }) | 201 | Ty::Apply(ApplicationTy { name, parameters }) |
202 | } | 202 | } |
203 | pub fn unit() -> Self { | 203 | pub fn unit() -> Self { |
204 | Ty::apply(TypeName::Tuple, Substs::empty()) | 204 | Ty::apply(TypeCtor::Tuple, Substs::empty()) |
205 | } | 205 | } |
206 | 206 | ||
207 | pub fn walk(&self, f: &mut impl FnMut(&Ty)) { | 207 | pub fn walk(&self, f: &mut impl FnMut(&Ty)) { |
@@ -236,7 +236,7 @@ impl Ty { | |||
236 | 236 | ||
237 | pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { | 237 | pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { |
238 | match self { | 238 | match self { |
239 | Ty::Apply(ApplicationTy { name: TypeName::Ref(mutability), parameters }) => { | 239 | Ty::Apply(ApplicationTy { name: TypeCtor::Ref(mutability), parameters }) => { |
240 | Some((parameters.as_single(), *mutability)) | 240 | Some((parameters.as_single(), *mutability)) |
241 | } | 241 | } |
242 | _ => None, | 242 | _ => None, |
@@ -245,7 +245,7 @@ impl Ty { | |||
245 | 245 | ||
246 | pub fn as_adt(&self) -> Option<(AdtDef, &Substs)> { | 246 | pub fn as_adt(&self) -> Option<(AdtDef, &Substs)> { |
247 | match self { | 247 | match self { |
248 | Ty::Apply(ApplicationTy { name: TypeName::Adt(adt_def), parameters }) => { | 248 | Ty::Apply(ApplicationTy { name: TypeCtor::Adt(adt_def), parameters }) => { |
249 | Some((*adt_def, parameters)) | 249 | Some((*adt_def, parameters)) |
250 | } | 250 | } |
251 | _ => None, | 251 | _ => None, |
@@ -254,7 +254,7 @@ impl Ty { | |||
254 | 254 | ||
255 | pub fn as_tuple(&self) -> Option<&Substs> { | 255 | pub fn as_tuple(&self) -> Option<&Substs> { |
256 | match self { | 256 | match self { |
257 | Ty::Apply(ApplicationTy { name: TypeName::Tuple, parameters }) => Some(parameters), | 257 | Ty::Apply(ApplicationTy { name: TypeCtor::Tuple, parameters }) => Some(parameters), |
258 | _ => None, | 258 | _ => None, |
259 | } | 259 | } |
260 | } | 260 | } |
@@ -262,8 +262,8 @@ impl Ty { | |||
262 | fn builtin_deref(&self) -> Option<Ty> { | 262 | fn builtin_deref(&self) -> Option<Ty> { |
263 | match self { | 263 | match self { |
264 | Ty::Apply(a_ty) => match a_ty.name { | 264 | Ty::Apply(a_ty) => match a_ty.name { |
265 | TypeName::Ref(..) => Some(Ty::clone(a_ty.parameters.as_single())), | 265 | TypeCtor::Ref(..) => Some(Ty::clone(a_ty.parameters.as_single())), |
266 | TypeName::RawPtr(..) => Some(Ty::clone(a_ty.parameters.as_single())), | 266 | TypeCtor::RawPtr(..) => Some(Ty::clone(a_ty.parameters.as_single())), |
267 | _ => None, | 267 | _ => None, |
268 | }, | 268 | }, |
269 | _ => None, | 269 | _ => None, |
@@ -318,25 +318,25 @@ impl HirDisplay for &Ty { | |||
318 | impl HirDisplay for ApplicationTy { | 318 | impl HirDisplay for ApplicationTy { |
319 | fn hir_fmt(&self, f: &mut HirFormatter<impl HirDatabase>) -> fmt::Result { | 319 | fn hir_fmt(&self, f: &mut HirFormatter<impl HirDatabase>) -> fmt::Result { |
320 | match self.name { | 320 | match self.name { |
321 | TypeName::Bool => write!(f, "bool")?, | 321 | TypeCtor::Bool => write!(f, "bool")?, |
322 | TypeName::Char => write!(f, "char")?, | 322 | TypeCtor::Char => write!(f, "char")?, |
323 | TypeName::Int(t) => write!(f, "{}", t)?, | 323 | TypeCtor::Int(t) => write!(f, "{}", t)?, |
324 | TypeName::Float(t) => write!(f, "{}", t)?, | 324 | TypeCtor::Float(t) => write!(f, "{}", t)?, |
325 | TypeName::Str => write!(f, "str")?, | 325 | TypeCtor::Str => write!(f, "str")?, |
326 | TypeName::Slice | TypeName::Array => { | 326 | TypeCtor::Slice | TypeCtor::Array => { |
327 | let t = self.parameters.as_single(); | 327 | let t = self.parameters.as_single(); |
328 | write!(f, "[{}]", t.display(f.db))?; | 328 | write!(f, "[{}]", t.display(f.db))?; |
329 | } | 329 | } |
330 | TypeName::RawPtr(m) => { | 330 | TypeCtor::RawPtr(m) => { |
331 | let t = self.parameters.as_single(); | 331 | let t = self.parameters.as_single(); |
332 | write!(f, "*{}{}", m.as_keyword_for_ptr(), t.display(f.db))?; | 332 | write!(f, "*{}{}", m.as_keyword_for_ptr(), t.display(f.db))?; |
333 | } | 333 | } |
334 | TypeName::Ref(m) => { | 334 | TypeCtor::Ref(m) => { |
335 | let t = self.parameters.as_single(); | 335 | let t = self.parameters.as_single(); |
336 | write!(f, "&{}{}", m.as_keyword_for_ref(), t.display(f.db))?; | 336 | write!(f, "&{}{}", m.as_keyword_for_ref(), t.display(f.db))?; |
337 | } | 337 | } |
338 | TypeName::Never => write!(f, "!")?, | 338 | TypeCtor::Never => write!(f, "!")?, |
339 | TypeName::Tuple => { | 339 | TypeCtor::Tuple => { |
340 | let ts = &self.parameters; | 340 | let ts = &self.parameters; |
341 | if ts.0.len() == 1 { | 341 | if ts.0.len() == 1 { |
342 | write!(f, "({},)", ts.0[0].display(f.db))?; | 342 | write!(f, "({},)", ts.0[0].display(f.db))?; |
@@ -346,13 +346,13 @@ impl HirDisplay for ApplicationTy { | |||
346 | write!(f, ")")?; | 346 | write!(f, ")")?; |
347 | } | 347 | } |
348 | } | 348 | } |
349 | TypeName::FnPtr => { | 349 | TypeCtor::FnPtr => { |
350 | let sig = FnSig::from_fn_ptr_substs(&self.parameters); | 350 | let sig = FnSig::from_fn_ptr_substs(&self.parameters); |
351 | write!(f, "fn(")?; | 351 | write!(f, "fn(")?; |
352 | f.write_joined(sig.params(), ", ")?; | 352 | f.write_joined(sig.params(), ", ")?; |
353 | write!(f, ") -> {}", sig.ret().display(f.db))?; | 353 | write!(f, ") -> {}", sig.ret().display(f.db))?; |
354 | } | 354 | } |
355 | TypeName::FnDef(def) => { | 355 | TypeCtor::FnDef(def) => { |
356 | let sig = f.db.callable_item_signature(def); | 356 | let sig = f.db.callable_item_signature(def); |
357 | let name = match def { | 357 | let name = match def { |
358 | CallableDef::Function(ff) => ff.name(f.db), | 358 | CallableDef::Function(ff) => ff.name(f.db), |
@@ -372,7 +372,7 @@ impl HirDisplay for ApplicationTy { | |||
372 | f.write_joined(sig.params(), ", ")?; | 372 | f.write_joined(sig.params(), ", ")?; |
373 | write!(f, ") -> {}", sig.ret().display(f.db))?; | 373 | write!(f, ") -> {}", sig.ret().display(f.db))?; |
374 | } | 374 | } |
375 | TypeName::Adt(def_id) => { | 375 | TypeCtor::Adt(def_id) => { |
376 | let name = match def_id { | 376 | let name = match def_id { |
377 | AdtDef::Struct(s) => s.name(f.db), | 377 | AdtDef::Struct(s) => s.name(f.db), |
378 | AdtDef::Enum(e) => e.name(f.db), | 378 | AdtDef::Enum(e) => e.name(f.db), |
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 0dafd8cbd..e975f9217 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -38,7 +38,7 @@ use crate::{ | |||
38 | resolve::{Resolver, Resolution}, | 38 | resolve::{Resolver, Resolution}, |
39 | nameres::Namespace | 39 | nameres::Namespace |
40 | }; | 40 | }; |
41 | use super::{Ty, TypableDef, Substs, primitive, op, FnSig, ApplicationTy, TypeName}; | 41 | use super::{Ty, TypableDef, Substs, primitive, op, FnSig, ApplicationTy, TypeCtor}; |
42 | 42 | ||
43 | /// The entry point of type inference. | 43 | /// The entry point of type inference. |
44 | pub fn infer(db: &impl HirDatabase, func: Function) -> Arc<InferenceResult> { | 44 | pub fn infer(db: &impl HirDatabase, func: Function) -> Arc<InferenceResult> { |
@@ -278,11 +278,11 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
278 | match ty { | 278 | match ty { |
279 | Ty::Unknown => self.new_type_var(), | 279 | Ty::Unknown => self.new_type_var(), |
280 | Ty::Apply(ApplicationTy { | 280 | Ty::Apply(ApplicationTy { |
281 | name: TypeName::Int(primitive::UncertainIntTy::Unknown), | 281 | name: TypeCtor::Int(primitive::UncertainIntTy::Unknown), |
282 | .. | 282 | .. |
283 | }) => self.new_integer_var(), | 283 | }) => self.new_integer_var(), |
284 | Ty::Apply(ApplicationTy { | 284 | Ty::Apply(ApplicationTy { |
285 | name: TypeName::Float(primitive::UncertainFloatTy::Unknown), | 285 | name: TypeCtor::Float(primitive::UncertainFloatTy::Unknown), |
286 | .. | 286 | .. |
287 | }) => self.new_float_var(), | 287 | }) => self.new_float_var(), |
288 | _ => ty, | 288 | _ => ty, |
@@ -629,7 +629,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
629 | .collect::<Vec<_>>() | 629 | .collect::<Vec<_>>() |
630 | .into(); | 630 | .into(); |
631 | 631 | ||
632 | Ty::apply(TypeName::Tuple, Substs(inner_tys)) | 632 | Ty::apply(TypeCtor::Tuple, Substs(inner_tys)) |
633 | } | 633 | } |
634 | Pat::Ref { pat, mutability } => { | 634 | Pat::Ref { pat, mutability } => { |
635 | let expectation = match expected.as_reference() { | 635 | let expectation = match expected.as_reference() { |
@@ -642,7 +642,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
642 | _ => &Ty::Unknown, | 642 | _ => &Ty::Unknown, |
643 | }; | 643 | }; |
644 | let subty = self.infer_pat(*pat, expectation, default_bm); | 644 | let subty = self.infer_pat(*pat, expectation, default_bm); |
645 | Ty::apply_one(TypeName::Ref(*mutability), subty.into()) | 645 | Ty::apply_one(TypeCtor::Ref(*mutability), subty.into()) |
646 | } | 646 | } |
647 | Pat::TupleStruct { path: ref p, args: ref subpats } => { | 647 | Pat::TupleStruct { path: ref p, args: ref subpats } => { |
648 | self.infer_tuple_struct_pat(p.as_ref(), subpats, expected, default_bm) | 648 | self.infer_tuple_struct_pat(p.as_ref(), subpats, expected, default_bm) |
@@ -670,7 +670,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
670 | 670 | ||
671 | let bound_ty = match mode { | 671 | let bound_ty = match mode { |
672 | BindingMode::Ref(mutability) => { | 672 | BindingMode::Ref(mutability) => { |
673 | Ty::apply_one(TypeName::Ref(mutability), inner_ty.clone().into()) | 673 | Ty::apply_one(TypeCtor::Ref(mutability), inner_ty.clone().into()) |
674 | } | 674 | } |
675 | BindingMode::Move => inner_ty.clone(), | 675 | BindingMode::Move => inner_ty.clone(), |
676 | }; | 676 | }; |
@@ -725,7 +725,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
725 | Expr::Missing => Ty::Unknown, | 725 | Expr::Missing => Ty::Unknown, |
726 | Expr::If { condition, then_branch, else_branch } => { | 726 | Expr::If { condition, then_branch, else_branch } => { |
727 | // if let is desugared to match, so this is always simple if | 727 | // if let is desugared to match, so this is always simple if |
728 | self.infer_expr(*condition, &Expectation::has_type(Ty::simple(TypeName::Bool))); | 728 | self.infer_expr(*condition, &Expectation::has_type(Ty::simple(TypeCtor::Bool))); |
729 | let then_ty = self.infer_expr(*then_branch, expected); | 729 | let then_ty = self.infer_expr(*then_branch, expected); |
730 | match else_branch { | 730 | match else_branch { |
731 | Some(else_branch) => { | 731 | Some(else_branch) => { |
@@ -742,11 +742,11 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
742 | Expr::Loop { body } => { | 742 | Expr::Loop { body } => { |
743 | self.infer_expr(*body, &Expectation::has_type(Ty::unit())); | 743 | self.infer_expr(*body, &Expectation::has_type(Ty::unit())); |
744 | // TODO handle break with value | 744 | // TODO handle break with value |
745 | Ty::simple(TypeName::Never) | 745 | Ty::simple(TypeCtor::Never) |
746 | } | 746 | } |
747 | Expr::While { condition, body } => { | 747 | Expr::While { condition, body } => { |
748 | // while let is desugared to a match loop, so this is always simple while | 748 | // while let is desugared to a match loop, so this is always simple while |
749 | self.infer_expr(*condition, &Expectation::has_type(Ty::simple(TypeName::Bool))); | 749 | self.infer_expr(*condition, &Expectation::has_type(Ty::simple(TypeCtor::Bool))); |
750 | self.infer_expr(*body, &Expectation::has_type(Ty::unit())); | 750 | self.infer_expr(*body, &Expectation::has_type(Ty::unit())); |
751 | Ty::unit() | 751 | Ty::unit() |
752 | } | 752 | } |
@@ -777,11 +777,11 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
777 | let callee_ty = self.infer_expr(*callee, &Expectation::none()); | 777 | let callee_ty = self.infer_expr(*callee, &Expectation::none()); |
778 | let (param_tys, ret_ty) = match &callee_ty { | 778 | let (param_tys, ret_ty) = match &callee_ty { |
779 | Ty::Apply(a_ty) => match a_ty.name { | 779 | Ty::Apply(a_ty) => match a_ty.name { |
780 | TypeName::FnPtr => { | 780 | TypeCtor::FnPtr => { |
781 | let sig = FnSig::from_fn_ptr_substs(&a_ty.parameters); | 781 | let sig = FnSig::from_fn_ptr_substs(&a_ty.parameters); |
782 | (sig.params().to_vec(), sig.ret().clone()) | 782 | (sig.params().to_vec(), sig.ret().clone()) |
783 | } | 783 | } |
784 | TypeName::FnDef(def) => { | 784 | TypeCtor::FnDef(def) => { |
785 | let sig = self.db.callable_item_signature(def); | 785 | let sig = self.db.callable_item_signature(def); |
786 | let ret_ty = sig.ret().clone().subst(&a_ty.parameters); | 786 | let ret_ty = sig.ret().clone().subst(&a_ty.parameters); |
787 | let param_tys = sig | 787 | let param_tys = sig |
@@ -824,7 +824,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
824 | let method_ty = self.insert_type_vars(method_ty); | 824 | let method_ty = self.insert_type_vars(method_ty); |
825 | let (expected_receiver_ty, param_tys, ret_ty) = match &method_ty { | 825 | let (expected_receiver_ty, param_tys, ret_ty) = match &method_ty { |
826 | Ty::Apply(a_ty) => match a_ty.name { | 826 | Ty::Apply(a_ty) => match a_ty.name { |
827 | TypeName::FnPtr => { | 827 | TypeCtor::FnPtr => { |
828 | let sig = FnSig::from_fn_ptr_substs(&a_ty.parameters); | 828 | let sig = FnSig::from_fn_ptr_substs(&a_ty.parameters); |
829 | if !sig.params().is_empty() { | 829 | if !sig.params().is_empty() { |
830 | ( | 830 | ( |
@@ -836,7 +836,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
836 | (Ty::Unknown, Vec::new(), sig.ret().clone()) | 836 | (Ty::Unknown, Vec::new(), sig.ret().clone()) |
837 | } | 837 | } |
838 | } | 838 | } |
839 | TypeName::FnDef(def) => { | 839 | TypeCtor::FnDef(def) => { |
840 | let sig = self.db.callable_item_signature(def); | 840 | let sig = self.db.callable_item_signature(def); |
841 | let ret_ty = sig.ret().clone().subst(&a_ty.parameters); | 841 | let ret_ty = sig.ret().clone().subst(&a_ty.parameters); |
842 | 842 | ||
@@ -858,7 +858,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
858 | // Apply autoref so the below unification works correctly | 858 | // Apply autoref so the below unification works correctly |
859 | let actual_receiver_ty = match expected_receiver_ty.as_reference() { | 859 | let actual_receiver_ty = match expected_receiver_ty.as_reference() { |
860 | Some((_, mutability)) => { | 860 | Some((_, mutability)) => { |
861 | Ty::apply_one(TypeName::Ref(mutability), derefed_receiver_ty) | 861 | Ty::apply_one(TypeCtor::Ref(mutability), derefed_receiver_ty) |
862 | } | 862 | } |
863 | _ => derefed_receiver_ty, | 863 | _ => derefed_receiver_ty, |
864 | }; | 864 | }; |
@@ -885,7 +885,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
885 | if let Some(guard_expr) = arm.guard { | 885 | if let Some(guard_expr) = arm.guard { |
886 | self.infer_expr( | 886 | self.infer_expr( |
887 | guard_expr, | 887 | guard_expr, |
888 | &Expectation::has_type(Ty::simple(TypeName::Bool)), | 888 | &Expectation::has_type(Ty::simple(TypeCtor::Bool)), |
889 | ); | 889 | ); |
890 | } | 890 | } |
891 | self.infer_expr(arm.expr, &expected); | 891 | self.infer_expr(arm.expr, &expected); |
@@ -898,19 +898,19 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
898 | let resolver = expr::resolver_for_expr(self.body.clone(), self.db, tgt_expr); | 898 | let resolver = expr::resolver_for_expr(self.body.clone(), self.db, tgt_expr); |
899 | self.infer_path_expr(&resolver, p, tgt_expr.into()).unwrap_or(Ty::Unknown) | 899 | self.infer_path_expr(&resolver, p, tgt_expr.into()).unwrap_or(Ty::Unknown) |
900 | } | 900 | } |
901 | Expr::Continue => Ty::simple(TypeName::Never), | 901 | Expr::Continue => Ty::simple(TypeCtor::Never), |
902 | Expr::Break { expr } => { | 902 | Expr::Break { expr } => { |
903 | if let Some(expr) = expr { | 903 | if let Some(expr) = expr { |
904 | // TODO handle break with value | 904 | // TODO handle break with value |
905 | self.infer_expr(*expr, &Expectation::none()); | 905 | self.infer_expr(*expr, &Expectation::none()); |
906 | } | 906 | } |
907 | Ty::simple(TypeName::Never) | 907 | Ty::simple(TypeCtor::Never) |
908 | } | 908 | } |
909 | Expr::Return { expr } => { | 909 | Expr::Return { expr } => { |
910 | if let Some(expr) = expr { | 910 | if let Some(expr) = expr { |
911 | self.infer_expr(*expr, &Expectation::has_type(self.return_ty.clone())); | 911 | self.infer_expr(*expr, &Expectation::has_type(self.return_ty.clone())); |
912 | } | 912 | } |
913 | Ty::simple(TypeName::Never) | 913 | Ty::simple(TypeCtor::Never) |
914 | } | 914 | } |
915 | Expr::StructLit { path, fields, spread } => { | 915 | Expr::StructLit { path, fields, spread } => { |
916 | let (ty, def_id) = self.resolve_variant(path.as_ref()); | 916 | let (ty, def_id) = self.resolve_variant(path.as_ref()); |
@@ -933,11 +933,11 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
933 | .autoderef(self.db) | 933 | .autoderef(self.db) |
934 | .find_map(|derefed_ty| match derefed_ty { | 934 | .find_map(|derefed_ty| match derefed_ty { |
935 | Ty::Apply(a_ty) => match a_ty.name { | 935 | Ty::Apply(a_ty) => match a_ty.name { |
936 | TypeName::Tuple => { | 936 | TypeCtor::Tuple => { |
937 | let i = name.to_string().parse::<usize>().ok(); | 937 | let i = name.to_string().parse::<usize>().ok(); |
938 | i.and_then(|i| a_ty.parameters.0.get(i).cloned()) | 938 | i.and_then(|i| a_ty.parameters.0.get(i).cloned()) |
939 | } | 939 | } |
940 | TypeName::Adt(AdtDef::Struct(s)) => { | 940 | TypeCtor::Adt(AdtDef::Struct(s)) => { |
941 | s.field(self.db, name).map(|field| { | 941 | s.field(self.db, name).map(|field| { |
942 | self.write_field_resolution(tgt_expr, field); | 942 | self.write_field_resolution(tgt_expr, field); |
943 | field.ty(self.db).subst(&a_ty.parameters) | 943 | field.ty(self.db).subst(&a_ty.parameters) |
@@ -973,7 +973,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
973 | }; | 973 | }; |
974 | // TODO reference coercions etc. | 974 | // TODO reference coercions etc. |
975 | let inner_ty = self.infer_expr(*expr, &expectation); | 975 | let inner_ty = self.infer_expr(*expr, &expectation); |
976 | Ty::apply_one(TypeName::Ref(*mutability), inner_ty) | 976 | Ty::apply_one(TypeCtor::Ref(*mutability), inner_ty) |
977 | } | 977 | } |
978 | Expr::UnaryOp { expr, op } => { | 978 | Expr::UnaryOp { expr, op } => { |
979 | let inner_ty = self.infer_expr(*expr, &Expectation::none()); | 979 | let inner_ty = self.infer_expr(*expr, &Expectation::none()); |
@@ -989,9 +989,9 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
989 | UnaryOp::Neg => { | 989 | UnaryOp::Neg => { |
990 | match &inner_ty { | 990 | match &inner_ty { |
991 | Ty::Apply(a_ty) => match a_ty.name { | 991 | Ty::Apply(a_ty) => match a_ty.name { |
992 | TypeName::Int(primitive::UncertainIntTy::Unknown) | 992 | TypeCtor::Int(primitive::UncertainIntTy::Unknown) |
993 | | TypeName::Int(primitive::UncertainIntTy::Signed(..)) | 993 | | TypeCtor::Int(primitive::UncertainIntTy::Signed(..)) |
994 | | TypeName::Float(..) => inner_ty, | 994 | | TypeCtor::Float(..) => inner_ty, |
995 | _ => Ty::Unknown, | 995 | _ => Ty::Unknown, |
996 | }, | 996 | }, |
997 | Ty::Infer(InferTy::IntVar(..)) | Ty::Infer(InferTy::FloatVar(..)) => { | 997 | Ty::Infer(InferTy::IntVar(..)) | Ty::Infer(InferTy::FloatVar(..)) => { |
@@ -1004,7 +1004,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1004 | UnaryOp::Not => { | 1004 | UnaryOp::Not => { |
1005 | match &inner_ty { | 1005 | match &inner_ty { |
1006 | Ty::Apply(a_ty) => match a_ty.name { | 1006 | Ty::Apply(a_ty) => match a_ty.name { |
1007 | TypeName::Bool | TypeName::Int(_) => inner_ty, | 1007 | TypeCtor::Bool | TypeCtor::Int(_) => inner_ty, |
1008 | _ => Ty::Unknown, | 1008 | _ => Ty::Unknown, |
1009 | }, | 1009 | }, |
1010 | Ty::Infer(InferTy::IntVar(..)) => inner_ty, | 1010 | Ty::Infer(InferTy::IntVar(..)) => inner_ty, |
@@ -1018,7 +1018,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1018 | Some(op) => { | 1018 | Some(op) => { |
1019 | let lhs_expectation = match op { | 1019 | let lhs_expectation = match op { |
1020 | BinaryOp::BooleanAnd | BinaryOp::BooleanOr => { | 1020 | BinaryOp::BooleanAnd | BinaryOp::BooleanOr => { |
1021 | Expectation::has_type(Ty::simple(TypeName::Bool)) | 1021 | Expectation::has_type(Ty::simple(TypeCtor::Bool)) |
1022 | } | 1022 | } |
1023 | _ => Expectation::none(), | 1023 | _ => Expectation::none(), |
1024 | }; | 1024 | }; |
@@ -1039,12 +1039,12 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1039 | ty_vec.push(self.infer_expr(*arg, &Expectation::none())); | 1039 | ty_vec.push(self.infer_expr(*arg, &Expectation::none())); |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | Ty::apply(TypeName::Tuple, Substs(ty_vec.into())) | 1042 | Ty::apply(TypeCtor::Tuple, Substs(ty_vec.into())) |
1043 | } | 1043 | } |
1044 | Expr::Array { exprs } => { | 1044 | Expr::Array { exprs } => { |
1045 | let elem_ty = match &expected.ty { | 1045 | let elem_ty = match &expected.ty { |
1046 | Ty::Apply(a_ty) => match a_ty.name { | 1046 | Ty::Apply(a_ty) => match a_ty.name { |
1047 | TypeName::Slice | TypeName::Array => { | 1047 | TypeCtor::Slice | TypeCtor::Array => { |
1048 | Ty::clone(&a_ty.parameters.as_single()) | 1048 | Ty::clone(&a_ty.parameters.as_single()) |
1049 | } | 1049 | } |
1050 | _ => self.new_type_var(), | 1050 | _ => self.new_type_var(), |
@@ -1056,23 +1056,23 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1056 | self.infer_expr(*expr, &Expectation::has_type(elem_ty.clone())); | 1056 | self.infer_expr(*expr, &Expectation::has_type(elem_ty.clone())); |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | Ty::apply_one(TypeName::Array, elem_ty) | 1059 | Ty::apply_one(TypeCtor::Array, elem_ty) |
1060 | } | 1060 | } |
1061 | Expr::Literal(lit) => match lit { | 1061 | Expr::Literal(lit) => match lit { |
1062 | Literal::Bool(..) => Ty::simple(TypeName::Bool), | 1062 | Literal::Bool(..) => Ty::simple(TypeCtor::Bool), |
1063 | Literal::String(..) => { | 1063 | Literal::String(..) => { |
1064 | Ty::apply_one(TypeName::Ref(Mutability::Shared), Ty::simple(TypeName::Str)) | 1064 | Ty::apply_one(TypeCtor::Ref(Mutability::Shared), Ty::simple(TypeCtor::Str)) |
1065 | } | 1065 | } |
1066 | Literal::ByteString(..) => { | 1066 | Literal::ByteString(..) => { |
1067 | let byte_type = Ty::simple(TypeName::Int(primitive::UncertainIntTy::Unsigned( | 1067 | let byte_type = Ty::simple(TypeCtor::Int(primitive::UncertainIntTy::Unsigned( |
1068 | primitive::UintTy::U8, | 1068 | primitive::UintTy::U8, |
1069 | ))); | 1069 | ))); |
1070 | let slice_type = Ty::apply_one(TypeName::Slice, byte_type); | 1070 | let slice_type = Ty::apply_one(TypeCtor::Slice, byte_type); |
1071 | Ty::apply_one(TypeName::Ref(Mutability::Shared), slice_type) | 1071 | Ty::apply_one(TypeCtor::Ref(Mutability::Shared), slice_type) |
1072 | } | 1072 | } |
1073 | Literal::Char(..) => Ty::simple(TypeName::Char), | 1073 | Literal::Char(..) => Ty::simple(TypeCtor::Char), |
1074 | Literal::Int(_v, ty) => Ty::simple(TypeName::Int(*ty)), | 1074 | Literal::Int(_v, ty) => Ty::simple(TypeCtor::Int(*ty)), |
1075 | Literal::Float(_v, ty) => Ty::simple(TypeName::Float(*ty)), | 1075 | Literal::Float(_v, ty) => Ty::simple(TypeCtor::Float(*ty)), |
1076 | }, | 1076 | }, |
1077 | }; | 1077 | }; |
1078 | // use a new type variable if we got Ty::Unknown here | 1078 | // use a new type variable if we got Ty::Unknown here |
@@ -1208,9 +1208,9 @@ impl InferTy { | |||
1208 | match self { | 1208 | match self { |
1209 | InferTy::TypeVar(..) => Ty::Unknown, | 1209 | InferTy::TypeVar(..) => Ty::Unknown, |
1210 | InferTy::IntVar(..) => { | 1210 | InferTy::IntVar(..) => { |
1211 | Ty::simple(TypeName::Int(primitive::UncertainIntTy::Signed(primitive::IntTy::I32))) | 1211 | Ty::simple(TypeCtor::Int(primitive::UncertainIntTy::Signed(primitive::IntTy::I32))) |
1212 | } | 1212 | } |
1213 | InferTy::FloatVar(..) => Ty::simple(TypeName::Float( | 1213 | InferTy::FloatVar(..) => Ty::simple(TypeCtor::Float( |
1214 | primitive::UncertainFloatTy::Known(primitive::FloatTy::F64), | 1214 | primitive::UncertainFloatTy::Known(primitive::FloatTy::F64), |
1215 | )), | 1215 | )), |
1216 | } | 1216 | } |
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index a346879d8..72b1234bf 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs | |||
@@ -19,40 +19,40 @@ use crate::{ | |||
19 | generics::GenericParams, | 19 | generics::GenericParams, |
20 | adt::VariantDef, | 20 | adt::VariantDef, |
21 | }; | 21 | }; |
22 | use super::{Ty, primitive, FnSig, Substs, TypeName}; | 22 | use super::{Ty, primitive, FnSig, Substs, TypeCtor}; |
23 | 23 | ||
24 | impl Ty { | 24 | impl Ty { |
25 | pub(crate) fn from_hir(db: &impl HirDatabase, resolver: &Resolver, type_ref: &TypeRef) -> Self { | 25 | pub(crate) fn from_hir(db: &impl HirDatabase, resolver: &Resolver, type_ref: &TypeRef) -> Self { |
26 | match type_ref { | 26 | match type_ref { |
27 | TypeRef::Never => Ty::simple(TypeName::Never), | 27 | TypeRef::Never => Ty::simple(TypeCtor::Never), |
28 | TypeRef::Tuple(inner) => { | 28 | TypeRef::Tuple(inner) => { |
29 | let inner_tys = | 29 | let inner_tys = |
30 | inner.iter().map(|tr| Ty::from_hir(db, resolver, tr)).collect::<Vec<_>>(); | 30 | inner.iter().map(|tr| Ty::from_hir(db, resolver, tr)).collect::<Vec<_>>(); |
31 | Ty::apply(TypeName::Tuple, Substs(inner_tys.into())) | 31 | Ty::apply(TypeCtor::Tuple, Substs(inner_tys.into())) |
32 | } | 32 | } |
33 | TypeRef::Path(path) => Ty::from_hir_path(db, resolver, path), | 33 | TypeRef::Path(path) => Ty::from_hir_path(db, resolver, path), |
34 | TypeRef::RawPtr(inner, mutability) => { | 34 | TypeRef::RawPtr(inner, mutability) => { |
35 | let inner_ty = Ty::from_hir(db, resolver, inner); | 35 | let inner_ty = Ty::from_hir(db, resolver, inner); |
36 | Ty::apply_one(TypeName::RawPtr(*mutability), inner_ty) | 36 | Ty::apply_one(TypeCtor::RawPtr(*mutability), inner_ty) |
37 | } | 37 | } |
38 | TypeRef::Array(inner) => { | 38 | TypeRef::Array(inner) => { |
39 | let inner_ty = Ty::from_hir(db, resolver, inner); | 39 | let inner_ty = Ty::from_hir(db, resolver, inner); |
40 | Ty::apply_one(TypeName::Array, inner_ty) | 40 | Ty::apply_one(TypeCtor::Array, inner_ty) |
41 | } | 41 | } |
42 | TypeRef::Slice(inner) => { | 42 | TypeRef::Slice(inner) => { |
43 | let inner_ty = Ty::from_hir(db, resolver, inner); | 43 | let inner_ty = Ty::from_hir(db, resolver, inner); |
44 | Ty::apply_one(TypeName::Slice, inner_ty) | 44 | Ty::apply_one(TypeCtor::Slice, inner_ty) |
45 | } | 45 | } |
46 | TypeRef::Reference(inner, mutability) => { | 46 | TypeRef::Reference(inner, mutability) => { |
47 | let inner_ty = Ty::from_hir(db, resolver, inner); | 47 | let inner_ty = Ty::from_hir(db, resolver, inner); |
48 | Ty::apply_one(TypeName::Ref(*mutability), inner_ty) | 48 | Ty::apply_one(TypeCtor::Ref(*mutability), inner_ty) |
49 | } | 49 | } |
50 | TypeRef::Placeholder => Ty::Unknown, | 50 | TypeRef::Placeholder => Ty::Unknown, |
51 | TypeRef::Fn(params) => { | 51 | TypeRef::Fn(params) => { |
52 | let inner_tys = | 52 | let inner_tys = |
53 | params.iter().map(|tr| Ty::from_hir(db, resolver, tr)).collect::<Vec<_>>(); | 53 | params.iter().map(|tr| Ty::from_hir(db, resolver, tr)).collect::<Vec<_>>(); |
54 | let sig = Substs(inner_tys.into()); | 54 | let sig = Substs(inner_tys.into()); |
55 | Ty::apply(TypeName::FnPtr, sig) | 55 | Ty::apply(TypeCtor::FnPtr, sig) |
56 | } | 56 | } |
57 | TypeRef::Error => Ty::Unknown, | 57 | TypeRef::Error => Ty::Unknown, |
58 | } | 58 | } |
@@ -62,14 +62,14 @@ impl Ty { | |||
62 | if let Some(name) = path.as_ident() { | 62 | if let Some(name) = path.as_ident() { |
63 | // TODO handle primitive type names in resolver as well? | 63 | // TODO handle primitive type names in resolver as well? |
64 | if let Some(int_ty) = primitive::UncertainIntTy::from_type_name(name) { | 64 | if let Some(int_ty) = primitive::UncertainIntTy::from_type_name(name) { |
65 | return Ty::simple(TypeName::Int(int_ty)); | 65 | return Ty::simple(TypeCtor::Int(int_ty)); |
66 | } else if let Some(float_ty) = primitive::UncertainFloatTy::from_type_name(name) { | 66 | } else if let Some(float_ty) = primitive::UncertainFloatTy::from_type_name(name) { |
67 | return Ty::simple(TypeName::Float(float_ty)); | 67 | return Ty::simple(TypeCtor::Float(float_ty)); |
68 | } else if let Some(known) = name.as_known_name() { | 68 | } else if let Some(known) = name.as_known_name() { |
69 | match known { | 69 | match known { |
70 | KnownName::Bool => return Ty::simple(TypeName::Bool), | 70 | KnownName::Bool => return Ty::simple(TypeCtor::Bool), |
71 | KnownName::Char => return Ty::simple(TypeName::Char), | 71 | KnownName::Char => return Ty::simple(TypeCtor::Char), |
72 | KnownName::Str => return Ty::simple(TypeName::Str), | 72 | KnownName::Str => return Ty::simple(TypeCtor::Str), |
73 | _ => {} | 73 | _ => {} |
74 | } | 74 | } |
75 | } | 75 | } |
@@ -245,7 +245,7 @@ fn fn_sig_for_fn(db: &impl HirDatabase, def: Function) -> FnSig { | |||
245 | fn type_for_fn(db: &impl HirDatabase, def: Function) -> Ty { | 245 | fn type_for_fn(db: &impl HirDatabase, def: Function) -> Ty { |
246 | let generics = def.generic_params(db); | 246 | let generics = def.generic_params(db); |
247 | let substs = make_substs(&generics); | 247 | let substs = make_substs(&generics); |
248 | Ty::apply(TypeName::FnDef(def.into()), substs) | 248 | Ty::apply(TypeCtor::FnDef(def.into()), substs) |
249 | } | 249 | } |
250 | 250 | ||
251 | /// Build the declared type of a const. | 251 | /// Build the declared type of a const. |
@@ -287,7 +287,7 @@ fn type_for_struct_constructor(db: &impl HirDatabase, def: Struct) -> Ty { | |||
287 | } | 287 | } |
288 | let generics = def.generic_params(db); | 288 | let generics = def.generic_params(db); |
289 | let substs = make_substs(&generics); | 289 | let substs = make_substs(&generics); |
290 | Ty::apply(TypeName::FnDef(def.into()), substs) | 290 | Ty::apply(TypeCtor::FnDef(def.into()), substs) |
291 | } | 291 | } |
292 | 292 | ||
293 | fn fn_sig_for_enum_variant_constructor(db: &impl HirDatabase, def: EnumVariant) -> FnSig { | 293 | fn fn_sig_for_enum_variant_constructor(db: &impl HirDatabase, def: EnumVariant) -> FnSig { |
@@ -315,7 +315,7 @@ fn type_for_enum_variant_constructor(db: &impl HirDatabase, def: EnumVariant) -> | |||
315 | } | 315 | } |
316 | let generics = def.parent_enum(db).generic_params(db); | 316 | let generics = def.parent_enum(db).generic_params(db); |
317 | let substs = make_substs(&generics); | 317 | let substs = make_substs(&generics); |
318 | Ty::apply(TypeName::FnDef(def.into()), substs) | 318 | Ty::apply(TypeCtor::FnDef(def.into()), substs) |
319 | } | 319 | } |
320 | 320 | ||
321 | fn make_substs(generics: &GenericParams) -> Substs { | 321 | fn make_substs(generics: &GenericParams) -> Substs { |
@@ -331,12 +331,12 @@ fn make_substs(generics: &GenericParams) -> Substs { | |||
331 | 331 | ||
332 | fn type_for_struct(db: &impl HirDatabase, s: Struct) -> Ty { | 332 | fn type_for_struct(db: &impl HirDatabase, s: Struct) -> Ty { |
333 | let generics = s.generic_params(db); | 333 | let generics = s.generic_params(db); |
334 | Ty::apply(TypeName::Adt(s.into()), make_substs(&generics)) | 334 | Ty::apply(TypeCtor::Adt(s.into()), make_substs(&generics)) |
335 | } | 335 | } |
336 | 336 | ||
337 | fn type_for_enum(db: &impl HirDatabase, s: Enum) -> Ty { | 337 | fn type_for_enum(db: &impl HirDatabase, s: Enum) -> Ty { |
338 | let generics = s.generic_params(db); | 338 | let generics = s.generic_params(db); |
339 | Ty::apply(TypeName::Adt(s.into()), make_substs(&generics)) | 339 | Ty::apply(TypeCtor::Adt(s.into()), make_substs(&generics)) |
340 | } | 340 | } |
341 | 341 | ||
342 | fn type_for_type_alias(db: &impl HirDatabase, t: TypeAlias) -> Ty { | 342 | fn type_for_type_alias(db: &impl HirDatabase, t: TypeAlias) -> Ty { |
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index 06bfe85cd..9422bad84 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -10,7 +10,7 @@ use crate::{ | |||
10 | HirDatabase, Module, Crate, Name, Function, Trait, | 10 | HirDatabase, Module, Crate, Name, Function, Trait, |
11 | ids::TraitId, | 11 | ids::TraitId, |
12 | impl_block::{ImplId, ImplBlock, ImplItem}, | 12 | impl_block::{ImplId, ImplBlock, ImplItem}, |
13 | ty::{Ty, TypeName}, | 13 | ty::{Ty, TypeCtor}, |
14 | nameres::CrateModuleId, | 14 | nameres::CrateModuleId, |
15 | 15 | ||
16 | }; | 16 | }; |
@@ -18,7 +18,7 @@ use crate::{ | |||
18 | /// This is used as a key for indexing impls. | 18 | /// This is used as a key for indexing impls. |
19 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | 19 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
20 | pub enum TyFingerprint { | 20 | pub enum TyFingerprint { |
21 | Apply(TypeName), | 21 | Apply(TypeCtor), |
22 | } | 22 | } |
23 | 23 | ||
24 | impl TyFingerprint { | 24 | impl TyFingerprint { |
@@ -112,7 +112,7 @@ impl CrateImplBlocks { | |||
112 | fn def_crate(db: &impl HirDatabase, ty: &Ty) -> Option<Crate> { | 112 | fn def_crate(db: &impl HirDatabase, ty: &Ty) -> Option<Crate> { |
113 | match ty { | 113 | match ty { |
114 | Ty::Apply(a_ty) => match a_ty.name { | 114 | Ty::Apply(a_ty) => match a_ty.name { |
115 | TypeName::Adt(def_id) => def_id.krate(db), | 115 | TypeCtor::Adt(def_id) => def_id.krate(db), |
116 | _ => None, | 116 | _ => None, |
117 | }, | 117 | }, |
118 | _ => None, | 118 | _ => None, |
diff --git a/crates/ra_hir/src/ty/op.rs b/crates/ra_hir/src/ty/op.rs index f581004d2..1d230140b 100644 --- a/crates/ra_hir/src/ty/op.rs +++ b/crates/ra_hir/src/ty/op.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use crate::{ ty::ApplicationTy, expr::BinaryOp}; | 1 | use crate::{ ty::ApplicationTy, expr::BinaryOp}; |
2 | use super::{Ty, TypeName, InferTy}; | 2 | use super::{Ty, TypeCtor, InferTy}; |
3 | 3 | ||
4 | pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { | 4 | pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { |
5 | match op { | 5 | match op { |
@@ -10,7 +10,7 @@ pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { | |||
10 | | BinaryOp::LesserEqualTest | 10 | | BinaryOp::LesserEqualTest |
11 | | BinaryOp::GreaterEqualTest | 11 | | BinaryOp::GreaterEqualTest |
12 | | BinaryOp::LesserTest | 12 | | BinaryOp::LesserTest |
13 | | BinaryOp::GreaterTest => Ty::simple(TypeName::Bool), | 13 | | BinaryOp::GreaterTest => Ty::simple(TypeCtor::Bool), |
14 | BinaryOp::Assignment | 14 | BinaryOp::Assignment |
15 | | BinaryOp::AddAssign | 15 | | BinaryOp::AddAssign |
16 | | BinaryOp::SubAssign | 16 | | BinaryOp::SubAssign |
@@ -33,7 +33,7 @@ pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { | |||
33 | | BinaryOp::BitwiseOr | 33 | | BinaryOp::BitwiseOr |
34 | | BinaryOp::BitwiseXor => match rhs_ty { | 34 | | BinaryOp::BitwiseXor => match rhs_ty { |
35 | Ty::Apply(ApplicationTy { name, .. }) => match name { | 35 | Ty::Apply(ApplicationTy { name, .. }) => match name { |
36 | TypeName::Int(..) | TypeName::Float(..) => rhs_ty, | 36 | TypeCtor::Int(..) | TypeCtor::Float(..) => rhs_ty, |
37 | _ => Ty::Unknown, | 37 | _ => Ty::Unknown, |
38 | }, | 38 | }, |
39 | Ty::Infer(InferTy::IntVar(..)) | Ty::Infer(InferTy::FloatVar(..)) => rhs_ty, | 39 | Ty::Infer(InferTy::IntVar(..)) | Ty::Infer(InferTy::FloatVar(..)) => rhs_ty, |
@@ -45,14 +45,14 @@ pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { | |||
45 | 45 | ||
46 | pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty { | 46 | pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty { |
47 | match op { | 47 | match op { |
48 | BinaryOp::BooleanAnd | BinaryOp::BooleanOr => Ty::simple(TypeName::Bool), | 48 | BinaryOp::BooleanAnd | BinaryOp::BooleanOr => Ty::simple(TypeCtor::Bool), |
49 | BinaryOp::Assignment | BinaryOp::EqualityTest => match lhs_ty { | 49 | BinaryOp::Assignment | BinaryOp::EqualityTest => match lhs_ty { |
50 | Ty::Apply(ApplicationTy { name, .. }) => match name { | 50 | Ty::Apply(ApplicationTy { name, .. }) => match name { |
51 | TypeName::Int(..) | 51 | TypeCtor::Int(..) |
52 | | TypeName::Float(..) | 52 | | TypeCtor::Float(..) |
53 | | TypeName::Str | 53 | | TypeCtor::Str |
54 | | TypeName::Char | 54 | | TypeCtor::Char |
55 | | TypeName::Bool => lhs_ty, | 55 | | TypeCtor::Bool => lhs_ty, |
56 | _ => Ty::Unknown, | 56 | _ => Ty::Unknown, |
57 | }, | 57 | }, |
58 | Ty::Infer(InferTy::IntVar(..)) | Ty::Infer(InferTy::FloatVar(..)) => lhs_ty, | 58 | Ty::Infer(InferTy::IntVar(..)) | Ty::Infer(InferTy::FloatVar(..)) => lhs_ty, |
@@ -83,7 +83,7 @@ pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty { | |||
83 | | BinaryOp::BitwiseOr | 83 | | BinaryOp::BitwiseOr |
84 | | BinaryOp::BitwiseXor => match lhs_ty { | 84 | | BinaryOp::BitwiseXor => match lhs_ty { |
85 | Ty::Apply(ApplicationTy { name, .. }) => match name { | 85 | Ty::Apply(ApplicationTy { name, .. }) => match name { |
86 | TypeName::Int(..) | TypeName::Float(..) => lhs_ty, | 86 | TypeCtor::Int(..) | TypeCtor::Float(..) => lhs_ty, |
87 | _ => Ty::Unknown, | 87 | _ => Ty::Unknown, |
88 | }, | 88 | }, |
89 | Ty::Infer(InferTy::IntVar(..)) | Ty::Infer(InferTy::FloatVar(..)) => lhs_ty, | 89 | Ty::Infer(InferTy::IntVar(..)) | Ty::Infer(InferTy::FloatVar(..)) => lhs_ty, |