Skip to content

Commit 6d9cf69

Browse files
authored
CI - rustfmt instead of cargo fmt (#4595)
# Description of Changes `cargo ci lint` was running `cargo fmt`, but that didn't pick up all files. As a result, our pre-commit hook (which just runs `rustfmt` on any changed `.rs` files) would change otherwise-untouched files in merge commits. This PR addresses that discrepancy by having `cargo ci lint` run `rustfmt` on all tracked `.rs` files. The entire diff is just `rustfmt` changes except for the changes in `tools/ci/src/main.rs`. # API and ABI breaking changes <!-- If this is an API or ABI breaking change, please apply the corresponding GitHub label. --> # Expected complexity level and risk 2 # Testing - [x] `cargo ci lint` fails - [x] `cargo ci lint` passes after running `rustfmt` on everything - [x] `cargo fmt --all` doesn't cause any diff after doing the above --------- Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
1 parent de9505c commit 6d9cf69

31 files changed

Lines changed: 499 additions & 343 deletions

File tree

crates/bindings/tests/ui/views.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ fn sched_table_view(_: &ViewContext, _args: ScheduledTable) -> Vec<PlayerInfo> {
144144
vec![]
145145
}
146146

147-
148147
#[table(accessor = player_info)]
149148
struct PlayerInfo {
150149
#[unique]

crates/bindings/tests/ui/views.stderr

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,20 @@ error[E0425]: cannot find type `ScheduledTable` in this scope
6161
| ^^^^^^^^^^^^^^ not found in this scope
6262

6363
error[E0425]: cannot find type `T` in this scope
64-
--> tests/ui/views.rs:202:60
64+
--> tests/ui/views.rs:201:60
6565
|
66-
202 | fn view_nonexistent_table(ctx: &ViewContext) -> impl Query<T> {
66+
201 | fn view_nonexistent_table(ctx: &ViewContext) -> impl Query<T> {
6767
| ^ not found in this scope
6868
|
6969
help: you might be missing a type parameter
7070
|
71-
202 | fn view_nonexistent_table<T>(ctx: &ViewContext) -> impl Query<T> {
71+
201 | fn view_nonexistent_table<T>(ctx: &ViewContext) -> impl Query<T> {
7272
| +++
7373

7474
error[E0425]: cannot find type `T` in this scope
75-
--> tests/ui/views.rs:202:60
75+
--> tests/ui/views.rs:201:60
7676
|
77-
202 | fn view_nonexistent_table(ctx: &ViewContext) -> impl Query<T> {
77+
201 | fn view_nonexistent_table(ctx: &ViewContext) -> impl Query<T> {
7878
| ^ not found in this scope
7979

8080
error[E0277]: the trait bound `ViewKind<ReducerContext>: ViewKindTrait` is not satisfied
@@ -411,9 +411,9 @@ help: the trait `SpacetimeType` is not implemented for `NotSpacetimeType`
411411
= note: required for `Option<NotSpacetimeType>` to implement `SpacetimeType`
412412

413413
error[E0277]: the trait bound `{integer}: RHS<Player, spacetimedb::Identity>` is not satisfied
414-
--> tests/ui/views.rs:160:49
414+
--> tests/ui/views.rs:159:49
415415
|
416-
160 | ctx.from.player().r#where(|a| a.identity.eq(42)).build()
416+
159 | ctx.from.player().r#where(|a| a.identity.eq(42)).build()
417417
| -- ^^ the trait `RHS<Player, spacetimedb::Identity>` is not implemented for `{integer}`
418418
| |
419419
| required by a bound introduced by this call
@@ -435,9 +435,9 @@ note: required by a bound in `Col::<T, V>::eq`
435435
| ^^^^^^^^^ required by this bound in `Col::<T, V>::eq`
436436

437437
error[E0277]: the trait bound `u32: RHS<PlayerInfo, u8>` is not satisfied
438-
--> tests/ui/views.rs:166:49
438+
--> tests/ui/views.rs:165:49
439439
|
440-
166 | ctx.from.player_info().r#where(|a| a.age.eq(4200u32)).build()
440+
165 | ctx.from.player_info().r#where(|a| a.age.eq(4200u32)).build()
441441
| -- ^^^^^^^ the trait `RHS<PlayerInfo, u8>` is not implemented for `u32`
442442
| |
443443
| required by a bound introduced by this call
@@ -457,9 +457,9 @@ note: required by a bound in `Col::<T, V>::eq`
457457
= note: this error originates in the macro `impl_rhs` (in Nightly builds, run with -Z macro-backtrace for more info)
458458

459459
error[E0308]: mismatched types
460-
--> tests/ui/views.rs:175:62
460+
--> tests/ui/views.rs:174:62
461461
|
462-
175 | .left_semijoin(ctx.from.player(), |a, b| a.weight.eq(b.identity))
462+
174 | .left_semijoin(ctx.from.player(), |a, b| a.weight.eq(b.identity))
463463
| -- ^^^^^^^^^^ expected `IxCol<Player, u32>`, found `IxCol<Player, Identity>`
464464
| |
465465
| arguments to this method are incorrect
@@ -473,15 +473,15 @@ note: method defined here
473473
| ^^
474474

475475
error[E0609]: no field `age` on type `&PlayerInfoIxCols`
476-
--> tests/ui/views.rs:185:72
476+
--> tests/ui/views.rs:184:72
477477
|
478-
185 | .right_semijoin(ctx.from.player_info(), |a, b| a.identity.eq(b.age))
478+
184 | .right_semijoin(ctx.from.player_info(), |a, b| a.identity.eq(b.age))
479479
| ^^^ unknown field
480480
|
481481
= note: available fields are: `identity`, `weight`
482482

483483
error[E0599]: no method named `xyz` found for struct `QueryBuilder` in the current scope
484-
--> tests/ui/views.rs:203:14
484+
--> tests/ui/views.rs:202:14
485485
|
486-
203 | ctx.from.xyz().build()
486+
202 | ctx.from.xyz().build()
487487
| ^^^ method not found in `QueryBuilder`

crates/smoketests/modules/add-remove-index-indexed/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
use spacetimedb::{ReducerContext, Table};
22

33
#[spacetimedb::table(accessor = t1)]
4-
pub struct T1 { #[index(btree)] id: u64 }
4+
pub struct T1 {
5+
#[index(btree)]
6+
id: u64,
7+
}
58

69
#[spacetimedb::table(accessor = t2)]
7-
pub struct T2 { #[index(btree)] id: u64 }
10+
pub struct T2 {
11+
#[index(btree)]
12+
id: u64,
13+
}
814

915
#[spacetimedb::reducer(init)]
1016
pub fn init(ctx: &ReducerContext) {

crates/smoketests/modules/add-remove-index/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
use spacetimedb::{ReducerContext, Table};
22

33
#[spacetimedb::table(accessor = t1)]
4-
pub struct T1 { id: u64 }
4+
pub struct T1 {
5+
id: u64,
6+
}
57

68
#[spacetimedb::table(accessor = t2)]
7-
pub struct T2 { id: u64 }
9+
pub struct T2 {
10+
id: u64,
11+
}
812

913
#[spacetimedb::reducer(init)]
1014
pub fn init(ctx: &ReducerContext) {

crates/smoketests/modules/call-reducer-procedure/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ pub fn say_hello(_ctx: &ReducerContext) {
1212

1313
#[spacetimedb::procedure]
1414
pub fn return_person(_ctx: &mut ProcedureContext) -> Person {
15-
return Person { name: "World".to_owned() };
15+
return Person {
16+
name: "World".to_owned(),
17+
};
1618
}

crates/smoketests/modules/delete-database/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use spacetimedb::{ReducerContext, Table, duration};
1+
use spacetimedb::{duration, ReducerContext, Table};
22

33
#[spacetimedb::table(accessor = counter, public)]
44
pub struct Counter {
55
#[primary_key]
66
id: u64,
7-
val: u64
7+
val: u64,
88
}
99

1010
#[spacetimedb::table(accessor = scheduled_counter, public, scheduled(inc, at = sched_at))]

crates/smoketests/modules/filtering/src/lib.rs

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,24 @@ pub struct Person {
1313

1414
#[spacetimedb::reducer]
1515
pub fn insert_person(ctx: &ReducerContext, id: i32, name: String, nick: String) {
16-
ctx.db.person().insert(Person { id, name, nick} );
16+
ctx.db.person().insert(Person { id, name, nick });
1717
}
1818

1919
#[spacetimedb::reducer]
2020
pub fn insert_person_twice(ctx: &ReducerContext, id: i32, name: String, nick: String) {
2121
// We'd like to avoid an error due to a set-semantic error.
2222
let name2 = format!("{name}2");
23-
ctx.db.person().insert(Person { id, name, nick: nick.clone()} );
24-
match ctx.db.person().try_insert(Person { id, name: name2, nick: nick.clone()}) {
25-
Ok(_) => {},
23+
ctx.db.person().insert(Person {
24+
id,
25+
name,
26+
nick: nick.clone(),
27+
});
28+
match ctx.db.person().try_insert(Person {
29+
id,
30+
name: name2,
31+
nick: nick.clone(),
32+
}) {
33+
Ok(_) => {}
2634
Err(_) => {
2735
log::info!("UNIQUE CONSTRAINT VIOLATION ERROR: id = {}, nick = {}", id, nick)
2836
}
@@ -85,7 +93,7 @@ pub struct NonuniquePerson {
8593

8694
#[spacetimedb::reducer]
8795
pub fn insert_nonunique_person(ctx: &ReducerContext, id: i32, name: String, is_human: bool) {
88-
ctx.db.nonunique_person().insert(NonuniquePerson { id, name, is_human } );
96+
ctx.db.nonunique_person().insert(NonuniquePerson { id, name, is_human });
8997
}
9098

9199
#[spacetimedb::reducer]
@@ -158,7 +166,11 @@ struct IndexedPerson {
158166

159167
#[spacetimedb::reducer]
160168
fn insert_indexed_person(ctx: &ReducerContext, id: i32, given_name: String, surname: String) {
161-
ctx.db.indexed_person().insert(IndexedPerson { id, given_name, surname });
169+
ctx.db.indexed_person().insert(IndexedPerson {
170+
id,
171+
given_name,
172+
surname,
173+
});
162174
}
163175

164176
#[spacetimedb::reducer]
@@ -169,14 +181,24 @@ fn delete_indexed_person(ctx: &ReducerContext, id: i32) {
169181
#[spacetimedb::reducer]
170182
fn find_indexed_people(ctx: &ReducerContext, surname: String) {
171183
for person in ctx.db.indexed_person().surname().filter(&surname) {
172-
log::info!("INDEXED FOUND: id {}: {}, {}", person.id, person.surname, person.given_name);
184+
log::info!(
185+
"INDEXED FOUND: id {}: {}, {}",
186+
person.id,
187+
person.surname,
188+
person.given_name
189+
);
173190
}
174191
}
175192

176193
#[spacetimedb::reducer]
177194
fn find_indexed_people_read_only(ctx: &ReducerContext, surname: String) {
178195
let ctx = ctx.as_read_only();
179196
for person in ctx.db.indexed_person().surname().filter(&surname) {
180-
log::info!("INDEXED FOUND: id {}: {}, {}", person.id, person.surname, person.given_name);
197+
log::info!(
198+
"INDEXED FOUND: id {}: {}, {}",
199+
person.id,
200+
person.surname,
201+
person.given_name
202+
);
181203
}
182204
}

crates/smoketests/modules/module-nested-op/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ pub struct Friends {
1515

1616
#[spacetimedb::reducer]
1717
pub fn create_account(ctx: &ReducerContext, account_id: i32, name: String) {
18-
ctx.db.account().insert(Account { id: account_id, name } );
18+
ctx.db.account().insert(Account { id: account_id, name });
1919
}
2020

2121
#[spacetimedb::reducer]
2222
pub fn add_friend(ctx: &ReducerContext, my_id: i32, their_id: i32) {
2323
// Make sure our friend exists
2424
for account in ctx.db.account().iter() {
2525
if account.id == their_id {
26-
ctx.db.friends().insert(Friends { friend_1: my_id, friend_2: their_id });
26+
ctx.db.friends().insert(Friends {
27+
friend_1: my_id,
28+
friend_2: their_id,
29+
});
2730
return;
2831
}
2932
}

crates/smoketests/modules/new-user-flow/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use spacetimedb::{log, ReducerContext, Table};
22

33
#[spacetimedb::table(accessor = person)]
44
pub struct Person {
5-
name: String
5+
name: String,
66
}
77

88
#[spacetimedb::reducer]

crates/smoketests/modules/pg-wire/src/lib.rs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use spacetimedb::sats::{i256, u256};
2-
use spacetimedb::{ConnectionId, Identity, ReducerContext, SpacetimeType, Table, Timestamp, TimeDuration, Uuid};
2+
use spacetimedb::{ConnectionId, Identity, ReducerContext, SpacetimeType, Table, TimeDuration, Timestamp, Uuid};
33

44
#[derive(Copy, Clone)]
55
#[spacetimedb::table(accessor = t_ints, public)]
@@ -50,7 +50,7 @@ pub struct TOthers {
5050

5151
#[spacetimedb::table(accessor = t_others_tuple, public)]
5252
pub struct TOthersTuple {
53-
tuple: TOthers
53+
tuple: TOthers,
5454
}
5555

5656
#[derive(SpacetimeType, Debug, Clone, Copy)]
@@ -79,9 +79,9 @@ pub struct TEnum {
7979

8080
#[spacetimedb::table(accessor = t_nested, public)]
8181
pub struct TNested {
82-
en: TEnum,
83-
se: TSimpleEnum,
84-
ints: TInts,
82+
en: TEnum,
83+
se: TSimpleEnum,
84+
ints: TInts,
8585
}
8686

8787
#[derive(Clone)]
@@ -127,7 +127,7 @@ pub fn test(ctx: &ReducerContext) {
127127
f32: 594806.58906,
128128
f64: -3454353.345389043278459,
129129
str: "This is spacetimedb".to_string(),
130-
bytes: vec!(1, 2, 3, 4, 5, 6, 7),
130+
bytes: vec![1, 2, 3, 4, 5, 6, 7],
131131
identity: Identity::ONE,
132132
connection_id: ConnectionId::ZERO,
133133
timestamp: Timestamp::UNIX_EPOCH,
@@ -137,14 +137,29 @@ pub fn test(ctx: &ReducerContext) {
137137
ctx.db.t_others().insert(tuple.clone());
138138
ctx.db.t_others_tuple().insert(TOthersTuple { tuple });
139139

140-
ctx.db.t_simple_enum().insert(TSimpleEnum { id: 1, action: Action::Inactive });
141-
ctx.db.t_simple_enum().insert(TSimpleEnum { id: 2, action: Action::Active });
140+
ctx.db.t_simple_enum().insert(TSimpleEnum {
141+
id: 1,
142+
action: Action::Inactive,
143+
});
144+
ctx.db.t_simple_enum().insert(TSimpleEnum {
145+
id: 2,
146+
action: Action::Active,
147+
});
142148

143-
ctx.db.t_enum().insert(TEnum { id: 1, color: Color::Gray(128) });
149+
ctx.db.t_enum().insert(TEnum {
150+
id: 1,
151+
color: Color::Gray(128),
152+
});
144153

145154
ctx.db.t_nested().insert(TNested {
146-
en: TEnum { id: 1, color: Color::Gray(128) },
147-
se: TSimpleEnum { id: 2, action: Action::Active },
155+
en: TEnum {
156+
id: 1,
157+
color: Color::Gray(128),
158+
},
159+
se: TSimpleEnum {
160+
id: 2,
161+
action: Action::Active,
162+
},
148163
ints,
149164
});
150165

0 commit comments

Comments
 (0)