From cbb418ebb87309a798ca16408c1dfb09cd638a9b Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 21 Mar 2019 22:29:12 +0100 Subject: Rename name field to ctor as well --- crates/ra_hir/src/ty.rs | 28 ++++++++++++++-------------- crates/ra_hir/src/ty/infer.rs | 18 +++++++++--------- crates/ra_hir/src/ty/method_resolution.rs | 4 ++-- crates/ra_hir/src/ty/op.rs | 6 +++--- 4 files changed, 28 insertions(+), 28 deletions(-) (limited to 'crates/ra_hir') 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 { /// several other things. #[derive(Clone, PartialEq, Eq, Debug)] pub struct ApplicationTy { - pub name: TypeCtor, + pub ctor: TypeCtor, pub parameters: Substs, } @@ -201,14 +201,14 @@ impl FnSig { } impl Ty { - pub fn simple(name: TypeCtor) -> Ty { - Ty::Apply(ApplicationTy { name, parameters: Substs::empty() }) + pub fn simple(ctor: TypeCtor) -> Ty { + Ty::Apply(ApplicationTy { ctor, parameters: Substs::empty() }) } - pub fn apply_one(name: TypeCtor, param: Ty) -> Ty { - Ty::Apply(ApplicationTy { name, parameters: Substs::single(param) }) + pub fn apply_one(ctor: TypeCtor, param: Ty) -> Ty { + Ty::Apply(ApplicationTy { ctor, parameters: Substs::single(param) }) } - pub fn apply(name: TypeCtor, parameters: Substs) -> Ty { - Ty::Apply(ApplicationTy { name, parameters }) + pub fn apply(ctor: TypeCtor, parameters: Substs) -> Ty { + Ty::Apply(ApplicationTy { ctor, parameters }) } pub fn unit() -> Self { Ty::apply(TypeCtor::Tuple, Substs::empty()) @@ -246,7 +246,7 @@ impl Ty { pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { match self { - Ty::Apply(ApplicationTy { name: TypeCtor::Ref(mutability), parameters }) => { + Ty::Apply(ApplicationTy { ctor: TypeCtor::Ref(mutability), parameters }) => { Some((parameters.as_single(), *mutability)) } _ => None, @@ -255,7 +255,7 @@ impl Ty { pub fn as_adt(&self) -> Option<(AdtDef, &Substs)> { match self { - Ty::Apply(ApplicationTy { name: TypeCtor::Adt(adt_def), parameters }) => { + Ty::Apply(ApplicationTy { ctor: TypeCtor::Adt(adt_def), parameters }) => { Some((*adt_def, parameters)) } _ => None, @@ -264,14 +264,14 @@ impl Ty { pub fn as_tuple(&self) -> Option<&Substs> { match self { - Ty::Apply(ApplicationTy { name: TypeCtor::Tuple, parameters }) => Some(parameters), + Ty::Apply(ApplicationTy { ctor: TypeCtor::Tuple, parameters }) => Some(parameters), _ => None, } } fn builtin_deref(&self) -> Option { match self { - Ty::Apply(a_ty) => match a_ty.name { + Ty::Apply(a_ty) => match a_ty.ctor { TypeCtor::Ref(..) => Some(Ty::clone(a_ty.parameters.as_single())), TypeCtor::RawPtr(..) => Some(Ty::clone(a_ty.parameters.as_single())), _ => None, @@ -286,8 +286,8 @@ impl Ty { /// `Option` afterwards.) pub fn apply_substs(self, substs: Substs) -> Ty { match self { - Ty::Apply(ApplicationTy { name, .. }) => { - Ty::Apply(ApplicationTy { name, parameters: substs }) + Ty::Apply(ApplicationTy { ctor, .. }) => { + Ty::Apply(ApplicationTy { ctor, parameters: substs }) } _ => self, } @@ -327,7 +327,7 @@ impl HirDisplay for &Ty { impl HirDisplay for ApplicationTy { fn hir_fmt(&self, f: &mut HirFormatter) -> fmt::Result { - match self.name { + match self.ctor { TypeCtor::Bool => write!(f, "bool")?, TypeCtor::Char => write!(f, "char")?, 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> { match (&*ty1, &*ty2) { (Ty::Unknown, ..) => true, (.., Ty::Unknown) => true, - (Ty::Apply(a_ty1), Ty::Apply(a_ty2)) if a_ty1.name == a_ty2.name => { + (Ty::Apply(a_ty1), Ty::Apply(a_ty2)) if a_ty1.ctor == a_ty2.ctor => { self.unify_substs(&a_ty1.parameters, &a_ty2.parameters, depth + 1) } (Ty::Infer(InferTy::TypeVar(tv1)), Ty::Infer(InferTy::TypeVar(tv2))) @@ -278,11 +278,11 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { match ty { Ty::Unknown => self.new_type_var(), Ty::Apply(ApplicationTy { - name: TypeCtor::Int(primitive::UncertainIntTy::Unknown), + ctor: TypeCtor::Int(primitive::UncertainIntTy::Unknown), .. }) => self.new_integer_var(), Ty::Apply(ApplicationTy { - name: TypeCtor::Float(primitive::UncertainFloatTy::Unknown), + ctor: TypeCtor::Float(primitive::UncertainFloatTy::Unknown), .. }) => self.new_float_var(), _ => ty, @@ -776,7 +776,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { Expr::Call { callee, args } => { let callee_ty = self.infer_expr(*callee, &Expectation::none()); let (param_tys, ret_ty) = match &callee_ty { - Ty::Apply(a_ty) => match a_ty.name { + Ty::Apply(a_ty) => match a_ty.ctor { TypeCtor::FnPtr => { let sig = FnSig::from_fn_ptr_substs(&a_ty.parameters); (sig.params().to_vec(), sig.ret().clone()) @@ -823,7 +823,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { let method_ty = method_ty.apply_substs(substs); let method_ty = self.insert_type_vars(method_ty); let (expected_receiver_ty, param_tys, ret_ty) = match &method_ty { - Ty::Apply(a_ty) => match a_ty.name { + Ty::Apply(a_ty) => match a_ty.ctor { TypeCtor::FnPtr => { let sig = FnSig::from_fn_ptr_substs(&a_ty.parameters); if !sig.params().is_empty() { @@ -932,7 +932,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { let ty = receiver_ty .autoderef(self.db) .find_map(|derefed_ty| match derefed_ty { - Ty::Apply(a_ty) => match a_ty.name { + Ty::Apply(a_ty) => match a_ty.ctor { TypeCtor::Tuple => { let i = name.to_string().parse::().ok(); i.and_then(|i| a_ty.parameters.0.get(i).cloned()) @@ -988,7 +988,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { } UnaryOp::Neg => { match &inner_ty { - Ty::Apply(a_ty) => match a_ty.name { + Ty::Apply(a_ty) => match a_ty.ctor { TypeCtor::Int(primitive::UncertainIntTy::Unknown) | TypeCtor::Int(primitive::UncertainIntTy::Signed(..)) | TypeCtor::Float(..) => inner_ty, @@ -1003,7 +1003,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { } UnaryOp::Not => { match &inner_ty { - Ty::Apply(a_ty) => match a_ty.name { + Ty::Apply(a_ty) => match a_ty.ctor { TypeCtor::Bool | TypeCtor::Int(_) => inner_ty, _ => Ty::Unknown, }, @@ -1043,7 +1043,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { } Expr::Array { exprs } => { let elem_ty = match &expected.ty { - Ty::Apply(a_ty) => match a_ty.name { + Ty::Apply(a_ty) => match a_ty.ctor { TypeCtor::Slice | TypeCtor::Array => { Ty::clone(&a_ty.parameters.as_single()) } 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 { /// `impl &S`. Hence, this will return `None` for reference types and such. fn for_impl(ty: &Ty) -> Option { match ty { - Ty::Apply(a_ty) => Some(TyFingerprint::Apply(a_ty.name)), + Ty::Apply(a_ty) => Some(TyFingerprint::Apply(a_ty.ctor)), _ => None, } } @@ -111,7 +111,7 @@ impl CrateImplBlocks { fn def_crate(db: &impl HirDatabase, ty: &Ty) -> Option { match ty { - Ty::Apply(a_ty) => match a_ty.name { + Ty::Apply(a_ty) => match a_ty.ctor { TypeCtor::Adt(def_id) => def_id.krate(db), _ => None, }, 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 { | BinaryOp::BitwiseAnd | BinaryOp::BitwiseOr | BinaryOp::BitwiseXor => match rhs_ty { - Ty::Apply(ApplicationTy { name, .. }) => match name { + Ty::Apply(ApplicationTy { ctor, .. }) => match ctor { TypeCtor::Int(..) | TypeCtor::Float(..) => rhs_ty, _ => Ty::Unknown, }, @@ -47,7 +47,7 @@ pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty { match op { BinaryOp::BooleanAnd | BinaryOp::BooleanOr => Ty::simple(TypeCtor::Bool), BinaryOp::Assignment | BinaryOp::EqualityTest => match lhs_ty { - Ty::Apply(ApplicationTy { name, .. }) => match name { + Ty::Apply(ApplicationTy { ctor, .. }) => match ctor { TypeCtor::Int(..) | TypeCtor::Float(..) | TypeCtor::Str @@ -82,7 +82,7 @@ pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty { | BinaryOp::BitwiseAnd | BinaryOp::BitwiseOr | BinaryOp::BitwiseXor => match lhs_ty { - Ty::Apply(ApplicationTy { name, .. }) => match name { + Ty::Apply(ApplicationTy { ctor, .. }) => match ctor { TypeCtor::Int(..) | TypeCtor::Float(..) => lhs_ty, _ => Ty::Unknown, }, -- cgit v1.2.3