Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up drop glue notification #19425

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ConradIrwin
Copy link

The current notifications are quite verbose (as discussed in #19410), which
causes some arguably more useful information (like the documentation) to be
harder to see.

One option would just be to disable the option by default, but as proposed
there, it seems like a reasonable middle ground would be to show it but
significantly less verbosely.

This change 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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 23, 2025
@ConradIrwin ConradIrwin force-pushed the drop-drop-glue-goo branch 2 times, most recently from 1a90ad4 to a6d3abf Compare March 23, 2025 05:02
Comment on lines 721 to 729
let rendered_drop_glue = match (drop_info.drop_glue, drop_info.has_dtor) {
(DropGlue::HasDropGlue, _) | (_, Some(true)) => "has Drop",
(DropGlue::DependOnParams, _) => "type param may have Drop",
_ => "no Drop",
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"having Drop` sounds weird to me, we might as well use the term drop glue then or significant destructor

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer to call it significant destructor

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to avoid drop glue (at least until rust-lang/reference#873 is resolved), so like the idea of using destructor.

How about:

  • has destructor
  • no destructor
  • type param may have destructor

What does "significant" mean in this context?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, reading through https://doc.rust-lang.org/nomicon/destructors.html, we use the phrase "needs Drop" for a type that has drop glue but no impl Drop.

So we could also do:

  • impl Drop
  • needs Drop
  • no Drop
  • type params may need Drop

I don't have a strong preference, but do like using Drop as the word that shows up in the source code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slight vote/preference for impl Drop from me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impl Drop won't be correct though, these don't necessarily implement Drop when they have drop glue. But sure, needs Drop would probably work

This combines the memory layout and drop information on one line,
and makes the wording more succinct.

Closes rust-lang#19410
@ConradIrwin
Copy link
Author

Ok, I've gone with:

  • impl Drop for the has_dtor case (though reading your comment @Veykril, it sounds like that may not always be true?)
  • needs Drop if there is drop glue (and it does not impl Drop)
  • type param may need Drop
  • no Drop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make drop-glue/destructor hover tooltip more compact and distinguishable
4 participants