Skip to content

Commit bc33782

Browse files
committed
Auto merge of #125948 - nnethercote:rustfmt-more-tests, r=lqd
rustfmt more tests This finishes the formatting of tests begun in #125759 and continued in #125912. r? `@lqd`
2 parents 85f90a4 + d2ea692 commit bc33782

Some content is hidden

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

48 files changed

+351
-189
lines changed

rustfmt.toml

+6-11
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,13 @@ ignore = [
1515
"/tests/crashes/", # Many of these tests contain syntax errors.
1616
"/tests/debuginfo/", # These tests are somewhat sensitive to source code layout.
1717
"/tests/incremental/", # These tests are somewhat sensitive to source code layout.
18-
"/tests/pretty/",
18+
"/tests/pretty/", # These tests are very sensitive to source code layout.
1919
"/tests/run-make/translation/test.rs", # This test contains syntax errors.
20-
"/tests/run-make-fulldeps/",
21-
"/tests/run-pass-valgrind/",
22-
"/tests/rustdoc/",
23-
"/tests/rustdoc-gui/",
24-
"/tests/rustdoc-js/",
25-
"/tests/rustdoc-json/",
26-
"/tests/rustdoc-js-std/",
27-
"/tests/rustdoc-ui/",
28-
"/tests/ui/",
29-
"/tests/ui-fulldeps/",
20+
"/tests/rustdoc/", # Some have syntax errors, some are whitespace-sensitive.
21+
"/tests/rustdoc-gui/", # Some tests are sensitive to source code layout.
22+
"/tests/rustdoc-ui/", # Some have syntax errors, some are whitespace-sensitive.
23+
"/tests/ui/", # Some have syntax errors, some are whitespace-sensitive.
24+
"/tests/ui-fulldeps/", # Some are whitespace-sensitive (e.g. `// ~ERROR` comments).
3025

3126
# Do not format submodules.
3227
# FIXME: sync submodule list with tidy/bootstrap/etc

tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ use std::any::Any;
2727
struct TheBackend;
2828

2929
impl CodegenBackend for TheBackend {
30-
fn locale_resource(&self) -> &'static str { "" }
30+
fn locale_resource(&self) -> &'static str {
31+
""
32+
}
3133

3234
fn codegen_crate<'a, 'tcx>(
3335
&self,
@@ -62,7 +64,10 @@ impl CodegenBackend for TheBackend {
6264
codegen_results: CodegenResults,
6365
outputs: &OutputFilenames,
6466
) -> Result<(), ErrorGuaranteed> {
65-
use rustc_session::{config::{CrateType, OutFileName}, output::out_filename};
67+
use rustc_session::{
68+
config::{CrateType, OutFileName},
69+
output::out_filename,
70+
};
6671
use std::io::Write;
6772
let crate_name = codegen_results.crate_info.local_crate_name;
6873
for &crate_type in sess.opts.crate_types.iter() {
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
// #13544
22

3-
#[derive(Debug)] pub struct A;
4-
#[derive(Debug)] pub struct B(isize);
5-
#[derive(Debug)] pub struct C { x: isize }
6-
#[derive(Debug)] pub enum D {}
7-
#[derive(Debug)] pub enum E { y }
8-
#[derive(Debug)] pub enum F { z(isize) }
3+
#[derive(Debug)]
4+
pub struct A;
5+
6+
#[derive(Debug)]
7+
pub struct B(isize);
8+
9+
#[derive(Debug)]
10+
pub struct C {
11+
x: isize,
12+
}
13+
14+
#[derive(Debug)]
15+
pub enum D {}
16+
17+
#[derive(Debug)]
18+
pub enum E {
19+
y,
20+
}
21+
22+
#[derive(Debug)]
23+
pub enum F {
24+
z(isize),
25+
}

tests/run-pass-valgrind/cast-enum-with-dtor.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
// check dtor calling order when casting enums.
44

5+
use std::mem;
56
use std::sync::atomic;
67
use std::sync::atomic::Ordering;
7-
use std::mem;
88

99
enum E {
1010
A = 0,
1111
B = 1,
12-
C = 2
12+
C = 2,
1313
}
1414

1515
static FLAG: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
@@ -19,7 +19,7 @@ impl Drop for E {
1919
// avoid dtor loop
2020
unsafe { mem::forget(mem::replace(self, E::B)) };
2121

22-
FLAG.store(FLAG.load(Ordering::SeqCst)+1, Ordering::SeqCst);
22+
FLAG.store(FLAG.load(Ordering::SeqCst) + 1, Ordering::SeqCst);
2323
}
2424
}
2525

tests/run-pass-valgrind/cleanup-auto-borrow-obj.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ static mut DROP_RAN: bool = false;
77
struct Foo;
88
impl Drop for Foo {
99
fn drop(&mut self) {
10-
unsafe { DROP_RAN = true; }
10+
unsafe {
11+
DROP_RAN = true;
12+
}
1113
}
1214
}
1315

14-
15-
trait Trait { fn dummy(&self) { } }
16+
trait Trait {
17+
fn dummy(&self) {}
18+
}
1619
impl Trait for Foo {}
1720

1821
pub fn main() {

tests/run-pass-valgrind/coerce-match-calls.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ use std::boxed::Box;
77
pub fn main() {
88
let _: Box<[isize]> = if true { Box::new([1, 2, 3]) } else { Box::new([1]) };
99

10-
let _: Box<[isize]> = match true { true => Box::new([1, 2, 3]), false => Box::new([1]) };
10+
let _: Box<[isize]> = match true {
11+
true => Box::new([1, 2, 3]),
12+
false => Box::new([1]),
13+
};
1114

1215
// Check we don't get over-keen at propagating coercions in the case of casts.
1316
let x = if true { 42 } else { 42u8 } as u16;
14-
let x = match true { true => 42, false => 42u8 } as u16;
17+
let x = match true {
18+
true => 42,
19+
false => 42u8,
20+
} as u16;
1521
}

tests/run-pass-valgrind/coerce-match.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,20 @@ pub fn main() {
1212
};
1313

1414
let _: Box<[isize]> = match true {
15-
true => { let b: Box<_> = Box::new([1, 2, 3]); b }
16-
false => { let b: Box<_> = Box::new([1]); b }
15+
true => {
16+
let b: Box<_> = Box::new([1, 2, 3]);
17+
b
18+
}
19+
false => {
20+
let b: Box<_> = Box::new([1]);
21+
b
22+
}
1723
};
1824

1925
// Check we don't get over-keen at propagating coercions in the case of casts.
2026
let x = if true { 42 } else { 42u8 } as u16;
21-
let x = match true { true => 42, false => 42u8 } as u16;
27+
let x = match true {
28+
true => 42,
29+
false => 42u8,
30+
} as u16;
2231
}

tests/run-pass-valgrind/down-with-thread-dtors.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ impl Drop for Bar {
2727

2828
impl Drop for Baz {
2929
fn drop(&mut self) {
30-
unsafe { HIT = true; }
30+
unsafe {
31+
HIT = true;
32+
}
3133
}
3234
}
3335

3436
fn main() {
3537
std::thread::spawn(|| {
3638
FOO.with(|_| {});
37-
}).join().unwrap();
39+
})
40+
.join()
41+
.unwrap();
3842
assert!(unsafe { HIT });
3943
}

tests/run-pass-valgrind/dst-dtor-1.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ static mut DROP_RAN: bool = false;
33
struct Foo;
44
impl Drop for Foo {
55
fn drop(&mut self) {
6-
unsafe { DROP_RAN = true; }
6+
unsafe {
7+
DROP_RAN = true;
8+
}
79
}
810
}
911

10-
trait Trait { fn dummy(&self) { } }
12+
trait Trait {
13+
fn dummy(&self) {}
14+
}
1115
impl Trait for Foo {}
1216

1317
struct Fat<T: ?Sized> {
14-
f: T
18+
f: T,
1519
}
1620

1721
pub fn main() {

tests/run-pass-valgrind/dst-dtor-2.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ static mut DROP_RAN: isize = 0;
33
struct Foo;
44
impl Drop for Foo {
55
fn drop(&mut self) {
6-
unsafe { DROP_RAN += 1; }
6+
unsafe {
7+
DROP_RAN += 1;
8+
}
79
}
810
}
911

1012
struct Fat<T: ?Sized> {
11-
f: T
13+
f: T,
1214
}
1315

1416
pub fn main() {

tests/run-pass-valgrind/dst-dtor-3.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ static mut DROP_RAN: bool = false;
55
struct Foo;
66
impl Drop for Foo {
77
fn drop(&mut self) {
8-
unsafe { DROP_RAN = true; }
8+
unsafe {
9+
DROP_RAN = true;
10+
}
911
}
1012
}
1113

12-
trait Trait { fn dummy(&self) { } }
14+
trait Trait {
15+
fn dummy(&self) {}
16+
}
1317
impl Trait for Foo {}
1418

1519
pub fn main() {

tests/run-pass-valgrind/dst-dtor-4.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ static mut DROP_RAN: isize = 0;
55
struct Foo;
66
impl Drop for Foo {
77
fn drop(&mut self) {
8-
unsafe { DROP_RAN += 1; }
8+
unsafe {
9+
DROP_RAN += 1;
10+
}
911
}
1012
}
1113

tests/run-pass-valgrind/unsized-locals/by-value-trait-objects-rust-call.rs

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ impl FnOnce<()> for D {
4343
}
4444
}
4545

46-
4746
fn main() {
4847
let x = *(Box::new(A) as Box<dyn FnOnce<(), Output = String>>);
4948
assert_eq!(x.call_once(()), format!("hello"));

tests/run-pass-valgrind/unsized-locals/by-value-trait-objects-rust-call2.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ impl FnOnce<(String, Box<str>)> for D {
5151
}
5252
}
5353

54-
5554
fn main() {
5655
let (s1, s2) = (format!("s1"), format!("s2").into_boxed_str());
5756
let x = *(Box::new(A) as Box<dyn FnOnce<(String, Box<str>), Output = String>>);
@@ -61,10 +60,10 @@ fn main() {
6160
assert_eq!(x.call_once((s1, s2)), format!("42"));
6261
let (s1, s2) = (format!("s1"), format!("s2").into_boxed_str());
6362
let x = *(Box::new(C(format!("jumping fox")))
64-
as Box<dyn FnOnce<(String, Box<str>), Output = String>>);
63+
as Box<dyn FnOnce<(String, Box<str>), Output = String>>);
6564
assert_eq!(x.call_once((s1, s2)), format!("jumping fox"));
6665
let (s1, s2) = (format!("s1"), format!("s2").into_boxed_str());
6766
let x = *(Box::new(D(Box::new(format!("lazy dog"))))
68-
as Box<dyn FnOnce<(String, Box<str>), Output = String>>);
67+
as Box<dyn FnOnce<(String, Box<str>), Output = String>>);
6968
assert_eq!(x.call_once((s1, s2)), format!("lazy dog"));
7069
}

tests/run-pass-valgrind/unsized-locals/by-value-trait-objects.rs

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ impl Foo for D {
3636
}
3737
}
3838

39-
4039
fn main() {
4140
let x = *(Box::new(A) as Box<dyn Foo>);
4241
assert_eq!(x.foo(), format!("hello"));

tests/rustdoc-js/assoc-type-backtrack.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,27 @@ pub trait MyTrait2<X> {
55
pub trait MyTrait {
66
type Item;
77
fn next(&mut self) -> Option<Self::Item>;
8-
fn fold<B, F>(self, init: B, f: F) -> B where
8+
fn fold<B, F>(self, init: B, f: F) -> B
9+
where
910
Self: Sized,
10-
F: MyTrait2<(B, Self::Item), Output=B>;
11+
F: MyTrait2<(B, Self::Item), Output = B>;
1112
}
1213

1314
pub struct Cloned<I>(I);
1415

15-
impl<'a, T, I> MyTrait for Cloned<I> where
16+
impl<'a, T, I> MyTrait for Cloned<I>
17+
where
1618
T: 'a + Clone,
17-
I: MyTrait<Item = &'a T>
19+
I: MyTrait<Item = &'a T>,
1820
{
1921
type Item = T;
20-
fn next(&mut self) -> Option<Self::Item> { loop {} }
21-
fn fold<B, F>(self, init: B, f: F) -> B where
22+
fn next(&mut self) -> Option<Self::Item> {
23+
loop {}
24+
}
25+
fn fold<B, F>(self, init: B, f: F) -> B
26+
where
2227
Self: Sized,
23-
F: MyTrait2<(B, Self::Item), Output=B>
28+
F: MyTrait2<(B, Self::Item), Output = B>,
2429
{
2530
loop {}
2631
}
@@ -32,7 +37,7 @@ pub trait MyFuture {
3237

3338
pub trait MyIntoFuture {
3439
type Output;
35-
type Fut: MyFuture<Output=Self::Output>;
40+
type Fut: MyFuture<Output = Self::Output>;
3641
fn into_future(self) -> Self::Fut;
3742
fn into_future_2(self, other: Self) -> Self::Fut;
3843
}

tests/rustdoc-js/assoc-type-loop.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#![crate_name="foo"]
1+
#![crate_name = "foo"]
22

33
// reduced from sqlx 0.7.3
44
use std::future::Future;
5-
use std::pin::Pin;
65
use std::ops::{Deref, DerefMut};
6+
use std::pin::Pin;
77
pub enum Error {}
88
pub trait Acquire<'c> {
99
type Database: Database;
@@ -16,7 +16,7 @@ pub trait Connection {
1616
type Database: Database;
1717
type Options: ConnectionOptions<Connection = Self>;
1818
fn begin(
19-
&mut self
19+
&mut self,
2020
) -> Pin<Box<dyn Future<Output = Result<Transaction<'_, Self::Database>, Error>> + Send + '_>>
2121
where
2222
Self: Sized;
@@ -28,7 +28,8 @@ pub struct Transaction<'c, DB: Database> {
2828
_db: &'c DB,
2929
}
3030
impl<'t, 'c, DB: Database> Acquire<'t> for &'t mut Transaction<'c, DB>
31-
where <DB as Database>::Connection: Send
31+
where
32+
<DB as Database>::Connection: Send,
3233
{
3334
type Database = DB;
3435
type Connection = &'t mut <DB as Database>::Connection;

0 commit comments

Comments
 (0)