aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty.rs')
-rw-r--r--crates/ra_hir/src/ty.rs18
1 files changed, 6 insertions, 12 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 31f726f35..2ea3b341f 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -16,7 +16,7 @@ use std::{fmt, mem};
16 16
17use crate::{Name, AdtDef, type_ref::Mutability, db::HirDatabase}; 17use crate::{Name, AdtDef, type_ref::Mutability, db::HirDatabase};
18 18
19pub(crate) use lower::{TypableDef, CallableDef, type_for_def, type_for_field}; 19pub(crate) use lower::{TypableDef, CallableDef, type_for_def, type_for_field, callable_item_sig};
20pub(crate) use infer::{infer, InferenceResult, InferTy}; 20pub(crate) use infer::{infer, InferenceResult, InferTy};
21use display::{HirDisplay, HirFormatter}; 21use display::{HirDisplay, HirFormatter};
22 22
@@ -77,8 +77,6 @@ pub enum Ty {
77 FnDef { 77 FnDef {
78 /// The definition of the function / constructor. 78 /// The definition of the function / constructor.
79 def: CallableDef, 79 def: CallableDef,
80 /// Parameters and return type
81 sig: FnSig,
82 /// Substitutions for the generic parameters of the type 80 /// Substitutions for the generic parameters of the type
83 substs: Substs, 81 substs: Substs,
84 }, 82 },
@@ -189,11 +187,7 @@ impl Ty {
189 } 187 }
190 sig.ret().walk(f); 188 sig.ret().walk(f);
191 } 189 }
192 Ty::FnDef { substs, sig, .. } => { 190 Ty::FnDef { substs, .. } => {
193 for input in sig.params() {
194 input.walk(f);
195 }
196 sig.ret().walk(f);
197 for t in substs.0.iter() { 191 for t in substs.0.iter() {
198 t.walk(f); 192 t.walk(f);
199 } 193 }
@@ -232,8 +226,7 @@ impl Ty {
232 Ty::FnPtr(sig) => { 226 Ty::FnPtr(sig) => {
233 sig.walk_mut(f); 227 sig.walk_mut(f);
234 } 228 }
235 Ty::FnDef { substs, sig, .. } => { 229 Ty::FnDef { substs, .. } => {
236 sig.walk_mut(f);
237 substs.walk_mut(f); 230 substs.walk_mut(f);
238 } 231 }
239 Ty::Adt { substs, .. } => { 232 Ty::Adt { substs, .. } => {
@@ -275,7 +268,7 @@ impl Ty {
275 pub fn apply_substs(self, substs: Substs) -> Ty { 268 pub fn apply_substs(self, substs: Substs) -> Ty {
276 match self { 269 match self {
277 Ty::Adt { def_id, .. } => Ty::Adt { def_id, substs }, 270 Ty::Adt { def_id, .. } => Ty::Adt { def_id, substs },
278 Ty::FnDef { def, sig, .. } => Ty::FnDef { def, sig, substs }, 271 Ty::FnDef { def, .. } => Ty::FnDef { def, substs },
279 _ => self, 272 _ => self,
280 } 273 }
281 } 274 }
@@ -344,7 +337,8 @@ impl HirDisplay for Ty {
344 f.write_joined(sig.params(), ", ")?; 337 f.write_joined(sig.params(), ", ")?;
345 write!(f, ") -> {}", sig.ret().display(f.db))?; 338 write!(f, ") -> {}", sig.ret().display(f.db))?;
346 } 339 }
347 Ty::FnDef { def, substs, sig, .. } => { 340 Ty::FnDef { def, substs, .. } => {
341 let sig = f.db.callable_item_signature(*def);
348 let name = match def { 342 let name = match def {
349 CallableDef::Function(ff) => ff.name(f.db), 343 CallableDef::Function(ff) => ff.name(f.db),
350 CallableDef::Struct(s) => s.name(f.db).unwrap_or_else(Name::missing), 344 CallableDef::Struct(s) => s.name(f.db).unwrap_or_else(Name::missing),