Repository: rust-lang/rust-analyzer (rust)

Issue:
[Feature Request] Preview struct fields when hover on type.
something like this:
![image](https://user-images.githubusercontent.com/14040068/213071789-83df0fa7-f5f2-46ca-bc7a-b2dbc1098b2b.png)


Pull request:
feat: preview adt field when hover
Closes #13977 
![20231108194345_rec_](https://github.com/rust-lang/rust-analyzer/assets/14040068/95894c4b-de6e-4ca4-98b3-6ab4559d0950)



Patch:
diff --git a/Cargo.lock b/Cargo.lock
index fcb188c0df..0a3d38645f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1454,12 +1454,12 @@ dependencies = [
 
 [[package]]
 name = "ra-ap-rustc_abi"
-version = "0.18.0"
+version = "0.14.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7082716cb2bbcd8b5f062fe950cbbc87f3aba022d6da4168db35af6732a7f15d"
+checksum = "a51b7a02377b3246ec5c095b852b5cf1678bd9ed6b572b2a79efbf7ad711c292"
 dependencies = [
  "bitflags 1.3.2",
- "ra-ap-rustc_index 0.18.0",
+ "ra-ap-rustc_index",
  "tracing",
 ]
 
@@ -1473,16 +1473,6 @@ dependencies = [
  "smallvec",
 ]
 
-[[package]]
-name = "ra-ap-rustc_index"
-version = "0.18.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "19e14b1fc835d6992b128a03a3f3a8365ba9f03e1c656a1670305f63f30d786d"
-dependencies = [
- "arrayvec",
- "smallvec",
-]
-
 [[package]]
 name = "ra-ap-rustc_lexer"
 version = "0.14.0"
@@ -1493,24 +1483,14 @@ dependencies = [
  "unicode-xid",
 ]
 
-[[package]]
-name = "ra-ap-rustc_lexer"
-version = "0.18.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1762abb25eb1e37c1823f62b5da0821bbcd870812318db084c9516c2f78d2dcd"
-dependencies = [
- "unicode-properties",
- "unicode-xid",
-]
-
 [[package]]
 name = "ra-ap-rustc_parse_format"
 version = "0.14.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "207b5ac1a21d4926695e03b605ffb9f63d4968e0488e9197c04c512c37303aa7"
 dependencies = [
- "ra-ap-rustc_index 0.14.0",
- "ra-ap-rustc_lexer 0.14.0",
+ "ra-ap-rustc_index",
+ "ra-ap-rustc_lexer",
 ]
 
 [[package]]
@@ -1634,8 +1614,8 @@ name = "rustc-dependencies"
 version = "0.0.0"
 dependencies = [
  "ra-ap-rustc_abi",
- "ra-ap-rustc_index 0.18.0",
- "ra-ap-rustc_lexer 0.18.0",
+ "ra-ap-rustc_index",
+ "ra-ap-rustc_lexer",
  "ra-ap-rustc_parse_format",
 ]
 
diff --git a/crates/base-db/src/lib.rs b/crates/base-db/src/lib.rs
index c5c4afa30f..af204e44e6 100644
--- a/crates/base-db/src/lib.rs
+++ b/crates/base-db/src/lib.rs
@@ -75,7 +75,7 @@ pub trait SourceDatabase: FileLoader + std::fmt::Debug {
     #[salsa::input]
     fn crate_graph(&self) -> Arc<CrateGraph>;
 
-    /// The proc macros.
+    /// The crate graph.
     #[salsa::input]
     fn proc_macros(&self) -> Arc<ProcMacros>;
 }
diff --git a/crates/hir-def/src/data/adt.rs b/crates/hir-def/src/data/adt.rs
index b163112db9..76c8d9a0c3 100644
--- a/crates/hir-def/src/data/adt.rs
+++ b/crates/hir-def/src/data/adt.rs
@@ -178,7 +178,7 @@ fn parse_repr_tt(tt: &Subtree) -> Option<ReprOptions> {
         }
     }
 
-    Some(ReprOptions { int, align: max_align, pack: min_pack, flags, field_shuffle_seed: 0 })
+    Some(ReprOptions { int, align: max_align, pack: min_pack, flags })
 }
 
 impl StructData {
diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs
index ac171026d5..cf3ff62fc6 100644
--- a/crates/hir/src/display.rs
+++ b/crates/hir/src/display.rs
@@ -1,6 +1,6 @@
 //! HirDisplay implementations for various hir types.
 use hir_def::{
-    data::adt::VariantData,
+    data::adt::{StructKind, VariantData},
     generics::{
         TypeOrConstParamData, TypeParamProvenance, WherePredicate, WherePredicateTypeTarget,
     },
@@ -163,7 +163,40 @@ impl HirDisplay for Struct {
         write!(f, "{}", self.name(f.db).display(f.db.upcast()))?;
         let def_id = GenericDefId::AdtId(AdtId::StructId(self.id));
         write_generic_params(def_id, f)?;
+
+        let variant_data = self.variant_data(f.db);
+        if let StructKind::Tuple = variant_data.kind() {
+            f.write_char('(')?;
+            let mut it = variant_data.fields().iter().peekable();
+
+            while let Some((id, _)) = it.next() {
+                let field = Field { parent: (*self).into(), id };
+                field.ty(f.db).hir_fmt(f)?;
+                if it.peek().is_some() {
+                    f.write_str(", ")?;
+                }
+            }
+
+            f.write_str(");")?;
+        }
+
         write_where_clause(def_id, f)?;
+
+        if let StructKind::Record = variant_data.kind() {
+            let fields = self.fields(f.db);
+            if fields.is_empty() {
+                f.write_str(" {}")?;
+            } else {
+                f.write_str(" {\n")?;
+                for field in self.fields(f.db) {
+                    f.write_str("    ")?;
+                    field.hir_fmt(f)?;
+                    f.write_str(",\n")?;
+                }
+                f.write_str("}")?;
+            }
+        }
+
         Ok(())
     }
 }
@@ -176,6 +209,18 @@ impl HirDisplay for Enum {
         let def_id = GenericDefId::AdtId(AdtId::EnumId(self.id));
         write_generic_params(def_id, f)?;
         write_where_clause(def_id, f)?;
+
+        let variants = self.variants(f.db);
+        if !variants.is_empty() {
+            f.write_str(" {\n")?;
+            for variant in variants {
+                f.write_str("    ")?;
+                variant.hir_fmt(f)?;
+                f.write_str(",\n")?;
+            }
+            f.write_str("}")?;
+        }
+
         Ok(())
     }
 }
@@ -188,6 +233,18 @@ impl HirDisplay for Union {
         let def_id = GenericDefId::AdtId(AdtId::UnionId(self.id));
         write_generic_params(def_id, f)?;
         write_where_clause(def_id, f)?;
+
+        let fields = self.fields(f.db);
+        if !fields.is_empty() {
+            f.write_str(" {\n")?;
+            for field in self.fields(f.db) {
+                f.write_str("    ")?;
+                field.hir_fmt(f)?;
+                f.write_str(",\n")?;
+            }
+            f.write_str("}")?;
+        }
+
         Ok(())
     }
 }
diff --git a/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs b/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs
deleted file mode 100644
index cb8ef39565..0000000000
--- a/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs
+++ /dev/null
@@ -1,202 +0,0 @@
-use ide_db::famous_defs::FamousDefs;
-use syntax::{
-    ast::{self, make},
-    ted, AstNode,
-};
-
-use crate::{AssistContext, AssistId, AssistKind, Assists};
-
-// FIXME: Generate proper `index_mut` method body refer to `index` method body may impossible due to the unpredicable case [#15581].
-// Here just leave the `index_mut` method body be same as `index` method body, user can modify it manually to meet their need.
-
-// Assist: generate_mut_trait_impl
-//
-// Adds a IndexMut impl from the `Index` trait.
-//
-// ```
-// # //- minicore: index
-// pub enum Axis { X = 0, Y = 1, Z = 2 }
-//
-// impl<T> core::ops::Index$0<Axis> for [T; 3] {
-//     type Output = T;
-//
-//     fn index(&self, index: Axis) -> &Self::Output {
-//         &self[index as usize]
-//     }
-// }
-// ```
-// ->
-// ```
-// pub enum Axis { X = 0, Y = 1, Z = 2 }
-//
-// $0impl<T> core::ops::IndexMut<Axis> for [T; 3] {
-//     fn index_mut(&mut self, index: Axis) -> &mut Self::Output {
-//         &self[index as usize]
-//     }
-// }
-//
-// impl<T> core::ops::Index<Axis> for [T; 3] {
-//     type Output = T;
-//
-//     fn index(&self, index: Axis) -> &Self::Output {
-//         &self[index as usize]
-//     }
-// }
-// ```
-pub(crate) fn generate_mut_trait_impl(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
-    let impl_def = ctx.find_node_at_offset::<ast::Impl>()?.clone_for_update();
-
-    let trait_ = impl_def.trait_()?;
-    if let ast::Type::PathType(trait_path) = trait_.clone() {
-        let trait_type = ctx.sema.resolve_trait(&trait_path.path()?)?;
-        let scope = ctx.sema.scope(trait_path.syntax())?;
-        if trait_type != FamousDefs(&ctx.sema, scope.krate()).core_convert_Index()? {
-            return None;
-        }
-    }
-
-    // Index -> IndexMut
-    let index_trait = impl_def
-        .syntax()
-        .descendants()
-        .filter_map(ast::NameRef::cast)
-        .find(|it| it.text() == "Index")?;
-    ted::replace(
-        index_trait.syntax(),
-        make::path_segment(make::name_ref("IndexMut")).clone_for_update().syntax(),
-    );
-
-    // index -> index_mut
-    let trait_method_name = impl_def
-        .syntax()
-        .descendants()
-        .filter_map(ast::Name::cast)
-        .find(|it| it.text() == "index")?;
-    ted::replace(trait_method_name.syntax(), make::name("index_mut").clone_for_update().syntax());
-
-    let type_alias = impl_def.syntax().descendants().find_map(ast::TypeAlias::cast)?;
-    ted::remove(type_alias.syntax());
-
-    // &self -> &mut self
-    let mut_self_param = make::mut_self_param();
-    let self_param: ast::SelfParam =
-        impl_def.syntax().descendants().find_map(ast::SelfParam::cast)?;
-    ted::replace(self_param.syntax(), mut_self_param.clone_for_update().syntax());
-
-    // &Self::Output -> &mut Self::Output
-    let ret_type = impl_def.syntax().descendants().find_map(ast::RetType::cast)?;
-    ted::replace(
-        ret_type.syntax(),
-        make::ret_type(make::ty("&mut Self::Output")).clone_for_update().syntax(),
-    );
-
-    let fn_ = impl_def.assoc_item_list()?.assoc_items().find_map(|it| match it {
-        ast::AssocItem::Fn(f) => Some(f),
-        _ => None,
-    })?;
-
-    let assoc_list = make::assoc_item_list().clone_for_update();
-    assoc_list.add_item(syntax::ast::AssocItem::Fn(fn_));
-    ted::replace(impl_def.assoc_item_list()?.syntax(), assoc_list.syntax());
-
-    let target = impl_def.syntax().text_range();
-    acc.add(
-        AssistId("generate_mut_trait_impl", AssistKind::Generate),
-        "Generate `IndexMut` impl from this `Index` trait",
-        target,
-        |edit| {
-            edit.insert(target.start(), format!("$0{}\n\n", impl_def.to_string()));
-        },
-    )
-}
-
-#[cfg(test)]
-mod tests {
-    use crate::tests::{check_assist, check_assist_not_applicable};
-
-    use super::*;
-
-    #[test]
-    fn test_generate_mut_trait_impl() {
-        check_assist(
-            generate_mut_trait_impl,
-            r#"
-//- minicore: index
-pub enum Axis { X = 0, Y = 1, Z = 2 }
-
-impl<T> core::ops::Index$0<Axis> for [T; 3] {
-    type Output = T;
-
-    fn index(&self, index: Axis) -> &Self::Output {
-        &self[index as usize]
-    }
-}
-"#,
-            r#"
-pub enum Axis { X = 0, Y = 1, Z = 2 }
-
-$0impl<T> core::ops::IndexMut<Axis> for [T; 3] {
-    fn index_mut(&mut self, index: Axis) -> &mut Self::Output {
-        &self[index as usize]
-    }
-}
-
-impl<T> core::ops::Index<Axis> for [T; 3] {
-    type Output = T;
-
-    fn index(&self, index: Axis) -> &Self::Output {
-        &self[index as usize]
-    }
-}
-"#,
-        );
-
-        check_assist(
-            generate_mut_trait_impl,
-            r#"
-//- minicore: index
-pub enum Axis { X = 0, Y = 1, Z = 2 }
-
-impl<T> core::ops::Index$0<Axis> for [T; 3] where T: Copy {
-    type Output = T;
-
-    fn index(&self, index: Axis) -> &Self::Output {
-        let var_name = &self[index as usize];
-        var_name
-    }
-}
-"#,
-            r#"
-pub enum Axis { X = 0, Y = 1, Z = 2 }
-
-$0impl<T> core::ops::IndexMut<Axis> for [T; 3] where T: Copy {
-    fn index_mut(&mut self, index: Axis) -> &mut Self::Output {
-        let var_name = &self[index as usize];
-        var_name
-    }
-}
-
-impl<T> core::ops::Index<Axis> for [T; 3] where T: Copy {
-    type Output = T;
-
-    fn index(&self, index: Axis) -> &Self::Output {
-        let var_name = &self[index as usize];
-        var_name
-    }
-}
-"#,
-        );
-    }
-
-    #[test]
-    fn test_generate_mut_trait_impl_not_applicable() {
-        check_assist_not_applicable(
-            generate_mut_trait_impl,
-            r#"
-pub trait Index<Idx: ?Sized> {}
-
-impl<T> Index$0<i32> for [T; 3] {}
-"#,
-        );
-    }
-}
diff --git a/crates/ide-assists/src/lib.rs b/crates/ide-assists/src/lib.rs
index e6f03214ed..d2b291631c 100644
--- a/crates/ide-assists/src/lib.rs
+++ b/crates/ide-assists/src/lib.rs
@@ -160,7 +160,6 @@ mod handlers {
     mod generate_getter_or_setter;
     mod generate_impl;
     mod generate_is_empty_from_len;
-    mod generate_mut_trait_impl;
     mod generate_new;
     mod generate_delegate_methods;
     mod generate_trait_from_impl;
@@ -275,7 +274,6 @@ mod handlers {
             generate_function::generate_function,
             generate_impl::generate_impl,
             generate_impl::generate_trait_impl,
-            generate_mut_trait_impl::generate_mut_trait_impl,
             generate_is_empty_from_len::generate_is_empty_from_len,
             generate_new::generate_new,
             generate_trait_from_impl::generate_trait_from_impl,
diff --git a/crates/ide-db/src/famous_defs.rs b/crates/ide-db/src/famous_defs.rs
index 722517a767..b63dde2c21 100644
--- a/crates/ide-db/src/famous_defs.rs
+++ b/crates/ide-db/src/famous_defs.rs
@@ -54,10 +54,6 @@ impl FamousDefs<'_, '_> {
         self.find_trait("core:convert:Into")
     }
 
-    pub fn core_convert_Index(&self) -> Option<Trait> {
-        self.find_trait("core:ops:Index")
-    }
-
     pub fn core_option_Option(&self) -> Option<Enum> {
         self.find_enum("core:option:Option")
     }
diff --git a/crates/rustc-dependencies/Cargo.toml b/crates/rustc-dependencies/Cargo.toml
index a313507bff..7ead3d84cd 100644
--- a/crates/rustc-dependencies/Cargo.toml
+++ b/crates/rustc-dependencies/Cargo.toml
@@ -11,10 +11,10 @@ authors.workspace = true
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-ra-ap-rustc_lexer = { version = "0.18.0" }
+ra-ap-rustc_lexer = { version = "0.14.0" }
 ra-ap-rustc_parse_format = { version = "0.14.0", default-features = false }
-ra-ap-rustc_index = { version = "0.18.0", default-features = false }
-ra-ap-rustc_abi = { version = "0.18.0", default-features = false }
+ra-ap-rustc_index = { version = "0.14.0", default-features = false }
+ra-ap-rustc_abi = { version = "0.14.0", default-features = false }
 
 [features]
 in-rust-tree = []
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs
index 31a858b91a..96f685d8d6 100644
--- a/crates/syntax/src/ast/make.rs
+++ b/crates/syntax/src/ast/make.rs
@@ -852,10 +852,6 @@ pub fn self_param() -> ast::SelfParam {
     ast_from_text("fn f(&self) { }")
 }
 
-pub fn mut_self_param() -> ast::SelfParam {
-    ast_from_text("fn f(&mut self) { }")
-}
-
 pub fn ret_type(ty: ast::Type) -> ast::RetType {
     ast_from_text(&format!("fn f() -> {ty} {{ }}"))
 }


Test patch:
diff --git a/crates/ide-assists/src/tests/generated.rs b/crates/ide-assists/src/tests/generated.rs
index da5822bba9..8523632acf 100644
--- a/crates/ide-assists/src/tests/generated.rs
+++ b/crates/ide-assists/src/tests/generated.rs
@@ -1538,42 +1538,6 @@ impl MyStruct {
     )
 }
 
-#[test]
-fn doctest_generate_mut_trait_impl() {
-    check_doc_test(
-        "generate_mut_trait_impl",
-        r#####"
-//- minicore: index
-pub enum Axis { X = 0, Y = 1, Z = 2 }
-
-impl<T> core::ops::Index$0<Axis> for [T; 3] {
-    type Output = T;
-
-    fn index(&self, index: Axis) -> &Self::Output {
-        &self[index as usize]
-    }
-}
-"#####,
-        r#####"
-pub enum Axis { X = 0, Y = 1, Z = 2 }
-
-$0impl<T> core::ops::IndexMut<Axis> for [T; 3] {
-    fn index_mut(&mut self, index: Axis) -> &mut Self::Output {
-        &self[index as usize]
-    }
-}
-
-impl<T> core::ops::Index<Axis> for [T; 3] {
-    type Output = T;
-
-    fn index(&self, index: Axis) -> &Self::Output {
-        &self[index as usize]
-    }
-}
-"#####,
-    )
-}
-
 #[test]
 fn doctest_generate_new() {
     check_doc_test(
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index e54bc48d55..d3d492f3fd 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -1136,7 +1136,9 @@ impl Thing {
                 ```
 
                 ```rust
-                struct Thing
+                struct Thing {
+                    x: u32,
+                }
                 ```
             "#]],
     );
@@ -1155,7 +1157,9 @@ impl Thing {
                 ```
 
                 ```rust
-                struct Thing
+                struct Thing {
+                    x: u32,
+                }
                 ```
             "#]],
     );
@@ -1174,7 +1178,9 @@ impl Thing {
                 ```
 
                 ```rust
-                enum Thing
+                enum Thing {
+                    A,
+                }
                 ```
             "#]],
     );
@@ -1193,7 +1199,9 @@ impl Thing {
                 ```
 
                 ```rust
-                enum Thing
+                enum Thing {
+                    A,
+                }
                 ```
             "#]],
     );
@@ -2005,7 +2013,10 @@ fn test_hover_layout_of_enum() {
             ```
 
             ```rust
-            enum Foo // size = 16 (0x10), align = 8, niches = 254
+            enum Foo {
+                Variant1(u8, u16),
+                Variant2(i32, u8, i64),
+            } // size = 16 (0x10), align = 8, niches = 254
             ```
         "#]],
     );
@@ -2346,7 +2357,7 @@ fn main() { let s$0t = S{ f1:0 }; }
                                     focus_range: 7..8,
                                     name: "S",
                                     kind: Struct,
-                                    description: "struct S",
+                                    description: "struct S {\n    f1: u32,\n}",
                                 },
                             },
                         ],
@@ -2379,7 +2390,7 @@ fn main() { let s$0t = S{ f1:Arg(0) }; }
                                     focus_range: 24..25,
                                     name: "S",
                                     kind: Struct,
-                                    description: "struct S<T>",
+                                    description: "struct S<T> {\n    f1: T,\n}",
                                 },
                             },
                             HoverGotoTypeData {
@@ -2392,7 +2403,7 @@ fn main() { let s$0t = S{ f1:Arg(0) }; }
                                     focus_range: 7..10,
                                     name: "Arg",
                                     kind: Struct,
-                                    description: "struct Arg",
+                                    description: "struct Arg(u32);",
                                 },
                             },
                         ],
@@ -2438,7 +2449,7 @@ fn main() { let s$0t = S{ f1: S{ f1: Arg(0) } }; }
                                     focus_range: 24..25,
                                     name: "S",
                                     kind: Struct,
-                                    description: "struct S<T>",
+                                    description: "struct S<T> {\n    f1: T,\n}",
                                 },
                             },
                             HoverGotoTypeData {
@@ -2451,7 +2462,7 @@ fn main() { let s$0t = S{ f1: S{ f1: Arg(0) } }; }
                                     focus_range: 7..10,
                                     name: "Arg",
                                     kind: Struct,
-                                    description: "struct Arg",
+                                    description: "struct Arg(u32);",
                                 },
                             },
                         ],
@@ -2487,7 +2498,7 @@ fn main() { let s$0t = (A(1), B(2), M::C(3) ); }
                                 focus_range: 7..8,
                                 name: "A",
                                 kind: Struct,
-                                description: "struct A",
+                                description: "struct A(u32);",
                             },
                         },
                         HoverGotoTypeData {
@@ -2500,7 +2511,7 @@ fn main() { let s$0t = (A(1), B(2), M::C(3) ); }
                                 focus_range: 22..23,
                                 name: "B",
                                 kind: Struct,
-                                description: "struct B",
+                                description: "struct B(u32);",
                             },
                         },
                         HoverGotoTypeData {
@@ -2514,7 +2525,7 @@ fn main() { let s$0t = (A(1), B(2), M::C(3) ); }
                                 name: "C",
                                 kind: Struct,
                                 container_name: "M",
-                                description: "pub struct C",
+                                description: "pub struct C(u32);",
                             },
                         },
                     ],
@@ -2704,7 +2715,7 @@ fn main() { let s$0t = foo(); }
                                     focus_range: 39..41,
                                     name: "S1",
                                     kind: Struct,
-                                    description: "struct S1",
+                                    description: "struct S1 {}",
                                 },
                             },
                             HoverGotoTypeData {
@@ -2717,7 +2728,7 @@ fn main() { let s$0t = foo(); }
                                     focus_range: 52..54,
                                     name: "S2",
                                     kind: Struct,
-                                    description: "struct S2",
+                                    description: "struct S2 {}",
                                 },
                             },
                         ],
@@ -2808,7 +2819,7 @@ fn foo(ar$0g: &impl Foo + Bar<S>) {}
                                     focus_range: 36..37,
                                     name: "S",
                                     kind: Struct,
-                                    description: "struct S",
+                                    description: "struct S {}",
                                 },
                             },
                         ],
@@ -2908,7 +2919,7 @@ fn foo(ar$0g: &impl Foo<S>) {}
                                     focus_range: 23..24,
                                     name: "S",
                                     kind: Struct,
-                                    description: "struct S",
+                                    description: "struct S {}",
                                 },
                             },
                         ],
@@ -2945,7 +2956,7 @@ fn main() { let s$0t = foo(); }
                                     focus_range: 49..50,
                                     name: "B",
                                     kind: Struct,
-                                    description: "struct B<T>",
+                                    description: "struct B<T> {}",
                                 },
                             },
                             HoverGotoTypeData {
@@ -3034,7 +3045,7 @@ fn foo(ar$0g: &dyn Foo<S>) {}
                                     focus_range: 23..24,
                                     name: "S",
                                     kind: Struct,
-                                    description: "struct S",
+                                    description: "struct S {}",
                                 },
                             },
                         ],
@@ -3082,7 +3093,7 @@ fn foo(a$0rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
                                     focus_range: 50..51,
                                     name: "B",
                                     kind: Struct,
-                                    description: "struct B<T>",
+                                    description: "struct B<T> {}",
                                 },
                             },
                             HoverGotoTypeData {
@@ -3108,7 +3119,7 @@ fn foo(a$0rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
                                     focus_range: 65..66,
                                     name: "S",
                                     kind: Struct,
-                                    description: "struct S",
+                                    description: "struct S {}",
                                 },
                             },
                         ],
@@ -3335,7 +3346,7 @@ struct S$0T<const C: usize = 1, T = Foo>(T);
             ```
 
             ```rust
-            struct ST<const C: usize = 1, T = Foo>
+            struct ST<const C: usize = 1, T = Foo>(T);
             ```
         "#]],
     );
@@ -3356,7 +3367,7 @@ struct S$0T<const C: usize = {40 + 2}, T = Foo>(T);
             ```
 
             ```rust
-            struct ST<const C: usize = {const}, T = Foo>
+            struct ST<const C: usize = {const}, T = Foo>(T);
             ```
         "#]],
     );
@@ -3378,7 +3389,7 @@ struct S$0T<const C: usize = VAL, T = Foo>(T);
             ```
 
             ```rust
-            struct ST<const C: usize = VAL, T = Foo>
+            struct ST<const C: usize = VAL, T = Foo>(T);
             ```
         "#]],
     );
@@ -5935,7 +5946,7 @@ pub struct Foo(i32);
             ```
 
             ```rust
-            pub struct Foo // size = 4, align = 4
+            pub struct Foo(i32); // size = 4, align = 4
             ```
 
             ---