Skip to content

Commit 6a4af82

Browse files
authored
Update rc.rs docs
Update comment per review feedback
1 parent dd20225 commit 6a4af82

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

library/alloc/src/rc.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3536,11 +3536,11 @@ impl<T> Default for Weak<T> {
35363536
}
35373537
}
35383538

3539-
// NOTE: We wrapping_add here to deal with mem::forget safely. In particular
3540-
// if you mem::forget Rcs (or Weaks), the ref-count can overflow, and then
3541-
// you can free the allocation while outstanding Rcs (or Weaks) exist.
3542-
// We abort because this is such a degenerate scenario that we don't care about
3543-
// what happens -- no real program should ever experience this.
3539+
// NOTE: If you mem::forget Rcs (or Weaks), drop is skipped and the ref-count
3540+
// is not decremented, meaning the ref-count can overflow, and then you can
3541+
// free the allocation while outstanding Rcs (or Weaks) exist, which would be
3542+
// unsound. We abort because this is such a degenerate scenario that we don't
3543+
// care about what happens -- no real program should ever experience this.
35443544
//
35453545
// This should have negligible overhead since you don't actually need to
35463546
// clone these much in Rust thanks to ownership and move-semantics.

0 commit comments

Comments
 (0)