Skip to content

Commit a6d3abf

Browse files
committed
Tidy up drop glue notification
This reduces the amount of information shown (a direct `Drop` impl is rendered the same way as the drop glue that calls `Drop` impls transitively), but I don't know of a scenario where the difference is meaningful. Closes #19410
1 parent 3bf18d4 commit a6d3abf

File tree

2 files changed

+104
-422
lines changed

2 files changed

+104
-422
lines changed

crates/ide/src/hover/render.rs

+13-15
Original file line numberDiff line numberDiff line change
@@ -718,18 +718,13 @@ 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"
725-
}
726-
DropGlue::HasDropGlue => "contain types with destructors (drop glue)",
721+
let rendered_drop_glue = match (drop_info.drop_glue, drop_info.has_dtor) {
722+
(DropGlue::HasDropGlue, _) | (_, Some(true)) => "has Drop",
723+
(DropGlue::DependOnParams, _) => "type param may have Drop",
724+
_ => "no Drop",
727725
};
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-
})
726+
727+
Some(rendered_drop_glue.to_owned())
733728
};
734729

735730
let dyn_compatibility_info = || match def {
@@ -761,15 +756,18 @@ pub(super) fn definition(
761756
if let Some(layout_info) = layout_info() {
762757
extra.push_str("\n___\n");
763758
extra.push_str(&layout_info);
759+
if let Some(drop_info) = drop_info() {
760+
extra.push_str(", ");
761+
extra.push_str(&drop_info)
762+
}
763+
} else if let Some(drop_info) = drop_info() {
764+
extra.push_str("\n___\n");
765+
extra.push_str(&drop_info);
764766
}
765767
if let Some(dyn_compatibility_info) = dyn_compatibility_info() {
766768
extra.push_str("\n___\n");
767769
extra.push_str(&dyn_compatibility_info);
768770
}
769-
if let Some(drop_info) = drop_info() {
770-
extra.push_str("\n___\n");
771-
extra.push_str(&drop_info);
772-
}
773771
}
774772
let mut desc = String::new();
775773
desc.push_str(&label);

0 commit comments

Comments
 (0)