Skip to content

Commit 67bcac6

Browse files
author
James Munns
committed
Remove call to clone, and explain why
1 parent 4676b10 commit 67bcac6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libcore/cell.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,10 @@ impl<T: ?Sized> UnsafeCell<T> {
15151515
#[stable(feature = "unsafe_cell_copy_clone_conservative", since = "1.31.0")]
15161516
impl<T: Clone + Copy> Clone for UnsafeCell<T> {
15171517
fn clone(&self) -> UnsafeCell<T> {
1518-
UnsafeCell::new(self.value.clone())
1518+
// NOTE: we are explicitly not calling `.clone()` here, to enforce the
1519+
// use of Copy, rather than relying on what could be a custom impl
1520+
// of Clone
1521+
UnsafeCell::new(self.value)
15191522
}
15201523
}
15211524

0 commit comments

Comments
 (0)