diff options
author | Florian Diebold <[email protected]> | 2019-03-21 21:29:12 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-03-21 21:29:12 +0000 |
commit | cbb418ebb87309a798ca16408c1dfb09cd638a9b (patch) | |
tree | 8298b4c130452808efad219ebae169d3eec90a81 /crates | |
parent | 97be0e6c46196552607aa0121b32a41a3515873d (diff) |
Rename name field to ctor as well
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/ty.rs | 28 | ||||
-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 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_dot.rs | 2 |
5 files changed, 29 insertions, 29 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index fc1f054dc..5cd766b85 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -93,7 +93,7 @@ pub enum TypeCtor { | |||
93 | /// several other things. | 93 | /// several other things. |
94 | #[derive(Clone, PartialEq, Eq, Debug)] | 94 | #[derive(Clone, PartialEq, Eq, Debug)] |
95 | pub struct ApplicationTy { | 95 | pub struct ApplicationTy { |
96 | pub name: TypeCtor, | 96 | pub ctor: TypeCtor, |
97 | pub parameters: Substs, | 97 | pub parameters: Substs, |
98 | } | 98 | } |
99 | 99 | ||
@@ -201,14 +201,14 @@ impl FnSig { | |||
201 | } | 201 | } |
202 | 202 | ||
203 | impl Ty { | 203 | impl Ty { |
204 | pub fn simple(name: TypeCtor) -> Ty { | 204 | pub fn simple(ctor: TypeCtor) -> Ty { |
205 | Ty::Apply(ApplicationTy { name, parameters: Substs::empty() }) | 205 | Ty::Apply(ApplicationTy { ctor, parameters: Substs::empty() }) |
206 | } | 206 | } |
207 | pub fn apply_one(name: TypeCtor, param: Ty) -> Ty { | 207 | pub fn apply_one(ctor: TypeCtor, param: Ty) -> Ty { |
208 | Ty::Apply(ApplicationTy { name, parameters: Substs::single(param) }) | 208 | Ty::Apply(ApplicationTy { ctor, parameters: Substs::single(param) }) |
209 | } | 209 | } |
210 | pub fn apply(name: TypeCtor, parameters: Substs) -> Ty { | 210 | pub fn apply(ctor: TypeCtor, parameters: Substs) -> Ty { |
211 | Ty::Apply(ApplicationTy { name, parameters }) | 211 | Ty::Apply(ApplicationTy { ctor, parameters }) |
212 | } | 212 | } |
213 | pub fn unit() -> Self { | 213 | pub fn unit() -> Self { |
214 | Ty::apply(TypeCtor::Tuple, Substs::empty()) | 214 | Ty::apply(TypeCtor::Tuple, Substs::empty()) |
@@ -246,7 +246,7 @@ impl Ty { | |||
246 | 246 | ||
247 | pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { | 247 | pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { |
248 | match self { | 248 | match self { |
249 | Ty::Apply(ApplicationTy { name: TypeCtor::Ref(mutability), parameters }) => { | 249 | Ty::Apply(ApplicationTy { ctor: TypeCtor::Ref(mutability), parameters }) => { |
250 | Some((parameters.as_single(), *mutability)) | 250 | Some((parameters.as_single(), *mutability)) |
251 | } | 251 | } |
252 | _ => None, | 252 | _ => None, |
@@ -255,7 +255,7 @@ impl Ty { | |||
255 | 255 | ||
256 | pub fn as_adt(&self) -> Option<(AdtDef, &Substs)> { | 256 | pub fn as_adt(&self) -> Option<(AdtDef, &Substs)> { |
257 | match self { | 257 | match self { |
258 | Ty::Apply(ApplicationTy { name: TypeCtor::Adt(adt_def), parameters }) => { | 258 | Ty::Apply(ApplicationTy { ctor: TypeCtor::Adt(adt_def), parameters }) => { |
259 | Some((*adt_def, parameters)) | 259 | Some((*adt_def, parameters)) |
260 | } | 260 | } |
261 | _ => None, | 261 | _ => None, |
@@ -264,14 +264,14 @@ impl Ty { | |||
264 | 264 | ||
265 | pub fn as_tuple(&self) -> Option<&Substs> { | 265 | pub fn as_tuple(&self) -> Option<&Substs> { |
266 | match self { | 266 | match self { |
267 | Ty::Apply(ApplicationTy { name: TypeCtor::Tuple, parameters }) => Some(parameters), | 267 | Ty::Apply(ApplicationTy { ctor: TypeCtor::Tuple, parameters }) => Some(parameters), |
268 | _ => None, | 268 | _ => None, |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | fn builtin_deref(&self) -> Option<Ty> { | 272 | fn builtin_deref(&self) -> Option<Ty> { |
273 | match self { | 273 | match self { |
274 | Ty::Apply(a_ty) => match a_ty.name { | 274 | Ty::Apply(a_ty) => match a_ty.ctor { |
275 | TypeCtor::Ref(..) => Some(Ty::clone(a_ty.parameters.as_single())), | 275 | TypeCtor::Ref(..) => Some(Ty::clone(a_ty.parameters.as_single())), |
276 | TypeCtor::RawPtr(..) => Some(Ty::clone(a_ty.parameters.as_single())), | 276 | TypeCtor::RawPtr(..) => Some(Ty::clone(a_ty.parameters.as_single())), |
277 | _ => None, | 277 | _ => None, |
@@ -286,8 +286,8 @@ impl Ty { | |||
286 | /// `Option<u32>` afterwards.) | 286 | /// `Option<u32>` afterwards.) |
287 | pub fn apply_substs(self, substs: Substs) -> Ty { | 287 | pub fn apply_substs(self, substs: Substs) -> Ty { |
288 | match self { | 288 | match self { |
289 | Ty::Apply(ApplicationTy { name, .. }) => { | 289 | Ty::Apply(ApplicationTy { ctor, .. }) => { |
290 | Ty::Apply(ApplicationTy { name, parameters: substs }) | 290 | Ty::Apply(ApplicationTy { ctor, parameters: substs }) |
291 | } | 291 | } |
292 | _ => self, | 292 | _ => self, |
293 | } | 293 | } |
@@ -327,7 +327,7 @@ impl HirDisplay for &Ty { | |||
327 | 327 | ||
328 | impl HirDisplay for ApplicationTy { | 328 | impl HirDisplay for ApplicationTy { |
329 | fn hir_fmt(&self, f: &mut HirFormatter<impl HirDatabase>) -> fmt::Result { | 329 | fn hir_fmt(&self, f: &mut HirFormatter<impl HirDatabase>) -> fmt::Result { |
330 | match self.name { | 330 | match self.ctor { |
331 | TypeCtor::Bool => write!(f, "bool")?, | 331 | TypeCtor::Bool => write!(f, "bool")?, |
332 | TypeCtor::Char => write!(f, "char")?, | 332 | TypeCtor::Char => write!(f, "char")?, |
333 | TypeCtor::Int(t) => write!(f, "{}", t)?, | 333 | TypeCtor::Int(t) => write!(f, "{}", t)?, |
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 | }, |
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index f975214e9..31d5374ba 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs | |||
@@ -24,7 +24,7 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { | |||
24 | fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { | 24 | fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { |
25 | for receiver in receiver.autoderef(ctx.db) { | 25 | for receiver in receiver.autoderef(ctx.db) { |
26 | match receiver { | 26 | match receiver { |
27 | Ty::Apply(a_ty) => match a_ty.name { | 27 | Ty::Apply(a_ty) => match a_ty.ctor { |
28 | TypeCtor::Adt(AdtDef::Struct(s)) => { | 28 | TypeCtor::Adt(AdtDef::Struct(s)) => { |
29 | for field in s.fields(ctx.db) { | 29 | for field in s.fields(ctx.db) { |
30 | acc.add_field(ctx, field, &a_ty.parameters); | 30 | acc.add_field(ctx, field, &a_ty.parameters); |