Skip to content
Merged
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
8 changes: 7 additions & 1 deletion src/cow_rc_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,17 @@ impl Clone for CowRcStr<'_> {
}
}

#[cold]
#[inline(never)]
unsafe fn drop_slow(ptr: *const String) {
mem::drop(Rc::from_raw(ptr))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would surround this with unsafe, to avoid a warning on some versions of Rust.

Suggested change
mem::drop(Rc::from_raw(ptr))
unsafe { mem::drop(Rc::from_raw(ptr)) };

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Gah, sorry, the auto-merge stuff. Will do :(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Though IIRC I tested this with nightly and it didn't warn, is it edition dependent or something?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

(Yes: #453)

}

impl Drop for CowRcStr<'_> {
#[inline]
fn drop(&mut self) {
if let Err(ptr) = self.unpack() {
mem::drop(unsafe { Rc::from_raw(ptr) })
unsafe { drop_slow(ptr) }
}
}
}
Expand Down
Loading