Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Rust 1.82 #849

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ include = [
]
edition = "2021"
resolver = "2"
rust-version = "1.79"
rust-version = "1.82"

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion capi/bind_gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ fn main() {
if abi
.as_ref()
.and_then(|a| a.name.as_ref())
.map_or(true, |n| n.value() != "C")
.is_none_or(|n| n.value() != "C")
|| attrs.iter().all(|a| match &a.meta {
Meta::Path(w) => !w.is_ident("no_mangle"),
_ => true,
Expand Down
4 changes: 2 additions & 2 deletions capi/src/web_command_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! a JavaScript object that implements the necessary functions to handle the
//! timer commands. All of them are optional except for `getTimer`.

use core::ptr;

Check warning on line 5 in capi/src/web_command_sink.rs

View workflow job for this annotation

GitHub Actions / build (WebAssembly Web)

unused import: `core::ptr`
use std::{borrow::Cow, cell::Cell, convert::TryFrom, future::Future, sync::Arc};

use livesplit_core::{
Expand Down Expand Up @@ -267,7 +267,7 @@
handle_action_value(self.set_game_time.as_ref().and_then(|f| {
f.call1(
&self.obj,
&JsValue::from_f64(ptr::addr_of!(time) as usize as f64),
&JsValue::from_f64(&raw const time as usize as f64),
)
.ok()
}))
Expand Down Expand Up @@ -296,7 +296,7 @@
handle_action_value(self.set_loading_times.as_ref().and_then(|f| {
f.call1(
&self.obj,
&JsValue::from_f64(ptr::addr_of!(time) as usize as f64),
&JsValue::from_f64(&raw const time as usize as f64),
)
.ok()
}))
Expand Down
2 changes: 1 addition & 1 deletion crates/livesplit-auto-splitting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
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."
keywords = ["speedrun", "timer", "livesplit", "auto-splitting"]
edition = "2021"
rust-version = "1.79"
rust-version = "1.82"

[dependencies]
anyhow = { version = "1.0.45", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/livesplit-auto-splitting/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Process {
pub(super) fn list_pids_by_name<'a>(
name: &'a str,
process_list: &'a mut ProcessList,
) -> impl Iterator<Item = u32> + 'a {
) -> impl Iterator<Item = u32> + use<'a> {
process_list.refresh();
process_list
.processes_by_name(name)
Expand Down
4 changes: 2 additions & 2 deletions crates/livesplit-auto-splitting/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ impl ProcessList {
}
}

pub fn processes_by_name<'process: 'both, 'both>(
pub fn processes_by_name<'process, 'both>(
&'process self,
name: &'both str,
) -> impl Iterator<Item = &'process sysinfo::Process> + 'both {
) -> impl Iterator<Item = &'process sysinfo::Process> + use<'both, 'process> {
let name = name.as_bytes();

// On Linux the process name is limited to 15 bytes. So we ensure that
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/pb_chance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub fn for_timer(timer: &Snapshot<'_>) -> (f64, bool) {
let beat_pb = all_segments
.last()
.and_then(|s| s.personal_best_split_time()[method])
.map_or(true, |pb| current_time < pb);
.is_none_or(|pb| current_time < pb);
if beat_pb {
1.0
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/skill_curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl SkillCurve {
pub fn iter_segment_times_at_percentile(
&self,
percentile: f64,
) -> impl Iterator<Item = TimeSpan> + '_ {
) -> impl Iterator<Item = TimeSpan> + use<'_> {
self.all_weighted_segment_times
.iter()
.map(move |weighted_segment_times| {
Expand Down Expand Up @@ -181,7 +181,7 @@ impl SkillCurve {
&self,
percentile: f64,
offset: TimeSpan,
) -> impl Iterator<Item = TimeSpan> + '_ {
) -> impl Iterator<Item = TimeSpan> + use<'_> {
let mut sum = offset;
self.iter_segment_times_at_percentile(percentile)
.map(move |segment_time| {
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/state_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ pub fn check_best_segment(timer: &Timer, segment_index: usize, method: TimingMet
let delta = previous_segment_delta(timer, segment_index, best_segments::NAME, method);
let current_segment = previous_segment_time(timer, segment_index, method);
let best_segment = timer.run().segment(segment_index).best_segment_time()[method];
best_segment.map_or(true, |b| {
best_segment.is_none_or(|b| {
current_segment.is_some_and(|c| c < b) || delta.is_some_and(|d| d < TimeSpan::zero())
})
}
2 changes: 1 addition & 1 deletion src/analysis/sum_of_segments/best.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn populate_prediction(
predicted_time: Option<TimeSpan>,
) {
if let Some(predicted_time) = predicted_time {
if target_prediction.map_or(true, |p| predicted_time < p.time) {
if target_prediction.is_none_or(|p| predicted_time < p.time) {
*target_prediction = Some(Prediction {
time: predicted_time,
predecessor,
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/sum_of_segments/worst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn populate_prediction(
predicted_time: Option<TimeSpan>,
) {
if let Some(predicted_time) = predicted_time {
if target_prediction.map_or(true, |p| predicted_time > p.time) {
if target_prediction.is_none_or(|p| predicted_time > p.time) {
*target_prediction = Some(Prediction {
time: predicted_time,
predecessor,
Expand Down
2 changes: 1 addition & 1 deletion src/comparison/best_split_times.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn generate(segments: &mut [Segment], attempts: &[Attempt], method: TimingMethod
total_time += time;

let comp = &mut segment.comparison_mut(NAME)[method];
if comp.map_or(true, |c| total_time < c) {
if comp.is_none_or(|c| total_time < c) {
*comp = Some(total_time);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/component/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl Component {
.unwrap()
.comparison(current_comparison)[method];

if pb_time.map_or(true, |t| time < t) {
if pb_time.is_none_or(|t| time < t) {
SemanticColor::PersonalBest
} else {
SemanticColor::BehindLosingTime
Expand Down
8 changes: 4 additions & 4 deletions src/component/title/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,22 +293,22 @@ impl Component {
}
state.line2.clear();
} else {
if state.line1.last().map_or(true, |g| game_name != &**g) {
if state.line1.last().is_none_or(|g| game_name != &**g) {
state.line1.clear();
state.line1.extend(abbreviate_title(game_name));
}
if state
.line2
.last()
.map_or(true, |c| full_category_name != &**c)
.is_none_or(|c| full_category_name != &**c)
{
state.line2.clear();
state.line2.extend(abbreviate_category(full_category_name));
}
}
}
(true, false) => {
if state.line1.last().map_or(true, |g| game_name != &**g) {
if state.line1.last().is_none_or(|g| game_name != &**g) {
state.line1.clear();
state.line1.extend(abbreviate_title(game_name));
}
Expand All @@ -318,7 +318,7 @@ impl Component {
if state
.line1
.last()
.map_or(true, |c| full_category_name != &**c)
.is_none_or(|c| full_category_name != &**c)
{
state.line1.clear();
state.line1.extend(abbreviate_category(full_category_name));
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/default_text_engine/color_font/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl<'f> ColorTables<'f> {
&self,
palette: usize,
glyph: u16,
) -> Option<impl Iterator<Item = (u16, Option<Color>)> + '_> {
) -> Option<impl Iterator<Item = (u16, Option<Color>)> + use<'_>> {
let layers = colr::look_up(self.colr, glyph)?;
Some(layers.iter().map(move |layer| {
let entry_idx = layer.palette_entry_idx();
Expand Down
4 changes: 2 additions & 2 deletions src/run/comparisons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ impl Comparisons {
}

/// Iterates over all the comparisons and their times.
pub fn iter(&self) -> impl Iterator<Item = &(Box<str>, Time)> + '_ {
pub fn iter(&self) -> impl Iterator<Item = &(Box<str>, Time)> + use<'_> {
self.0.iter()
}

/// Mutably iterates over all the comparisons and their times. Be careful
/// when modifying the comparison name. Having duplicates will likely cause
/// problems.
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut (Box<str>, Time)> + '_ {
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut (Box<str>, Time)> + use<'_> {
self.0.iter_mut()
}
}
2 changes: 1 addition & 1 deletion src/run/editor/cleaning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ fn check_prediction<'a>(
method: TimingMethod,
) -> Option<PotentialCleanUp<'a>> {
if let Some(predicted_time) = predicted_time {
if predictions[ending_index + 1].map_or(true, |p| predicted_time < p.time) {
if predictions[ending_index + 1].is_none_or(|p| predicted_time < p.time) {
if let Some(segment_history_element) =
run.segment(ending_index).segment_history().get(run_index)
{
Expand Down
3 changes: 1 addition & 2 deletions src/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,7 @@ impl Run {
// Fix Best Segment time if the PB segment is faster
if comparison == personal_best::NAME {
let current_segment = time - previous_time;
if segment.best_segment_time()[method].map_or(true, |t| t > current_segment)
{
if segment.best_segment_time()[method].is_none_or(|t| t > current_segment) {
segment.best_segment_time_mut()[method] = Some(current_segment);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/timing/timer/active_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ fn update_best_segments(run: &mut Run) {
if split
.best_segment_time()
.real_time
.map_or(true, |b| current_segment.is_some_and(|c| c < b))
.is_none_or(|b| current_segment.is_some_and(|c| c < b))
{
new_best_segment.real_time = current_segment;
}
Expand All @@ -219,7 +219,7 @@ fn update_best_segments(run: &mut Run) {
if split
.best_segment_time()
.game_time
.map_or(true, |b| current_segment.is_some_and(|c| c < b))
.is_none_or(|b| current_segment.is_some_and(|c| c < b))
{
new_best_segment.game_time = current_segment;
}
Expand All @@ -236,7 +236,7 @@ fn update_pb_splits(run: &mut Run, method: TimingMethod) {
last_segment.personal_best_split_time()[method],
)
};
if split_time.is_some_and(|s| pb_split_time.map_or(true, |pb| s < pb)) {
if split_time.is_some_and(|s| pb_split_time.is_none_or(|pb| s < pb)) {
super::set_run_as_pb(run);
}
}
2 changes: 1 addition & 1 deletion src/timing/timer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ impl Timer {

if let Some(final_time) = last_segment.split_time()[timing_method] {
if last_segment.personal_best_split_time()[timing_method]
.map_or(true, |pb| final_time < pb)
.is_none_or(|pb| final_time < pb)
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/xml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Debug for TagName<'_> {
pub struct Attributes<'a>(&'a str);

impl<'a> Attributes<'a> {
pub fn iter(self) -> impl Iterator<Item = (&'a str, Text<'a>)> + 'a {
pub fn iter(self) -> impl Iterator<Item = (&'a str, Text<'a>)> + use<'a> {
let mut rem = self.0;
iter::from_fn(move || {
rem = trim_start(rem);
Expand Down
Loading