Skip to content

Commit 0a0734e

Browse files
committed
Auto merge of #66820 - dtolnay:fmt3, r=Dylan-DPC
Format libstd with rustfmt (Same strategy as #66691.) This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd *that are not involved in any currently open PR* to minimize merge conflicts, and are not part of libstd/os (#66818) or libstd/sys (#66819). 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 -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of libstd. 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 9081929 + 688e381 commit 0a0734e

Some content is hidden

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

50 files changed

+2889
-2637
lines changed

src/libstd/ascii.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#![stable(feature = "rust1", since = "1.0.0")]
1818

1919
#[stable(feature = "rust1", since = "1.0.0")]
20-
pub use core::ascii::{EscapeDefault, escape_default};
20+
pub use core::ascii::{escape_default, EscapeDefault};
2121

2222
/// Extension methods for ASCII-subset only operations.
2323
///

src/libstd/backtrace.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ use crate::env;
9595
use crate::fmt;
9696
use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst};
9797
use crate::sync::Mutex;
98-
use crate::sys_common::backtrace::{output_filename, lock};
98+
use crate::sys_common::backtrace::{lock, output_filename};
9999
use crate::vec::Vec;
100-
use backtrace_rs as backtrace;
101100
use backtrace::BytesOrWideString;
101+
use backtrace_rs as backtrace;
102102

103103
/// A captured OS thread stack backtrace.
104104
///

src/libstd/benches/hash/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg(test)]
22

3-
use test::Bencher;
43
use std::collections::HashMap;
4+
use test::Bencher;
55

66
#[bench]
77
fn new_drop(b: &mut Bencher) {

src/libstd/collections/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -413,20 +413,20 @@
413413
#[doc(hidden)]
414414
pub use crate::ops::Bound;
415415
#[stable(feature = "rust1", since = "1.0.0")]
416-
pub use alloc_crate::collections::{BinaryHeap, BTreeMap, BTreeSet};
417-
#[stable(feature = "rust1", since = "1.0.0")]
418-
pub use alloc_crate::collections::{LinkedList, VecDeque};
419-
#[stable(feature = "rust1", since = "1.0.0")]
420416
pub use alloc_crate::collections::{binary_heap, btree_map, btree_set};
421417
#[stable(feature = "rust1", since = "1.0.0")]
422418
pub use alloc_crate::collections::{linked_list, vec_deque};
419+
#[stable(feature = "rust1", since = "1.0.0")]
420+
pub use alloc_crate::collections::{BTreeMap, BTreeSet, BinaryHeap};
421+
#[stable(feature = "rust1", since = "1.0.0")]
422+
pub use alloc_crate::collections::{LinkedList, VecDeque};
423423

424424
#[stable(feature = "rust1", since = "1.0.0")]
425425
pub use self::hash_map::HashMap;
426426
#[stable(feature = "rust1", since = "1.0.0")]
427427
pub use self::hash_set::HashSet;
428428

429-
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
429+
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
430430
pub use alloc_crate::collections::TryReserveError;
431431

432432
mod hash;

src/libstd/f32.rs

+37-45
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ use crate::intrinsics;
1414
use crate::sys::cmath;
1515

1616
#[stable(feature = "rust1", since = "1.0.0")]
17-
pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
17+
pub use core::f32::consts;
1818
#[stable(feature = "rust1", since = "1.0.0")]
19-
pub use core::f32::{MIN_EXP, MAX_EXP, MIN_10_EXP};
19+
pub use core::f32::{DIGITS, EPSILON, MANTISSA_DIGITS, RADIX};
2020
#[stable(feature = "rust1", since = "1.0.0")]
21-
pub use core::f32::{MAX_10_EXP, NAN, INFINITY, NEG_INFINITY};
21+
pub use core::f32::{INFINITY, MAX_10_EXP, NAN, NEG_INFINITY};
2222
#[stable(feature = "rust1", since = "1.0.0")]
23-
pub use core::f32::{MIN, MIN_POSITIVE, MAX};
23+
pub use core::f32::{MAX, MIN, MIN_POSITIVE};
2424
#[stable(feature = "rust1", since = "1.0.0")]
25-
pub use core::f32::consts;
25+
pub use core::f32::{MAX_EXP, MIN_10_EXP, MIN_EXP};
2626

2727
#[cfg(not(test))]
2828
#[lang = "f32_runtime"]
@@ -142,7 +142,9 @@ impl f32 {
142142
#[must_use = "method returns a new number and does not mutate the original value"]
143143
#[stable(feature = "rust1", since = "1.0.0")]
144144
#[inline]
145-
pub fn fract(self) -> f32 { self - self.trunc() }
145+
pub fn fract(self) -> f32 {
146+
self - self.trunc()
147+
}
146148

147149
/// Computes the absolute value of `self`. Returns `NAN` if the
148150
/// number is `NAN`.
@@ -192,11 +194,7 @@ impl f32 {
192194
#[stable(feature = "rust1", since = "1.0.0")]
193195
#[inline]
194196
pub fn signum(self) -> f32 {
195-
if self.is_nan() {
196-
NAN
197-
} else {
198-
1.0_f32.copysign(self)
199-
}
197+
if self.is_nan() { NAN } else { 1.0_f32.copysign(self) }
200198
}
201199

202200
/// Returns a number composed of the magnitude of `self` and the sign of
@@ -277,7 +275,7 @@ impl f32 {
277275
pub fn div_euclid(self, rhs: f32) -> f32 {
278276
let q = (self / rhs).trunc();
279277
if self % rhs < 0.0 {
280-
return if rhs > 0.0 { q - 1.0 } else { q + 1.0 }
278+
return if rhs > 0.0 { q - 1.0 } else { q + 1.0 };
281279
}
282280
q
283281
}
@@ -310,14 +308,9 @@ impl f32 {
310308
#[stable(feature = "euclidean_division", since = "1.38.0")]
311309
pub fn rem_euclid(self, rhs: f32) -> f32 {
312310
let r = self % rhs;
313-
if r < 0.0 {
314-
r + rhs.abs()
315-
} else {
316-
r
317-
}
311+
if r < 0.0 { r + rhs.abs() } else { r }
318312
}
319313

320-
321314
/// Raises a number to an integer power.
322315
///
323316
/// Using this function is generally faster than using `powf`
@@ -383,11 +376,7 @@ impl f32 {
383376
#[stable(feature = "rust1", since = "1.0.0")]
384377
#[inline]
385378
pub fn sqrt(self) -> f32 {
386-
if self < 0.0 {
387-
NAN
388-
} else {
389-
unsafe { intrinsics::sqrtf32(self) }
390-
}
379+
if self < 0.0 { NAN } else { unsafe { intrinsics::sqrtf32(self) } }
391380
}
392381

393382
/// Returns `e^(self)`, (the exponential function).
@@ -486,7 +475,9 @@ impl f32 {
486475
#[must_use = "method returns a new number and does not mutate the original value"]
487476
#[stable(feature = "rust1", since = "1.0.0")]
488477
#[inline]
489-
pub fn log(self, base: f32) -> f32 { self.ln() / base.ln() }
478+
pub fn log(self, base: f32) -> f32 {
479+
self.ln() / base.ln()
480+
}
490481

491482
/// Returns the base 2 logarithm of the number.
492483
///
@@ -559,14 +550,16 @@ impl f32 {
559550
#[must_use = "method returns a new number and does not mutate the original value"]
560551
#[stable(feature = "rust1", since = "1.0.0")]
561552
#[inline]
562-
#[rustc_deprecated(since = "1.10.0",
563-
reason = "you probably meant `(self - other).abs()`: \
564-
this operation is `(self - other).max(0.0)` \
565-
except that `abs_sub` also propagates NaNs (also \
566-
known as `fdimf` in C). If you truly need the positive \
567-
difference, consider using that expression or the C function \
568-
`fdimf`, depending on how you wish to handle NaN (please consider \
569-
filing an issue describing your use-case too).")]
553+
#[rustc_deprecated(
554+
since = "1.10.0",
555+
reason = "you probably meant `(self - other).abs()`: \
556+
this operation is `(self - other).max(0.0)` \
557+
except that `abs_sub` also propagates NaNs (also \
558+
known as `fdimf` in C). If you truly need the positive \
559+
difference, consider using that expression or the C function \
560+
`fdimf`, depending on how you wish to handle NaN (please consider \
561+
filing an issue describing your use-case too)."
562+
)]
570563
pub fn abs_sub(self, other: f32) -> f32 {
571564
unsafe { cmath::fdimf(self, other) }
572565
}
@@ -967,11 +960,7 @@ impl f32 {
967960
#[stable(feature = "rust1", since = "1.0.0")]
968961
#[inline]
969962
pub fn acosh(self) -> f32 {
970-
if self < 1.0 {
971-
crate::f32::NAN
972-
} else {
973-
(self + ((self * self) - 1.0).sqrt()).ln()
974-
}
963+
if self < 1.0 { crate::f32::NAN } else { (self + ((self * self) - 1.0).sqrt()).ln() }
975964
}
976965

977966
/// Inverse hyperbolic tangent function.
@@ -1022,19 +1011,22 @@ impl f32 {
10221011
pub fn clamp(self, min: f32, max: f32) -> f32 {
10231012
assert!(min <= max);
10241013
let mut x = self;
1025-
if x < min { x = min; }
1026-
if x > max { x = max; }
1014+
if x < min {
1015+
x = min;
1016+
}
1017+
if x > max {
1018+
x = max;
1019+
}
10271020
x
10281021
}
1029-
10301022
}
10311023

10321024
#[cfg(test)]
10331025
mod tests {
10341026
use crate::f32;
10351027
use crate::f32::*;
1036-
use crate::num::*;
10371028
use crate::num::FpCategory as Fp;
1029+
use crate::num::*;
10381030

10391031
#[test]
10401032
fn test_num_f32() {
@@ -1279,7 +1271,7 @@ mod tests {
12791271
assert_eq!((-0f32).abs(), 0f32);
12801272
assert_eq!((-1f32).abs(), 1f32);
12811273
assert_eq!(NEG_INFINITY.abs(), INFINITY);
1282-
assert_eq!((1f32/NEG_INFINITY).abs(), 0f32);
1274+
assert_eq!((1f32 / NEG_INFINITY).abs(), 0f32);
12831275
assert!(NAN.abs().is_nan());
12841276
}
12851277

@@ -1291,7 +1283,7 @@ mod tests {
12911283
assert_eq!((-0f32).signum(), -1f32);
12921284
assert_eq!((-1f32).signum(), -1f32);
12931285
assert_eq!(NEG_INFINITY.signum(), -1f32);
1294-
assert_eq!((1f32/NEG_INFINITY).signum(), -1f32);
1286+
assert_eq!((1f32 / NEG_INFINITY).signum(), -1f32);
12951287
assert!(NAN.signum().is_nan());
12961288
}
12971289

@@ -1303,7 +1295,7 @@ mod tests {
13031295
assert!(!(-0f32).is_sign_positive());
13041296
assert!(!(-1f32).is_sign_positive());
13051297
assert!(!NEG_INFINITY.is_sign_positive());
1306-
assert!(!(1f32/NEG_INFINITY).is_sign_positive());
1298+
assert!(!(1f32 / NEG_INFINITY).is_sign_positive());
13071299
assert!(NAN.is_sign_positive());
13081300
assert!(!(-NAN).is_sign_positive());
13091301
}
@@ -1316,7 +1308,7 @@ mod tests {
13161308
assert!((-0f32).is_sign_negative());
13171309
assert!((-1f32).is_sign_negative());
13181310
assert!(NEG_INFINITY.is_sign_negative());
1319-
assert!((1f32/NEG_INFINITY).is_sign_negative());
1311+
assert!((1f32 / NEG_INFINITY).is_sign_negative());
13201312
assert!(!NAN.is_sign_negative());
13211313
assert!((-NAN).is_sign_negative());
13221314
}

0 commit comments

Comments
 (0)