Skip to content

Commit a677041

Browse files
committed
Fix new Clippy errors
Introduced in Clippy v0.1.89 / Rust v1.89.0.
1 parent da0e35b commit a677041

File tree

7 files changed

+55
-57
lines changed

7 files changed

+55
-57
lines changed

src/database/mod.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -248,23 +248,22 @@ impl Database {
248248
) -> Result<Option<PluginMetadata>, MetadataRetrievalError> {
249249
let mut metadata = self.masterlist.find_plugin(plugin_name)?;
250250

251-
if include_user_metadata == MergeMode::WithUserMetadata {
252-
if let Some(mut user_metadata) = self.userlist.find_plugin(plugin_name)? {
253-
if let Some(metadata) = metadata {
254-
user_metadata.merge_metadata(&metadata);
255-
}
256-
metadata = Some(user_metadata);
257-
}
258-
}
259-
260-
if evaluate_conditions == EvalMode::Evaluate {
251+
if include_user_metadata == MergeMode::WithUserMetadata
252+
&& let Some(mut user_metadata) = self.userlist.find_plugin(plugin_name)?
253+
{
261254
if let Some(metadata) = metadata {
262-
return evaluate_all_conditions(metadata, &self.condition_evaluator_state)
263-
.map_err(Into::into);
255+
user_metadata.merge_metadata(&metadata);
264256
}
257+
metadata = Some(user_metadata);
265258
}
266259

267-
Ok(metadata)
260+
if evaluate_conditions == EvalMode::Evaluate
261+
&& let Some(metadata) = metadata
262+
{
263+
evaluate_all_conditions(metadata, &self.condition_evaluator_state).map_err(Into::into)
264+
} else {
265+
Ok(metadata)
266+
}
268267
}
269268

270269
/// Get a plugin's metadata loaded from the given userlist.
@@ -278,14 +277,13 @@ impl Database {
278277
) -> Result<Option<PluginMetadata>, MetadataRetrievalError> {
279278
let metadata = self.userlist.find_plugin(plugin_name)?;
280279

281-
if evaluate_conditions == EvalMode::Evaluate {
282-
if let Some(metadata) = metadata {
283-
return evaluate_all_conditions(metadata, &self.condition_evaluator_state)
284-
.map_err(Into::into);
285-
}
280+
if evaluate_conditions == EvalMode::Evaluate
281+
&& let Some(metadata) = metadata
282+
{
283+
evaluate_all_conditions(metadata, &self.condition_evaluator_state).map_err(Into::into)
284+
} else {
285+
Ok(metadata)
286286
}
287-
288-
Ok(metadata)
289287
}
290288

291289
/// Sets a plugin's user metadata, replacing any loaded user metadata for

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::sorting::error::{
1111
};
1212
use crate::{Vertex, escape_ascii};
1313

14-
/// Represents an error that occurred while trying to create a [`Game`].
14+
/// Represents an error that occurred while trying to create a [`Game`](crate::Game).
1515
#[derive(Debug)]
1616
#[non_exhaustive]
1717
pub enum GameHandleCreationError {

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ fn case_insensitive_regex(value: &str) -> Result<Regex, Box<RegexImplError>> {
4646
Regex::with_flags(value, "iu").map_err(Into::into)
4747
}
4848

49-
fn escape_ascii(path: &Path) -> EscapeAscii {
49+
fn escape_ascii(path: &Path) -> EscapeAscii<'_> {
5050
path.as_os_str().as_encoded_bytes().escape_ascii()
5151
}

src/metadata/message.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,11 @@ pub fn select_message_content<'a>(
129129
} else if matched.is_none() {
130130
if language_code.is_some_and(|c| c == mc.language.as_ref()) {
131131
matched = Some(mc);
132-
} else if language_code.is_none() {
133-
if let Some((content_language_code, _)) = mc.language.split_once('_') {
134-
if content_language_code == language {
135-
matched = Some(mc);
136-
}
137-
}
132+
} else if language_code.is_none()
133+
&& let Some((content_language_code, _)) = mc.language.split_once('_')
134+
&& content_language_code == language
135+
{
136+
matched = Some(mc);
138137
}
139138

140139
if mc.language.as_ref() == MessageContent::DEFAULT_LANGUAGE {
@@ -375,16 +374,16 @@ fn format(text: &str, subs: &[&str]) -> Result<Box<str>, MetadataParsingErrorRea
375374
new_text.push('{');
376375
}
377376

378-
if let Some(sub_index) = unused_sub_indexes.first() {
379-
if let Some(sub) = subs.get(*sub_index) {
380-
return Err(MetadataParsingErrorReason::MissingPlaceholder(
381-
(*sub).to_owned(),
382-
*sub_index,
383-
));
384-
}
377+
if let Some(sub_index) = unused_sub_indexes.first()
378+
&& let Some(sub) = subs.get(*sub_index)
379+
{
380+
Err(MetadataParsingErrorReason::MissingPlaceholder(
381+
(*sub).to_owned(),
382+
*sub_index,
383+
))
384+
} else {
385+
Ok(new_text.into_boxed_str())
385386
}
386-
387-
Ok(new_text.into_boxed_str())
388387
}
389388

390389
impl EmitYaml for MessageContent {

src/metadata/metadata_document.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -358,21 +358,21 @@ fn split_on_prelude(masterlist: &str) -> Option<(&str, &str)> {
358358
continue;
359359
}
360360

361-
if let Some((_, next_byte)) = iter.peek() {
362-
if !matches!(next_byte, b' ' | b'#' | b'\n' | b'\r') {
363-
// LIMITATION: Slicing at index should never fail, but the
364-
// compiler can't see that. A variation of str.find() that
365-
// could take a closure that matches on substrings would
366-
// eliminate the need for this.
367-
if let Some(suffix) = remainder.get(index..) {
368-
return Some((prefix, suffix));
369-
}
370-
371-
logging::error!(
372-
"Unexpectedly failed to slice the masterlist on a new line at index {}",
373-
prefix.len() + index
374-
);
361+
if let Some((_, next_byte)) = iter.peek()
362+
&& !matches!(next_byte, b' ' | b'#' | b'\n' | b'\r')
363+
{
364+
// LIMITATION: Slicing at index should never fail, but the
365+
// compiler can't see that. A variation of str.find() that
366+
// could take a closure that matches on substrings would
367+
// eliminate the need for this.
368+
if let Some(suffix) = remainder.get(index..) {
369+
return Some((prefix, suffix));
375370
}
371+
372+
logging::error!(
373+
"Unexpectedly failed to slice the masterlist on a new line at index {}",
374+
prefix.len() + index
375+
);
376376
}
377377
}
378378

src/metadata/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn emit<T: yaml::EmitYaml>(metadata: &T) -> String {
2727
}
2828

2929
#[cfg(test)]
30-
fn parse(yaml: &str) -> saphyr::MarkedYaml {
30+
fn parse(yaml: &str) -> saphyr::MarkedYaml<'_> {
3131
use saphyr::LoadableYamlNode;
3232

3333
saphyr::MarkedYaml::load_from_str(yaml)

src/plugin/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,13 @@ fn calculate_crc(path: &Path) -> std::io::Result<u32> {
391391
}
392392

393393
fn extract_bash_tags(description: &str) -> Vec<String> {
394-
if let Some((_, bash_tags)) = description.split_once("{{BASH:") {
395-
if let Some((bash_tags, _)) = bash_tags.split_once("}}") {
396-
return bash_tags.split(',').map(|s| s.trim().to_owned()).collect();
397-
}
394+
if let Some((_, bash_tags)) = description.split_once("{{BASH:")
395+
&& let Some((bash_tags, _)) = bash_tags.split_once("}}")
396+
{
397+
bash_tags.split(',').map(|s| s.trim().to_owned()).collect()
398+
} else {
399+
Vec::new()
398400
}
399-
Vec::new()
400401
}
401402

402403
fn extract_version(description: &str) -> Option<String> {

0 commit comments

Comments
 (0)