Skip to content

Commit 6ce52ec

Browse files
authored
Some Cleanup for Rust 1.89 (#885)
- Replaced nested if / if let with let chains. - With the new lifetime warning rules, it became possible to remove some unnecessary explicit `'_` lifetimes. - Resolved some clippy lints (mostly missing const fns). - Switched `#[allow]` to `#[expect]` for most lints. This should catch situations where the warning no longer applies. It already caught a few of those. - Updated test snapshot hashes that seem to have changed again (the fonts on Windows got updated).
1 parent 80c4e59 commit 6ce52ec

142 files changed

Lines changed: 809 additions & 864 deletions

File tree

Some content is hidden

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ include = [
2323
"/README.md",
2424
]
2525
edition = "2024"
26-
rust-version = "1.85"
26+
rust-version = "1.89"
2727

2828
[package.metadata.docs.rs]
2929
all-features = true

capi/bind_gen/src/swift/code.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
io::{Result, Write},
88
};
99

10-
fn get_hl_type(ty: &Type) -> Cow<str> {
10+
fn get_hl_type(ty: &Type) -> Cow<'_, str> {
1111
if ty.is_custom {
1212
match ty.kind {
1313
TypeKind::Ref => Cow::Owned(format!("{}Ref", ty.name)),
@@ -46,7 +46,7 @@ fn get_ll_type(ty: &Type) -> &str {
4646
}
4747
}
4848

49-
fn get_input_name(name: &str) -> Cow<str> {
49+
fn get_input_name(name: &str) -> Cow<'_, str> {
5050
if name == "this" {
5151
Cow::Borrowed("self")
5252
} else {

capi/src/auto_splitting_runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ type AutoSplittingRuntime = livesplit_core::auto_splitting::Runtime<livesplit_co
1212
use livesplit_core::SharedTimer;
1313

1414
#[cfg(not(feature = "auto-splitting"))]
15-
#[allow(missing_docs)]
15+
#[expect(missing_docs)]
1616
pub struct AutoSplittingRuntime;
1717

18-
#[allow(warnings)]
18+
#[expect(warnings)]
1919
#[cfg(not(feature = "auto-splitting"))]
2020
impl AutoSplittingRuntime {
2121
pub fn new() -> Self {

capi/src/command_sink.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
use std::{borrow::Cow, future::Future, ops::Deref, pin::Pin, sync::Arc};
1212

1313
use livesplit_core::{
14-
event::{self, Result},
1514
TimeSpan, Timer, TimingMethod,
15+
event::{self, Result},
1616
};
1717

1818
use crate::shared_timer::OwnedSharedTimer;
@@ -50,15 +50,15 @@ pub(crate) trait CommandSinkAndQuery: Send + Sync + 'static {
5050
fn dyn_undo_all_pauses(&self) -> Fut;
5151
fn dyn_switch_to_previous_comparison(&self) -> Fut;
5252
fn dyn_switch_to_next_comparison(&self) -> Fut;
53-
fn dyn_set_current_comparison(&self, comparison: Cow<'_, str>) -> Fut;
53+
fn dyn_set_current_comparison(&self, comparison: Cow<str>) -> Fut;
5454
fn dyn_toggle_timing_method(&self) -> Fut;
5555
fn dyn_set_current_timing_method(&self, method: TimingMethod) -> Fut;
5656
fn dyn_initialize_game_time(&self) -> Fut;
5757
fn dyn_set_game_time(&self, time: TimeSpan) -> Fut;
5858
fn dyn_pause_game_time(&self) -> Fut;
5959
fn dyn_resume_game_time(&self) -> Fut;
6060
fn dyn_set_loading_times(&self, time: TimeSpan) -> Fut;
61-
fn dyn_set_custom_variable(&self, name: Cow<'_, str>, value: Cow<'_, str>) -> Fut;
61+
fn dyn_set_custom_variable(&self, name: Cow<str>, value: Cow<str>) -> Fut;
6262
}
6363

6464
type Fut = Pin<Box<dyn Future<Output = Result> + 'static>>;
@@ -107,7 +107,7 @@ where
107107
fn dyn_switch_to_next_comparison(&self) -> Fut {
108108
Box::pin(self.switch_to_next_comparison())
109109
}
110-
fn dyn_set_current_comparison(&self, comparison: Cow<'_, str>) -> Fut {
110+
fn dyn_set_current_comparison(&self, comparison: Cow<str>) -> Fut {
111111
Box::pin(self.set_current_comparison(comparison))
112112
}
113113
fn dyn_toggle_timing_method(&self) -> Fut {
@@ -131,7 +131,7 @@ where
131131
fn dyn_set_loading_times(&self, time: TimeSpan) -> Fut {
132132
Box::pin(self.set_loading_times(time))
133133
}
134-
fn dyn_set_custom_variable(&self, name: Cow<'_, str>, value: Cow<'_, str>) -> Fut {
134+
fn dyn_set_custom_variable(&self, name: Cow<str>, value: Cow<str>) -> Fut {
135135
Box::pin(self.set_custom_variable(name, value))
136136
}
137137
}
@@ -187,7 +187,7 @@ impl event::CommandSink for CommandSink {
187187

188188
fn set_current_comparison(
189189
&self,
190-
comparison: Cow<'_, str>,
190+
comparison: Cow<str>,
191191
) -> impl Future<Output = Result> + 'static {
192192
self.0.dyn_set_current_comparison(comparison)
193193
}
@@ -225,8 +225,8 @@ impl event::CommandSink for CommandSink {
225225

226226
fn set_custom_variable(
227227
&self,
228-
name: Cow<'_, str>,
229-
value: Cow<'_, str>,
228+
name: Cow<str>,
229+
value: Cow<str>,
230230
) -> impl Future<Output = Result> + 'static {
231231
self.0.dyn_set_custom_variable(name, value)
232232
}

capi/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
clippy::perf,
55
clippy::style,
66
clippy::needless_pass_by_ref_mut,
7-
missing_docs,
8-
rust_2018_idioms
7+
missing_docs
98
)]
109
#![allow(clippy::missing_safety_doc, non_camel_case_types, non_snake_case)]
1110

@@ -101,7 +100,7 @@ use livesplit_core::{Time, TimeSpan};
101100
/// type
102101
pub type Json = *const c_char;
103102
/// type
104-
#[allow(non_camel_case_types)]
103+
#[expect(non_camel_case_types)]
105104
pub type Nullablec_char = c_char;
106105

107106
thread_local! {

capi/src/software_renderer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl SoftwareRenderer {
1717
panic!("The software renderer is not compiled in.")
1818
}
1919

20-
#[allow(warnings)]
20+
#[expect(warnings)]
2121
fn render(
2222
&mut self,
2323
_: &LayoutState,

capi/src/web_command_sink.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl CommandSink for WebCommandSink {
222222

223223
fn set_current_comparison(
224224
&self,
225-
comparison: Cow<'_, str>,
225+
comparison: Cow<str>,
226226
) -> impl Future<Output = Result> + 'static {
227227
debug_assert!(!self.locked.get());
228228
handle_action_value(
@@ -303,8 +303,8 @@ impl CommandSink for WebCommandSink {
303303

304304
fn set_custom_variable(
305305
&self,
306-
name: Cow<'_, str>,
307-
value: Cow<'_, str>,
306+
name: Cow<str>,
307+
value: Cow<str>,
308308
) -> impl Future<Output = Result> + 'static {
309309
debug_assert!(!self.locked.get());
310310
handle_action_value(self.set_custom_variable.as_ref().and_then(|f| {

capi/src/web_rendering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl WebRenderer {
2020
/// default fonts. They are called "timer" and "fira". Make sure they are
2121
/// fully loaded before creating the renderer as otherwise information about
2222
/// a fallback font is cached instead.
23-
#[allow(clippy::new_without_default)]
23+
#[expect(clippy::new_without_default)]
2424
#[wasm_bindgen(constructor)]
2525
pub fn new() -> Self {
2626
Self {

crates/livesplit-auto-splitting/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
88
description = "livesplit-auto-splitting is a library that provides a runtime for running auto splitters that can control a speedrun timer. These auto splitters are provided as WebAssembly modules."
99
keywords = ["speedrun", "timer", "livesplit", "auto-splitting"]
1010
edition = "2024"
11-
rust-version = "1.85"
11+
rust-version = "1.89"
1212

1313
[dependencies]
1414
anyhow = { version = "1.0.45", default-features = false }

crates/livesplit-auto-splitting/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,7 @@
570570
clippy::style,
571571
clippy::missing_const_for_fn,
572572
clippy::undocumented_unsafe_blocks,
573-
missing_docs,
574-
rust_2018_idioms
573+
missing_docs
575574
)]
576575
#![forbid(clippy::incompatible_msrv)]
577576

@@ -595,6 +594,7 @@ const _: () = {
595594
assert_send_sync::<Process>();
596595
assert_send_sync::<Runtime>();
597596
assert_send_sync::<CompiledAutoSplitter>();
597+
#[expect(dead_code)] // Not actually dead, as we use it for the assertion inside.
598598
const fn with_timer<T: Send + Sync + Timer>() {
599599
assert_send_sync::<AutoSplitter<T>>();
600600
}

0 commit comments

Comments
 (0)