diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 18 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/op.rs | 6 |
3 files changed, 14 insertions, 14 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index e975f9217..be74b9fa6 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -237,7 +237,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
237 | match (&*ty1, &*ty2) { | 237 | match (&*ty1, &*ty2) { |
238 | (Ty::Unknown, ..) => true, | 238 | (Ty::Unknown, ..) => true, |
239 | (.., Ty::Unknown) => true, | 239 | (.., Ty::Unknown) => true, |
240 | (Ty::Apply(a_ty1), Ty::Apply(a_ty2)) if a_ty1.name == a_ty2.name => { | 240 | (Ty::Apply(a_ty1), Ty::Apply(a_ty2)) if a_ty1.ctor == a_ty2.ctor => { |
241 | self.unify_substs(&a_ty1.parameters, &a_ty2.parameters, depth + 1) | 241 | self.unify_substs(&a_ty1.parameters, &a_ty2.parameters, depth + 1) |
242 | } | 242 | } |
243 | (Ty::Infer(InferTy::TypeVar(tv1)), Ty::Infer(InferTy::TypeVar(tv2))) | 243 | (Ty::Infer(InferTy::TypeVar(tv1)), Ty::Infer(InferTy::TypeVar(tv2))) |
@@ -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: TypeCtor::Int(primitive::UncertainIntTy::Unknown), | 281 | ctor: 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: TypeCtor::Float(primitive::UncertainFloatTy::Unknown), | 285 | ctor: TypeCtor::Float(primitive::UncertainFloatTy::Unknown), |
286 | .. | 286 | .. |
287 | }) => self.new_float_var(), | 287 | }) => self.new_float_var(), |
288 | _ => ty, | 288 | _ => ty, |
@@ -776,7 +776,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
776 | Expr::Call { callee, args } => { | 776 | Expr::Call { callee, args } => { |
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.ctor { |
780 | TypeCtor::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()) |
@@ -823,7 +823,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
823 | let method_ty = method_ty.apply_substs(substs); | 823 | let method_ty = method_ty.apply_substs(substs); |
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.ctor { |
827 | TypeCtor::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() { |
@@ -932,7 +932,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
932 | let ty = receiver_ty | 932 | let ty = receiver_ty |
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.ctor { |
936 | TypeCtor::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()) |
@@ -988,7 +988,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
988 | } | 988 | } |
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.ctor { |
992 | TypeCtor::Int(primitive::UncertainIntTy::Unknown) | 992 | TypeCtor::Int(primitive::UncertainIntTy::Unknown) |
993 | | TypeCtor::Int(primitive::UncertainIntTy::Signed(..)) | 993 | | TypeCtor::Int(primitive::UncertainIntTy::Signed(..)) |
994 | | TypeCtor::Float(..) => inner_ty, | 994 | | TypeCtor::Float(..) => inner_ty, |
@@ -1003,7 +1003,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1003 | } | 1003 | } |
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.ctor { |
1007 | TypeCtor::Bool | TypeCtor::Int(_) => inner_ty, | 1007 | TypeCtor::Bool | TypeCtor::Int(_) => inner_ty, |
1008 | _ => Ty::Unknown, | 1008 | _ => Ty::Unknown, |
1009 | }, | 1009 | }, |
@@ -1043,7 +1043,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
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.ctor { |
1047 | TypeCtor::Slice | TypeCtor::Array => { | 1047 | TypeCtor::Slice | TypeCtor::Array => { |
1048 | Ty::clone(&a_ty.parameters.as_single()) | 1048 | Ty::clone(&a_ty.parameters.as_single()) |
1049 | } | 1049 | } |
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index 9422bad84..ed75bfaee 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -27,7 +27,7 @@ impl TyFingerprint { | |||
27 | /// `impl &S`. Hence, this will return `None` for reference types and such. | 27 | /// `impl &S`. Hence, this will return `None` for reference types and such. |
28 | fn for_impl(ty: &Ty) -> Option<TyFingerprint> { | 28 | fn for_impl(ty: &Ty) -> Option<TyFingerprint> { |
29 | match ty { | 29 | match ty { |
30 | Ty::Apply(a_ty) => Some(TyFingerprint::Apply(a_ty.name)), | 30 | Ty::Apply(a_ty) => Some(TyFingerprint::Apply(a_ty.ctor)), |
31 | _ => None, | 31 | _ => None, |
32 | } | 32 | } |
33 | } | 33 | } |
@@ -111,7 +111,7 @@ impl CrateImplBlocks { | |||
111 | 111 | ||
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.ctor { |
115 | TypeCtor::Adt(def_id) => def_id.krate(db), | 115 | TypeCtor::Adt(def_id) => def_id.krate(db), |
116 | _ => None, | 116 | _ => None, |
117 | }, | 117 | }, |
diff --git a/crates/ra_hir/src/ty/op.rs b/crates/ra_hir/src/ty/op.rs index 1d230140b..235661a5d 100644 --- a/crates/ra_hir/src/ty/op.rs +++ b/crates/ra_hir/src/ty/op.rs | |||
@@ -32,7 +32,7 @@ pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { | |||
32 | | BinaryOp::BitwiseAnd | 32 | | BinaryOp::BitwiseAnd |
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 { ctor, .. }) => match ctor { |
36 | TypeCtor::Int(..) | TypeCtor::Float(..) => rhs_ty, | 36 | TypeCtor::Int(..) | TypeCtor::Float(..) => rhs_ty, |
37 | _ => Ty::Unknown, | 37 | _ => Ty::Unknown, |
38 | }, | 38 | }, |
@@ -47,7 +47,7 @@ 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(TypeCtor::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 { ctor, .. }) => match ctor { |
51 | TypeCtor::Int(..) | 51 | TypeCtor::Int(..) |
52 | | TypeCtor::Float(..) | 52 | | TypeCtor::Float(..) |
53 | | TypeCtor::Str | 53 | | TypeCtor::Str |
@@ -82,7 +82,7 @@ pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty { | |||
82 | | BinaryOp::BitwiseAnd | 82 | | BinaryOp::BitwiseAnd |
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 { ctor, .. }) => match ctor { |
86 | TypeCtor::Int(..) | TypeCtor::Float(..) => lhs_ty, | 86 | TypeCtor::Int(..) | TypeCtor::Float(..) => lhs_ty, |
87 | _ => Ty::Unknown, | 87 | _ => Ty::Unknown, |
88 | }, | 88 | }, |