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/ra_hir/src/ty.rs | |
parent | 97be0e6c46196552607aa0121b32a41a3515873d (diff) |
Rename name field to ctor as well
Diffstat (limited to 'crates/ra_hir/src/ty.rs')
-rw-r--r-- | crates/ra_hir/src/ty.rs | 28 |
1 files changed, 14 insertions, 14 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)?, |