Skip to content

Commit 01a4518

Browse files
Re-format code with new rustfmt
1 parent d823ae6 commit 01a4518

File tree

9 files changed

+43
-36
lines changed

9 files changed

+43
-36
lines changed

alloc/src/vec/into_iter.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
285285
// Also note the implementation of `Self: TrustedRandomAccess` requires
286286
// that `T: Copy` so reading elements from the buffer doesn't invalidate
287287
// them for `Drop`.
288-
unsafe {
289-
if T::IS_ZST { mem::zeroed() } else { ptr::read(self.ptr.add(i)) }
290-
}
288+
unsafe { if T::IS_ZST { mem::zeroed() } else { ptr::read(self.ptr.add(i)) } }
291289
}
292290
}
293291

core/src/escape.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ pub(crate) fn escape_ascii_into(output: &mut [ascii::Char; 4], byte: u8) -> Rang
2121
b'\\' => backslash(ascii::Char::ReverseSolidus),
2222
b'\'' => backslash(ascii::Char::Apostrophe),
2323
b'\"' => backslash(ascii::Char::QuotationMark),
24-
_ => if let Some(a) = byte.as_ascii() && !byte.is_ascii_control() {
25-
([a, ascii::Char::Null, ascii::Char::Null, ascii::Char::Null], 1)
26-
} else {
27-
let hi = HEX_DIGITS[usize::from(byte >> 4)];
28-
let lo = HEX_DIGITS[usize::from(byte & 0xf)];
29-
([ascii::Char::ReverseSolidus, ascii::Char::SmallX, hi, lo], 4)
24+
_ => {
25+
if let Some(a) = byte.as_ascii()
26+
&& !byte.is_ascii_control()
27+
{
28+
([a, ascii::Char::Null, ascii::Char::Null, ascii::Char::Null], 1)
29+
} else {
30+
let hi = HEX_DIGITS[usize::from(byte >> 4)];
31+
let lo = HEX_DIGITS[usize::from(byte & 0xf)];
32+
([ascii::Char::ReverseSolidus, ascii::Char::SmallX, hi, lo], 4)
33+
}
3034
}
3135
};
3236
*output = data;

core/src/iter/adapters/step_by.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ where
8383
// last element. Used in the `DoubleEndedIterator` implementation.
8484
fn next_back_index(&self) -> usize {
8585
let rem = self.iter.len() % (self.step + 1);
86-
if self.first_take {
87-
if rem == 0 { self.step } else { rem - 1 }
88-
} else {
89-
rem
90-
}
86+
if self.first_take { if rem == 0 { self.step } else { rem - 1 } } else { rem }
9187
}
9288
}
9389

core/src/mem/maybe_uninit.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,10 +691,7 @@ impl<T> MaybeUninit<T> {
691691
/// // they both get dropped!
692692
/// ```
693693
#[stable(feature = "maybe_uninit_extra", since = "1.60.0")]
694-
#[rustc_const_stable(
695-
feature = "const_maybe_uninit_assume_init_read",
696-
since = "1.75.0"
697-
)]
694+
#[rustc_const_stable(feature = "const_maybe_uninit_assume_init_read", since = "1.75.0")]
698695
#[inline(always)]
699696
#[track_caller]
700697
pub const unsafe fn assume_init_read(&self) -> T {

std/src/sys/unix/fs.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,13 +1300,17 @@ impl File {
13001300

13011301
pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
13021302
#[cfg(not(any(target_os = "redox", target_os = "espidf", target_os = "horizon")))]
1303-
let to_timespec = |time: Option<SystemTime>| {
1304-
match time {
1305-
Some(time) if let Some(ts) = time.t.to_timespec() => Ok(ts),
1306-
Some(time) if time > crate::sys::time::UNIX_EPOCH => Err(io::const_io_error!(io::ErrorKind::InvalidInput, "timestamp is too large to set as a file time")),
1307-
Some(_) => Err(io::const_io_error!(io::ErrorKind::InvalidInput, "timestamp is too small to set as a file time")),
1308-
None => Ok(libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ }),
1309-
}
1303+
let to_timespec = |time: Option<SystemTime>| match time {
1304+
Some(time) if let Some(ts) = time.t.to_timespec() => Ok(ts),
1305+
Some(time) if time > crate::sys::time::UNIX_EPOCH => Err(io::const_io_error!(
1306+
io::ErrorKind::InvalidInput,
1307+
"timestamp is too large to set as a file time"
1308+
)),
1309+
Some(_) => Err(io::const_io_error!(
1310+
io::ErrorKind::InvalidInput,
1311+
"timestamp is too small to set as a file time"
1312+
)),
1313+
None => Ok(libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ }),
13101314
};
13111315
cfg_if::cfg_if! {
13121316
if #[cfg(any(target_os = "redox", target_os = "espidf", target_os = "horizon"))] {

std/src/sys/unix/os.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,19 @@ pub fn current_exe() -> io::Result<PathBuf> {
274274
return path.canonicalize();
275275
}
276276
// Search PWD to infer current_exe.
277-
if let Some(pstr) = path.to_str() && pstr.contains("/") {
277+
if let Some(pstr) = path.to_str()
278+
&& pstr.contains("/")
279+
{
278280
return getcwd().map(|cwd| cwd.join(path))?.canonicalize();
279281
}
280282
// Search PATH to infer current_exe.
281283
if let Some(p) = getenv(OsStr::from_bytes("PATH".as_bytes())) {
282284
for search_path in split_paths(&p) {
283285
let pb = search_path.join(&path);
284-
if pb.is_file() && let Ok(metadata) = crate::fs::metadata(&pb) &&
285-
metadata.permissions().mode() & 0o111 != 0 {
286+
if pb.is_file()
287+
&& let Ok(metadata) = crate::fs::metadata(&pb)
288+
&& metadata.permissions().mode() & 0o111 != 0
289+
{
286290
return pb.canonicalize();
287291
}
288292
}

std/src/sys/wasi/fs.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,13 @@ impl File {
477477
}
478478

479479
pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
480-
let to_timestamp = |time: Option<SystemTime>| {
481-
match time {
482-
Some(time) if let Some(ts) = time.to_wasi_timestamp() => Ok(ts),
483-
Some(_) => Err(io::const_io_error!(io::ErrorKind::InvalidInput, "timestamp is too large to set as a file time")),
484-
None => Ok(0),
485-
}
480+
let to_timestamp = |time: Option<SystemTime>| match time {
481+
Some(time) if let Some(ts) = time.to_wasi_timestamp() => Ok(ts),
482+
Some(_) => Err(io::const_io_error!(
483+
io::ErrorKind::InvalidInput,
484+
"timestamp is too large to set as a file time"
485+
)),
486+
None => Ok(0),
486487
};
487488
self.fd.filestat_set_times(
488489
to_timestamp(times.accessed)?,

std/src/sys/windows/path.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ pub fn parse_prefix(path: &OsStr) -> Option<Prefix<'_>> {
104104

105105
// The meaning of verbatim paths can change when they use a different
106106
// separator.
107-
if let Some(parser) = parser.strip_prefix(r"?\") && !parser.prefix_bytes().iter().any(|&x| x == b'/') {
107+
if let Some(parser) = parser.strip_prefix(r"?\")
108+
&& !parser.prefix_bytes().iter().any(|&x| x == b'/')
109+
{
108110
// \\?\
109111
if let Some(parser) = parser.strip_prefix(r"UNC\") {
110112
// \\?\UNC\server\share

std/src/sys_common/once/futex.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ impl Once {
128128
RUNNING | QUEUED => {
129129
// Set the state to QUEUED if it is not already.
130130
if state == RUNNING
131-
&& let Err(new) = self.state.compare_exchange_weak(RUNNING, QUEUED, Relaxed, Acquire)
131+
&& let Err(new) =
132+
self.state.compare_exchange_weak(RUNNING, QUEUED, Relaxed, Acquire)
132133
{
133134
state = new;
134135
continue;

0 commit comments

Comments
 (0)