@@ -50,6 +50,28 @@ fn check(ra_fixture: &str, expect: Expect) {
5050 expect. assert_eq ( & actual)
5151}
5252
53+ #[ track_caller]
54+ fn check_hover_struct_limit ( count : usize , ra_fixture : & str , expect : Expect ) {
55+ let ( analysis, position) = fixture:: position ( ra_fixture) ;
56+ let hover = analysis
57+ . hover (
58+ & HoverConfig {
59+ links_in_hover : true ,
60+ max_struct_field_count : Some ( count) ,
61+ ..HOVER_BASE_CONFIG
62+ } ,
63+ FileRange { file_id : position. file_id , range : TextRange :: empty ( position. offset ) } ,
64+ )
65+ . unwrap ( )
66+ . unwrap ( ) ;
67+
68+ let content = analysis. db . file_text ( position. file_id ) ;
69+ let hovered_element = & content[ hover. range ] ;
70+
71+ let actual = format ! ( "*{hovered_element}*\n {}\n " , hover. info. markup) ;
72+ expect. assert_eq ( & actual)
73+ }
74+
5375#[ track_caller]
5476fn check_assoc_count ( count : usize , ra_fixture : & str , expect : Expect ) {
5577 let ( analysis, position) = fixture:: position ( ra_fixture) ;
@@ -879,6 +901,75 @@ struct Foo$0 where u32: Copy { field: u32 }
879901 ) ;
880902}
881903
904+ #[ test]
905+ fn hover_record_struct_limit ( ) {
906+ check_hover_struct_limit (
907+ 3 ,
908+ r#"
909+ struct Foo$0 { a: u32, b: i32, c: i32 }
910+ "# ,
911+ expect ! [ [ r#"
912+ *Foo*
913+
914+ ```rust
915+ test
916+ ```
917+
918+ ```rust
919+ // size = 12 (0xC), align = 4
920+ struct Foo {
921+ a: u32,
922+ b: i32,
923+ c: i32,
924+ }
925+ ```
926+ "# ] ] ,
927+ ) ;
928+ check_hover_struct_limit (
929+ 3 ,
930+ r#"
931+ struct Foo$0 { a: u32 }
932+ "# ,
933+ expect ! [ [ r#"
934+ *Foo*
935+
936+ ```rust
937+ test
938+ ```
939+
940+ ```rust
941+ // size = 4, align = 4
942+ struct Foo {
943+ a: u32,
944+ }
945+ ```
946+ "# ] ] ,
947+ ) ;
948+ check_hover_struct_limit (
949+ 3 ,
950+ r#"
951+ struct Foo$0 { a: u32, b: i32, c: i32, d: u32 }
952+ "# ,
953+ expect ! [ [ r#"
954+ *Foo*
955+
956+ ```rust
957+ test
958+ ```
959+
960+ ```rust
961+ // size = 16 (0x10), align = 4
962+ struct Foo {
963+ a: u32,
964+ b: i32,
965+ c: i32,
966+ /* … */
967+ }
968+ ```
969+ "# ] ] ,
970+ ) ;
971+ }
972+
882973#[ test]
883974fn hover_unit_struct ( ) {
884975 check (
0 commit comments