From d609de74a958b26d12a78a962a0bfcdc0dea56fc Mon Sep 17 00:00:00 2001 From: Felix Obenhuber Date: Tue, 16 Aug 2022 14:47:41 +0200 Subject: [PATCH] Fix clippy lints --- src/compiler/args.rs | 12 ++++++------ src/compiler/c.rs | 8 ++++---- src/compiler/compiler.rs | 14 +++++++------- src/compiler/msvc.rs | 2 +- src/compiler/rust.rs | 5 +++-- tests/system.rs | 2 +- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/compiler/args.rs b/src/compiler/args.rs index a9c81580..e551c0f8 100644 --- a/src/compiler/args.rs +++ b/src/compiler/args.rs @@ -11,7 +11,7 @@ pub type ArgParseResult = StdResult; pub type ArgToStringResult = StdResult; pub type PathTransformerFn<'a> = &'a mut dyn FnMut(&Path) -> Option; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum ArgParseError { UnexpectedEndOfArgs, InvalidUnicode(OsString), @@ -35,7 +35,7 @@ impl Error for ArgParseError { } } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum ArgToStringError { FailedPathTransform(PathBuf), InvalidUnicode(OsString), @@ -69,7 +69,7 @@ pub type Delimiter = Option; /// on the different kinds of argument). `Flag`s may contain a simple /// variant which influences how to do caching, whereas `WithValue`s could /// be a struct variant with parsed data from the value. -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] pub enum Argument { /// Unknown non-flag argument ; e.g. "foo" Raw(OsString), @@ -83,7 +83,7 @@ pub enum Argument { } /// How a value is passed to an argument with a value. -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] pub enum ArgDisposition { /// As "-arg value" Separated, @@ -299,7 +299,7 @@ macro_rules! ArgData { // PartialEq necessary for tests { pub $( $tok:tt )+ } => { - #[derive(Clone, Debug, PartialEq)] + #[derive(Clone, Debug, PartialEq, Eq)] pub enum ArgData { $($tok)+ } @@ -387,7 +387,7 @@ pub fn split_os_string_arg(val: OsString, split: &str) -> ArgParseResult<(String } /// The description of how an argument may be parsed -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] pub enum ArgInfo { /// An simple flag argument, of the form "-foo" Flag(&'static str, T), diff --git a/src/compiler/c.rs b/src/compiler/c.rs index bcceca1d..5d39dff2 100644 --- a/src/compiler/c.rs +++ b/src/compiler/c.rs @@ -60,7 +60,7 @@ where compiler: I, } -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum Language { C, Cxx, @@ -70,7 +70,7 @@ pub enum Language { } /// Artifact produced by a C/C++ compiler. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct ArtifactDesciptor { /// Path to the artifact. pub path: PathBuf, @@ -80,7 +80,7 @@ pub struct ArtifactDesciptor { /// The results of parsing a compiler commandline. #[allow(dead_code)] -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub struct ParsedArguments { /// The input source file. pub input: PathBuf, @@ -166,7 +166,7 @@ struct CCompilation { } /// Supported C compilers. -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub enum CCompilerKind { /// GCC Gcc, diff --git a/src/compiler/compiler.rs b/src/compiler/compiler.rs index 166f000e..015963d3 100644 --- a/src/compiler/compiler.rs +++ b/src/compiler/compiler.rs @@ -79,7 +79,7 @@ impl CompileCommand { } /// Supported compilers. -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub enum CompilerKind { /// A C compiler. C(CCompilerKind), @@ -691,7 +691,7 @@ pub struct HashResult { } /// Possible results of parsing compiler arguments. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum CompilerArguments { /// Commandline can be handled. Ok(T), @@ -720,7 +720,7 @@ macro_rules! try_or_cannot_cache { } /// Specifics about distributed compilation. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum DistType { /// Distribution was not enabled. NoDist, @@ -731,7 +731,7 @@ pub enum DistType { } /// Specifics about cache misses. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum MissType { /// The compilation was not found in the cache, nothing more. Normal, @@ -772,7 +772,7 @@ pub enum CompileResult { } /// The state of `--color` options passed to a compiler. -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum ColorMode { Off, On, @@ -818,14 +818,14 @@ impl PartialEq for CompileResult { } /// Can this result be stored in cache? -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Cacheable { Yes, No, } /// Control of caching behavior. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum CacheControl { /// Default caching behavior. Default, diff --git a/src/compiler/msvc.rs b/src/compiler/msvc.rs index 60e6e497..4320974a 100644 --- a/src/compiler/msvc.rs +++ b/src/compiler/msvc.rs @@ -36,7 +36,7 @@ use crate::errors::*; /// A struct on which to implement `CCompilerImpl`. /// /// Needs a little bit of state just to persist `includes_prefix`. -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub struct Msvc { /// The prefix used in the output of `-showIncludes`. pub includes_prefix: String, diff --git a/src/compiler/rust.rs b/src/compiler/rust.rs index e9937b57..f18f3161 100644 --- a/src/compiler/rust.rs +++ b/src/compiler/rust.rs @@ -180,7 +180,7 @@ pub struct RustCompilation { } // The selection of crate types for this compilation -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct CrateTypes { rlib: bool, staticlib: bool, @@ -3148,7 +3148,8 @@ proc_macro false o => panic!("Got unexpected parse result: {:?}", o), }; // Just use empty files for sources. - for src in ["foo.rs"].iter() { + { + let src = &"foo.rs"; let s = format!("Failed to create {}", src); f.touch(src).expect(&s); } diff --git a/tests/system.rs b/tests/system.rs index c93e5852..dac6f6d8 100644 --- a/tests/system.rs +++ b/tests/system.rs @@ -89,7 +89,7 @@ const OUTPUT: &str = "test.o"; // Copy the source files into the tempdir so we can compile with relative paths, since the commandline winds up in the hash key. fn copy_to_tempdir(inputs: &[&str], tempdir: &Path) { for f in inputs { - let original_source_file = Path::new(file!()).parent().unwrap().join(&*f); + let original_source_file = Path::new(file!()).parent().unwrap().join(f); let source_file = tempdir.join(f); trace!("fs::copy({:?}, {:?})", original_source_file, source_file); fs::copy(&original_source_file, &source_file).unwrap();