diff --git a/crates/ide/src/hover/render.rs b/crates/ide/src/hover/render.rs index a4cb869ac1f6..7bb88006f6d1 100644 --- a/crates/ide/src/hover/render.rs +++ b/crates/ide/src/hover/render.rs @@ -718,18 +718,17 @@ pub(super) fn definition( } _ => return None, }; - let rendered_drop_glue = match drop_info.drop_glue { - DropGlue::None => "does not contain types with destructors (drop glue)", - DropGlue::DependOnParams => { - "may contain types with destructors (drop glue) depending on type parameters" + let rendered_drop_glue = if drop_info.has_dtor == Some(true) { + "impl Drop" + } else { + match drop_info.drop_glue { + DropGlue::HasDropGlue => "needs Drop", + DropGlue::None => "no Drop", + DropGlue::DependOnParams => "type param may need Drop", } - DropGlue::HasDropGlue => "contain types with destructors (drop glue)", }; - Some(match drop_info.has_dtor { - Some(true) => format!("{}; has a destructor", rendered_drop_glue), - Some(false) => format!("{}; doesn't have a destructor", rendered_drop_glue), - None => rendered_drop_glue.to_owned(), - }) + + Some(rendered_drop_glue.to_owned()) }; let dyn_compatibility_info = || match def { @@ -761,15 +760,18 @@ pub(super) fn definition( if let Some(layout_info) = layout_info() { extra.push_str("\n___\n"); extra.push_str(&layout_info); + if let Some(drop_info) = drop_info() { + extra.push_str(", "); + extra.push_str(&drop_info) + } + } else if let Some(drop_info) = drop_info() { + extra.push_str("\n___\n"); + extra.push_str(&drop_info); } if let Some(dyn_compatibility_info) = dyn_compatibility_info() { extra.push_str("\n___\n"); extra.push_str(&dyn_compatibility_info); } - if let Some(drop_info) = drop_info() { - extra.push_str("\n___\n"); - extra.push_str(&drop_info); - } } let mut desc = String::new(); desc.push_str(&label); diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index c5f87910302e..a3258627170b 100644 --- a/crates/ide/src/hover/tests.rs +++ b/crates/ide/src/hover/tests.rs @@ -567,11 +567,7 @@ fn main() { --- - size = 8, align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 8, align = 4, no Drop "#]], ); } @@ -816,11 +812,7 @@ struct Foo { fiel$0d_a: u8, field_b: i32, field_c: i16 } --- - size = 1, align = 1, offset = 6 - - --- - - does not contain types with destructors (drop glue) + size = 1, align = 1, offset = 6, no Drop "#]], ); } @@ -871,11 +863,7 @@ fn main() { --- - size = 4, align = 4, offset = 0 - - --- - - does not contain types with destructors (drop glue) + size = 4, align = 4, offset = 0, no Drop "#]], ); } @@ -945,11 +933,7 @@ struct Foo$0(pub u32) where u32: Copy; --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 4, align = 4, no Drop "#]], ); } @@ -975,11 +959,7 @@ struct Foo$0 { field: u32 } --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 4, align = 4, no Drop "#]], ); check( @@ -1004,11 +984,7 @@ struct Foo$0 where u32: Copy { field: u32 } --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 4, align = 4, no Drop "#]], ); } @@ -1037,11 +1013,7 @@ fn hover_record_struct_limit() { --- - size = 12 (0xC), align = 4 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 12 (0xC), align = 4, no Drop "#]], ); check_hover_fields_limit( @@ -1064,11 +1036,7 @@ fn hover_record_struct_limit() { --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 4, align = 4, no Drop "#]], ); check_hover_fields_limit( @@ -1094,11 +1062,7 @@ fn hover_record_struct_limit() { --- - size = 16 (0x10), align = 4 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 16 (0x10), align = 4, no Drop "#]], ); check_hover_fields_limit( @@ -1119,11 +1083,7 @@ fn hover_record_struct_limit() { --- - size = 12 (0xC), align = 4 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 12 (0xC), align = 4, no Drop "#]], ); check_hover_fields_limit( @@ -1144,11 +1104,7 @@ fn hover_record_struct_limit() { --- - size = 12 (0xC), align = 4 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 12 (0xC), align = 4, no Drop "#]], ); @@ -1171,11 +1127,7 @@ fn hover_record_struct_limit() { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 0, align = 1, no Drop "#]], ); } @@ -1200,11 +1152,7 @@ fn hover_record_variant_limit() { --- - size = 12 (0xC), align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 12 (0xC), align = 4, no Drop "#]], ); check_hover_fields_limit( @@ -1225,11 +1173,7 @@ fn hover_record_variant_limit() { --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 4, align = 4, no Drop "#]], ); check_hover_fields_limit( @@ -1250,11 +1194,7 @@ fn hover_record_variant_limit() { --- - size = 16 (0x10), align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 16 (0x10), align = 4, no Drop "#]], ); check_hover_fields_limit( @@ -1275,11 +1215,7 @@ fn hover_record_variant_limit() { --- - size = 12 (0xC), align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 12 (0xC), align = 4, no Drop "#]], ); check_hover_fields_limit( @@ -1300,11 +1236,7 @@ fn hover_record_variant_limit() { --- - size = 12 (0xC), align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 12 (0xC), align = 4, no Drop "#]], ); } @@ -1330,11 +1262,7 @@ fn hover_enum_limit() { --- - size = 1, align = 1, niches = 254 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 1, align = 1, niches = 254, no Drop "#]], ); check_hover_enum_variants_limit( @@ -1356,11 +1284,7 @@ fn hover_enum_limit() { --- - size = 1, align = 1, niches = 254 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 1, align = 1, niches = 254, no Drop "#]], ); check_hover_enum_variants_limit( @@ -1379,11 +1303,7 @@ fn hover_enum_limit() { --- - size = 1, align = 1, niches = 254 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 1, align = 1, niches = 254, no Drop "#]], ); check_hover_enum_variants_limit( @@ -1402,11 +1322,7 @@ fn hover_enum_limit() { --- - size = 1, align = 1, niches = 254 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 1, align = 1, niches = 254, no Drop "#]], ); check_hover_enum_variants_limit( @@ -1443,11 +1359,7 @@ fn hover_enum_limit() { --- - size = 12 (0xC), align = 4, niches = a lot - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 12 (0xC), align = 4, niches = a lot, no Drop "#]], ); } @@ -1473,11 +1385,7 @@ fn hover_union_limit() { --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 4, align = 4, no Drop "#]], ); check_hover_fields_limit( @@ -1499,11 +1407,7 @@ fn hover_union_limit() { --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 4, align = 4, no Drop "#]], ); check_hover_fields_limit( @@ -1522,11 +1426,7 @@ fn hover_union_limit() { --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 4, align = 4, no Drop "#]], ); check_hover_fields_limit( @@ -1545,11 +1445,7 @@ fn hover_union_limit() { --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 4, align = 4, no Drop "#]], ); } @@ -1575,11 +1471,7 @@ struct Foo$0 where u32: Copy; --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 0, align = 1, no Drop "#]], ); } @@ -1605,7 +1497,7 @@ type Fo$0o: Trait = S where T: Trait; --- - does not contain types with destructors (drop glue) + no Drop "#]], ); } @@ -1754,11 +1646,7 @@ fn main() { --- - size = 8, align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 8, align = 4, no Drop "#]], ); check_hover_range( @@ -1813,11 +1701,7 @@ fn main() { let b$0ar = Some(12); } --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 4, align = 4, no Drop "#]], ); } @@ -1845,7 +1729,7 @@ enum Option { --- - does not contain types with destructors (drop glue) + no Drop --- @@ -1908,11 +1792,7 @@ fn hover_for_local_variable_pat() { --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 4, align = 4, no Drop "#]], ) } @@ -1944,11 +1824,7 @@ fn hover_for_param_edge() { --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 4, align = 4, no Drop "#]], ) } @@ -1974,7 +1850,7 @@ fn hover_for_param_with_multiple_traits() { --- - may contain types with destructors (drop glue) depending on type parameters + type param may need Drop "#]], ) } @@ -2000,11 +1876,7 @@ fn main() { let foo_$0test = Thing::new(); } --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 4, align = 4, no Drop "#]], ) } @@ -2257,11 +2129,7 @@ where --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 0, align = 1, no Drop "#]], ); } @@ -2807,11 +2675,7 @@ fn test_hover_function_pointer_show_identifiers() { --- - size = 8, align = 8, niches = 1 - - --- - - does not contain types with destructors (drop glue) + size = 8, align = 8, niches = 1, no Drop "#]], ); } @@ -2833,11 +2697,7 @@ fn test_hover_function_pointer_no_identifier() { --- - size = 8, align = 8, niches = 1 - - --- - - does not contain types with destructors (drop glue) + size = 8, align = 8, niches = 1, no Drop "#]], ); } @@ -3080,11 +2940,7 @@ pub struct B$0ar --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 0, align = 1, no Drop --- @@ -3115,11 +2971,7 @@ pub struct B$0ar --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 0, align = 1, no Drop --- @@ -3212,11 +3064,7 @@ fn test_hover_layout_of_variant() { --- - size = 4, align = 2 - - --- - - does not contain types with destructors (drop glue) + size = 4, align = 2, no Drop "#]], ); } @@ -3241,7 +3089,7 @@ fn test_hover_layout_of_variant_generic() { --- - does not contain types with destructors (drop glue) + no Drop "#]], ); } @@ -3266,11 +3114,7 @@ struct S$0(core::marker::PhantomData); --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 0, align = 1, no Drop "#]], ); } @@ -3298,11 +3142,7 @@ fn test_hover_layout_of_enum() { --- - size = 16 (0x10), align = 8, niches = 254 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 16 (0x10), align = 8, niches = 254, no Drop "#]], ); } @@ -3324,7 +3164,7 @@ fn test_hover_no_memory_layout() { --- - does not contain types with destructors (drop glue) + no Drop "#]], ); @@ -4632,11 +4472,7 @@ fn main() { --- - size = 8, align = 8, niches = 1 - - --- - - does not contain types with destructors (drop glue) + size = 8, align = 8, niches = 1, no Drop --- @@ -4650,11 +4486,7 @@ fn main() { --- - size = 4, align = 4, offset = 0 - - --- - - does not contain types with destructors (drop glue) + size = 4, align = 4, offset = 0, no Drop "#]], ); } @@ -4679,11 +4511,7 @@ struct S$0T(T); --- - size = 0, align = 1 - - --- - - may contain types with destructors (drop glue) depending on type parameters; doesn't have a destructor + size = 0, align = 1, type param may need Drop "#]], ); } @@ -4708,11 +4536,7 @@ struct S$0T(T); --- - size = 0, align = 1 - - --- - - may contain types with destructors (drop glue) depending on type parameters; doesn't have a destructor + size = 0, align = 1, type param may need Drop "#]], ); } @@ -4738,11 +4562,7 @@ struct S$0T(T); --- - size = 0, align = 1 - - --- - - may contain types with destructors (drop glue) depending on type parameters; doesn't have a destructor + size = 0, align = 1, type param may need Drop "#]], ); } @@ -4766,11 +4586,7 @@ fn main() { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); } @@ -4794,11 +4610,7 @@ fn main() { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); } @@ -4822,11 +4634,7 @@ fn main() { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); } @@ -4850,11 +4658,7 @@ fn main() { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); } @@ -4878,11 +4682,7 @@ fn main() { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); } @@ -4905,11 +4705,7 @@ impl Foo { --- - size = 8, align = 8, niches = 1 - - --- - - does not contain types with destructors (drop glue) + size = 8, align = 8, niches = 1, no Drop "#]], ); } @@ -4933,11 +4729,7 @@ impl Foo { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); } @@ -5427,11 +5219,7 @@ type Fo$0o2 = Foo<2>; --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); } @@ -5481,11 +5269,7 @@ enum E { --- - size = 1, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 1, align = 1, no Drop --- @@ -5514,11 +5298,7 @@ enum E { --- - size = 1, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 1, align = 1, no Drop --- @@ -5548,11 +5328,7 @@ enum E { --- - size = 1, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 1, align = 1, no Drop --- @@ -5582,11 +5358,7 @@ enum E { --- - size = 1, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 1, align = 1, no Drop --- @@ -6517,11 +6289,7 @@ fn main() { --- - size = 32 (0x20), align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 32 (0x20), align = 4, no Drop "#]], ); } @@ -7820,11 +7588,7 @@ enum Enum { --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 4, align = 4, no Drop "#]], ); } @@ -7850,11 +7614,7 @@ enum Enum { --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 4, align = 4, no Drop "#]], ); } @@ -8524,11 +8284,7 @@ fn test() { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); } @@ -9177,11 +8933,7 @@ fn main(notable$0: u32) {} --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 4, align = 4, no Drop "#]], ); } @@ -9273,11 +9025,7 @@ extern "C" { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); } @@ -9423,11 +9171,7 @@ struct Pedro$0<'a> { --- - size = 16 (0x10), align = 8, niches = 1 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 16 (0x10), align = 8, niches = 1, no Drop "#]], ) } @@ -9448,7 +9192,7 @@ fn main(a$0: impl T) {} --- - may contain types with destructors (drop glue) depending on type parameters + type param may need Drop "#]], ); } @@ -9469,11 +9213,7 @@ fn main(a$0: T) {} --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); } @@ -9526,11 +9266,7 @@ fn main() { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); } @@ -9864,11 +9600,7 @@ type A$0 = B; --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop --- @@ -9901,11 +9633,7 @@ type A$0 = B; --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop --- @@ -9939,11 +9667,7 @@ type A$0 = B; --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop --- @@ -9975,11 +9699,7 @@ type A$0 = B; --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); @@ -10103,11 +9823,7 @@ fn main() { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); @@ -10135,11 +9851,7 @@ fn main() { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); @@ -10174,11 +9886,7 @@ fn main() { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); } @@ -10497,11 +10205,7 @@ fn bar() { --- - size = 4, align = 4 - - --- - - does not contain types with destructors (drop glue) + size = 4, align = 4, no Drop --- @@ -10515,7 +10219,7 @@ fn bar() { --- - may contain types with destructors (drop glue) depending on type parameters + type param may need Drop --- @@ -10748,11 +10452,7 @@ struct NoDrop$0; --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue); doesn't have a destructor + size = 0, align = 1, no Drop "#]], ); check( @@ -10776,11 +10476,7 @@ impl Drop for NeedsDrop { --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue); has a destructor + size = 0, align = 1, impl Drop "#]], ); check( @@ -10805,11 +10501,7 @@ type NoDrop$0 = core::mem::ManuallyDrop; --- - size = 0, align = 1 - - --- - - does not contain types with destructors (drop glue) + size = 0, align = 1, no Drop "#]], ); check( @@ -10840,11 +10532,7 @@ struct DropField$0 { --- - size = 4, align = 4 - - --- - - contain types with destructors (drop glue); doesn't have a destructor + size = 4, align = 4, needs Drop "#]], ); check( @@ -10865,7 +10553,7 @@ type Foo$0 = impl Sized; --- - contain types with destructors (drop glue) + needs Drop "#]], ); check( @@ -10893,11 +10581,7 @@ enum Enum { --- - size = 16 (0x10), align = 8, niches = 1 - - --- - - does not contain types with destructors (drop glue) + size = 16 (0x10), align = 8, niches = 1, no Drop "#]], ); check( @@ -10917,7 +10601,7 @@ struct Foo$0(T); --- - may contain types with destructors (drop glue) depending on type parameters; doesn't have a destructor + type param may need Drop "#]], ); check( @@ -10940,7 +10624,7 @@ struct Foo$0(T); --- - does not contain types with destructors (drop glue); doesn't have a destructor + no Drop "#]], ); check( @@ -10966,7 +10650,7 @@ struct Foo$0(T::Assoc); --- - does not contain types with destructors (drop glue); doesn't have a destructor + no Drop "#]], ); check( @@ -10997,7 +10681,7 @@ pub struct ManuallyDrop$0 { --- - does not contain types with destructors (drop glue); doesn't have a destructor + no Drop "#]], ); }