Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit cbb649a

Browse files
committed
Auto merge of rust-lang#2249 - dtolnay-contrib:rustfmt3, r=oli-obk
Format tests with rustfmt (151-200 of 300) Extracted from rust-lang#2097. This PR is still only doing the easy cases with no comments involved. In the next PRs after this, I'll start grouping by common comment patterns, e.g. all the cases resembling rust-lang/miri#2097 (comment) together in one PR.
2 parents 332f289 + 1c66163 commit cbb649a

Some content is hidden

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

65 files changed

+350
-314
lines changed

tests/fail/intrinsics/simd-rem-by-zero.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ extern "platform-intrinsic" {
88
#[allow(non_camel_case_types)]
99
struct i32x2(i32, i32);
1010

11-
fn main() { unsafe {
12-
let x = i32x2(1, 1);
13-
let y = i32x2(1, 0);
14-
simd_rem(x, y); //~ERROR Undefined Behavior: calculating the remainder with a divisor of zero
15-
} }
11+
fn main() {
12+
unsafe {
13+
let x = i32x2(1, 1);
14+
let y = i32x2(1, 0);
15+
simd_rem(x, y); //~ERROR Undefined Behavior: calculating the remainder with a divisor of zero
16+
}
17+
}

tests/fail/intrinsics/simd-rem-by-zero.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: calculating the remainder with a divisor of zero
22
--> $DIR/simd-rem-by-zero.rs:LL:CC
33
|
4-
LL | simd_rem(x, y);
5-
| ^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero
4+
LL | simd_rem(x, y);
5+
| ^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/simd-scatter.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
#![feature(portable_simd)]
33
use std::simd::*;
44

5-
fn main() { unsafe {
6-
let mut vec: Vec<i8> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
7-
let idxs = Simd::from_array([9, 3, 0, 17]);
8-
Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked(&mut vec, Mask::splat(true), idxs);
9-
} }
5+
fn main() {
6+
unsafe {
7+
let mut vec: Vec<i8> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
8+
let idxs = Simd::from_array([9, 3, 0, 17]);
9+
Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked(
10+
&mut vec,
11+
Mask::splat(true),
12+
idxs,
13+
);
14+
}
15+
}

tests/fail/intrinsics/simd-scatter.stderr

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ LL | intrinsics::simd_scatter(self, ptrs, enable.to_int())
1111
note: inside `main` at $DIR/simd-scatter.rs:LL:CC
1212
--> $DIR/simd-scatter.rs:LL:CC
1313
|
14-
LL | Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked(&mut vec, Mask::splat(true), idxs);
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
LL | / Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked(
15+
LL | | &mut vec,
16+
LL | | Mask::splat(true),
17+
LL | | idxs,
18+
LL | | );
19+
| |_________^
1620

1721
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1822

tests/fail/intrinsics/simd-select-bitmask-invalid.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ extern "platform-intrinsic" {
99
#[derive(Copy, Clone)]
1010
struct i32x2(i32, i32);
1111

12-
fn main() { unsafe {
13-
let x = i32x2(0, 1);
14-
simd_select_bitmask(0b11111111u8, x, x); //~ERROR bitmask less than 8 bits long must be filled with 0s for the remaining bits
15-
} }
12+
fn main() {
13+
unsafe {
14+
let x = i32x2(0, 1);
15+
simd_select_bitmask(0b11111111u8, x, x); //~ERROR bitmask less than 8 bits long must be filled with 0s for the remaining bits
16+
}
17+
}

tests/fail/intrinsics/simd-select-bitmask-invalid.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: a SIMD bitmask less than 8 bits long must be filled with 0s for the remaining bits
22
--> $DIR/simd-select-bitmask-invalid.rs:LL:CC
33
|
4-
LL | simd_select_bitmask(0b11111111u8, x, x);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ a SIMD bitmask less than 8 bits long must be filled with 0s for the remaining bits
4+
LL | simd_select_bitmask(0b11111111u8, x, x);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ a SIMD bitmask less than 8 bits long must be filled with 0s for the remaining bits
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/simd-select-invalid-bool.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ extern "platform-intrinsic" {
99
#[derive(Copy, Clone)]
1010
struct i32x2(i32, i32);
1111

12-
fn main() { unsafe {
13-
let x = i32x2(0, 1);
14-
simd_select(x, x, x); //~ERROR must be all-0-bits or all-1-bits
15-
} }
12+
fn main() {
13+
unsafe {
14+
let x = i32x2(0, 1);
15+
simd_select(x, x, x); //~ERROR must be all-0-bits or all-1-bits
16+
}
17+
}

tests/fail/intrinsics/simd-select-invalid-bool.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: each element of a SIMD mask must be all-0-bits or all-1-bits
22
--> $DIR/simd-select-invalid-bool.rs:LL:CC
33
|
4-
LL | simd_select(x, x, x);
5-
| ^^^^^^^^^^^^^^^^^^^^ each element of a SIMD mask must be all-0-bits or all-1-bits
4+
LL | simd_select(x, x, x);
5+
| ^^^^^^^^^^^^^^^^^^^^ each element of a SIMD mask must be all-0-bits or all-1-bits
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/simd-shl-too-far.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ extern "platform-intrinsic" {
88
#[allow(non_camel_case_types)]
99
struct i32x2(i32, i32);
1010

11-
fn main() { unsafe {
12-
let x = i32x2(1, 1);
13-
let y = i32x2(100, 0);
14-
simd_shl(x, y); //~ERROR overflowing shift by 100 in `simd_shl` in SIMD lane 0
15-
} }
11+
fn main() {
12+
unsafe {
13+
let x = i32x2(1, 1);
14+
let y = i32x2(100, 0);
15+
simd_shl(x, y); //~ERROR overflowing shift by 100 in `simd_shl` in SIMD lane 0
16+
}
17+
}

tests/fail/intrinsics/simd-shl-too-far.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: overflowing shift by 100 in `simd_shl` in SIMD lane 0
22
--> $DIR/simd-shl-too-far.rs:LL:CC
33
|
4-
LL | simd_shl(x, y);
5-
| ^^^^^^^^^^^^^^ overflowing shift by 100 in `simd_shl` in SIMD lane 0
4+
LL | simd_shl(x, y);
5+
| ^^^^^^^^^^^^^^ overflowing shift by 100 in `simd_shl` in SIMD lane 0
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/simd-shr-too-far.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ extern "platform-intrinsic" {
88
#[allow(non_camel_case_types)]
99
struct i32x2(i32, i32);
1010

11-
fn main() { unsafe {
12-
let x = i32x2(1, 1);
13-
let y = i32x2(20, 40);
14-
simd_shr(x, y); //~ERROR overflowing shift by 40 in `simd_shr` in SIMD lane 1
15-
} }
11+
fn main() {
12+
unsafe {
13+
let x = i32x2(1, 1);
14+
let y = i32x2(20, 40);
15+
simd_shr(x, y); //~ERROR overflowing shift by 40 in `simd_shr` in SIMD lane 1
16+
}
17+
}

tests/fail/intrinsics/simd-shr-too-far.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: overflowing shift by 40 in `simd_shr` in SIMD lane 1
22
--> $DIR/simd-shr-too-far.rs:LL:CC
33
|
4-
LL | simd_shr(x, y);
5-
| ^^^^^^^^^^^^^^ overflowing shift by 40 in `simd_shr` in SIMD lane 1
4+
LL | simd_shr(x, y);
5+
| ^^^^^^^^^^^^^^ overflowing shift by 40 in `simd_shr` in SIMD lane 1
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/invalid_enum_tag.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ use std::mem;
88

99
#[repr(C)]
1010
pub enum Foo {
11-
A, B, C, D
11+
A,
12+
B,
13+
C,
14+
D,
1215
}
1316

1417
fn main() {

tests/fail/issue-miri-1112.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ pub struct Meta {
1212

1313
impl Meta {
1414
pub fn new() -> Self {
15-
Meta {
16-
drop_fn: |_| {},
17-
size: 0,
18-
align: 1,
19-
}
15+
Meta { drop_fn: |_| {}, size: 0, align: 1 }
2016
}
2117
}
2218

tests/fail/memleak_rc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// stderr-per-bitwidth
33
// normalize-stderr-test: ".*│.*" -> "$$stripped$$"
44

5-
use std::rc::Rc;
65
use std::cell::RefCell;
6+
use std::rc::Rc;
77

88
struct Dummy(Rc<RefCell<Option<Dummy>>>);
99

tests/fail/modifying_constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
fn main() {
55
let x = &1; // the `&1` is promoted to a constant, but it used to be that only the pointer is marked static, not the pointee
66
let y = unsafe { &mut *(x as *const i32 as *mut i32) };
7-
*y = 42; //~ ERROR read-only
7+
*y = 42; //~ ERROR read-only
88
assert_eq!(*x, 42);
99
}

tests/fail/never_say_never.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
fn main() {
88
let y = &5;
99
let x: ! = unsafe {
10-
*(y as *const _ as *const !) //~ ERROR entering unreachable code
10+
*(y as *const _ as *const !) //~ ERROR entering unreachable code
1111
};
1212
f(x)
1313
}
1414

15-
fn f(x: !) -> ! { x }
15+
fn f(x: !) -> ! {
16+
x
17+
}

tests/fail/never_transmute_void.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ mod m {
1414
}
1515

1616
fn main() {
17-
let v = unsafe {
18-
std::mem::transmute::<(), m::Void>(())
19-
};
17+
let v = unsafe { std::mem::transmute::<(), m::Void>(()) };
2018
m::f(v); //~ inside `main`
2119
}

tests/fail/rc_as_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// This should fail even without validation
22
// compile-flags: -Zmiri-disable-validation
33

4-
use std::rc::{Rc, Weak};
54
use std::ptr;
5+
use std::rc::{Rc, Weak};
66

77
/// Taken from the `Weak::as_ptr` doctest.
88
fn main() {

tests/fail/reading_half_a_pointer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct Wrapper {
1313
data: Data,
1414
}
1515

16-
static G : i32 = 0;
16+
static G: i32 = 0;
1717

1818
fn main() {
1919
let mut w = Wrapper { align: 0, data: Data { pad: 0, ptr: &G } };

tests/fail/shim_arg_size.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ fn main() {
44
extern "C" {
55
// Use the wrong type(ie. not the pointer width) for the `size`
66
// argument.
7-
#[cfg(target_pointer_width="64")]
7+
#[cfg(target_pointer_width = "64")]
88
fn malloc(size: u32) -> *mut std::ffi::c_void;
99

10-
#[cfg(target_pointer_width="32")]
10+
#[cfg(target_pointer_width = "32")]
1111
fn malloc(size: u16) -> *mut std::ffi::c_void;
1212
}
1313

tests/fail/should-pass/cpp20_rwc_syncs.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ fn test_cpp20_rwc_syncs() {
7676
// Our ui_test does not yet support overriding failure status codes.
7777
if (b, c) == (0, 0) {
7878
// This *should* be unreachable, but Miri will reach it.
79-
unsafe { std::hint::unreachable_unchecked(); }
79+
unsafe {
80+
std::hint::unreachable_unchecked();
81+
}
8082
}
8183
}
8284

tests/fail/should-pass/cpp20_rwc_syncs.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | unsafe { intrinsics::unreachable() }
1111
note: inside `test_cpp20_rwc_syncs` at $DIR/cpp20_rwc_syncs.rs:LL:CC
1212
--> $DIR/cpp20_rwc_syncs.rs:LL:CC
1313
|
14-
LL | unsafe { std::hint::unreachable_unchecked(); }
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
LL | std::hint::unreachable_unchecked();
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616
note: inside `main` at $DIR/cpp20_rwc_syncs.rs:LL:CC
1717
--> $DIR/cpp20_rwc_syncs.rs:LL:CC
1818
|

tests/fail/stacked_borrows/alias_through_mutation.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// This makes a ref that was passed to us via &mut alias with things it should not alias with
22
fn retarget(x: &mut &u32, target: &mut u32) {
3-
unsafe { *x = &mut *(target as *mut _); }
3+
unsafe {
4+
*x = &mut *(target as *mut _);
5+
}
46
}
57

68
fn main() {

tests/fail/stacked_borrows/alias_through_mutation.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ LL | let _val = *target_alias;
1212
help: <TAG> was created by a retag at offsets [0x0..0x4]
1313
--> $DIR/alias_through_mutation.rs:LL:CC
1414
|
15-
LL | unsafe { *x = &mut *(target as *mut _); }
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^
15+
LL | *x = &mut *(target as *mut _);
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^
1717
help: <TAG> was later invalidated at offsets [0x0..0x4]
1818
--> $DIR/alias_through_mutation.rs:LL:CC
1919
|

tests/fail/stacked_borrows/aliasing_mut1.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ fn main() {
88
// We need to apply some tricky to be able to call `safe` with two mutable references
99
// with the same tag: We transmute both the fn ptr (to take raw ptrs) and the argument
1010
// (to be raw, but still have the unique tag).
11-
let safe_raw: fn(x: *mut i32, y: *mut i32) = unsafe {
12-
mem::transmute::<fn(&mut i32, &mut i32), _>(safe)
13-
};
11+
let safe_raw: fn(x: *mut i32, y: *mut i32) =
12+
unsafe { mem::transmute::<fn(&mut i32, &mut i32), _>(safe) };
1413
safe_raw(xraw, xraw);
1514
}

tests/fail/stacked_borrows/aliasing_mut2.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ fn main() {
88
let xraw: *mut i32 = unsafe { mem::transmute_copy(&xref) };
99
let xshr = &*xref;
1010
// transmute fn ptr around so that we can avoid retagging
11-
let safe_raw: fn(x: *const i32, y: *mut i32) = unsafe {
12-
mem::transmute::<fn(&i32, &mut i32), _>(safe)
13-
};
11+
let safe_raw: fn(x: *const i32, y: *mut i32) =
12+
unsafe { mem::transmute::<fn(&i32, &mut i32), _>(safe) };
1413
safe_raw(xshr, xraw);
1514
}

tests/fail/stacked_borrows/aliasing_mut3.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ fn main() {
88
let xraw: *mut i32 = unsafe { mem::transmute_copy(&xref) };
99
let xshr = &*xref;
1010
// transmute fn ptr around so that we can avoid retagging
11-
let safe_raw: fn(x: *mut i32, y: *const i32) = unsafe {
12-
mem::transmute::<fn(&mut i32, &i32), _>(safe)
13-
};
11+
let safe_raw: fn(x: *mut i32, y: *const i32) =
12+
unsafe { mem::transmute::<fn(&mut i32, &i32), _>(safe) };
1413
safe_raw(xraw, xshr);
1514
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::mem;
21
use std::cell::Cell;
2+
use std::mem;
33

44
// Make sure &mut UnsafeCell also is exclusive
55
pub fn safe(_x: &i32, _y: &mut Cell<i32>) {} //~ ERROR protect
@@ -10,8 +10,7 @@ fn main() {
1010
let xraw: *mut i32 = unsafe { mem::transmute_copy(&xref) };
1111
let xshr = &*xref;
1212
// transmute fn ptr around so that we can avoid retagging
13-
let safe_raw: fn(x: *const i32, y: *mut Cell<i32>) = unsafe {
14-
mem::transmute::<fn(&i32, &mut Cell<i32>), _>(safe)
15-
};
13+
let safe_raw: fn(x: *const i32, y: *mut Cell<i32>) =
14+
unsafe { mem::transmute::<fn(&i32, &mut Cell<i32>), _>(safe) };
1615
safe_raw(xshr, xraw as *mut _);
1716
}

0 commit comments

Comments
 (0)