Skip to content

Commit 92e3b9b

Browse files
committed
---
yaml --- r: 236555 b: refs/heads/tmp c: 012f369 h: refs/heads/master i: 236553: 1b1b233 236551: e120579 v: v3
1 parent 9c7be66 commit 92e3b9b

File tree

11 files changed

+141
-268
lines changed

11 files changed

+141
-268
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: e7a73881e916d08c3edd97369c127e451b4717c8
28+
refs/heads/tmp: 012f36947afb3362a686f3d85f6398c8886b9255
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/liballoc/arc.rs

Lines changed: 23 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,7 @@ impl<T> Arc<T> {
214214
#[stable(feature = "arc_unique", since = "1.4.0")]
215215
pub fn try_unwrap(this: Self) -> Result<T, Self> {
216216
// See `drop` for why all these atomics are like this
217-
if this.inner().strong.compare_and_swap(1, 0, Release) != 1 {
218-
return Err(this)
219-
}
217+
if this.inner().strong.compare_and_swap(1, 0, Release) != 1 { return Err(this) }
220218

221219
atomic::fence(Acquire);
222220

@@ -253,9 +251,7 @@ impl<T: ?Sized> Arc<T> {
253251
let cur = this.inner().weak.load(Relaxed);
254252

255253
// check if the weak counter is currently "locked"; if so, spin.
256-
if cur == usize::MAX {
257-
continue
258-
}
254+
if cur == usize::MAX { continue }
259255

260256
// NOTE: this code currently ignores the possibility of overflow
261257
// into usize::MAX; in general both Rc and Arc need to be adjusted
@@ -307,9 +303,7 @@ impl<T: ?Sized> Arc<T> {
307303

308304
if self.inner().weak.fetch_sub(1, Release) == 1 {
309305
atomic::fence(Acquire);
310-
deallocate(ptr as *mut u8,
311-
size_of_val(&*ptr),
312-
align_of_val(&*ptr))
306+
deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr))
313307
}
314308
}
315309
}
@@ -354,9 +348,7 @@ impl<T: ?Sized> Clone for Arc<T> {
354348
// We abort because such a program is incredibly degenerate, and we
355349
// don't care to support it.
356350
if old_size > MAX_REFCOUNT {
357-
unsafe {
358-
abort();
359-
}
351+
unsafe { abort(); }
360352
}
361353

362354
Arc { _ptr: self._ptr }
@@ -564,9 +556,7 @@ impl<T: ?Sized> Drop for Arc<T> {
564556
// Because `fetch_sub` is already atomic, we do not need to synchronize
565557
// with other threads unless we are going to delete the object. This
566558
// same logic applies to the below `fetch_sub` to the `weak` count.
567-
if self.inner().strong.fetch_sub(1, Release) != 1 {
568-
return
569-
}
559+
if self.inner().strong.fetch_sub(1, Release) != 1 { return }
570560

571561
// This fence is needed to prevent reordering of use of the data and
572562
// deletion of the data. Because it is marked `Release`, the decreasing
@@ -588,7 +578,7 @@ impl<T: ?Sized> Drop for Arc<T> {
588578
atomic::fence(Acquire);
589579

590580
unsafe {
591-
self.drop_slow();
581+
self.drop_slow()
592582
}
593583
}
594584
}
@@ -623,15 +613,11 @@ impl<T: ?Sized> Weak<T> {
623613
// "stale" read of 0 is fine), and any other value is
624614
// confirmed via the CAS below.
625615
let n = inner.strong.load(Relaxed);
626-
if n == 0 {
627-
return None
628-
}
616+
if n == 0 { return None }
629617

630618
// Relaxed is valid for the same reason it is on Arc's Clone impl
631619
let old = inner.strong.compare_and_swap(n, n + 1, Relaxed);
632-
if old == n {
633-
return Some(Arc { _ptr: self._ptr })
634-
}
620+
if old == n { return Some(Arc { _ptr: self._ptr }) }
635621
}
636622
}
637623

@@ -667,9 +653,7 @@ impl<T: ?Sized> Clone for Weak<T> {
667653

668654
// See comments in Arc::clone() for why we do this (for mem::forget).
669655
if old_size > MAX_REFCOUNT {
670-
unsafe {
671-
abort();
672-
}
656+
unsafe { abort(); }
673657
}
674658

675659
return Weak { _ptr: self._ptr }
@@ -721,11 +705,9 @@ impl<T: ?Sized> Drop for Weak<T> {
721705
// ref, which can only happen after the lock is released.
722706
if self.inner().weak.fetch_sub(1, Release) == 1 {
723707
atomic::fence(Acquire);
724-
unsafe {
725-
deallocate(ptr as *mut u8,
726-
size_of_val(&*ptr),
727-
align_of_val(&*ptr))
728-
}
708+
unsafe { deallocate(ptr as *mut u8,
709+
size_of_val(&*ptr),
710+
align_of_val(&*ptr)) }
729711
}
730712
}
731713
}
@@ -745,9 +727,7 @@ impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
745727
///
746728
/// five == Arc::new(5);
747729
/// ```
748-
fn eq(&self, other: &Arc<T>) -> bool {
749-
*(*self) == *(*other)
750-
}
730+
fn eq(&self, other: &Arc<T>) -> bool { *(*self) == *(*other) }
751731

752732
/// Inequality for two `Arc<T>`s.
753733
///
@@ -762,9 +742,7 @@ impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
762742
///
763743
/// five != Arc::new(5);
764744
/// ```
765-
fn ne(&self, other: &Arc<T>) -> bool {
766-
*(*self) != *(*other)
767-
}
745+
fn ne(&self, other: &Arc<T>) -> bool { *(*self) != *(*other) }
768746
}
769747
#[stable(feature = "rust1", since = "1.0.0")]
770748
impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
@@ -798,9 +776,7 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
798776
///
799777
/// five < Arc::new(5);
800778
/// ```
801-
fn lt(&self, other: &Arc<T>) -> bool {
802-
*(*self) < *(*other)
803-
}
779+
fn lt(&self, other: &Arc<T>) -> bool { *(*self) < *(*other) }
804780

805781
/// 'Less-than or equal to' comparison for two `Arc<T>`s.
806782
///
@@ -815,9 +791,7 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
815791
///
816792
/// five <= Arc::new(5);
817793
/// ```
818-
fn le(&self, other: &Arc<T>) -> bool {
819-
*(*self) <= *(*other)
820-
}
794+
fn le(&self, other: &Arc<T>) -> bool { *(*self) <= *(*other) }
821795

822796
/// Greater-than comparison for two `Arc<T>`s.
823797
///
@@ -832,9 +806,7 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
832806
///
833807
/// five > Arc::new(5);
834808
/// ```
835-
fn gt(&self, other: &Arc<T>) -> bool {
836-
*(*self) > *(*other)
837-
}
809+
fn gt(&self, other: &Arc<T>) -> bool { *(*self) > *(*other) }
838810

839811
/// 'Greater-than or equal to' comparison for two `Arc<T>`s.
840812
///
@@ -849,15 +821,11 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
849821
///
850822
/// five >= Arc::new(5);
851823
/// ```
852-
fn ge(&self, other: &Arc<T>) -> bool {
853-
*(*self) >= *(*other)
854-
}
824+
fn ge(&self, other: &Arc<T>) -> bool { *(*self) >= *(*other) }
855825
}
856826
#[stable(feature = "rust1", since = "1.0.0")]
857827
impl<T: ?Sized + Ord> Ord for Arc<T> {
858-
fn cmp(&self, other: &Arc<T>) -> Ordering {
859-
(**self).cmp(&**other)
860-
}
828+
fn cmp(&self, other: &Arc<T>) -> Ordering { (**self).cmp(&**other) }
861829
}
862830
#[stable(feature = "rust1", since = "1.0.0")]
863831
impl<T: ?Sized + Eq> Eq for Arc<T> {}
@@ -886,9 +854,7 @@ impl<T> fmt::Pointer for Arc<T> {
886854
#[stable(feature = "rust1", since = "1.0.0")]
887855
impl<T: Default> Default for Arc<T> {
888856
#[stable(feature = "rust1", since = "1.0.0")]
889-
fn default() -> Arc<T> {
890-
Arc::new(Default::default())
891-
}
857+
fn default() -> Arc<T> { Arc::new(Default::default()) }
892858
}
893859

894860
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1049,7 +1015,7 @@ mod tests {
10491015
#[test]
10501016
fn weak_self_cyclic() {
10511017
struct Cycle {
1052-
x: Mutex<Option<Weak<Cycle>>>,
1018+
x: Mutex<Option<Weak<Cycle>>>
10531019
}
10541020

10551021
let a = Arc::new(Cycle { x: Mutex::new(None) });
@@ -1129,9 +1095,7 @@ mod tests {
11291095

11301096
// Make sure deriving works with Arc<T>
11311097
#[derive(Eq, Ord, PartialEq, PartialOrd, Clone, Debug, Default)]
1132-
struct Foo {
1133-
inner: Arc<i32>,
1134-
}
1098+
struct Foo { inner: Arc<i32> }
11351099

11361100
#[test]
11371101
fn test_unsized() {
@@ -1144,7 +1108,5 @@ mod tests {
11441108
}
11451109

11461110
impl<T: ?Sized> borrow::Borrow<T> for Arc<T> {
1147-
fn borrow(&self) -> &T {
1148-
&**self
1149-
}
1111+
fn borrow(&self) -> &T { &**self }
11501112
}

0 commit comments

Comments
 (0)