Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/hir-def/src/expr_store/lower.rs7
-rw-r--r--crates/hir-ty/src/tests/simple.rs1
-rw-r--r--crates/hir-ty/src/tests/traits.rs3
3 files changed, 11 insertions, 0 deletions
diff --git a/crates/hir-def/src/expr_store/lower.rs b/crates/hir-def/src/expr_store/lower.rs
index a9697d8e72..afd53cca99 100644
--- a/crates/hir-def/src/expr_store/lower.rs
+++ b/crates/hir-def/src/expr_store/lower.rs
@@ -1013,11 +1013,15 @@ impl<'db> ExprCollector<'db> {
}
_ => (self.generate_new_name(), HygieneId::ROOT, false),
};
+ let pat_syntax = self.store.pat_map_back.get(*param).copied();
let child_binding_id =
self.alloc_binding(name.clone(), BindingAnnotation::Mutable, hygiene);
let child_pat_id =
self.alloc_pat_desugared(Pat::Bind { id: child_binding_id, subpat: None });
self.add_definition_to_binding(child_binding_id, child_pat_id);
+ if let Some(pat_syntax) = pat_syntax {
+ self.store.pat_map_back.insert(child_pat_id, pat_syntax);
+ }
let expr = self.alloc_expr_desugared(Expr::Path(name.clone().into()));
if !hygiene.is_root() {
self.store.ident_hygiene.insert(expr.into(), hygiene);
@@ -1045,6 +1049,9 @@ impl<'db> ExprCollector<'db> {
let parent_pat_id =
self.alloc_pat_desugared(Pat::Bind { id: parent_binding_id, subpat: None });
self.add_definition_to_binding(parent_binding_id, parent_pat_id);
+ if let Some(pat_syntax) = pat_syntax {
+ self.store.pat_map_back.insert(parent_pat_id, pat_syntax);
+ }
*param = parent_pat_id;
}
}
diff --git a/crates/hir-ty/src/tests/simple.rs b/crates/hir-ty/src/tests/simple.rs
index a8ace69017..fbe7c3bd37 100644
--- a/crates/hir-ty/src/tests/simple.rs
+++ b/crates/hir-ty/src/tests/simple.rs
@@ -4032,6 +4032,7 @@ fn main() {
100..147 'async_... })': ()
114..146 'async ... }': impl AsyncFnOnce(i32)
121..124 'arg': i32
+ 121..124 'arg': i32
126..146 '{ ... }': ()
136..139 'arg': i32
153..160 'closure': fn closure<impl FnOnce(i32)>(impl FnOnce(i32))
diff --git a/crates/hir-ty/src/tests/traits.rs b/crates/hir-ty/src/tests/traits.rs
index bcb5e5de16..18e4a5b41d 100644
--- a/crates/hir-ty/src/tests/traits.rs
+++ b/crates/hir-ty/src/tests/traits.rs
@@ -4930,6 +4930,7 @@ async fn baz<T: AsyncFnOnce(u32) -> i32>(c: T) {
"#,
expect![[r#"
37..38 'a': T
+ 37..38 'a': T
43..83 '{ ...ait; }': ()
53..57 'fut1': <T as AsyncFnMut<(u32,)>>::CallRefFuture<'?>
60..61 'a': T
@@ -4938,6 +4939,7 @@ async fn baz<T: AsyncFnOnce(u32) -> i32>(c: T) {
70..74 'fut1': <T as AsyncFnMut<(u32,)>>::CallRefFuture<'?>
70..80 'fut1.await': i32
124..129 'mut b': T
+ 124..129 'mut b': T
134..174 '{ ...ait; }': ()
144..148 'fut2': <T as AsyncFnMut<(u32,)>>::CallRefFuture<'?>
151..152 'b': T
@@ -4946,6 +4948,7 @@ async fn baz<T: AsyncFnOnce(u32) -> i32>(c: T) {
161..165 'fut2': <T as AsyncFnMut<(u32,)>>::CallRefFuture<'?>
161..171 'fut2.await': i32
216..217 'c': T
+ 216..217 'c': T
222..262 '{ ...ait; }': ()
232..236 'fut3': <T as AsyncFnOnce<(u32,)>>::CallOnceFuture
239..240 'c': T