Skip to content

Commit cb76e42

Browse files
authored
Disable inlining of packed io::Error destructor
1 parent 683dd08 commit cb76e42

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

library/std/src/io/error/repr_bitpacked.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,13 @@ impl Repr {
235235
}
236236

237237
impl Drop for Repr {
238-
#[inline]
238+
// This was #[inline] previously. Inlining the destructor of ErrorData is in
239+
// no way helpful in real programs (as the source of the error will not be
240+
// inlined, so there will not be any match assumptions to gain). The cost,
241+
// meanwhile, is a code size increase by a factor of up to 5.4 in the case
242+
// of dropping multiple io::Results in the same function
243+
// (https://godbolt.org/z/8hfGchjsT).
244+
#[inline(never)]
239245
fn drop(&mut self) {
240246
// Safety: We're a Repr, decode_repr is fine. The `Box::from_raw` is
241247
// safe because we're being dropped.

0 commit comments

Comments
 (0)