Skip to content

Commit 7dfa6c8

Browse files
committed
---
yaml --- r: 175572 b: refs/heads/auto c: a7525bc h: refs/heads/master v: v3
1 parent d0ecabd commit 7dfa6c8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 9bbfd681c9fa47f462a89e8f5eedd3fa2a5de2e7
13+
refs/heads/auto: a7525bc4c8eb8507a5c248d29286e77133217cf3
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/liballoc/rc.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,8 @@ trait RcBoxPtr<T> {
909909
fn inc_strong(&self) {
910910
let strong = self.strong();
911911
// The reference count is always at least one unless we're about to drop the type
912+
// This allows the bulk of the destructor to be omitted in cases where we know that
913+
// the reference count must be > 0.
912914
unsafe { assume(strong > 0); }
913915
self.inner().strong.set(strong + 1);
914916
}
@@ -917,6 +919,8 @@ trait RcBoxPtr<T> {
917919
fn dec_strong(&self) {
918920
let strong = self.strong();
919921
// The reference count is always at least one unless we're about to drop the type
922+
// This allows the bulk of the destructor to be omitted in cases where we know that
923+
// the reference count must be > 0
920924
unsafe { assume(strong > 0); }
921925
self.inner().strong.set(strong - 1);
922926
}
@@ -936,7 +940,9 @@ impl<T> RcBoxPtr<T> for Rc<T> {
936940
fn inner(&self) -> &RcBox<T> {
937941
unsafe {
938942
// Safe to assume this here, as if it weren't true, we'd be breaking
939-
// the contract anyway
943+
// the contract anyway.
944+
// This allows the null check to be elided in the destructor if we
945+
// manipulated the reference count in the same function.
940946
assume(!self._ptr.is_null());
941947
&(**self._ptr)
942948
}
@@ -949,6 +955,8 @@ impl<T> RcBoxPtr<T> for Weak<T> {
949955
unsafe {
950956
// Safe to assume this here, as if it weren't true, we'd be breaking
951957
// the contract anyway
958+
// This allows the null check to be elided in the destructor if we
959+
// manipulated the reference count in the same function.
952960
assume(!self._ptr.is_null());
953961
&(**self._ptr)
954962
}

0 commit comments

Comments
 (0)