Skip to content

Commit 50f3e01

Browse files
authored
Merge pull request rust-lang#19425 from ConradIrwin/drop-drop-glue-goo
Tidy up drop glue notification
2 parents dfe13e5 + 441eb00 commit 50f3e01

File tree

2 files changed

+107
-421
lines changed

2 files changed

+107
-421
lines changed

src/tools/rust-analyzer/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)