Skip to content

Commit 1f1a1e6

Browse files
committed
rustfmt: liballoc, liballoc_*, libarena
1 parent e24fffe commit 1f1a1e6

File tree

8 files changed

+52
-51
lines changed

8 files changed

+52
-51
lines changed

src/liballoc/arc.rs

+19-18
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,12 @@ pub struct Arc<T: ?Sized> {
131131
}
132132

133133
#[stable(feature = "rust1", since = "1.0.0")]
134-
unsafe impl<T: ?Sized + Sync + Send> Send for Arc<T> { }
134+
unsafe impl<T: ?Sized + Sync + Send> Send for Arc<T> {}
135135
#[stable(feature = "rust1", since = "1.0.0")]
136-
unsafe impl<T: ?Sized + Sync + Send> Sync for Arc<T> { }
136+
unsafe impl<T: ?Sized + Sync + Send> Sync for Arc<T> {}
137137

138-
#[cfg(not(stage0))] // remove cfg after new snapshot
138+
// remove cfg after new snapshot
139+
#[cfg(not(stage0))]
139140
#[unstable(feature = "coerce_unsized", issue = "27732")]
140141
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Arc<U>> for Arc<T> {}
141142

@@ -152,11 +153,12 @@ pub struct Weak<T: ?Sized> {
152153
}
153154

154155
#[stable(feature = "rust1", since = "1.0.0")]
155-
unsafe impl<T: ?Sized + Sync + Send> Send for Weak<T> { }
156+
unsafe impl<T: ?Sized + Sync + Send> Send for Weak<T> {}
156157
#[stable(feature = "rust1", since = "1.0.0")]
157-
unsafe impl<T: ?Sized + Sync + Send> Sync for Weak<T> { }
158+
unsafe impl<T: ?Sized + Sync + Send> Sync for Weak<T> {}
158159

159-
#[cfg(not(stage0))] // remove cfg after new snapshot
160+
// remove cfg after new snapshot
161+
#[cfg(not(stage0))]
160162
#[unstable(feature = "coerce_unsized", issue = "27732")]
161163
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Weak<U>> for Weak<T> {}
162164

@@ -226,7 +228,7 @@ impl<T> Arc<T> {
226228
pub fn try_unwrap(this: Self) -> Result<T, Self> {
227229
// See `drop` for why all these atomics are like this
228230
if this.inner().strong.compare_and_swap(1, 0, Release) != 1 {
229-
return Err(this)
231+
return Err(this);
230232
}
231233

232234
atomic::fence(Acquire);
@@ -265,7 +267,7 @@ impl<T: ?Sized> Arc<T> {
265267

266268
// check if the weak counter is currently "locked"; if so, spin.
267269
if cur == usize::MAX {
268-
continue
270+
continue;
269271
}
270272

271273
// NOTE: this code currently ignores the possibility of overflow
@@ -276,7 +278,7 @@ impl<T: ?Sized> Arc<T> {
276278
// synchronize with the write coming from `is_unique`, so that the
277279
// events prior to that write happen before this read.
278280
if this.inner().weak.compare_and_swap(cur, cur + 1, Acquire) == cur {
279-
return Weak { _ptr: this._ptr }
281+
return Weak { _ptr: this._ptr };
280282
}
281283
}
282284
}
@@ -568,14 +570,14 @@ impl<T: ?Sized> Drop for Arc<T> {
568570
let ptr = *self._ptr;
569571
// if ptr.is_null() { return }
570572
if ptr as *mut u8 as usize == 0 || ptr as *mut u8 as usize == mem::POST_DROP_USIZE {
571-
return
573+
return;
572574
}
573575

574576
// Because `fetch_sub` is already atomic, we do not need to synchronize
575577
// with other threads unless we are going to delete the object. This
576578
// same logic applies to the below `fetch_sub` to the `weak` count.
577579
if self.inner().strong.fetch_sub(1, Release) != 1 {
578-
return
580+
return;
579581
}
580582

581583
// This fence is needed to prevent reordering of use of the data and
@@ -634,13 +636,13 @@ impl<T: ?Sized> Weak<T> {
634636
// confirmed via the CAS below.
635637
let n = inner.strong.load(Relaxed);
636638
if n == 0 {
637-
return None
639+
return None;
638640
}
639641

640642
// Relaxed is valid for the same reason it is on Arc's Clone impl
641643
let old = inner.strong.compare_and_swap(n, n + 1, Relaxed);
642644
if old == n {
643-
return Some(Arc { _ptr: self._ptr })
645+
return Some(Arc { _ptr: self._ptr });
644646
}
645647
}
646648
}
@@ -682,7 +684,7 @@ impl<T: ?Sized> Clone for Weak<T> {
682684
}
683685
}
684686

685-
return Weak { _ptr: self._ptr }
687+
return Weak { _ptr: self._ptr };
686688
}
687689
}
688690

@@ -718,7 +720,7 @@ impl<T: ?Sized> Drop for Weak<T> {
718720

719721
// see comments above for why this check is here
720722
if ptr as *mut u8 as usize == 0 || ptr as *mut u8 as usize == mem::POST_DROP_USIZE {
721-
return
723+
return;
722724
}
723725

724726
// If we find out that we were the last weak pointer, then its time to
@@ -928,8 +930,7 @@ mod tests {
928930

929931
struct Canary(*mut atomic::AtomicUsize);
930932

931-
impl Drop for Canary
932-
{
933+
impl Drop for Canary {
933934
fn drop(&mut self) {
934935
unsafe {
935936
match *self {
@@ -943,7 +944,7 @@ mod tests {
943944

944945
#[test]
945946
fn manually_share_arc() {
946-
let v = vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
947+
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
947948
let arc_v = Arc::new(v);
948949

949950
let (tx, rx) = channel();

src/liballoc/boxed.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ use core::convert::From;
8888
#[unstable(feature = "box_heap",
8989
reason = "may be renamed; uncertain about custom allocator design",
9090
issue = "27779")]
91-
pub const HEAP: ExchangeHeapSingleton =
92-
ExchangeHeapSingleton { _force_singleton: () };
91+
pub const HEAP: ExchangeHeapSingleton = ExchangeHeapSingleton { _force_singleton: () };
9392

9493
/// This the singleton type used solely for `boxed::HEAP`.
9594
#[unstable(feature = "box_heap",
@@ -238,7 +237,7 @@ impl<T> Box<T> {
238237
}
239238
}
240239

241-
impl<T : ?Sized> Box<T> {
240+
impl<T: ?Sized> Box<T> {
242241
/// Constructs a box from the raw pointer.
243242
///
244243
/// After this function call, pointer is owned by resulting box.
@@ -535,8 +534,7 @@ pub trait FnBox<A> {
535534
}
536535

537536
#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
538-
impl<A,F> FnBox<A> for F
539-
where F: FnOnce<A>
537+
impl<A, F> FnBox<A> for F where F: FnOnce<A>
540538
{
541539
type Output = F::Output;
542540

@@ -546,7 +544,7 @@ impl<A,F> FnBox<A> for F
546544
}
547545

548546
#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
549-
impl<'a,A,R> FnOnce<A> for Box<FnBox<A,Output=R>+'a> {
547+
impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + 'a> {
550548
type Output = R;
551549

552550
extern "rust-call" fn call_once(self, args: A) -> R {
@@ -555,7 +553,7 @@ impl<'a,A,R> FnOnce<A> for Box<FnBox<A,Output=R>+'a> {
555553
}
556554

557555
#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
558-
impl<'a,A,R> FnOnce<A> for Box<FnBox<A,Output=R>+Send+'a> {
556+
impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + Send + 'a> {
559557
type Output = R;
560558

561559
extern "rust-call" fn call_once(self, args: A) -> R {
@@ -564,7 +562,7 @@ impl<'a,A,R> FnOnce<A> for Box<FnBox<A,Output=R>+Send+'a> {
564562
}
565563

566564
#[unstable(feature = "coerce_unsized", issue = "27732")]
567-
impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
565+
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
568566

569567
#[stable(feature = "box_slice_clone", since = "1.3.0")]
570568
impl<T: Clone> Clone for Box<[T]> {

src/liballoc/boxed_test.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ fn test_show() {
7474

7575
#[test]
7676
fn deref() {
77-
fn homura<T: Deref<Target = i32>>(_: T) {
78-
}
77+
fn homura<T: Deref<Target = i32>>(_: T) {}
7978
homura(Box::new(765));
8079
}
8180

src/liballoc/heap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use core::{isize, usize};
1919

2020
#[allow(improper_ctypes)]
21-
extern {
21+
extern "C" {
2222
#[allocator]
2323
fn __rust_allocate(size: usize, align: usize) -> *mut u8;
2424
fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize);

src/liballoc/rc.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,10 @@ impl<T: ?Sized> !marker::Send for Rc<T> {}
196196
#[stable(feature = "rust1", since = "1.0.0")]
197197
impl<T: ?Sized> !marker::Sync for Rc<T> {}
198198

199-
#[cfg(not(stage0))] // remove cfg after new snapshot
199+
// remove cfg after new snapshot
200+
#[cfg(not(stage0))]
200201
#[unstable(feature = "coerce_unsized", issue = "27732")]
201-
impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<Rc<U>> for Rc<T> {}
202+
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Rc<U>> for Rc<T> {}
202203

203204
impl<T> Rc<T> {
204205
/// Constructs a new `Rc<T>`.
@@ -482,7 +483,6 @@ impl<T: ?Sized> Drop for Rc<T> {
482483

483484
#[stable(feature = "rust1", since = "1.0.0")]
484485
impl<T: ?Sized> Clone for Rc<T> {
485-
486486
/// Makes a clone of the `Rc<T>`.
487487
///
488488
/// When you clone an `Rc<T>`, it will create another pointer to the data and
@@ -678,21 +678,21 @@ impl<T: ?Sized + Ord> Ord for Rc<T> {
678678
}
679679

680680
#[stable(feature = "rust1", since = "1.0.0")]
681-
impl<T: ?Sized+Hash> Hash for Rc<T> {
681+
impl<T: ?Sized + Hash> Hash for Rc<T> {
682682
fn hash<H: Hasher>(&self, state: &mut H) {
683683
(**self).hash(state);
684684
}
685685
}
686686

687687
#[stable(feature = "rust1", since = "1.0.0")]
688-
impl<T: ?Sized+fmt::Display> fmt::Display for Rc<T> {
688+
impl<T: ?Sized + fmt::Display> fmt::Display for Rc<T> {
689689
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
690690
fmt::Display::fmt(&**self, f)
691691
}
692692
}
693693

694694
#[stable(feature = "rust1", since = "1.0.0")]
695-
impl<T: ?Sized+fmt::Debug> fmt::Debug for Rc<T> {
695+
impl<T: ?Sized + fmt::Debug> fmt::Debug for Rc<T> {
696696
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
697697
fmt::Debug::fmt(&**self, f)
698698
}
@@ -731,9 +731,10 @@ impl<T: ?Sized> !marker::Send for Weak<T> {}
731731
#[stable(feature = "rust1", since = "1.0.0")]
732732
impl<T: ?Sized> !marker::Sync for Weak<T> {}
733733

734-
#[cfg(not(stage0))] // remove cfg after new snapshot
734+
// remove cfg after new snapshot
735+
#[cfg(not(stage0))]
735736
#[unstable(feature = "coerce_unsized", issue = "27732")]
736-
impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<Weak<U>> for Weak<T> {}
737+
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Weak<U>> for Weak<T> {}
737738

738739
impl<T: ?Sized> Weak<T> {
739740
/// Upgrades a weak reference to a strong reference.
@@ -810,7 +811,6 @@ impl<T: ?Sized> Drop for Weak<T> {
810811

811812
#[stable(feature = "rc_weak", since = "1.4.0")]
812813
impl<T: ?Sized> Clone for Weak<T> {
813-
814814
/// Makes a clone of the `Weak<T>`.
815815
///
816816
/// This increases the weak reference count.
@@ -832,7 +832,7 @@ impl<T: ?Sized> Clone for Weak<T> {
832832
}
833833

834834
#[stable(feature = "rust1", since = "1.0.0")]
835-
impl<T: ?Sized+fmt::Debug> fmt::Debug for Weak<T> {
835+
impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> {
836836
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
837837
write!(f, "(Weak)")
838838
}

src/liballoc_jemalloc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use libc::{c_int, c_void, size_t};
4141
not(target_os = "android"),
4242
not(target_env = "musl")),
4343
link(name = "pthread"))]
44-
extern {
44+
extern "C" {
4545
fn je_mallocx(size: size_t, flags: c_int) -> *mut c_void;
4646
fn je_rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
4747
fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;

src/liballoc_system/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ mod imp {
7979
use libc;
8080
use MIN_ALIGN;
8181

82-
extern {
82+
extern "C" {
8383
// Apparently android doesn't have posix_memalign
8484
#[cfg(target_os = "android")]
8585
fn memalign(align: libc::size_t, size: libc::size_t) -> *mut libc::c_void;
@@ -180,7 +180,7 @@ mod imp {
180180
} else {
181181
let ptr = HeapAlloc(GetProcessHeap(), 0, (size + align) as SIZE_T) as *mut u8;
182182
if ptr.is_null() {
183-
return ptr
183+
return ptr;
184184
}
185185
align_ptr(ptr, align)
186186
}
@@ -196,7 +196,7 @@ mod imp {
196196
header.0 as LPVOID,
197197
(size + align) as SIZE_T) as *mut u8;
198198
if new.is_null() {
199-
return new
199+
return new;
200200
}
201201
align_ptr(new, align)
202202
}

src/libarena/lib.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
168168

169169
let start = round_up(after_tydesc, align);
170170

171-
//debug!("freeing object: idx = {}, size = {}, align = {}, done = {}",
172-
// start, size, align, is_done);
171+
// debug!("freeing object: idx = {}, size = {}, align = {}, done = {}",
172+
// start, size, align, is_done);
173173
if is_done {
174174
((*tydesc).drop_glue)(buf.offset(start as isize) as *const i8);
175175
}
@@ -201,8 +201,11 @@ struct TyDesc {
201201
align: usize,
202202
}
203203

204-
trait AllTypes { fn dummy(&self) { } }
205-
impl<T:?Sized> AllTypes for T { }
204+
trait AllTypes {
205+
fn dummy(&self) {}
206+
}
207+
208+
impl<T: ?Sized> AllTypes for T {}
206209

207210
unsafe fn get_tydesc<T>() -> *const TyDesc {
208211
use std::raw::TraitObject;
@@ -624,7 +627,7 @@ mod tests {
624627
for _ in 0..100000 {
625628
arena.alloc(Noncopy {
626629
string: "hello world".to_string(),
627-
array: vec!(1, 2, 3, 4, 5),
630+
array: vec![1, 2, 3, 4, 5],
628631
});
629632
}
630633
}
@@ -635,7 +638,7 @@ mod tests {
635638
b.iter(|| {
636639
arena.alloc(Noncopy {
637640
string: "hello world".to_string(),
638-
array: vec!(1, 2, 3, 4, 5),
641+
array: vec![1, 2, 3, 4, 5],
639642
})
640643
})
641644
}
@@ -645,7 +648,7 @@ mod tests {
645648
b.iter(|| {
646649
let _: Box<_> = box Noncopy {
647650
string: "hello world".to_string(),
648-
array: vec!(1, 2, 3, 4, 5),
651+
array: vec![1, 2, 3, 4, 5],
649652
};
650653
})
651654
}
@@ -657,7 +660,7 @@ mod tests {
657660
arena.alloc(|| {
658661
Noncopy {
659662
string: "hello world".to_string(),
660-
array: vec!(1, 2, 3, 4, 5),
663+
array: vec![1, 2, 3, 4, 5],
661664
}
662665
})
663666
})

0 commit comments

Comments
 (0)