Add back Param struct

This commit is contained in:
adamrk 2020-09-01 22:13:12 +02:00
parent c6ddb90714
commit 04fc937700
2 changed files with 13 additions and 3 deletions

View file

@ -708,7 +708,7 @@ impl Function {
Some(SelfParam { func: self.id })
}
pub fn params(self, db: &dyn HirDatabase) -> Vec<Type> {
pub fn params(self, db: &dyn HirDatabase) -> Vec<Param> {
let resolver = self.id.resolver(db.upcast());
let ctx = hir_ty::TyLoweringContext::new(db, &resolver);
let environment = TraitEnvironment::lower(db, &resolver);
@ -724,7 +724,7 @@ impl Function {
environment: environment.clone(),
},
};
ty
Param { ty }
})
.collect()
}
@ -754,6 +754,16 @@ impl From<Mutability> for Access {
}
}
pub struct Param {
ty: Type,
}
impl Param {
pub fn ty(&self) -> &Type {
&self.ty
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct SelfParam {
func: FunctionId,

View file

@ -231,7 +231,7 @@ impl Completions {
if let Some(pat) = it.pat() {
let name = pat.to_string();
let arg = name.trim_start_matches('_');
return Some(add_arg(arg, &param_ty, ctx));
return Some(add_arg(arg, param_ty.ty(), ctx));
}
None
})