Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #18809 from Veykril/push-ktwrzsmzlplw
internal: Do not render closure ids in hover messages
Lukas Wirth 2025-01-01
parent a612fc9 · parent 721e43e · commit e5950cd
-rw-r--r--crates/ide/src/hover/render.rs3
-rw-r--r--crates/ide/src/hover/tests.rs6
-rw-r--r--crates/ide/src/inlay_hints/binding_mode.rs3
3 files changed, 3 insertions, 9 deletions
diff --git a/crates/ide/src/hover/render.rs b/crates/ide/src/hover/render.rs
index 03ab9d1ba4..9d55827fe2 100644
--- a/crates/ide/src/hover/render.rs
+++ b/crates/ide/src/hover/render.rs
@@ -890,12 +890,11 @@ fn closure_ty(
} else {
String::new()
};
- let mut markup = format!("```rust\n{}", c.display_with_id(sema.db, edition));
+ let mut markup = format!("```rust\n{}\n```", c.display_with_impl(sema.db, edition));
if let Some(trait_) = c.fn_trait(sema.db).get_id(sema.db, original.krate(sema.db).into()) {
push_new_def(hir::Trait::from(trait_).into())
}
- format_to!(markup, "\n{}\n```", c.display_with_impl(sema.db, edition),);
if let Some(layout) =
render_memory_layout(config.memory_layout, || original.layout(sema.db), |_| None, |_| None)
{
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index 4154572383..039d380925 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -348,7 +348,6 @@ fn main() {
expect![[r#"
*|*
```rust
- {closure#0}
impl Fn(i32) -> i32
```
___
@@ -372,7 +371,6 @@ fn main() {
expect![[r#"
*|*
```rust
- {closure#0}
impl Fn(i32) -> i32
```
___
@@ -407,7 +405,6 @@ fn main() {
expect![[r#"
*|*
```rust
- {closure#0}
impl FnOnce()
```
___
@@ -437,7 +434,6 @@ fn main() {
expect![[r#"
*|*
```rust
- {closure#0}
impl FnMut()
```
___
@@ -463,7 +459,6 @@ fn main() {
"#,
expect![[r#"
```rust
- {closure#0}
impl FnOnce() -> S2
```
___
@@ -3017,7 +3012,6 @@ fn main() {
expect![[r#"
*|*
```rust
- {closure#0}
impl Fn(i32) -> i32
```
diff --git a/crates/ide/src/inlay_hints/binding_mode.rs b/crates/ide/src/inlay_hints/binding_mode.rs
index cfe8657fd0..5afb98cb1c 100644
--- a/crates/ide/src/inlay_hints/binding_mode.rs
+++ b/crates/ide/src/inlay_hints/binding_mode.rs
@@ -61,7 +61,6 @@ pub(super) fn hints(
}
hint.label.append_str(r);
});
- hint.pad_right = was_mut_last;
let acc_base = acc.len();
match pat {
ast::Pat::IdentPat(pat) if pat.ref_token().is_none() && pat.mut_token().is_none() => {
@@ -86,6 +85,7 @@ pub(super) fn hints(
}
ast::Pat::OrPat(pat) if !pattern_adjustments.is_empty() && outer_paren_pat.is_none() => {
hint.label.append_str("(");
+ was_mut_last = false;
acc.push(InlayHint::closing_paren_after(
InlayKind::BindingMode,
pat.syntax().text_range(),
@@ -94,6 +94,7 @@ pub(super) fn hints(
_ => (),
}
if !hint.label.parts.is_empty() {
+ hint.pad_right = was_mut_last;
acc.push(hint);
}