Skip to content

Rustfmt'ing some libs #30017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ pub struct Arc<T: ?Sized> {
}

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

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

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

#[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<T: ?Sized + Sync + Send> Send for Weak<T> { }
unsafe impl<T: ?Sized + Sync + Send> Send for Weak<T> {}
#[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<T: ?Sized + Sync + Send> Sync for Weak<T> { }
unsafe impl<T: ?Sized + Sync + Send> Sync for Weak<T> {}

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

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

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

// check if the weak counter is currently "locked"; if so, spin.
if cur == usize::MAX {
continue
continue;
}

// NOTE: this code currently ignores the possibility of overflow
Expand All @@ -276,7 +278,7 @@ impl<T: ?Sized> Arc<T> {
// synchronize with the write coming from `is_unique`, so that the
// events prior to that write happen before this read.
if this.inner().weak.compare_and_swap(cur, cur + 1, Acquire) == cur {
return Weak { _ptr: this._ptr }
return Weak { _ptr: this._ptr };
}
}
}
Expand Down Expand Up @@ -568,14 +570,14 @@ impl<T: ?Sized> Drop for Arc<T> {
let ptr = *self._ptr;
// if ptr.is_null() { return }
if ptr as *mut u8 as usize == 0 || ptr as *mut u8 as usize == mem::POST_DROP_USIZE {
return
return;
}

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

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

// Relaxed is valid for the same reason it is on Arc's Clone impl
let old = inner.strong.compare_and_swap(n, n + 1, Relaxed);
if old == n {
return Some(Arc { _ptr: self._ptr })
return Some(Arc { _ptr: self._ptr });
}
}
}
Expand Down Expand Up @@ -682,7 +684,7 @@ impl<T: ?Sized> Clone for Weak<T> {
}
}

return Weak { _ptr: self._ptr }
return Weak { _ptr: self._ptr };
}
}

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

// see comments above for why this check is here
if ptr as *mut u8 as usize == 0 || ptr as *mut u8 as usize == mem::POST_DROP_USIZE {
return
return;
}

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

struct Canary(*mut atomic::AtomicUsize);

impl Drop for Canary
{
impl Drop for Canary {
fn drop(&mut self) {
unsafe {
match *self {
Expand All @@ -943,7 +944,7 @@ mod tests {

#[test]
fn manually_share_arc() {
let v = vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let arc_v = Arc::new(v);

let (tx, rx) = channel();
Expand Down
14 changes: 6 additions & 8 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ use core::convert::From;
#[unstable(feature = "box_heap",
reason = "may be renamed; uncertain about custom allocator design",
issue = "27779")]
pub const HEAP: ExchangeHeapSingleton =
ExchangeHeapSingleton { _force_singleton: () };
pub const HEAP: ExchangeHeapSingleton = ExchangeHeapSingleton { _force_singleton: () };

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

impl<T : ?Sized> Box<T> {
impl<T: ?Sized> Box<T> {
/// Constructs a box from the raw pointer.
///
/// After this function call, pointer is owned by resulting box.
Expand Down Expand Up @@ -535,8 +534,7 @@ pub trait FnBox<A> {
}

#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
impl<A,F> FnBox<A> for F
where F: FnOnce<A>
impl<A, F> FnBox<A> for F where F: FnOnce<A>
{
type Output = F::Output;

Expand All @@ -546,7 +544,7 @@ impl<A,F> FnBox<A> for F
}

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

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

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

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

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

#[stable(feature = "box_slice_clone", since = "1.3.0")]
impl<T: Clone> Clone for Box<[T]> {
Expand Down
3 changes: 1 addition & 2 deletions src/liballoc/boxed_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ fn test_show() {

#[test]
fn deref() {
fn homura<T: Deref<Target = i32>>(_: T) {
}
fn homura<T: Deref<Target = i32>>(_: T) {}
homura(Box::new(765));
}

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use core::{isize, usize};

#[allow(improper_ctypes)]
extern {
extern "C" {
#[allocator]
fn __rust_allocate(size: usize, align: usize) -> *mut u8;
fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize);
Expand Down
20 changes: 10 additions & 10 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ impl<T: ?Sized> !marker::Send for Rc<T> {}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> !marker::Sync for Rc<T> {}

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

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

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Clone for Rc<T> {

/// Makes a clone of the `Rc<T>`.
///
/// When you clone an `Rc<T>`, it will create another pointer to the data and
Expand Down Expand Up @@ -678,21 +678,21 @@ impl<T: ?Sized + Ord> Ord for Rc<T> {
}

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

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

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

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

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

#[stable(feature = "rc_weak", since = "1.4.0")]
impl<T: ?Sized> Clone for Weak<T> {

/// Makes a clone of the `Weak<T>`.
///
/// This increases the weak reference count.
Expand All @@ -832,7 +832,7 @@ impl<T: ?Sized> Clone for Weak<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized+fmt::Debug> fmt::Debug for Weak<T> {
impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "(Weak)")
}
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc_jemalloc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use libc::{c_int, c_void, size_t};
not(target_os = "android"),
not(target_env = "musl")),
link(name = "pthread"))]
extern {
extern "C" {
fn je_mallocx(size: size_t, flags: c_int) -> *mut c_void;
fn je_rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc_system/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod imp {
use libc;
use MIN_ALIGN;

extern {
extern "C" {
// Apparently android doesn't have posix_memalign
#[cfg(target_os = "android")]
fn memalign(align: libc::size_t, size: libc::size_t) -> *mut libc::c_void;
Expand Down Expand Up @@ -180,7 +180,7 @@ mod imp {
} else {
let ptr = HeapAlloc(GetProcessHeap(), 0, (size + align) as SIZE_T) as *mut u8;
if ptr.is_null() {
return ptr
return ptr;
}
align_ptr(ptr, align)
}
Expand All @@ -196,7 +196,7 @@ mod imp {
header.0 as LPVOID,
(size + align) as SIZE_T) as *mut u8;
if new.is_null() {
return new
return new;
}
align_ptr(new, align)
}
Expand Down
19 changes: 11 additions & 8 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ unsafe fn destroy_chunk(chunk: &Chunk) {

let start = round_up(after_tydesc, align);

//debug!("freeing object: idx = {}, size = {}, align = {}, done = {}",
// start, size, align, is_done);
// debug!("freeing object: idx = {}, size = {}, align = {}, done = {}",
// start, size, align, is_done);
if is_done {
((*tydesc).drop_glue)(buf.offset(start as isize) as *const i8);
}
Expand Down Expand Up @@ -201,8 +201,11 @@ struct TyDesc {
align: usize,
}

trait AllTypes { fn dummy(&self) { } }
impl<T:?Sized> AllTypes for T { }
trait AllTypes {
fn dummy(&self) {}
}

impl<T: ?Sized> AllTypes for T {}

unsafe fn get_tydesc<T>() -> *const TyDesc {
use std::raw::TraitObject;
Expand Down Expand Up @@ -624,7 +627,7 @@ mod tests {
for _ in 0..100000 {
arena.alloc(Noncopy {
string: "hello world".to_string(),
array: vec!(1, 2, 3, 4, 5),
array: vec![1, 2, 3, 4, 5],
});
}
}
Expand All @@ -635,7 +638,7 @@ mod tests {
b.iter(|| {
arena.alloc(Noncopy {
string: "hello world".to_string(),
array: vec!(1, 2, 3, 4, 5),
array: vec![1, 2, 3, 4, 5],
})
})
}
Expand All @@ -645,7 +648,7 @@ mod tests {
b.iter(|| {
let _: Box<_> = box Noncopy {
string: "hello world".to_string(),
array: vec!(1, 2, 3, 4, 5),
array: vec![1, 2, 3, 4, 5],
};
})
}
Expand All @@ -657,7 +660,7 @@ mod tests {
arena.alloc(|| {
Noncopy {
string: "hello world".to_string(),
array: vec!(1, 2, 3, 4, 5),
array: vec![1, 2, 3, 4, 5],
}
})
})
Expand Down
Loading