Skip to content

Commit

Permalink
chore: clippies and such
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Jan 4, 2024
1 parent 142114f commit f28020c
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 52 deletions.
1 change: 0 additions & 1 deletion src/artifact_output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,6 @@ impl ArtifactOutput for MinimalCombinedArtifactsHardhatFallback {
}

#[cfg(test)]
#[allow(clippy::extra_unused_type_parameters)]
mod tests {
use super::*;

Expand Down
2 changes: 0 additions & 2 deletions src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ pub static SUPPORTS_INCLUDE_PATH: Lazy<VersionReq> =
use std::sync::Mutex;

#[cfg(any(test, feature = "tests"))]
#[allow(unused)]
static LOCK: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));

/// take the lock in tests, we use this to enforce that
Expand All @@ -74,7 +73,6 @@ static LOCK: Lazy<Mutex<()>> = 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()
}
Expand Down
5 changes: 1 addition & 4 deletions src/compile/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,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),
}

Expand Down Expand Up @@ -452,7 +452,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),
Expand Down Expand Up @@ -481,7 +480,6 @@ impl FilteredCompilerSources {
}

#[cfg(test)]
#[allow(unused)]
fn sources(&self) -> &VersionedFilteredSources {
match self {
FilteredCompilerSources::Sequential(v) => v,
Expand Down Expand Up @@ -682,7 +680,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())
Expand Down
26 changes: 12 additions & 14 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ use thiserror::Error;

pub type Result<T> = std::result::Result<T, SolcError>;

#[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 {
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 3 additions & 7 deletions src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ pub trait FileFilter {
fn is_match(&self, file: &Path) -> bool;
}

impl<F> FileFilter for F
where
F: Fn(&Path) -> bool,
{
impl<F: Fn(&Path) -> bool> FileFilter for F {
fn is_match(&self, file: &Path) -> bool {
(self)(file)
}
Expand Down Expand Up @@ -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()
Expand All @@ -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<dyn FileFilter>,
f: &dyn FileFilter,
) {
trace!("optimizing output selection with custom filter");
let selection = settings
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#[macro_use]
extern crate tracing;

#[macro_use]
pub mod error;

pub mod artifacts;
pub mod sourcemap;

Expand Down Expand Up @@ -33,7 +36,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;
Expand Down
1 change: 0 additions & 1 deletion src/project_util/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ impl MockProjectGenerator {
}
}

#[allow(clippy::derivable_impls)]
impl Default for MockProjectGenerator {
fn default() -> Self {
Self { name_strategy: Box::<SimpleNamingStrategy>::default(), inner: Default::default() }
Expand Down
2 changes: 1 addition & 1 deletion src/project_util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::{
artifacts::Settings,
config::ProjectPathsConfigBuilder,
error::{bail, Result, SolcError},
error::{Result, SolcError},
hh::HardhatArtifacts,
project_util::mock::{MockProjectGenerator, MockProjectSettings},
remappings::Remapping,
Expand Down
6 changes: 3 additions & 3 deletions src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
4 changes: 1 addition & 3 deletions src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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,
}

Expand Down Expand Up @@ -936,7 +934,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),
Expand Down
3 changes: 1 addition & 2 deletions src/resolver/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SolDataUnit<String>>,
pub version: Option<SolDataUnit<String>>,
Expand All @@ -23,7 +22,7 @@ pub struct SolData {
}

impl SolData {
#[allow(unused)]
#[allow(dead_code)]
pub fn fmt_version<W: std::fmt::Write>(
&self,
f: &mut W,
Expand Down
2 changes: 1 addition & 1 deletion src/resolver/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions src/sourcemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,6 @@ pub fn parse(input: &str) -> Result<SourceMap, SyntaxError> {
mod tests {
use super::*;

#[allow(unused)]
fn tokenize(s: &str) -> Vec<Spanned<Token, usize, SyntaxError>> {
TokenStream::new(s).collect()
}

#[test]
fn can_parse_source_maps() {
// all source maps from the compiler output test data
Expand Down
7 changes: 0 additions & 7 deletions tests/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit f28020c

Please sign in to comment.