Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_def/src/item_tree/lower.rs')
-rw-r--r--crates/hir_def/src/item_tree/lower.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs
index 4396801116..acc26bcf63 100644
--- a/crates/hir_def/src/item_tree/lower.rs
+++ b/crates/hir_def/src/item_tree/lower.rs
@@ -269,7 +269,7 @@ impl<'a> Ctx<'a> {
}
};
let ty = Interned::new(self_type);
- let idx = self.data().params.alloc(Param::Normal(ty));
+ let idx = self.data().params.alloc(Param::Normal(None, ty));
self.add_attrs(idx.into(), RawAttrs::new(self.db, &self_param, &self.hygiene));
has_self_param = true;
}
@@ -279,7 +279,19 @@ impl<'a> Ctx<'a> {
None => {
let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ty());
let ty = Interned::new(type_ref);
- self.data().params.alloc(Param::Normal(ty))
+ let mut pat = param.pat();
+ // FIXME: This really shouldn't be here, in fact FunctionData/ItemTree's function shouldn't know about
+ // pattern names at all
+ let name = loop {
+ match pat {
+ Some(ast::Pat::RefPat(ref_pat)) => pat = ref_pat.pat(),
+ Some(ast::Pat::IdentPat(ident)) => {
+ break ident.name().map(|it| it.as_name())
+ }
+ _ => break None,
+ }
+ };
+ self.data().params.alloc(Param::Normal(name, ty))
}
};
self.add_attrs(idx.into(), RawAttrs::new(self.db, &param, &self.hygiene));