Skip to content

Commit c6fb703

Browse files
committed
rustfmt tests/rustdoc-js/.
1 parent 98d65d6 commit c6fb703

28 files changed

+240
-133
lines changed

rustfmt.toml

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ ignore = [
1919
"/tests/run-make/translation/test.rs", # This test contains syntax errors.
2020
"/tests/rustdoc/", # Some have syntax errors, some are whitespace-sensitive.
2121
"/tests/rustdoc-gui/", # Some tests are sensitive to source code layout.
22-
"/tests/rustdoc-js/",
2322
"/tests/rustdoc-json/",
2423
"/tests/rustdoc-js-std/",
2524
"/tests/rustdoc-ui/",

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;

tests/rustdoc-js/auxiliary/interner.rs

+27-40
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,14 @@ pub trait Interner: Sized {
7777
type ClosureKind: Copy + Debug + Hash + Eq;
7878

7979
// Required method
80-
fn mk_canonical_var_infos(
81-
self,
82-
infos: &[CanonicalVarInfo<Self>]
83-
) -> Self::CanonicalVars;
80+
fn mk_canonical_var_infos(self, infos: &[CanonicalVarInfo<Self>]) -> Self::CanonicalVars;
8481
}
8582

8683
pub trait DebugWithInfcx<I: Interner>: Debug {
8784
// Required method
8885
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
8986
this: WithInfcx<'_, Infcx, &Self>,
90-
f: &mut Formatter<'_>
87+
f: &mut Formatter<'_>,
9188
) -> std::fmt::Result;
9289
}
9390

@@ -130,11 +127,7 @@ pub struct TypeFlags;
130127

131128
pub trait Ty<I: Interner<Ty = Self>> {
132129
// Required method
133-
fn new_anon_bound(
134-
interner: I,
135-
debruijn: DebruijnIndex,
136-
var: BoundVar
137-
) -> Self;
130+
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar) -> Self;
138131
}
139132

140133
pub trait PlaceholderLike {
@@ -152,12 +145,7 @@ pub struct BoundVar;
152145
pub struct ConstKind<I>(std::marker::PhantomData<I>);
153146
pub trait Const<I: Interner<Const = Self>> {
154147
// Required method
155-
fn new_anon_bound(
156-
interner: I,
157-
debruijn: DebruijnIndex,
158-
var: BoundVar,
159-
ty: I::Ty
160-
) -> Self;
148+
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar, ty: I::Ty) -> Self;
161149
}
162150

163151
pub trait ConstTy<I: Interner> {
@@ -170,25 +158,28 @@ pub struct DebruijnIndex;
170158
pub struct RegionKind<I>(std::marker::PhantomData<I>);
171159
pub trait Region<I: Interner<Region = Self>> {
172160
// Required method
173-
fn new_anon_bound(
174-
interner: I,
175-
debruijn: DebruijnIndex,
176-
var: BoundVar
177-
) -> Self;
161+
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar) -> Self;
178162
}
179163

180164
pub trait TypeVisitor<I: Interner>: Sized {
181165
type Result: VisitorResult = ();
182166

183167
// Provided methods
184-
fn visit_binder<T: TypeVisitable<I>>(
185-
&mut self,
186-
t: &I::Binder<T>
187-
) -> Self::Result { unimplemented!() }
188-
fn visit_ty(&mut self, t: I::Ty) -> Self::Result { unimplemented!() }
189-
fn visit_region(&mut self, _r: I::Region) -> Self::Result { unimplemented!() }
190-
fn visit_const(&mut self, c: I::Const) -> Self::Result { unimplemented!() }
191-
fn visit_predicate(&mut self, p: I::Predicate) -> Self::Result { unimplemented!() }
168+
fn visit_binder<T: TypeVisitable<I>>(&mut self, t: &I::Binder<T>) -> Self::Result {
169+
unimplemented!()
170+
}
171+
fn visit_ty(&mut self, t: I::Ty) -> Self::Result {
172+
unimplemented!()
173+
}
174+
fn visit_region(&mut self, _r: I::Region) -> Self::Result {
175+
unimplemented!()
176+
}
177+
fn visit_const(&mut self, c: I::Const) -> Self::Result {
178+
unimplemented!()
179+
}
180+
fn visit_predicate(&mut self, p: I::Predicate) -> Self::Result {
181+
unimplemented!()
182+
}
192183
}
193184

194185
pub trait VisitorResult {
@@ -206,7 +197,9 @@ impl VisitorResult for () {
206197
fn output() -> Self {}
207198
fn from_residual(_: Self::Residual) -> Self {}
208199
fn from_branch(_: ControlFlow<Self::Residual>) -> Self {}
209-
fn branch(self) -> ControlFlow<Self::Residual> { ControlFlow::Continue(()) }
200+
fn branch(self) -> ControlFlow<Self::Residual> {
201+
ControlFlow::Continue(())
202+
}
210203
}
211204

212205
pub struct WithInfcx<'a, Infcx: InferCtxtLike, T> {
@@ -221,24 +214,18 @@ pub trait InferCtxtLike {
221214
fn interner(&self) -> Self::Interner;
222215
fn universe_of_ty(&self, ty: TyVid) -> Option<UniverseIndex>;
223216
fn root_ty_var(&self, vid: TyVid) -> TyVid;
224-
fn probe_ty_var(
225-
&self,
226-
vid: TyVid
227-
) -> Option<<Self::Interner as Interner>::Ty>;
217+
fn probe_ty_var(&self, vid: TyVid) -> Option<<Self::Interner as Interner>::Ty>;
228218
fn universe_of_lt(
229219
&self,
230-
lt: <Self::Interner as Interner>::InferRegion
220+
lt: <Self::Interner as Interner>::InferRegion,
231221
) -> Option<UniverseIndex>;
232222
fn opportunistic_resolve_lt_var(
233223
&self,
234-
vid: <Self::Interner as Interner>::InferRegion
224+
vid: <Self::Interner as Interner>::InferRegion,
235225
) -> Option<<Self::Interner as Interner>::Region>;
236226
fn universe_of_ct(&self, ct: ConstVid) -> Option<UniverseIndex>;
237227
fn root_ct_var(&self, vid: ConstVid) -> ConstVid;
238-
fn probe_ct_var(
239-
&self,
240-
vid: ConstVid
241-
) -> Option<<Self::Interner as Interner>::Const>;
228+
fn probe_ct_var(&self, vid: ConstVid) -> Option<<Self::Interner as Interner>::Const>;
242229
}
243230

244231
pub struct TyVid;

tests/rustdoc-js/doc-alias.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ impl Trait for Struct {
1616
const AssociatedConst: i32 = 12;
1717

1818
#[doc(alias = "ImplTraitFunction")]
19-
fn function() -> Self::Target { 0 }
19+
fn function() -> Self::Target {
20+
0
21+
}
2022
}
2123

2224
#[doc(alias = "EnumItem")]
@@ -71,5 +73,5 @@ impl Union {
7173
#[doc(alias = "MacroItem")]
7274
#[macro_export]
7375
macro_rules! Macro {
74-
() => {}
76+
() => {};
7577
}

tests/rustdoc-js/enum-variant-not-type.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ pub trait MyTrait {
55
fn not_appearing(&self) -> Option<&Self::T>;
66
}
77

8-
pub fn my_fn<X>(t: X) -> X { t }
8+
pub fn my_fn<X>(t: X) -> X {
9+
t
10+
}
911

1012
pub trait AutoCorrectConfounder {
1113
type InsertUnnecessarilyLongTypeNameHere;
12-
fn assoc_type_acts_like_generic(&self, x: &Self::InsertUnnecessarilyLongTypeNameHere)
13-
-> Option<&Self::InsertUnnecessarilyLongTypeNameHere>;
14+
fn assoc_type_acts_like_generic(
15+
&self,
16+
x: &Self::InsertUnnecessarilyLongTypeNameHere,
17+
) -> Option<&Self::InsertUnnecessarilyLongTypeNameHere>;
1418
}

tests/rustdoc-js/foreign-type-path.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
pub mod aaaaaaa {
44

5-
extern {
5+
extern "C" {
66
pub type MyForeignType;
77
}
88

99
impl MyForeignType {
1010
pub fn my_method() {}
1111
}
12-
1312
}

tests/rustdoc-js/full-path-function.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@ pub mod sac {
22
pub struct Sac;
33

44
impl Sac {
5-
pub fn len(&self) -> usize { 0 }
5+
pub fn len(&self) -> usize {
6+
0
7+
}
68
}
79
}
810

911
pub mod b {
1012
pub struct Sac;
1113
impl Sac {
12-
pub fn len(&self) -> usize { 0 }
13-
pub fn bar(&self, w: u32) -> usize { 0 }
14-
pub fn bar2(&self, w: u32) -> u32 { 0 }
15-
pub fn string(w: String) -> u32 { 0 }
14+
pub fn len(&self) -> usize {
15+
0
16+
}
17+
pub fn bar(&self, w: u32) -> usize {
18+
0
19+
}
20+
pub fn bar2(&self, w: u32) -> u32 {
21+
0
22+
}
23+
pub fn string(w: String) -> u32 {
24+
0
25+
}
1626
}
1727
}

tests/rustdoc-js/gat.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ pub trait Foo {
22
type Assoc<T>;
33
}
44

5-
pub fn sample<X: Foo<Assoc<u8> = u8>>(_: X) -> u32 { loop {} }
6-
pub fn synergy(_: impl Foo<Assoc<u8> = u8>) -> ! { loop {} }
7-
pub fn consider(_: impl Foo<Assoc<u8> = u32>) -> bool { loop {} }
8-
pub fn integrate<T>(_: impl Foo<Assoc<T> = T>) -> T { loop {} }
5+
pub fn sample<X: Foo<Assoc<u8> = u8>>(_: X) -> u32 {
6+
loop {}
7+
}
8+
pub fn synergy(_: impl Foo<Assoc<u8> = u8>) -> ! {
9+
loop {}
10+
}
11+
pub fn consider(_: impl Foo<Assoc<u8> = u32>) -> bool {
12+
loop {}
13+
}
14+
pub fn integrate<T>(_: impl Foo<Assoc<T> = T>) -> T {
15+
loop {}
16+
}

tests/rustdoc-js/generics-impl.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::io::{Result as IoResult, Read};
1+
use std::io::{Read, Result as IoResult};
22

33
pub struct Aaaaaaa;
44

@@ -29,7 +29,10 @@ impl<T: Read> Ddddddd<T> {
2929
pub fn ggggggg(self) -> u64 {
3030
1
3131
}
32-
pub fn hhhhhhh() -> Self where T: Default {
32+
pub fn hhhhhhh() -> Self
33+
where
34+
T: Default,
35+
{
3336
Ddddddd(T::default())
3437
}
3538
}

tests/rustdoc-js/generics-trait.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
pub trait SomeTrait {}
22
pub trait OtherThingxxxxxxxx {}
33

4-
pub fn alef<T: OtherThingxxxxxxxx>() -> Result<T, ()> { loop {} }
5-
pub fn bet<T: SomeTrait>() -> Result<T, ()> { loop {} }
4+
pub fn alef<T: OtherThingxxxxxxxx>() -> Result<T, ()> {
5+
loop {}
6+
}
7+
pub fn bet<T: SomeTrait>() -> Result<T, ()> {
8+
loop {}
9+
}
610

7-
pub fn alpha<T: OtherThingxxxxxxxx>(_param: Result<T, ()>) { loop {} }
8-
pub fn beta<T: SomeTrait>(_param: Result<T, ()>) { loop {} }
11+
pub fn alpha<T: OtherThingxxxxxxxx>(_param: Result<T, ()>) {
12+
loop {}
13+
}
14+
pub fn beta<T: SomeTrait>(_param: Result<T, ()>) {
15+
loop {}
16+
}

0 commit comments

Comments
 (0)