Skip to content

Commit 498633e

Browse files
committed
Tidy up drop glue notification
This combines the memory layout and drop information on one line, and makes the wording more succinct. Closes #19410
1 parent 3bf18d4 commit 498633e

File tree

2 files changed

+107
-421
lines changed

2 files changed

+107
-421
lines changed

crates/ide/src/hover/render.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -718,18 +718,17 @@ pub(super) fn definition(
718718
}
719719
_ => return None,
720720
};
721-
let rendered_drop_glue = match drop_info.drop_glue {
722-
DropGlue::None => "does not contain types with destructors (drop glue)",
723-
DropGlue::DependOnParams => {
724-
"may contain types with destructors (drop glue) depending on type parameters"
721+
let rendered_drop_glue = if drop_info.has_dtor == Some(true) {
722+
"impl Drop"
723+
} else {
724+
match drop_info.drop_glue {
725+
DropGlue::HasDropGlue => "needs Drop",
726+
DropGlue::None => "no Drop",
727+
DropGlue::DependOnParams => "type param may need Drop",
725728
}
726-
DropGlue::HasDropGlue => "contain types with destructors (drop glue)",
727729
};
728-
Some(match drop_info.has_dtor {
729-
Some(true) => format!("{}; has a destructor", rendered_drop_glue),
730-
Some(false) => format!("{}; doesn't have a destructor", rendered_drop_glue),
731-
None => rendered_drop_glue.to_owned(),
732-
})
730+
731+
Some(rendered_drop_glue.to_owned())
733732
};
734733

735734
let dyn_compatibility_info = || match def {
@@ -761,15 +760,18 @@ pub(super) fn definition(
761760
if let Some(layout_info) = layout_info() {
762761
extra.push_str("\n___\n");
763762
extra.push_str(&layout_info);
763+
if let Some(drop_info) = drop_info() {
764+
extra.push_str(", ");
765+
extra.push_str(&drop_info)
766+
}
767+
} else if let Some(drop_info) = drop_info() {
768+
extra.push_str("\n___\n");
769+
extra.push_str(&drop_info);
764770
}
765771
if let Some(dyn_compatibility_info) = dyn_compatibility_info() {
766772
extra.push_str("\n___\n");
767773
extra.push_str(&dyn_compatibility_info);
768774
}
769-
if let Some(drop_info) = drop_info() {
770-
extra.push_str("\n___\n");
771-
extra.push_str(&drop_info);
772-
}
773775
}
774776
let mut desc = String::new();
775777
desc.push_str(&label);

0 commit comments

Comments
 (0)