Skip to content

Synthetic Partial Drop Glue #585

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

Closed
1 of 3 tasks
SoniEx2 opened this issue Jan 31, 2023 · 1 comment
Closed
1 of 3 tasks

Synthetic Partial Drop Glue #585

SoniEx2 opened this issue Jan 31, 2023 · 1 comment
Labels
major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@SoniEx2
Copy link

SoniEx2 commented Jan 31, 2023

Proposal

Currently core::mem::drop_in_place requires types which are fully initialized. Instead of "calling drop glue", the compiler currently synthesizes drop glue every time when a value is dropped. This is obviously inefficient.

This MCP proposes allowing core::mem::drop_in_place to accept partially-moved-from types, and synthesizing the drop glue as part of monomorphization. (In other words, this requires typestate-based-ish monomorphization, tho we can still use drop flags to pick the correct typestate at runtime.)

This MCP also proposes using core::mem::drop_in_place in Box::drop, and taking the Drop for Box impl out of the compiler.

Note: This MCP is not Partially Initialized Types. It's much more lightweight and doesn't require any syntax changes. It also doesn't introduce anything like DerefMove.

The main benefits of this MCP are:

  • Making Drop for Box just another impl.

This would likely make it less error-prone than having this impl in the compiler. (e.g. maybe reduce the likelihood of allocator_api-related ICEs? tho those seem to be mostly fixed by now, so maybe it isn't worth it...)

ref rust-lang/wg-allocators#103

Mentors or Reviewers

If you have a reviewer or mentor in mind for this work, mention then
here. You can put your own name here if you are planning to mentor the
work.

Process

The main points of the Major Change Process are as follows:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

@SoniEx2 SoniEx2 added major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team labels Jan 31, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jan 31, 2023

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

cc @rust-lang/compiler @rust-lang/compiler-contributors

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Jan 31, 2023
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Feb 3, 2023
@SoniEx2 SoniEx2 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

3 participants