Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/hir-def/src/data.rs2
-rw-r--r--crates/hir-def/src/item_tree.rs2
-rw-r--r--crates/hir-def/src/item_tree/lower.rs16
-rw-r--r--crates/hir-def/src/item_tree/pretty.rs16
-rw-r--r--crates/hir-def/src/item_tree/tests.rs12
5 files changed, 15 insertions, 33 deletions
diff --git a/crates/hir-def/src/data.rs b/crates/hir-def/src/data.rs
index de1e10ae2b..98cf69c168 100644
--- a/crates/hir-def/src/data.rs
+++ b/crates/hir-def/src/data.rs
@@ -100,7 +100,7 @@ impl FunctionData {
params: enabled_params
.clone()
.filter_map(|id| match &item_tree[id] {
- Param::Normal(_, ty) => Some(ty.clone()),
+ Param::Normal(ty) => Some(ty.clone()),
Param::Varargs => None,
})
.collect(),
diff --git a/crates/hir-def/src/item_tree.rs b/crates/hir-def/src/item_tree.rs
index d445e063f5..8546d36d79 100644
--- a/crates/hir-def/src/item_tree.rs
+++ b/crates/hir-def/src/item_tree.rs
@@ -606,7 +606,7 @@ pub struct Function {
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Param {
- Normal(Option<Name>, Interned<TypeRef>),
+ Normal(Interned<TypeRef>),
Varargs,
}
diff --git a/crates/hir-def/src/item_tree/lower.rs b/crates/hir-def/src/item_tree/lower.rs
index 0488bad3f9..c67c8bb440 100644
--- a/crates/hir-def/src/item_tree/lower.rs
+++ b/crates/hir-def/src/item_tree/lower.rs
@@ -293,7 +293,7 @@ impl<'a> Ctx<'a> {
}
};
let ty = Interned::new(self_type);
- let idx = self.data().params.alloc(Param::Normal(None, ty));
+ let idx = self.data().params.alloc(Param::Normal(ty));
self.add_attrs(
idx.into(),
RawAttrs::new(self.db.upcast(), &self_param, self.hygiene()),
@@ -306,19 +306,7 @@ impl<'a> Ctx<'a> {
None => {
let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ty());
let ty = Interned::new(type_ref);
- 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 = 'name: loop {
- match pat {
- Some(ast::Pat::RefPat(ref_pat)) => pat = ref_pat.pat(),
- Some(ast::Pat::IdentPat(ident)) => {
- break 'name ident.name().map(|it| it.as_name())
- }
- _ => break 'name None,
- }
- };
- self.data().params.alloc(Param::Normal(name, ty))
+ self.data().params.alloc(Param::Normal(ty))
}
};
self.add_attrs(idx.into(), RawAttrs::new(self.db.upcast(), &param, self.hygiene()));
diff --git a/crates/hir-def/src/item_tree/pretty.rs b/crates/hir-def/src/item_tree/pretty.rs
index edd5c3b115..94c5157386 100644
--- a/crates/hir-def/src/item_tree/pretty.rs
+++ b/crates/hir-def/src/item_tree/pretty.rs
@@ -257,21 +257,15 @@ impl<'a> Printer<'a> {
w!(self, "(");
if !params.is_empty() {
self.indented(|this| {
- for (i, param) in params.clone().enumerate() {
+ for param in params.clone() {
this.print_attrs_of(param);
match &this.tree[param] {
- Param::Normal(name, ty) => {
- match name {
- Some(name) => w!(this, "{}: ", name),
- None => w!(this, "_: "),
+ Param::Normal(ty) => {
+ if flags.contains(FnFlags::HAS_SELF_PARAM) {
+ w!(this, "self: ");
}
this.print_type_ref(ty);
- w!(this, ",");
- if flags.contains(FnFlags::HAS_SELF_PARAM) && i == 0 {
- wln!(this, " // self");
- } else {
- wln!(this);
- }
+ wln!(this, ",");
}
Param::Varargs => {
wln!(this, "...");
diff --git a/crates/hir-def/src/item_tree/tests.rs b/crates/hir-def/src/item_tree/tests.rs
index e30d9652bb..1b7564f7a9 100644
--- a/crates/hir-def/src/item_tree/tests.rs
+++ b/crates/hir-def/src/item_tree/tests.rs
@@ -165,7 +165,7 @@ trait Tr: SuperTrait + 'lifetime {
fn method(&self);
}
"#,
- expect![[r##"
+ expect![[r#"
pub static mut ST: () = _;
pub(self) const _: Anon = _;
@@ -174,8 +174,8 @@ trait Tr: SuperTrait + 'lifetime {
#[inner_attr_in_fn]
pub(self) fn f(
#[attr]
- arg: u8,
- _: (),
+ u8,
+ (),
) -> () { ... }
pub(self) trait Tr<Self>
@@ -186,10 +186,10 @@ trait Tr: SuperTrait + 'lifetime {
pub(self) type Assoc: AssocBound = Default;
pub(self) fn method(
- _: &Self, // self
+ self: &Self,
) -> ();
}
- "##]],
+ "#]],
);
}
@@ -336,7 +336,7 @@ trait Tr<'a, T: 'a>: Super where Self: for<'a> Tr<'a, T> {}
T: 'b
{
pub(self) fn f<G>(
- arg: impl Copy,
+ impl Copy,
) -> impl Copy
where
G: 'a { ... }