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

Update nomicon on drop flags #38555

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/doc/nomicon/drop-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,14 @@ if condition {
}
```

As of Rust 1.0, the drop flags are actually not-so-secretly stashed in a hidden
field of any type that implements Drop. Rust sets the drop flag by overwriting
the entire value with a particular bit pattern. This is pretty obviously Not
The Fastest and causes a bunch of trouble with optimizing code. It's legacy from
a time when you could do much more complex conditional initialization.

As such work is currently under way to move the flags out onto the stack frame
where they more reasonably belong. Unfortunately, this work will take some time
as it requires fairly substantial changes to the compiler.
In Rust 1.0, the drop flags were actually not-so-secretly stashed in a hidden
field of any type that implements Drop. Rust set the drop flag by overwriting
the entire value with a particular bit pattern. This was pretty obviously Not
The Fastest and caused a bunch of trouble with optimizing code. It was legacy
from a time when you could do much more complex conditional initialization.

Since Rust 1.13, the flags has been moved to the stack frame where they more
reasonably belong, and types implementing Drop no more take up any extra space.
Copy link
Member

@pnkfelix pnkfelix Jan 3, 2017

Choose a reason for hiding this comment

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

nit: this should say "no longer take up any ...", not "no more take up any ..."


Regardless, Rust programs don't need to worry about uninitialized values on
the stack for correctness. Although they might care for performance. Thankfully,
Expand Down