Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3c9808b

Browse files
authoredSep 30, 2024
Rollup merge of rust-lang#130914 - compiler-errors:insignificant-dtor, r=Amanieu
Mark some more types as having insignificant dtor These were caught by rust-lang#129864 (comment), which is implementing a lint for some changes in drop order for temporaries in tail expressions. Specifically, the destructors of `CString` and the bitpacked repr for `std::io::Error` are insignificant insofar as they don't have side-effects on things like locking or synchronization; they just free memory. See some discussion on rust-lang#89144 for what makes a drop impl "significant"
2 parents 99e9853 + 93916ed commit 3c9808b

File tree

4 files changed

+4
-0
lines changed

4 files changed

+4
-0
lines changed
 

‎alloc/src/boxed.rs

+1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ mod thin;
228228
#[lang = "owned_box"]
229229
#[fundamental]
230230
#[stable(feature = "rust1", since = "1.0.0")]
231+
#[rustc_insignificant_dtor]
231232
// The declaration of the `Box` struct must be kept in sync with the
232233
// compiler or ICEs will happen.
233234
pub struct Box<

‎alloc/src/ffi/c_str.rs

+1
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,7 @@ impl CString {
696696
// memory-unsafe code from working by accident. Inline
697697
// to prevent LLVM from optimizing it away in debug builds.
698698
#[stable(feature = "cstring_drop", since = "1.13.0")]
699+
#[rustc_insignificant_dtor]
699700
impl Drop for CString {
700701
#[inline]
701702
fn drop(&mut self) {

‎alloc/src/sync.rs

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ macro_rules! acquire {
237237
/// [rc_examples]: crate::rc#examples
238238
#[cfg_attr(not(test), rustc_diagnostic_item = "Arc")]
239239
#[stable(feature = "rust1", since = "1.0.0")]
240+
#[rustc_insignificant_dtor]
240241
pub struct Arc<
241242
T: ?Sized,
242243
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,

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

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const TAG_SIMPLE: usize = 0b11;
124124
/// is_unwind_safe::<std::io::Error>();
125125
/// ```
126126
#[repr(transparent)]
127+
#[rustc_insignificant_dtor]
127128
pub(super) struct Repr(NonNull<()>, PhantomData<ErrorData<Box<Custom>>>);
128129

129130
// All the types `Repr` stores internally are Send + Sync, and so is it.

0 commit comments

Comments
 (0)
Please sign in to comment.