Skip to content

Commit 77b5a05

Browse files
authored
Rollup merge of #66819 - dtolnay:fmt2, r=kennytm
Format libstd/sys with rustfmt (Same strategy as #66691.) This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd/sys *that are not involved in any currently open PR* to minimize merge conflicts. The list of files involved in open PRs was determined by querying GitHub's GraphQL API [with this script](https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8). With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd/sys -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd/sys outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of the files. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference
2 parents 34f2c2d + c34fbfa commit 77b5a05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+2527
-2285
lines changed

src/libstd/sys/cloudabi/os.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ pub fn errno() -> i32 {
1818
pub fn error_string(errno: i32) -> String {
1919
// cloudlibc's strerror() is guaranteed to be thread-safe. There is
2020
// thus no need to use strerror_r().
21-
str::from_utf8(unsafe { CStr::from_ptr(libc::strerror(errno)) }.to_bytes())
22-
.unwrap()
23-
.to_owned()
21+
str::from_utf8(unsafe { CStr::from_ptr(libc::strerror(errno)) }.to_bytes()).unwrap().to_owned()
2422
}
2523

2624
pub fn exit(code: i32) -> ! {

src/libstd/sys/cloudabi/shims/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::ffi::OsString;
22
use crate::fmt;
33
use crate::hash::{Hash, Hasher};
4-
use crate::io::{self, SeekFrom, IoSlice, IoSliceMut};
4+
use crate::io::{self, IoSlice, IoSliceMut, SeekFrom};
55
use crate::path::{Path, PathBuf};
66
use crate::sys::time::SystemTime;
77
use crate::sys::{unsupported, Void};

src/libstd/sys/cloudabi/shims/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ pub mod args;
44
pub mod env;
55
pub mod fs;
66
pub mod net;
7+
pub mod os;
78
#[path = "../../unix/path.rs"]
89
pub mod path;
910
pub mod pipe;
1011
pub mod process;
11-
pub mod os;
1212

1313
// This enum is used as the storage for a bunch of types which can't actually exist.
1414
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
1515
pub enum Void {}
1616

1717
pub fn unsupported<T>() -> io::Result<T> {
18-
Err(io::Error::new(
19-
io::ErrorKind::Other,
20-
"This function is not available on CloudABI.",
21-
))
18+
Err(io::Error::new(io::ErrorKind::Other, "This function is not available on CloudABI."))
2219
}

src/libstd/sys/cloudabi/shims/net.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
use crate::convert::TryFrom;
12
use crate::fmt;
23
use crate::io::{self, IoSlice, IoSliceMut};
34
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
4-
use crate::time::Duration;
55
use crate::sys::{unsupported, Void};
6-
use crate::convert::TryFrom;
6+
use crate::time::Duration;
77

88
#[allow(unused_extern_crates)]
99
pub extern crate libc as netc;

src/libstd/sys/cloudabi/shims/process.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ pub enum Stdio {
3232

3333
impl Command {
3434
pub fn new(_program: &OsStr) -> Command {
35-
Command {
36-
env: Default::default(),
37-
}
35+
Command { env: Default::default() }
3836
}
3937

4038
pub fn arg(&mut self, _arg: &OsStr) {}

src/libstd/sys/cloudabi/thread.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ impl Thread {
5858
}
5959

6060
pub fn sleep(dur: Duration) {
61-
let timeout = checked_dur2intervals(&dur)
62-
.expect("overflow converting duration to nanoseconds");
61+
let timeout =
62+
checked_dur2intervals(&dur).expect("overflow converting duration to nanoseconds");
6363
unsafe {
6464
let subscription = abi::subscription {
6565
type_: abi::eventtype::CLOCK,
@@ -85,11 +85,7 @@ impl Thread {
8585
unsafe {
8686
let ret = libc::pthread_join(self.id, ptr::null_mut());
8787
mem::forget(self);
88-
assert!(
89-
ret == 0,
90-
"failed to join thread: {}",
91-
io::Error::from_raw_os_error(ret)
92-
);
88+
assert!(ret == 0, "failed to join thread: {}", io::Error::from_raw_os_error(ret));
9389
}
9490
}
9591
}

src/libstd/sys/cloudabi/time.rs

+7-23
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ pub struct Instant {
1010
}
1111

1212
pub fn checked_dur2intervals(dur: &Duration) -> Option<abi::timestamp> {
13-
dur.as_secs()
14-
.checked_mul(NSEC_PER_SEC)?
15-
.checked_add(dur.subsec_nanos() as abi::timestamp)
13+
dur.as_secs().checked_mul(NSEC_PER_SEC)?.checked_add(dur.subsec_nanos() as abi::timestamp)
1614
}
1715

1816
impl Instant {
@@ -39,15 +37,11 @@ impl Instant {
3937
}
4038

4139
pub fn checked_add_duration(&self, other: &Duration) -> Option<Instant> {
42-
Some(Instant {
43-
t: self.t.checked_add(checked_dur2intervals(other)?)?,
44-
})
40+
Some(Instant { t: self.t.checked_add(checked_dur2intervals(other)?)? })
4541
}
4642

4743
pub fn checked_sub_duration(&self, other: &Duration) -> Option<Instant> {
48-
Some(Instant {
49-
t: self.t.checked_sub(checked_dur2intervals(other)?)?,
50-
})
44+
Some(Instant { t: self.t.checked_sub(checked_dur2intervals(other)?)? })
5145
}
5246
}
5347

@@ -69,29 +63,19 @@ impl SystemTime {
6963
pub fn sub_time(&self, other: &SystemTime) -> Result<Duration, Duration> {
7064
if self.t >= other.t {
7165
let diff = self.t - other.t;
72-
Ok(Duration::new(
73-
diff / NSEC_PER_SEC,
74-
(diff % NSEC_PER_SEC) as u32,
75-
))
66+
Ok(Duration::new(diff / NSEC_PER_SEC, (diff % NSEC_PER_SEC) as u32))
7667
} else {
7768
let diff = other.t - self.t;
78-
Err(Duration::new(
79-
diff / NSEC_PER_SEC,
80-
(diff % NSEC_PER_SEC) as u32,
81-
))
69+
Err(Duration::new(diff / NSEC_PER_SEC, (diff % NSEC_PER_SEC) as u32))
8270
}
8371
}
8472

8573
pub fn checked_add_duration(&self, other: &Duration) -> Option<SystemTime> {
86-
Some(SystemTime {
87-
t: self.t.checked_add(checked_dur2intervals(other)?)?,
88-
})
74+
Some(SystemTime { t: self.t.checked_add(checked_dur2intervals(other)?)? })
8975
}
9076

9177
pub fn checked_sub_duration(&self, other: &Duration) -> Option<SystemTime> {
92-
Some(SystemTime {
93-
t: self.t.checked_sub(checked_dur2intervals(other)?)?,
94-
})
78+
Some(SystemTime { t: self.t.checked_sub(checked_dur2intervals(other)?)? })
9579
}
9680
}
9781

src/libstd/sys/hermit/alloc.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ unsafe impl GlobalAlloc for System {
1313
let addr = abi::malloc(layout.size(), layout.align());
1414

1515
if !addr.is_null() {
16-
ptr::write_bytes(
17-
addr,
18-
0x00,
19-
layout.size()
20-
);
16+
ptr::write_bytes(addr, 0x00, layout.size());
2117
}
2218

2319
addr

src/libstd/sys/hermit/args.rs

+28-17
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ use crate::marker::PhantomData;
33
use crate::vec;
44

55
/// One-time global initialization.
6-
pub unsafe fn init(argc: isize, argv: *const *const u8) { imp::init(argc, argv) }
6+
pub unsafe fn init(argc: isize, argv: *const *const u8) {
7+
imp::init(argc, argv)
8+
}
79

810
/// One-time global cleanup.
9-
pub unsafe fn cleanup() { imp::cleanup() }
11+
pub unsafe fn cleanup() {
12+
imp::cleanup()
13+
}
1014

1115
/// Returns the command line arguments
1216
pub fn args() -> Args {
@@ -26,24 +30,32 @@ impl Args {
2630

2731
impl Iterator for Args {
2832
type Item = OsString;
29-
fn next(&mut self) -> Option<OsString> { self.iter.next() }
30-
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
33+
fn next(&mut self) -> Option<OsString> {
34+
self.iter.next()
35+
}
36+
fn size_hint(&self) -> (usize, Option<usize>) {
37+
self.iter.size_hint()
38+
}
3139
}
3240

3341
impl ExactSizeIterator for Args {
34-
fn len(&self) -> usize { self.iter.len() }
42+
fn len(&self) -> usize {
43+
self.iter.len()
44+
}
3545
}
3646

3747
impl DoubleEndedIterator for Args {
38-
fn next_back(&mut self) -> Option<OsString> { self.iter.next_back() }
48+
fn next_back(&mut self) -> Option<OsString> {
49+
self.iter.next_back()
50+
}
3951
}
4052

4153
mod imp {
42-
use crate::sys_common::os_str_bytes::*;
43-
use crate::ptr;
54+
use super::Args;
4455
use crate::ffi::{CStr, OsString};
4556
use crate::marker::PhantomData;
46-
use super::Args;
57+
use crate::ptr;
58+
use crate::sys_common::os_str_bytes::*;
4759

4860
use crate::sys_common::mutex::Mutex;
4961

@@ -64,19 +76,18 @@ mod imp {
6476
}
6577

6678
pub fn args() -> Args {
67-
Args {
68-
iter: clone().into_iter(),
69-
_dont_send_or_sync_me: PhantomData
70-
}
79+
Args { iter: clone().into_iter(), _dont_send_or_sync_me: PhantomData }
7180
}
7281

7382
fn clone() -> Vec<OsString> {
7483
unsafe {
7584
let _guard = LOCK.lock();
76-
(0..ARGC).map(|i| {
77-
let cstr = CStr::from_ptr(*ARGV.offset(i) as *const i8);
78-
OsStringExt::from_vec(cstr.to_bytes().to_vec())
79-
}).collect()
85+
(0..ARGC)
86+
.map(|i| {
87+
let cstr = CStr::from_ptr(*ARGV.offset(i) as *const i8);
88+
OsStringExt::from_vec(cstr.to_bytes().to_vec())
89+
})
90+
.collect()
8091
}
8192
}
8293
}

src/libstd/sys/hermit/cmath.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// These symbols are all defined in `compiler-builtins`
2-
extern {
2+
extern "C" {
33
pub fn acos(n: f64) -> f64;
44
pub fn acosf(n: f32) -> f32;
55
pub fn asin(n: f64) -> f64;

src/libstd/sys/hermit/condvar.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ impl Condvar {
1818
}
1919

2020
pub unsafe fn notify_one(&self) {
21-
let _ = abi::notify(self.id(), 1);
21+
let _ = abi::notify(self.id(), 1);
2222
}
2323

2424
#[inline]
2525
pub unsafe fn notify_all(&self) {
26-
let _ = abi::notify(self.id(), -1 /* =all */);
26+
let _ = abi::notify(self.id(), -1 /* =all */);
2727
}
2828

2929
pub unsafe fn wait(&self, mutex: &Mutex) {

src/libstd/sys/hermit/fd.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![unstable(reason = "not public", issue = "0", feature = "fd")]
22

3-
use crate::io::{self, Read, ErrorKind};
3+
use crate::io::{self, ErrorKind, Read};
44
use crate::mem;
55
use crate::sys::cvt;
66
use crate::sys::hermit::abi;
@@ -16,7 +16,9 @@ impl FileDesc {
1616
FileDesc { fd }
1717
}
1818

19-
pub fn raw(&self) -> i32 { self.fd }
19+
pub fn raw(&self) -> i32 {
20+
self.fd
21+
}
2022

2123
/// Extracts the actual file descriptor without closing it.
2224
pub fn into_raw(self) -> i32 {
@@ -67,7 +69,9 @@ impl<'a> Read for &'a FileDesc {
6769
}
6870

6971
impl AsInner<i32> for FileDesc {
70-
fn as_inner(&self) -> &i32 { &self.fd }
72+
fn as_inner(&self) -> &i32 {
73+
&self.fd
74+
}
7175
}
7276

7377
impl Drop for FileDesc {

0 commit comments

Comments
 (0)