Skip to content

Commit 18184d8

Browse files
committed
Format all tests in example/
1 parent 53d4428 commit 18184d8

11 files changed

+111
-312
lines changed

.github/workflows/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
run: |
2121
cargo fmt --check
2222
rustfmt --check build_system/mod.rs
23+
rustfmt --check example/*
2324
2425
2526
test:

example/arbitrary_self_types_pointers_and_wrappers.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#![feature(arbitrary_self_types, unsize, coerce_unsized, dispatch_from_dyn)]
44

55
use std::{
6-
ops::{Deref, CoerceUnsized, DispatchFromDyn},
76
marker::Unsize,
7+
ops::{CoerceUnsized, Deref, DispatchFromDyn},
88
};
99

1010
struct Ptr<T: ?Sized>(Box<T>);
@@ -33,7 +33,6 @@ impl<T: ?Sized> Deref for Wrapper<T> {
3333
impl<T: CoerceUnsized<U>, U> CoerceUnsized<Wrapper<U>> for Wrapper<T> {}
3434
impl<T: DispatchFromDyn<U>, U> DispatchFromDyn<Wrapper<U>> for Wrapper<T> {}
3535

36-
3736
trait Trait {
3837
// This method isn't object-safe yet. Unsized by-value `self` is object-safe (but not callable
3938
// without unsized_locals), but wrappers around `Self` currently are not.

example/dst-field-align.rs

+20-21
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,65 @@
22
#![allow(dead_code)]
33
struct Foo<T: ?Sized> {
44
a: u16,
5-
b: T
5+
b: T,
66
}
77

88
trait Bar {
99
fn get(&self) -> usize;
1010
}
1111

1212
impl Bar for usize {
13-
fn get(&self) -> usize { *self }
13+
fn get(&self) -> usize {
14+
*self
15+
}
1416
}
1517

1618
struct Baz<T: ?Sized> {
17-
a: T
19+
a: T,
1820
}
1921

2022
struct HasDrop<T: ?Sized> {
2123
ptr: Box<usize>,
22-
data: T
24+
data: T,
2325
}
2426

2527
fn main() {
2628
// Test that zero-offset works properly
27-
let b : Baz<usize> = Baz { a: 7 };
29+
let b: Baz<usize> = Baz { a: 7 };
2830
assert_eq!(b.a.get(), 7);
29-
let b : &Baz<dyn Bar> = &b;
31+
let b: &Baz<dyn Bar> = &b;
3032
assert_eq!(b.a.get(), 7);
3133

3234
// Test that the field is aligned properly
33-
let f : Foo<usize> = Foo { a: 0, b: 11 };
35+
let f: Foo<usize> = Foo { a: 0, b: 11 };
3436
assert_eq!(f.b.get(), 11);
35-
let ptr1 : *const u8 = &f.b as *const _ as *const u8;
37+
let ptr1: *const u8 = &f.b as *const _ as *const u8;
3638

37-
let f : &Foo<dyn Bar> = &f;
38-
let ptr2 : *const u8 = &f.b as *const _ as *const u8;
39+
let f: &Foo<dyn Bar> = &f;
40+
let ptr2: *const u8 = &f.b as *const _ as *const u8;
3941
assert_eq!(f.b.get(), 11);
4042

4143
// The pointers should be the same
4244
assert_eq!(ptr1, ptr2);
4345

4446
// Test that nested DSTs work properly
45-
let f : Foo<Foo<usize>> = Foo { a: 0, b: Foo { a: 1, b: 17 }};
47+
let f: Foo<Foo<usize>> = Foo { a: 0, b: Foo { a: 1, b: 17 } };
4648
assert_eq!(f.b.b.get(), 17);
47-
let f : &Foo<Foo<dyn Bar>> = &f;
49+
let f: &Foo<Foo<dyn Bar>> = &f;
4850
assert_eq!(f.b.b.get(), 17);
4951

5052
// Test that get the pointer via destructuring works
5153

52-
let f : Foo<usize> = Foo { a: 0, b: 11 };
53-
let f : &Foo<dyn Bar> = &f;
54+
let f: Foo<usize> = Foo { a: 0, b: 11 };
55+
let f: &Foo<dyn Bar> = &f;
5456
let &Foo { a: _, b: ref bar } = f;
5557
assert_eq!(bar.get(), 11);
5658

5759
// Make sure that drop flags don't screw things up
5860

59-
let d : HasDrop<Baz<[i32; 4]>> = HasDrop {
60-
ptr: Box::new(0),
61-
data: Baz { a: [1,2,3,4] }
62-
};
63-
assert_eq!([1,2,3,4], d.data.a);
61+
let d: HasDrop<Baz<[i32; 4]>> = HasDrop { ptr: Box::new(0), data: Baz { a: [1, 2, 3, 4] } };
62+
assert_eq!([1, 2, 3, 4], d.data.a);
6463

65-
let d : &HasDrop<Baz<[i32]>> = &d;
66-
assert_eq!(&[1,2,3,4], &d.data.a);
64+
let d: &HasDrop<Baz<[i32]>> = &d;
65+
assert_eq!(&[1, 2, 3, 4], &d.data.a);
6766
}

example/example.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ pub fn abc(a: u8) -> u8 {
1111
}
1212

1313
pub fn bcd(b: bool, a: u8) -> u8 {
14-
if b {
15-
a * 2
16-
} else {
17-
a * 3
18-
}
14+
if b { a * 2 } else { a * 3 }
1915
}
2016

2117
pub fn call() {

example/issue-72793.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
#![feature(type_alias_impl_trait)]
44

5-
trait T { type Item; }
5+
trait T {
6+
type Item;
7+
}
68

79
type Alias<'a> = impl T<Item = &'a ()>;
810

example/issue-91827-extern-types.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ impl<T, const N: usize> ListImpl<T, N> {
4040
}
4141
}
4242

43-
pub static A: ListImpl<u128, 3> = ListImpl {
44-
len: 3,
45-
data: [5, 6, 7],
46-
};
43+
pub static A: ListImpl<u128, 3> = ListImpl { len: 3, data: [5, 6, 7] };
4744
pub static A_REF: &'static List<u128> = A.as_list();
4845
pub static A_TAIL_OFFSET: isize = tail_offset(A.as_list());
4946

example/mini_core.rs

+27-14
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
3737
pub trait DispatchFromDyn<T> {}
3838

3939
// &T -> &U
40-
impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
40+
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
4141
// &mut T -> &mut U
42-
impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut T {}
42+
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut T {}
4343
// *const T -> *const U
44-
impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
44+
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
4545
// *mut T -> *mut U
46-
impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
46+
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
4747
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U>> for Box<T> {}
4848

4949
#[lang = "receiver"]
@@ -288,7 +288,6 @@ impl PartialEq for u32 {
288288
}
289289
}
290290

291-
292291
impl PartialEq for u64 {
293292
fn eq(&self, other: &u64) -> bool {
294293
(*self) == (*other)
@@ -361,7 +360,7 @@ impl<T: ?Sized> PartialEq for *const T {
361360
}
362361
}
363362

364-
impl <T: PartialEq> PartialEq for Option<T> {
363+
impl<T: PartialEq> PartialEq for Option<T> {
365364
fn eq(&self, other: &Self) -> bool {
366365
match (self, other) {
367366
(Some(lhs), Some(rhs)) => *lhs == *rhs,
@@ -472,7 +471,11 @@ pub fn panic(_msg: &'static str) -> ! {
472471
#[track_caller]
473472
fn panic_bounds_check(index: usize, len: usize) -> ! {
474473
unsafe {
475-
libc::printf("index out of bounds: the len is %d but the index is %d\n\0" as *const str as *const i8, len, index);
474+
libc::printf(
475+
"index out of bounds: the len is %d but the index is %d\n\0" as *const str as *const i8,
476+
len,
477+
index,
478+
);
476479
intrinsics::abort();
477480
}
478481
}
@@ -599,7 +602,7 @@ pub mod libc {
599602
// functions. legacy_stdio_definitions.lib which provides the printf wrapper functions as normal
600603
// symbols to link against.
601604
#[cfg_attr(unix, link(name = "c"))]
602-
#[cfg_attr(target_env="msvc", link(name="legacy_stdio_definitions"))]
605+
#[cfg_attr(target_env = "msvc", link(name = "legacy_stdio_definitions"))]
603606
extern "C" {
604607
pub fn printf(format: *const i8, ...) -> i32;
605608
}
@@ -638,7 +641,7 @@ impl<T> Index<usize> for [T] {
638641
}
639642
}
640643

641-
extern {
644+
extern "C" {
642645
type VaListImpl;
643646
}
644647

@@ -648,23 +651,33 @@ pub struct VaList<'a>(&'a mut VaListImpl);
648651

649652
#[rustc_builtin_macro]
650653
#[rustc_macro_transparency = "semitransparent"]
651-
pub macro stringify($($t:tt)*) { /* compiler built-in */ }
654+
pub macro stringify($($t:tt)*) {
655+
/* compiler built-in */
656+
}
652657

653658
#[rustc_builtin_macro]
654659
#[rustc_macro_transparency = "semitransparent"]
655-
pub macro file() { /* compiler built-in */ }
660+
pub macro file() {
661+
/* compiler built-in */
662+
}
656663

657664
#[rustc_builtin_macro]
658665
#[rustc_macro_transparency = "semitransparent"]
659-
pub macro line() { /* compiler built-in */ }
666+
pub macro line() {
667+
/* compiler built-in */
668+
}
660669

661670
#[rustc_builtin_macro]
662671
#[rustc_macro_transparency = "semitransparent"]
663-
pub macro cfg() { /* compiler built-in */ }
672+
pub macro cfg() {
673+
/* compiler built-in */
674+
}
664675

665676
#[rustc_builtin_macro]
666677
#[rustc_macro_transparency = "semitransparent"]
667-
pub macro global_asm() { /* compiler built-in */ }
678+
pub macro global_asm() {
679+
/* compiler built-in */
680+
}
668681

669682
pub static A_STATIC: u8 = 42;
670683

0 commit comments

Comments
 (0)