Skip to content

Commit f6d06e0

Browse files
Merge pull request #674 from swimos/rust-1.79
Updates for Rust 1.79.0
2 parents f1d3d6d + fd6a084 commit f6d06e0

File tree

9 files changed

+53
-113
lines changed

9 files changed

+53
-113
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
name: Continuous integration
77
env:
8-
latest_version: "1.78.0"
8+
latest_version: "1.79.0"
99

1010
jobs:
1111
test:

api/swimos_form/tests/enumeration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ fn annotated() {
626626
let ex = ExampleAnnotated::A {
627627
count: 1033,
628628
name: String::from("bob"),
629-
age: i32::max_value(),
629+
age: i32::MAX,
630630
};
631631

632632
let expected = Value::Record(

api/swimos_model/src/num.rs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,14 @@ mod tests {
8484

8585
#[test]
8686
fn much_less() {
87-
assert_eq!(cmp_i32_u32(10, u32::max_value()), Ordering::Less);
88-
assert_eq!(cmp_u32_i32(10, i32::max_value()), Ordering::Less);
87+
assert_eq!(cmp_i32_u32(10, u32::MAX), Ordering::Less);
88+
assert_eq!(cmp_u32_i32(10, i32::MAX), Ordering::Less);
8989
}
9090

9191
#[test]
9292
fn much_greater() {
93-
assert_eq!(
94-
cmp_i32_u32(i32::max_value(), u32::min_value()),
95-
Ordering::Greater
96-
);
97-
assert_eq!(
98-
cmp_u32_i32(u32::max_value(), i32::min_value()),
99-
Ordering::Greater
100-
);
93+
assert_eq!(cmp_i32_u32(i32::MAX, u32::MIN), Ordering::Greater);
94+
assert_eq!(cmp_u32_i32(u32::MAX, i32::MIN), Ordering::Greater);
10195
}
10296
}
10397

@@ -125,20 +119,14 @@ mod tests {
125119

126120
#[test]
127121
fn much_less() {
128-
assert_eq!(cmp_i64_u64(10, u64::max_value()), Ordering::Less);
129-
assert_eq!(cmp_u64_i64(10, i64::max_value()), Ordering::Less);
122+
assert_eq!(cmp_i64_u64(10, u64::MAX), Ordering::Less);
123+
assert_eq!(cmp_u64_i64(10, i64::MAX), Ordering::Less);
130124
}
131125

132126
#[test]
133127
fn much_greater() {
134-
assert_eq!(
135-
cmp_i64_u64(i64::max_value(), u64::min_value()),
136-
Ordering::Greater
137-
);
138-
assert_eq!(
139-
cmp_u64_i64(u64::max_value(), i64::min_value()),
140-
Ordering::Greater
141-
);
128+
assert_eq!(cmp_i64_u64(i64::MAX, u64::MIN), Ordering::Greater);
129+
assert_eq!(cmp_u64_i64(u64::MAX, i64::MIN), Ordering::Greater);
142130
}
143131
}
144132
}

runtime/swimos_remote/src/tls/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ impl CryptoProviderConfig {
4343
CryptoProviderConfig::FromFeatureFlags => {
4444
#[cfg(all(feature = "ring_provider", not(feature = "aws_lc_rs_provider")))]
4545
{
46-
return Arc::new(rustls::crypto::ring::default_provider());
46+
return Ok(Arc::new(rustls::crypto::ring::default_provider()));
4747
}
4848

4949
#[cfg(all(feature = "aws_lc_rs_provider", not(feature = "ring_provider")))]
5050
{
51-
return Arc::new(rustls::crypto::aws_lc_rs::default_provider());
51+
return Ok(Arc::new(rustls::crypto::aws_lc_rs::default_provider()));
5252
}
5353

5454
#[allow(unreachable_code)]

runtime/swimos_runtime/src/agent/task/init/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,7 @@ where
462462
http_lane_endpoints,
463463
store_endpoints,
464464
} = endpoints;
465-
let mut initializers: FuturesUnordered<ItemInitTask<'_, Store::StoreId>> =
466-
FuturesUnordered::new();
465+
let mut initializers: FuturesUnordered<ItemInitTask<'_>> = FuturesUnordered::new();
467466
loop {
468467
let event = tokio::select! {
469468
Some(item_init_done) = initializers.next(), if !initializers.is_empty() => Either::Left(item_init_done),
@@ -502,7 +501,10 @@ where
502501
if let Some(init) =
503502
initialization.add_lane(store, name.clone(), kind, config, promise)
504503
{
505-
initializers.push(init.map_ok(Into::into).boxed());
504+
initializers.push(
505+
init.map_ok(|(endpoint, _)| ItemEndpoint::Lane { endpoint })
506+
.boxed(),
507+
);
506508
}
507509
}
508510
AgentRuntimeRequest::AddStore(StoreRuntimeSpec {
@@ -515,7 +517,10 @@ where
515517
if let Some(init) =
516518
initialization.add_store(store, name.clone(), kind, config, promise)?
517519
{
518-
initializers.push(init.map_ok(Into::into).boxed());
520+
initializers.push(
521+
init.map_ok(|(endpoint, _)| ItemEndpoint::Store { endpoint })
522+
.boxed(),
523+
);
519524
}
520525
}
521526
AgentRuntimeRequest::OpenDownlink(request) => {

runtime/swimos_runtime/src/agent/task/mod.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,35 +1108,17 @@ struct InactiveTimeout<'a> {
11081108
enabled: bool,
11091109
}
11101110

1111-
pub enum ItemEndpoint<I> {
1112-
Lane {
1113-
endpoint: LaneEndpoint<Io>,
1114-
store_id: Option<I>,
1115-
},
1116-
Store {
1117-
endpoint: StoreEndpoint,
1118-
store_id: I,
1119-
},
1120-
}
1121-
1122-
impl<I> From<(LaneEndpoint<Io>, Option<I>)> for ItemEndpoint<I> {
1123-
fn from((endpoint, store_id): (LaneEndpoint<Io>, Option<I>)) -> Self {
1124-
ItemEndpoint::Lane { endpoint, store_id }
1125-
}
1126-
}
1127-
1128-
impl<I> From<(StoreEndpoint, I)> for ItemEndpoint<I> {
1129-
fn from((endpoint, store_id): (StoreEndpoint, I)) -> Self {
1130-
ItemEndpoint::Store { endpoint, store_id }
1131-
}
1111+
pub enum ItemEndpoint {
1112+
Lane { endpoint: LaneEndpoint<Io> },
1113+
Store { endpoint: StoreEndpoint },
11321114
}
11331115

11341116
type InitResult<T> = Result<T, AgentItemInitError>;
11351117

11361118
type LaneResult<I> = InitResult<(LaneEndpoint<Io>, Option<I>)>;
11371119
type StoreResult<I> = InitResult<(StoreEndpoint, I)>;
11381120

1139-
type ItemInitTask<'a, I> = BoxFuture<'a, InitResult<ItemEndpoint<I>>>;
1121+
type ItemInitTask<'a> = BoxFuture<'a, InitResult<ItemEndpoint>>;
11401122

11411123
/// Aggregates all of the streams of events for the write task.
11421124
#[derive(Debug)]

server/swimos_agent_derive/src/agent_lifecycle/model.rs

Lines changed: 19 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -289,18 +289,18 @@ fn validate_method_as<'a>(
289289
})
290290
}
291291
HandlerKind::Command => Validation::join(acc, validate_typed_sig(sig, 1, true))
292-
.and_then(|(mut acc, t)| {
292+
.and_then(|(mut acc, _t)| {
293293
for target in targets {
294-
if let Err(e) = acc.add_on_command(target, t, &sig.ident) {
294+
if let Err(e) = acc.add_on_command(target, &sig.ident) {
295295
return Validation::Validated(acc, Errors::of(e));
296296
}
297297
}
298298
Validation::valid(acc)
299299
}),
300300
HandlerKind::Cue => {
301-
Validation::join(acc, validate_cue_sig(sig)).and_then(|(mut acc, t)| {
301+
Validation::join(acc, validate_cue_sig(sig)).and_then(|(mut acc, _t)| {
302302
for target in targets {
303-
if let Err(e) = acc.add_on_cue(target, t, &sig.ident) {
303+
if let Err(e) = acc.add_on_cue(target, &sig.ident) {
304304
return Validation::Validated(acc, Errors::of(e));
305305
}
306306
}
@@ -384,9 +384,9 @@ fn validate_method_as<'a>(
384384
Validation::valid(acc)
385385
}),
386386
HandlerKind::JoinMap => Validation::join(acc, validate_join_map_lifecycle_sig(sig))
387-
.and_then(|(mut acc, (l, k, v))| {
387+
.and_then(|(mut acc, (_l, k, v))| {
388388
for target in targets {
389-
if let Err(e) = acc.add_join_map_lifecycle(target, l, k, v, &sig.ident) {
389+
if let Err(e) = acc.add_join_map_lifecycle(target, k, v, &sig.ident) {
390390
return Validation::Validated(acc, Errors::of(e));
391391
}
392392
}
@@ -1205,7 +1205,7 @@ impl<'a> AgentLifecycleDescriptorBuilder<'a> {
12051205
)),
12061206
ItemLifecycle::Map(MapLifecycleDescriptor {
12071207
name,
1208-
join_lifecycle: JoinLifecycle::JoinMap(_, join_lc),
1208+
join_lifecycle: JoinLifecycle::JoinMap(join_lc),
12091209
..
12101210
}) => Some(JoinLaneInit::new(name.clone(), JoinLaneKind::Map, join_lc)),
12111211
_ => None,
@@ -1247,7 +1247,6 @@ impl<'a> AgentLifecycleDescriptorBuilder<'a> {
12471247
pub fn add_join_map_lifecycle(
12481248
&mut self,
12491249
name: String,
1250-
link_key_type: &'a Type,
12511250
key_type: &'a Type,
12521251
value_type: &'a Type,
12531252
method: &'a Ident,
@@ -1257,14 +1256,13 @@ impl<'a> AgentLifecycleDescriptorBuilder<'a> {
12571256
} = self;
12581257
match lane_lifecycles.get_mut(&name) {
12591258
Some(ItemLifecycle::Map(desc)) => {
1260-
desc.add_join_map_lifecycle(link_key_type, key_type, value_type, method)
1259+
desc.add_join_map_lifecycle(key_type, value_type, method)
12611260
}
12621261
None => {
12631262
lane_lifecycles.insert(
12641263
name.clone(),
12651264
ItemLifecycle::Map(MapLifecycleDescriptor::new_join_map_lifecycle(
12661265
name,
1267-
link_key_type,
12681266
(key_type, value_type),
12691267
method,
12701268
)),
@@ -1316,12 +1314,7 @@ impl<'a> AgentLifecycleDescriptorBuilder<'a> {
13161314
}
13171315
}
13181316

1319-
pub fn add_on_command(
1320-
&mut self,
1321-
name: String,
1322-
handler_type: &'a Type,
1323-
method: &'a Ident,
1324-
) -> Result<(), syn::Error> {
1317+
pub fn add_on_command(&mut self, name: String, method: &'a Ident) -> Result<(), syn::Error> {
13251318
let AgentLifecycleDescriptorBuilder {
13261319
lane_lifecycles, ..
13271320
} = self;
@@ -1368,23 +1361,14 @@ impl<'a> AgentLifecycleDescriptorBuilder<'a> {
13681361
_ => {
13691362
lane_lifecycles.insert(
13701363
name.clone(),
1371-
ItemLifecycle::Command(CommandLifecycleDescriptor::new(
1372-
name,
1373-
handler_type,
1374-
method,
1375-
)),
1364+
ItemLifecycle::Command(CommandLifecycleDescriptor::new(name, method)),
13761365
);
13771366
Ok(())
13781367
}
13791368
}
13801369
}
13811370

1382-
pub fn add_on_cue(
1383-
&mut self,
1384-
name: String,
1385-
handler_type: Option<&'a Type>,
1386-
method: &'a Ident,
1387-
) -> Result<(), syn::Error> {
1371+
pub fn add_on_cue(&mut self, name: String, method: &'a Ident) -> Result<(), syn::Error> {
13881372
let AgentLifecycleDescriptorBuilder {
13891373
lane_lifecycles, ..
13901374
} = self;
@@ -1431,11 +1415,7 @@ impl<'a> AgentLifecycleDescriptorBuilder<'a> {
14311415
_ => {
14321416
lane_lifecycles.insert(
14331417
name.clone(),
1434-
ItemLifecycle::Demand(DemandLifecycleDescriptor::new(
1435-
name,
1436-
handler_type,
1437-
method,
1438-
)),
1418+
ItemLifecycle::Demand(DemandLifecycleDescriptor::new(name, method)),
14391419
);
14401420
Ok(())
14411421
}
@@ -2208,39 +2188,29 @@ impl<'a> ValueLifecycleDescriptor<'a> {
22082188

22092189
pub struct CommandLifecycleDescriptor<'a> {
22102190
pub name: String, //The name of the lane.
2211-
pub primary_lane_type: &'a Type,
22122191
pub on_command: &'a Ident,
22132192
}
22142193

22152194
impl<'a> CommandLifecycleDescriptor<'a> {
2216-
pub fn new(name: String, primary_lane_type: &'a Type, on_command: &'a Ident) -> Self {
2217-
CommandLifecycleDescriptor {
2218-
name,
2219-
primary_lane_type,
2220-
on_command,
2221-
}
2195+
pub fn new(name: String, on_command: &'a Ident) -> Self {
2196+
CommandLifecycleDescriptor { name, on_command }
22222197
}
22232198
}
22242199

22252200
pub struct DemandLifecycleDescriptor<'a> {
22262201
pub name: String, //The name of the lane.
2227-
pub primary_lane_type: Option<&'a Type>,
22282202
pub on_cue: &'a Ident,
22292203
}
22302204

22312205
impl<'a> DemandLifecycleDescriptor<'a> {
2232-
pub fn new(name: String, primary_lane_type: Option<&'a Type>, on_cue: &'a Ident) -> Self {
2233-
DemandLifecycleDescriptor {
2234-
name,
2235-
primary_lane_type,
2236-
on_cue,
2237-
}
2206+
pub fn new(name: String, on_cue: &'a Ident) -> Self {
2207+
DemandLifecycleDescriptor { name, on_cue }
22382208
}
22392209
}
22402210

22412211
pub enum JoinLifecycle<'a> {
22422212
None,
2243-
JoinMap(&'a Type, &'a Ident),
2213+
JoinMap(&'a Ident),
22442214
JoinValue(&'a Ident),
22452215
}
22462216

@@ -2427,7 +2397,6 @@ impl<'a> MapLifecycleDescriptor<'a> {
24272397

24282398
pub fn new_join_map_lifecycle(
24292399
name: String,
2430-
link_key_type: &'a Type,
24312400
map_type: (&'a Type, &'a Type),
24322401
join_lifecycle: &'a Ident,
24332402
) -> Self {
@@ -2438,7 +2407,7 @@ impl<'a> MapLifecycleDescriptor<'a> {
24382407
on_update: None,
24392408
on_remove: None,
24402409
on_clear: None,
2441-
join_lifecycle: JoinLifecycle::JoinMap(link_key_type, join_lifecycle),
2410+
join_lifecycle: JoinLifecycle::JoinMap(join_lifecycle),
24422411
}
24432412
}
24442413

@@ -2557,7 +2526,6 @@ impl<'a> MapLifecycleDescriptor<'a> {
25572526

25582527
pub fn add_join_map_lifecycle(
25592528
&mut self,
2560-
link_key_type: &'a Type,
25612529
key_type: &'a Type,
25622530
value_type: &'a Type,
25632531
method: &'a Ident,
@@ -2572,7 +2540,7 @@ impl<'a> MapLifecycleDescriptor<'a> {
25722540
let map_type = (key_type, value_type);
25732541
match join_lifecycle {
25742542
JoinLifecycle::None => {
2575-
*join_lifecycle = JoinLifecycle::JoinMap(link_key_type, method);
2543+
*join_lifecycle = JoinLifecycle::JoinMap(method);
25762544
if map_type != *primary_lane_type {
25772545
alternative_lane_types.insert(map_type);
25782546
}

server/swimos_agent_derive/src/lane_model_derive/model.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,12 @@ impl<'a> ItemModel<'a> {
199199
let ItemModel {
200200
name,
201201
kind,
202-
flags,
203202
transform,
203+
..
204204
} = self;
205205
kind.lane().map(move |kind| WarpLaneModel {
206206
name,
207207
kind,
208-
flags: *flags,
209208
transform: transform.clone(),
210209
})
211210
}
@@ -234,7 +233,7 @@ impl<'a> ItemModel<'a> {
234233
pub struct WarpLaneModel<'a> {
235234
pub name: &'a Ident,
236235
pub kind: WarpLaneSpec<'a>,
237-
pub flags: ItemFlags,
236+
//pub flags: ItemFlags,
238237
pub transform: NameTransform,
239238
}
240239

0 commit comments

Comments
 (0)