From c66dc44ee21d24a653cfee9f9718a8b660ab611f Mon Sep 17 00:00:00 2001 From: Robin Vobruba Date: Tue, 5 Dec 2023 18:09:19 +0100 Subject: [PATCH] Gets rid of some clippy errors and warnings [fix] --- src/coverage.rs | 19 ++++++++++++------- src/data.rs | 2 ++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/coverage.rs b/src/coverage.rs index 755cc35..d88d98d 100644 --- a/src/coverage.rs +++ b/src/coverage.rs @@ -85,7 +85,7 @@ pub struct Coverage { fn create_arbitrary_content_rgxs(tree_recs: &[RNode]) -> Vec { let mut rgxs = vec![]; - for rec_node in tree_recs.iter() { + for rec_node in tree_recs { let rec_brw = rec_node.borrow(); if let Some(rec) = rec_brw.value { if let Some(arbitrary_content) = rec.arbitrary_content { @@ -112,7 +112,7 @@ fn create_arbitrary_content_rgxs(tree_recs: &[RNode]) -> Vec { fn create_generated_content_rgxs(tree_recs: &[RNode]) -> Vec { let mut rgxs = vec![]; - for rec_node in tree_recs.iter() { + for rec_node in tree_recs { let rec_brw = rec_node.borrow(); if let Some(rec) = rec_brw.value { if rec.generated { @@ -138,7 +138,7 @@ fn create_generated_content_rgxs(tree_recs: &[RNode]) -> Vec { fn create_module_rgxs(tree_recs: &[RNode]) -> Vec { let mut rgxs = HashSet::new(); log::warn!("module rgxs:"); - for rec_node in tree_recs.iter() { + for rec_node in tree_recs { let rec_brw = rec_node.borrow(); if let Some(rec) = rec_brw.value { if rec.module { @@ -261,7 +261,7 @@ impl Checker { self.coverage .r#in .entry(rec) - .or_insert_with(Vec::new) + .or_default() .push(Rc::clone(dir_or_file)); } } @@ -464,6 +464,11 @@ where /// /// If any of the input listing entires is an error, /// usually caused by an I/O issue. +/// +/// # Panics +/// +/// Expecting `Option`s that logically have to be `Some`, +/// thus this should never panic in practice. pub fn cover_listing_by_stds( dirs_and_files: T, ignored_paths: &Regex, @@ -474,9 +479,9 @@ where { Ok(match stds { Standards::Default => { - let std = STDS - .get(DEFAULT_STD_NAME) - .expect("Clap already checked the name!"); + let std = STDS.get(DEFAULT_STD_NAME).expect( + "This name was chosen from the data itsself, so it should alwyas be available", + ); vec![cover_listing_with(dirs_and_files, ignored_paths, std)?] } Standards::All => cover_listing(dirs_and_files, ignored_paths)?, diff --git a/src/data.rs b/src/data.rs index c65990d..ac45445 100644 --- a/src/data.rs +++ b/src/data.rs @@ -2,4 +2,6 @@ // // SPDX-License-Identifier: AGPL-3.0-or-later +#![allow(clippy::needless_raw_string_hashes)] + include!(concat!(env!("OUT_DIR"), "/data_gen.rs"));