From bef7aa273eef984c0ea49ffa3df61989e47af18e Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 11 Dec 2021 07:59:01 +0200 Subject: fix: check for whether clippy is installed Previously, "cargo --list" had "clippy" on its own line, with no description. Now it has a description, so we need to change how we look for clippy. Sponsored-by: author --- check | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/check b/check index ac19c5f..cb5ffc1 100755 --- a/check +++ b/check @@ -107,7 +107,11 @@ class Runcmd: def got_cargo(self, subcommand): """Is a cargo subcommand available?""" p = self.runcmd(["cargo", "--list"], check=True, stdout=PIPE) - lines = [line.strip() for line in p.stdout.decode("UTF-8").splitlines()] + lines = [ + line.split()[0] + for line in p.stdout.decode("UTF-8").splitlines() + if line.strip() + ] return subcommand in lines def codegen(self, md, output, **kwargs): -- cgit v1.2.1 From a5858f2dc142411d7acc5b4a9f84b786a5082eb5 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 11 Dec 2021 08:02:37 +0200 Subject: chore: tidy up minor issues found by clippy Sponsored-by: author --- src/bindings.rs | 8 +------- src/metadata.rs | 2 +- subplotlib/helpers/subplotlib_context.rs | 11 +---------- subplotlib/src/steplibrary/datadir.rs | 7 +------ 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/bindings.rs b/src/bindings.rs index 91a2c8d..2d5f062 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -393,17 +393,11 @@ mod test_binding { } /// Set of all known bindings. -#[derive(Debug)] +#[derive(Debug, Default)] pub struct Bindings { bindings: Vec, } -impl Default for Bindings { - fn default() -> Self { - Bindings { bindings: vec![] } - } -} - #[derive(Debug, Deserialize)] struct ParsedImpl { function: String, diff --git a/src/metadata.rs b/src/metadata.rs index 0d0e844..3bc7268 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -77,7 +77,7 @@ impl Metadata { let mut bindings = Bindings::new(); - get_bindings(&bindings_filenames, &mut bindings, template.as_deref())?; + get_bindings(&bindings_filenames, &mut bindings, template)?; event!(Level::TRACE, "Loaded all metadata successfully"); diff --git a/subplotlib/helpers/subplotlib_context.rs b/subplotlib/helpers/subplotlib_context.rs index b986ed2..c662c98 100644 --- a/subplotlib/helpers/subplotlib_context.rs +++ b/subplotlib/helpers/subplotlib_context.rs @@ -1,21 +1,12 @@ use std::collections::HashMap; +#[derive(Default)] struct Context { counter: usize, files: HashMap, this_file: Option, } -impl Default for Context { - fn default() -> Self { - Self { - counter: 0, - files: HashMap::new(), - this_file: None, - } - } -} - impl Context { fn remember_file(&mut self, name: &str, content: SubplotDataFile) { self.files.insert(name.to_string(), content); diff --git a/subplotlib/src/steplibrary/datadir.rs b/subplotlib/src/steplibrary/datadir.rs index ab80d25..8aa6f00 100644 --- a/subplotlib/src/steplibrary/datadir.rs +++ b/subplotlib/src/steplibrary/datadir.rs @@ -10,6 +10,7 @@ use std::path::{Component, Path, PathBuf}; pub use crate::prelude::*; +#[derive(Default)] pub struct Datadir { inner: Option, } @@ -18,12 +19,6 @@ pub struct DatadirInner { base: tempfile::TempDir, } -impl Default for Datadir { - fn default() -> Self { - Self { inner: None } - } -} - impl ContextElement for Datadir { fn created(&mut self, scenario: &Scenario) { assert!(self.inner.is_none()); -- cgit v1.2.1