Skip to content

Commit 975e83a

Browse files
committed
Auto merge of #67184 - tmandry:rollup-mzqxtck, r=tmandry
Rollup of 11 pull requests Successful merges: - #66892 (Format libcore with rustfmt (including tests and benches)) - #67106 (resolve: Resolve visibilities on fields with non-builtin attributes) - #67113 (Print the visibility in `print_variant`.) - #67115 (Simplify `check_decl_no_pat`.) - #67119 (libstd miri tests: avoid warnings) - #67125 (Added ExactSizeIterator bound to return types) - #67138 (Simplify `Layout::extend_packed`) - #67145 (fix miri step debug printing) - #67149 (Do not ICE #67123) - #67155 (Move `Layout`s instead of binding by reference) - #67169 (inline some common methods on OsStr) Failed merges: r? @ghost
2 parents 76a252e + c255815 commit 975e83a

Some content is hidden

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

77 files changed

+1587
-1321
lines changed

src/liballoc/alloc/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn allocate_zeroed() {
2222
}
2323

2424
#[bench]
25-
#[cfg(not(miri))] // Miri does not support benchmarks
25+
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
2626
fn alloc_owned_small(b: &mut Bencher) {
2727
b.iter(|| {
2828
let _: Box<_> = box 10;

src/liballoc/collections/linked_list/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn test_insert_prev() {
182182

183183
#[test]
184184
#[cfg_attr(target_os = "emscripten", ignore)]
185-
#[cfg(not(miri))] // Miri does not support threads
185+
#[cfg_attr(miri, ignore)] // Miri does not support threads
186186
fn test_send() {
187187
let n = list_from(&[1, 2, 3]);
188188
thread::spawn(move || {

src/liballoc/collections/vec_deque/tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
use ::test;
44

55
#[bench]
6-
#[cfg(not(miri))] // Miri does not support benchmarks
6+
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
77
fn bench_push_back_100(b: &mut test::Bencher) {
88
let mut deq = VecDeque::with_capacity(101);
99
b.iter(|| {
@@ -16,7 +16,7 @@ fn bench_push_back_100(b: &mut test::Bencher) {
1616
}
1717

1818
#[bench]
19-
#[cfg(not(miri))] // Miri does not support benchmarks
19+
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
2020
fn bench_push_front_100(b: &mut test::Bencher) {
2121
let mut deq = VecDeque::with_capacity(101);
2222
b.iter(|| {
@@ -29,7 +29,7 @@ fn bench_push_front_100(b: &mut test::Bencher) {
2929
}
3030

3131
#[bench]
32-
#[cfg(not(miri))] // Miri does not support benchmarks
32+
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
3333
fn bench_pop_back_100(b: &mut test::Bencher) {
3434
let mut deq = VecDeque::<i32>::with_capacity(101);
3535

@@ -43,7 +43,7 @@ fn bench_pop_back_100(b: &mut test::Bencher) {
4343
}
4444

4545
#[bench]
46-
#[cfg(not(miri))] // Miri does not support benchmarks
46+
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
4747
fn bench_pop_front_100(b: &mut test::Bencher) {
4848
let mut deq = VecDeque::<i32>::with_capacity(101);
4949

src/liballoc/sync/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl Drop for Canary {
2929

3030
#[test]
3131
#[cfg_attr(target_os = "emscripten", ignore)]
32-
#[cfg(not(miri))] // Miri does not support threads
32+
#[cfg_attr(miri, ignore)] // Miri does not support threads
3333
fn manually_share_arc() {
3434
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
3535
let arc_v = Arc::new(v);
@@ -334,7 +334,7 @@ fn test_ptr_eq() {
334334

335335
#[test]
336336
#[cfg_attr(target_os = "emscripten", ignore)]
337-
#[cfg(not(miri))] // Miri does not support threads
337+
#[cfg_attr(miri, ignore)] // Miri does not support threads
338338
fn test_weak_count_locked() {
339339
let mut a = Arc::new(atomic::AtomicBool::new(false));
340340
let a2 = a.clone();

src/liballoc/tests/slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ fn test_reverse() {
388388
}
389389

390390
#[test]
391-
#[cfg(not(miri))] // Miri is too slow
391+
#[cfg_attr(miri, ignore)] // Miri is too slow
392392
fn test_sort() {
393393
let mut rng = thread_rng();
394394

@@ -1610,7 +1610,7 @@ fn panic_safe() {
16101610
let moduli = &[5, 20, 50];
16111611

16121612
#[cfg(miri)]
1613-
let lens = (1..13);
1613+
let lens = 1..13;
16141614
#[cfg(miri)]
16151615
let moduli = &[10];
16161616

src/liballoc/tests/str.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ fn test_join_for_different_lengths_with_long_separator() {
166166
}
167167

168168
#[test]
169-
#[cfg(not(miri))] // Miri is too slow
169+
#[cfg_attr(miri, ignore)] // Miri is too slow
170170
fn test_unsafe_slice() {
171171
assert_eq!("ab", unsafe {"abc".get_unchecked(0..2)});
172172
assert_eq!("bc", unsafe {"abc".get_unchecked(1..3)});
@@ -483,8 +483,8 @@ mod slice_index {
483483
}
484484

485485
#[test]
486-
#[cfg(not(target_os = "emscripten"))] // hits an OOM
487-
#[cfg(not(miri))] // Miri is too slow
486+
#[cfg_attr(target_os = "emscripten", ignore)] // hits an OOM
487+
#[cfg_attr(miri, ignore)] // Miri is too slow
488488
fn simple_big() {
489489
fn a_million_letter_x() -> String {
490490
let mut i = 0;
@@ -1069,7 +1069,7 @@ fn test_rev_iterator() {
10691069
}
10701070

10711071
#[test]
1072-
#[cfg(not(miri))] // Miri is too slow
1072+
#[cfg_attr(miri, ignore)] // Miri is too slow
10731073
fn test_chars_decoding() {
10741074
let mut bytes = [0; 4];
10751075
for c in (0..0x110000).filter_map(std::char::from_u32) {
@@ -1081,7 +1081,7 @@ fn test_chars_decoding() {
10811081
}
10821082

10831083
#[test]
1084-
#[cfg(not(miri))] // Miri is too slow
1084+
#[cfg_attr(miri, ignore)] // Miri is too slow
10851085
fn test_chars_rev_decoding() {
10861086
let mut bytes = [0; 4];
10871087
for c in (0..0x110000).filter_map(std::char::from_u32) {
@@ -1380,7 +1380,6 @@ fn test_bool_from_str() {
13801380
assert_eq!("not even a boolean".parse::<bool>().ok(), None);
13811381
}
13821382

1383-
#[cfg(not(miri))] // Miri is too slow
13841383
fn check_contains_all_substrings(s: &str) {
13851384
assert!(s.contains(""));
13861385
for i in 0..s.len() {
@@ -1391,7 +1390,7 @@ fn check_contains_all_substrings(s: &str) {
13911390
}
13921391

13931392
#[test]
1394-
#[cfg(not(miri))] // Miri is too slow
1393+
#[cfg_attr(miri, ignore)] // Miri is too slow
13951394
fn strslice_issue_16589() {
13961395
assert!("bananas".contains("nana"));
13971396

@@ -1408,7 +1407,7 @@ fn strslice_issue_16878() {
14081407

14091408

14101409
#[test]
1411-
#[cfg(not(miri))] // Miri is too slow
1410+
#[cfg_attr(miri, ignore)] // Miri is too slow
14121411
fn test_strslice_contains() {
14131412
let x = "There are moments, Jeeves, when one asks oneself, 'Do trousers matter?'";
14141413
check_contains_all_substrings(x);

src/liballoc/tests/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ fn test_reserve_exact() {
523523
}
524524

525525
#[test]
526-
#[cfg(not(miri))] // Miri does not support signalling OOM
526+
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
527527
fn test_try_reserve() {
528528

529529
// These are the interesting cases:
@@ -601,7 +601,7 @@ fn test_try_reserve() {
601601
}
602602

603603
#[test]
604-
#[cfg(not(miri))] // Miri does not support signalling OOM
604+
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
605605
fn test_try_reserve_exact() {
606606

607607
// This is exactly the same as test_try_reserve with the method changed.

src/liballoc/tests/vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ fn test_reserve_exact() {
10801080
}
10811081

10821082
#[test]
1083-
#[cfg(not(miri))] // Miri does not support signalling OOM
1083+
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
10841084
fn test_try_reserve() {
10851085

10861086
// These are the interesting cases:
@@ -1183,7 +1183,7 @@ fn test_try_reserve() {
11831183
}
11841184

11851185
#[test]
1186-
#[cfg(not(miri))] // Miri does not support signalling OOM
1186+
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
11871187
fn test_try_reserve_exact() {
11881188

11891189
// This is exactly the same as test_try_reserve with the method changed.

src/liballoc/tests/vec_deque.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ fn test_reserve_exact_2() {
11001100
}
11011101

11021102
#[test]
1103-
#[cfg(not(miri))] // Miri does not support signalling OOM
1103+
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
11041104
fn test_try_reserve() {
11051105
// These are the interesting cases:
11061106
// * exactly isize::MAX should never trigger a CapacityOverflow (can be OOM)
@@ -1214,7 +1214,7 @@ fn test_try_reserve() {
12141214
}
12151215

12161216
#[test]
1217-
#[cfg(not(miri))] // Miri does not support signalling OOM
1217+
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
12181218
fn test_try_reserve_exact() {
12191219
// This is exactly the same as test_try_reserve with the method changed.
12201220
// See that test for comments.

src/libcore/alloc.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ impl Layout {
310310
pub fn extend_packed(&self, next: Self) -> Result<Self, LayoutErr> {
311311
let new_size = self.size().checked_add(next.size())
312312
.ok_or(LayoutErr { private: () })?;
313-
let layout = Layout::from_size_align(new_size, self.align())?;
314-
Ok(layout)
313+
Layout::from_size_align(new_size, self.align())
315314
}
316315

317316
/// Creates a layout describing the record for a `[T; n]`.
@@ -1143,9 +1142,9 @@ pub unsafe trait Alloc {
11431142
where Self: Sized
11441143
{
11451144
match Layout::array::<T>(n) {
1146-
Ok(ref layout) if layout.size() > 0 => {
1145+
Ok(layout) if layout.size() > 0 => {
11471146
unsafe {
1148-
self.alloc(layout.clone()).map(|p| p.cast())
1147+
self.alloc(layout).map(|p| p.cast())
11491148
}
11501149
}
11511150
_ => Err(AllocErr),
@@ -1193,9 +1192,9 @@ pub unsafe trait Alloc {
11931192
where Self: Sized
11941193
{
11951194
match (Layout::array::<T>(n_old), Layout::array::<T>(n_new)) {
1196-
(Ok(ref k_old), Ok(ref k_new)) if k_old.size() > 0 && k_new.size() > 0 => {
1195+
(Ok(k_old), Ok(k_new)) if k_old.size() > 0 && k_new.size() > 0 => {
11971196
debug_assert!(k_old.align() == k_new.align());
1198-
self.realloc(ptr.cast(), k_old.clone(), k_new.size()).map(NonNull::cast)
1197+
self.realloc(ptr.cast(), k_old, k_new.size()).map(NonNull::cast)
11991198
}
12001199
_ => {
12011200
Err(AllocErr)
@@ -1227,8 +1226,8 @@ pub unsafe trait Alloc {
12271226
where Self: Sized
12281227
{
12291228
match Layout::array::<T>(n) {
1230-
Ok(ref k) if k.size() > 0 => {
1231-
Ok(self.dealloc(ptr.cast(), k.clone()))
1229+
Ok(k) if k.size() > 0 => {
1230+
Ok(self.dealloc(ptr.cast(), k))
12321231
}
12331232
_ => {
12341233
Err(AllocErr)

src/libcore/benches/any.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use core::any::*;
2-
use test::{Bencher, black_box};
2+
use test::{black_box, Bencher};
33

44
#[bench]
55
fn bench_downcast_ref(b: &mut Bencher) {

src/libcore/benches/ascii.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,9 @@
2222
//
2323
// Therefore:
2424
fn branchless_to_ascii_upper_case(byte: u8) -> u8 {
25-
byte &
26-
!(
27-
(
28-
byte.wrapping_add(0x1f) &
29-
!byte.wrapping_add(0x05) &
30-
0x80
31-
) >> 2
32-
)
25+
byte & !((byte.wrapping_add(0x1f) & !byte.wrapping_add(0x05) & 0x80) >> 2)
3326
}
3427

35-
3628
macro_rules! benches {
3729
($( fn $name: ident($arg: ident: &mut [u8]) $body: block )+ @iter $( $is_: ident, )+) => {
3830
benches! {@
@@ -254,12 +246,15 @@ benches! {
254246
}
255247

256248
macro_rules! repeat {
257-
($s: expr) => { concat!($s, $s, $s, $s, $s, $s, $s, $s, $s, $s) }
249+
($s: expr) => {
250+
concat!($s, $s, $s, $s, $s, $s, $s, $s, $s, $s)
251+
};
258252
}
259253

260254
const SHORT: &'static str = "Alice's";
261255
const MEDIUM: &'static str = "Alice's Adventures in Wonderland";
262-
const LONG: &'static str = repeat!(r#"
256+
const LONG: &'static str = repeat!(
257+
r#"
263258
La Guida di Bragia, a Ballad Opera for the Marionette Theatre (around 1850)
264259
Alice's Adventures in Wonderland (1865)
265260
Phantasmagoria and Other Poems (1869)
@@ -275,8 +270,10 @@ const LONG: &'static str = repeat!(r#"
275270
What the Tortoise Said to Achilles (1895)
276271
Three Sunsets and Other Poems (1898)
277272
The Manlet (1903)[106]
278-
"#);
273+
"#
274+
);
279275

276+
#[rustfmt::skip]
280277
const ASCII_UPPERCASE_MAP: [u8; 256] = [
281278
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
282279
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
@@ -330,6 +327,7 @@ enum AsciiCharacterClass {
330327
}
331328
use self::AsciiCharacterClass::*;
332329

330+
#[rustfmt::skip]
333331
static ASCII_CHARACTER_CLASS: [AsciiCharacterClass; 256] = [
334332
// _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _a _b _c _d _e _f
335333
C, C, C, C, C, C, C, C, C, Cw,Cw,C, Cw,Cw,C, C, // 0_

src/libcore/benches/char/methods.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ fn bench_to_digit_radix_36(b: &mut Bencher) {
2525

2626
#[bench]
2727
fn bench_to_digit_radix_var(b: &mut Bencher) {
28-
b.iter(|| CHARS.iter().cycle()
29-
.zip(RADIX.iter().cycle())
30-
.take(10_000)
31-
.map(|(c, radix)| c.to_digit(*radix)).min())
28+
b.iter(|| {
29+
CHARS
30+
.iter()
31+
.cycle()
32+
.zip(RADIX.iter().cycle())
33+
.take(10_000)
34+
.map(|(c, radix)| c.to_digit(*radix))
35+
.min()
36+
})
3237
}

src/libcore/benches/fmt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::io::{self, Write as IoWrite};
21
use std::fmt::{self, Write as FmtWrite};
2+
use std::io::{self, Write as IoWrite};
33
use test::Bencher;
44

55
#[bench]

0 commit comments

Comments
 (0)