Fix new Clippy errors

Introduced in Clippy v0.1.89 / Rust v1.89.0.
This commit is contained in:
Oliver Hamlet
2025-08-11 18:54:54 +01:00
parent da0e35bb2b
commit a677041a55
7 changed files with 55 additions and 57 deletions
+18 -20
View File
@@ -248,23 +248,22 @@ impl Database {
) -> Result<Option<PluginMetadata>, MetadataRetrievalError> {
let mut metadata = self.masterlist.find_plugin(plugin_name)?;
if include_user_metadata == MergeMode::WithUserMetadata {
if let Some(mut user_metadata) = self.userlist.find_plugin(plugin_name)? {
if let Some(metadata) = metadata {
user_metadata.merge_metadata(&metadata);
}
metadata = Some(user_metadata);
}
}
if evaluate_conditions == EvalMode::Evaluate {
if include_user_metadata == MergeMode::WithUserMetadata
&& let Some(mut user_metadata) = self.userlist.find_plugin(plugin_name)?
{
if let Some(metadata) = metadata {
return evaluate_all_conditions(metadata, &self.condition_evaluator_state)
.map_err(Into::into);
user_metadata.merge_metadata(&metadata);
}
metadata = Some(user_metadata);
}
Ok(metadata)
if evaluate_conditions == EvalMode::Evaluate
&& let Some(metadata) = metadata
{
evaluate_all_conditions(metadata, &self.condition_evaluator_state).map_err(Into::into)
} else {
Ok(metadata)
}
}
/// Get a plugin's metadata loaded from the given userlist.
@@ -278,14 +277,13 @@ impl Database {
) -> Result<Option<PluginMetadata>, MetadataRetrievalError> {
let metadata = self.userlist.find_plugin(plugin_name)?;
if evaluate_conditions == EvalMode::Evaluate {
if let Some(metadata) = metadata {
return evaluate_all_conditions(metadata, &self.condition_evaluator_state)
.map_err(Into::into);
}
if evaluate_conditions == EvalMode::Evaluate
&& let Some(metadata) = metadata
{
evaluate_all_conditions(metadata, &self.condition_evaluator_state).map_err(Into::into)
} else {
Ok(metadata)
}
Ok(metadata)
}
/// Sets a plugin's user metadata, replacing any loaded user metadata for
+1 -1
View File
@@ -11,7 +11,7 @@ use crate::sorting::error::{
};
use crate::{Vertex, escape_ascii};
/// Represents an error that occurred while trying to create a [`Game`].
/// Represents an error that occurred while trying to create a [`Game`](crate::Game).
#[derive(Debug)]
#[non_exhaustive]
pub enum GameHandleCreationError {
+1 -1
View File
@@ -46,6 +46,6 @@ fn case_insensitive_regex(value: &str) -> Result<Regex, Box<RegexImplError>> {
Regex::with_flags(value, "iu").map_err(Into::into)
}
fn escape_ascii(path: &Path) -> EscapeAscii {
fn escape_ascii(path: &Path) -> EscapeAscii<'_> {
path.as_os_str().as_encoded_bytes().escape_ascii()
}
+14 -15
View File
@@ -129,12 +129,11 @@ pub fn select_message_content<'a>(
} else if matched.is_none() {
if language_code.is_some_and(|c| c == mc.language.as_ref()) {
matched = Some(mc);
} else if language_code.is_none() {
if let Some((content_language_code, _)) = mc.language.split_once('_') {
if content_language_code == language {
matched = Some(mc);
}
}
} else if language_code.is_none()
&& let Some((content_language_code, _)) = mc.language.split_once('_')
&& content_language_code == language
{
matched = Some(mc);
}
if mc.language.as_ref() == MessageContent::DEFAULT_LANGUAGE {
@@ -375,16 +374,16 @@ fn format(text: &str, subs: &[&str]) -> Result<Box<str>, MetadataParsingErrorRea
new_text.push('{');
}
if let Some(sub_index) = unused_sub_indexes.first() {
if let Some(sub) = subs.get(*sub_index) {
return Err(MetadataParsingErrorReason::MissingPlaceholder(
(*sub).to_owned(),
*sub_index,
));
}
if let Some(sub_index) = unused_sub_indexes.first()
&& let Some(sub) = subs.get(*sub_index)
{
Err(MetadataParsingErrorReason::MissingPlaceholder(
(*sub).to_owned(),
*sub_index,
))
} else {
Ok(new_text.into_boxed_str())
}
Ok(new_text.into_boxed_str())
}
impl EmitYaml for MessageContent {
+14 -14
View File
@@ -358,21 +358,21 @@ fn split_on_prelude(masterlist: &str) -> Option<(&str, &str)> {
continue;
}
if let Some((_, next_byte)) = iter.peek() {
if !matches!(next_byte, b' ' | b'#' | b'\n' | b'\r') {
// LIMITATION: Slicing at index should never fail, but the
// compiler can't see that. A variation of str.find() that
// could take a closure that matches on substrings would
// eliminate the need for this.
if let Some(suffix) = remainder.get(index..) {
return Some((prefix, suffix));
}
logging::error!(
"Unexpectedly failed to slice the masterlist on a new line at index {}",
prefix.len() + index
);
if let Some((_, next_byte)) = iter.peek()
&& !matches!(next_byte, b' ' | b'#' | b'\n' | b'\r')
{
// LIMITATION: Slicing at index should never fail, but the
// compiler can't see that. A variation of str.find() that
// could take a closure that matches on substrings would
// eliminate the need for this.
if let Some(suffix) = remainder.get(index..) {
return Some((prefix, suffix));
}
logging::error!(
"Unexpectedly failed to slice the masterlist on a new line at index {}",
prefix.len() + index
);
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ fn emit<T: yaml::EmitYaml>(metadata: &T) -> String {
}
#[cfg(test)]
fn parse(yaml: &str) -> saphyr::MarkedYaml {
fn parse(yaml: &str) -> saphyr::MarkedYaml<'_> {
use saphyr::LoadableYamlNode;
saphyr::MarkedYaml::load_from_str(yaml)
+6 -5
View File
@@ -391,12 +391,13 @@ fn calculate_crc(path: &Path) -> std::io::Result<u32> {
}
fn extract_bash_tags(description: &str) -> Vec<String> {
if let Some((_, bash_tags)) = description.split_once("{{BASH:") {
if let Some((bash_tags, _)) = bash_tags.split_once("}}") {
return bash_tags.split(',').map(|s| s.trim().to_owned()).collect();
}
if let Some((_, bash_tags)) = description.split_once("{{BASH:")
&& let Some((bash_tags, _)) = bash_tags.split_once("}}")
{
bash_tags.split(',').map(|s| s.trim().to_owned()).collect()
} else {
Vec::new()
}
Vec::new()
}
fn extract_version(description: &str) -> Option<String> {