diff options
Diffstat (limited to 'crates/ra_hir/src/ty.rs')
-rw-r--r-- | crates/ra_hir/src/ty.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index f2b37b208..f4eee835f 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -82,13 +82,13 @@ pub enum TypeCtor { | |||
82 | /// fn foo() -> i32 { 1 } | 82 | /// fn foo() -> i32 { 1 } |
83 | /// let bar: fn() -> i32 = foo; | 83 | /// let bar: fn() -> i32 = foo; |
84 | /// ``` | 84 | /// ``` |
85 | FnPtr, | 85 | FnPtr { num_args: u16 }, |
86 | 86 | ||
87 | /// The never type `!`. | 87 | /// The never type `!`. |
88 | Never, | 88 | Never, |
89 | 89 | ||
90 | /// A tuple type. For example, `(i32, bool)`. | 90 | /// A tuple type. For example, `(i32, bool)`. |
91 | Tuple, | 91 | Tuple { cardinality: u16 }, |
92 | } | 92 | } |
93 | 93 | ||
94 | /// A nominal type with (maybe 0) type parameters. This might be a primitive | 94 | /// A nominal type with (maybe 0) type parameters. This might be a primitive |
@@ -299,7 +299,7 @@ impl Ty { | |||
299 | Ty::Apply(ApplicationTy { ctor, parameters }) | 299 | Ty::Apply(ApplicationTy { ctor, parameters }) |
300 | } | 300 | } |
301 | pub fn unit() -> Self { | 301 | pub fn unit() -> Self { |
302 | Ty::apply(TypeCtor::Tuple, Substs::empty()) | 302 | Ty::apply(TypeCtor::Tuple { cardinality: 0 }, Substs::empty()) |
303 | } | 303 | } |
304 | 304 | ||
305 | pub fn walk(&self, f: &mut impl FnMut(&Ty)) { | 305 | pub fn walk(&self, f: &mut impl FnMut(&Ty)) { |
@@ -352,7 +352,9 @@ impl Ty { | |||
352 | 352 | ||
353 | pub fn as_tuple(&self) -> Option<&Substs> { | 353 | pub fn as_tuple(&self) -> Option<&Substs> { |
354 | match self { | 354 | match self { |
355 | Ty::Apply(ApplicationTy { ctor: TypeCtor::Tuple, parameters }) => Some(parameters), | 355 | Ty::Apply(ApplicationTy { ctor: TypeCtor::Tuple { .. }, parameters }) => { |
356 | Some(parameters) | ||
357 | } | ||
356 | _ => None, | 358 | _ => None, |
357 | } | 359 | } |
358 | } | 360 | } |
@@ -380,7 +382,7 @@ impl Ty { | |||
380 | fn callable_sig(&self, db: &impl HirDatabase) -> Option<FnSig> { | 382 | fn callable_sig(&self, db: &impl HirDatabase) -> Option<FnSig> { |
381 | match self { | 383 | match self { |
382 | Ty::Apply(a_ty) => match a_ty.ctor { | 384 | Ty::Apply(a_ty) => match a_ty.ctor { |
383 | TypeCtor::FnPtr => Some(FnSig::from_fn_ptr_substs(&a_ty.parameters)), | 385 | TypeCtor::FnPtr { .. } => Some(FnSig::from_fn_ptr_substs(&a_ty.parameters)), |
384 | TypeCtor::FnDef(def) => { | 386 | TypeCtor::FnDef(def) => { |
385 | let sig = db.callable_item_signature(def); | 387 | let sig = db.callable_item_signature(def); |
386 | Some(sig.subst(&a_ty.parameters)) | 388 | Some(sig.subst(&a_ty.parameters)) |
@@ -466,7 +468,7 @@ impl HirDisplay for ApplicationTy { | |||
466 | write!(f, "&{}{}", m.as_keyword_for_ref(), t.display(f.db))?; | 468 | write!(f, "&{}{}", m.as_keyword_for_ref(), t.display(f.db))?; |
467 | } | 469 | } |
468 | TypeCtor::Never => write!(f, "!")?, | 470 | TypeCtor::Never => write!(f, "!")?, |
469 | TypeCtor::Tuple => { | 471 | TypeCtor::Tuple { .. } => { |
470 | let ts = &self.parameters; | 472 | let ts = &self.parameters; |
471 | if ts.len() == 1 { | 473 | if ts.len() == 1 { |
472 | write!(f, "({},)", ts[0].display(f.db))?; | 474 | write!(f, "({},)", ts[0].display(f.db))?; |
@@ -476,7 +478,7 @@ impl HirDisplay for ApplicationTy { | |||
476 | write!(f, ")")?; | 478 | write!(f, ")")?; |
477 | } | 479 | } |
478 | } | 480 | } |
479 | TypeCtor::FnPtr => { | 481 | TypeCtor::FnPtr { .. } => { |
480 | let sig = FnSig::from_fn_ptr_substs(&self.parameters); | 482 | let sig = FnSig::from_fn_ptr_substs(&self.parameters); |
481 | write!(f, "fn(")?; | 483 | write!(f, "fn(")?; |
482 | f.write_joined(sig.params(), ", ")?; | 484 | f.write_joined(sig.params(), ", ")?; |