diff --git a/src/artifact_output/mod.rs b/src/artifact_output/mod.rs index c4832e38..63e2bfee 100644 --- a/src/artifact_output/mod.rs +++ b/src/artifact_output/mod.rs @@ -1119,7 +1119,6 @@ impl ArtifactOutput for MinimalCombinedArtifactsHardhatFallback { } #[cfg(test)] -#[allow(clippy::extra_unused_type_parameters)] mod tests { use super::*; diff --git a/src/compile/mod.rs b/src/compile/mod.rs index aa0b5b04..45daec11 100644 --- a/src/compile/mod.rs +++ b/src/compile/mod.rs @@ -64,7 +64,6 @@ pub static SUPPORTS_INCLUDE_PATH: Lazy = use std::sync::Mutex; #[cfg(any(test, feature = "tests"))] -#[allow(unused)] static LOCK: Lazy> = Lazy::new(|| Mutex::new(())); /// take the lock in tests, we use this to enforce that @@ -74,7 +73,6 @@ static LOCK: Lazy> = Lazy::new(|| Mutex::new(())); /// Instead of taking this lock in `Solc::blocking_install`, the lock should be taken before /// installation is detected. #[cfg(any(test, feature = "tests"))] -#[allow(unused)] pub(crate) fn take_solc_installer_lock() -> std::sync::MutexGuard<'static, ()> { LOCK.lock().unwrap() } diff --git a/src/compile/project.rs b/src/compile/project.rs index 7138ea83..f11a85ee 100644 --- a/src/compile/project.rs +++ b/src/compile/project.rs @@ -379,11 +379,11 @@ impl<'a, T: ArtifactOutput> ArtifactsState<'a, T> { /// Determines how the `solc <-> sources` pairs are executed #[derive(Debug, Clone)] -#[allow(dead_code)] enum CompilerSources { /// Compile all these sequentially Sequential(VersionedSources), /// Compile all these in parallel using a certain amount of jobs + #[allow(dead_code)] Parallel(VersionedSources, usize), } @@ -453,7 +453,6 @@ impl CompilerSources { /// Determines how the `solc <-> sources` pairs are executed #[derive(Debug, Clone)] -#[allow(dead_code)] enum FilteredCompilerSources { /// Compile all these sequentially Sequential(VersionedFilteredSources), @@ -482,7 +481,6 @@ impl FilteredCompilerSources { } #[cfg(test)] - #[allow(unused)] fn sources(&self) -> &VersionedFilteredSources { match self { FilteredCompilerSources::Sequential(v) => v, @@ -683,7 +681,6 @@ mod tests { use std::path::PathBuf; - #[allow(unused)] fn init_tracing() { let _ = tracing_subscriber::fmt() .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) diff --git a/src/error.rs b/src/error.rs index 5cd823c7..40c4acce 100644 --- a/src/error.rs +++ b/src/error.rs @@ -7,6 +7,18 @@ use thiserror::Error; pub type Result = std::result::Result; +#[allow(unused_macros)] +macro_rules! format_err { + ($($tt:tt)*) => { + $crate::error::SolcError::msg(format!($($tt)*)) + }; +} + +#[allow(unused_macros)] +macro_rules! bail { + ($($tt:tt)*) => { return Err(format_err!($($tt)*)) }; +} + /// Various error types #[derive(Debug, Error)] pub enum SolcError { @@ -86,20 +98,6 @@ impl SolcError { } } -macro_rules! _format_err { - ($($tt:tt)*) => { - $crate::error::SolcError::msg(format!($($tt)*)) - }; -} -#[allow(unused)] -pub(crate) use _format_err as format_err; - -macro_rules! _bail { - ($($tt:tt)*) => { return Err($crate::error::format_err!($($tt)*)) }; -} -#[allow(unused)] -pub(crate) use _bail as bail; - #[derive(Debug, Error)] #[error("\"{}\": {io}", self.path.display())] pub struct SolcIoError { diff --git a/src/filter.rs b/src/filter.rs index 549c8464..cacc3a0c 100644 --- a/src/filter.rs +++ b/src/filter.rs @@ -18,10 +18,7 @@ pub trait FileFilter { fn is_match(&self, file: &Path) -> bool; } -impl FileFilter for F -where - F: Fn(&Path) -> bool, -{ +impl bool> FileFilter for F { fn is_match(&self, file: &Path) -> bool { (self)(file) } @@ -88,7 +85,7 @@ impl SparseOutputFilter { } } SparseOutputFilter::Custom(f) => { - Self::apply_custom_filter(&sources, settings, graph, f) + Self::apply_custom_filter(&sources, settings, graph, &**f) } }; sources.into() @@ -102,12 +99,11 @@ impl SparseOutputFilter { /// `*.t.sol` files and a test file makes use of a library that won't be inlined, then the /// libraries bytecode will be missing. Therefore, we detect all linkReferences of a file /// and treat them as if the filter would also apply to those. - #[allow(clippy::borrowed_box)] fn apply_custom_filter( sources: &FilteredSources, settings: &mut Settings, graph: &GraphEdges, - f: &Box, + f: &dyn FileFilter, ) { tracing::trace!("optimizing output selection with custom filter",); let selection = settings diff --git a/src/lib.rs b/src/lib.rs index ac6decb4..a9c6214c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,9 @@ #![deny(rustdoc::broken_intra_doc_links)] #![cfg_attr(docsrs, feature(doc_cfg))] +#[macro_use] +pub mod error; + pub mod artifacts; pub mod sourcemap; @@ -30,7 +33,6 @@ pub use config::{AllowedLibPaths, PathStyle, ProjectPaths, ProjectPathsConfig, S pub mod remappings; use crate::artifacts::{Source, SourceFile, StandardJsonCompilerInput}; -pub mod error; mod filter; pub mod report; pub mod utils; diff --git a/src/project_util/mock.rs b/src/project_util/mock.rs index b876816e..af8e4034 100644 --- a/src/project_util/mock.rs +++ b/src/project_util/mock.rs @@ -362,7 +362,6 @@ impl MockProjectGenerator { } } -#[allow(clippy::derivable_impls)] impl Default for MockProjectGenerator { fn default() -> Self { Self { name_strategy: Box::::default(), inner: Default::default() } diff --git a/src/project_util/mod.rs b/src/project_util/mod.rs index 0075f655..ce9c8296 100644 --- a/src/project_util/mod.rs +++ b/src/project_util/mod.rs @@ -2,7 +2,7 @@ use crate::{ artifacts::Settings, config::ProjectPathsConfigBuilder, - error::{bail, Result, SolcError}, + error::{Result, SolcError}, hh::HardhatArtifacts, project_util::mock::{MockProjectGenerator, MockProjectSettings}, remappings::Remapping, @@ -84,10 +84,7 @@ impl TempProject { self.project().compile() } - pub fn compile_sparse( - &self, - filter: F, - ) -> Result> { + pub fn compile_sparse(&self, filter: Box) -> Result> { self.project().compile_sparse(filter) } diff --git a/src/report/mod.rs b/src/report/mod.rs index f73cb644..a10bad15 100644 --- a/src/report/mod.rs +++ b/src/report/mod.rs @@ -199,17 +199,17 @@ pub(crate) fn solc_success( get_default(|r| r.reporter.on_solc_success(solc, version, output, duration)); } -#[allow(unused)] +#[allow(dead_code)] pub(crate) fn solc_installation_start(version: &Version) { get_default(|r| r.reporter.on_solc_installation_start(version)); } -#[allow(unused)] +#[allow(dead_code)] pub(crate) fn solc_installation_success(version: &Version) { get_default(|r| r.reporter.on_solc_installation_success(version)); } -#[allow(unused)] +#[allow(dead_code)] pub(crate) fn solc_installation_error(version: &Version, error: &str) { get_default(|r| r.reporter.on_solc_installation_error(version, error)); } diff --git a/src/resolver/mod.rs b/src/resolver/mod.rs index 667cdb65..189a26d7 100644 --- a/src/resolver/mod.rs +++ b/src/resolver/mod.rs @@ -93,7 +93,6 @@ pub struct GraphEdges { /// Absolute imports, like `import "src/Contract.sol"` are possible, but this does not play /// nice with the standard-json import format, since the VFS won't be able to resolve /// "src/Contract.sol" without help via `--include-path` - #[allow(unused)] resolved_solc_include_paths: IncludePaths, } @@ -204,7 +203,6 @@ pub struct Graph { /// relationship of the nodes edges: GraphEdges, /// the root of the project this graph represents - #[allow(unused)] root: PathBuf, } @@ -946,7 +944,7 @@ impl<'a> fmt::Display for DisplayNode<'a> { /// Errors thrown when checking the solc version of a file #[derive(Debug, thiserror::Error)] -#[allow(unused)] +#[allow(dead_code)] enum SourceVersionError { #[error("Failed to parse solidity version {0}: {1}")] InvalidVersion(String, SolcError), diff --git a/src/resolver/parse.rs b/src/resolver/parse.rs index 76a31b2b..62d111d3 100644 --- a/src/resolver/parse.rs +++ b/src/resolver/parse.rs @@ -11,7 +11,6 @@ use std::{ /// Represents various information about a solidity file parsed via [solang_parser] #[derive(Debug)] -#[allow(unused)] pub struct SolData { pub license: Option>, pub version: Option>, @@ -23,7 +22,7 @@ pub struct SolData { } impl SolData { - #[allow(unused)] + #[allow(dead_code)] pub fn fmt_version( &self, f: &mut W, diff --git a/src/resolver/tree.rs b/src/resolver/tree.rs index e140c3ab..a6181e11 100644 --- a/src/resolver/tree.rs +++ b/src/resolver/tree.rs @@ -132,7 +132,7 @@ fn print_node( } /// Prints all the imports of a node -#[allow(clippy::too_many_arguments, clippy::ptr_arg)] +#[allow(clippy::too_many_arguments)] fn print_imports( graph: &Graph, node_index: usize, diff --git a/src/sourcemap.rs b/src/sourcemap.rs index 1be14c13..f189245d 100644 --- a/src/sourcemap.rs +++ b/src/sourcemap.rs @@ -501,11 +501,6 @@ pub fn parse(input: &str) -> Result { mod tests { use super::*; - #[allow(unused)] - fn tokenize(s: &str) -> Vec> { - TokenStream::new(s).collect() - } - #[test] fn can_parse_source_maps() { // all source maps from the compiler output test data diff --git a/tests/project.rs b/tests/project.rs index 84950940..5311ba8c 100644 --- a/tests/project.rs +++ b/tests/project.rs @@ -24,13 +24,6 @@ use std::{ str::FromStr, }; -#[allow(unused)] -fn init_tracing() { - tracing_subscriber::fmt() - .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) - .init(); -} - #[test] fn can_get_versioned_linkrefs() { let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("test-data/test-versioned-linkrefs");