Skip to content

Commit

Permalink
chore: more lints
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Jan 7, 2025
1 parent 8c5683d commit 28f4d0b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ dbg-macro = "warn"
manual-string-new = "warn"
uninlined-format-args = "warn"
use-self = "warn"
redundant-clone = "warn"
# until <https://github.com/rust-lang/rust-clippy/issues/13885> is fixed
literal-string-with-formatting-args = "allow"

[workspace.lints.rust]
rust-2018-idioms = "deny"
rust-2018-idioms = "warn"
# unreachable-pub = "warn"
unused-must-use = "deny"
unused-must-use = "warn"
redundant-lifetimes = "warn"

[workspace.lints.rustdoc]
all = "warn"
Expand Down
3 changes: 1 addition & 2 deletions crates/artifacts/solc/src/remappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ impl FromStr for Remapping {
return Err(RemappingError::EmptyRemappingValue(remapping.to_string()));
}
// if the remapping just starts with : (no context name), treat it as global
let context =
context.and_then(|c| if c.trim().is_empty() { None } else { Some(c.to_string()) });
let context = context.filter(|c| !c.trim().is_empty());
Ok(Self { context, name: name.to_string(), path: path.to_string() })
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/compilers/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ impl<T: ArtifactOutput<CompilerContract = C::CompilerContract>, C: Compiler>
seen_by_compiler: false,
};

self.cache.files.insert(file, entry.clone());
self.cache.files.insert(file, entry);
}

/// Returns the set of [Source]s that need to be compiled to produce artifacts for requested
Expand Down
2 changes: 1 addition & 1 deletion crates/compilers/src/compile/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ mod tests {
fn extra_output_cached() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../test-data/dapp-sample");
let paths = ProjectPathsConfig::builder().sources(root.join("src")).lib(root.join("lib"));
let mut project = TempProject::<MultiCompiler>::new(paths.clone()).unwrap();
let mut project = TempProject::<MultiCompiler>::new(paths).unwrap();

// Compile once without enabled extra output
project.compile().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/compilers/src/compilers/restrictions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl<T: CompilerSettingsRestrictions> RestrictionsWithVersion<T> {
if let Some(self_version) = self.version.as_mut() {
self_version.comparators.extend(version.comparators);
} else {
self.version = Some(version.clone());
self.version = Some(version);
}
}
self.restrictions = self.restrictions.merge(other.restrictions)?;
Expand Down
12 changes: 4 additions & 8 deletions crates/compilers/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,9 @@ impl<L: Language, D: ParsedSource<Language = L>> Graph<D> {

if !all_versions.iter().any(|v| req.matches(v.as_ref())) {
return if project.offline {
Err(SourceVersionError::NoMatchingVersionOffline(req.clone()))
Err(SourceVersionError::NoMatchingVersionOffline(req))
} else {
Err(SourceVersionError::NoMatchingVersion(req.clone()))
Err(SourceVersionError::NoMatchingVersion(req))
};
}

Expand Down Expand Up @@ -685,9 +685,7 @@ impl<L: Language, D: ParsedSource<Language = L>> Graph<D> {
{
// check if the version is even valid
let f = utils::source_name(&failed_node.path, &self.root).display();
return Err(
format!("Encountered invalid solc version in {f}: {version_err}").to_string()
);
return Err(format!("Encountered invalid solc version in {f}: {version_err}"));
} else {
// if the node requirement makes sense, it means that there is at least one node
// which requirement conflicts with it
Expand Down Expand Up @@ -757,9 +755,7 @@ impl<L: Language, D: ParsedSource<Language = L>> Graph<D> {

if all_profiles.is_empty() {
let f = utils::source_name(&failed_node.path, &self.root).display();
return Err(
format!("Missing profile satisfying settings restrictions for {f}").to_string()
);
return Err(format!("Missing profile satisfying settings restrictions for {f}"));
}

// iterate over all the nodes once again and find the one incompatible
Expand Down

0 comments on commit 28f4d0b

Please sign in to comment.