Skip to content

Commit

Permalink
chore: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Dec 2, 2024
1 parent f9cb4fa commit e4c5c8e
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
8 changes: 5 additions & 3 deletions crates/artifacts/solc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,11 @@ impl fmt::Display for Error {
// unless it also contains a source location, in which case the entire error message is an
// old style error message, like:
// path/to/file:line:column: ErrorType: message
if lines.clone().next().map_or(false, |l| {
l.contains(short_msg) && l.bytes().filter(|b| *b == b':').count() < 3
}) {
if lines
.clone()
.next()
.is_some_and(|l| l.contains(short_msg) && l.bytes().filter(|b| *b == b':').count() < 3)
{
let _ = lines.next();
}

Expand Down
4 changes: 2 additions & 2 deletions crates/artifacts/solc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ impl SolcInput {
let mut yul_sources = Sources::new();

for (file, source) in sources {
if file.extension().map_or(false, |e| e == "yul") {
if file.extension().is_some_and(|e| e == "yul") {
yul_sources.insert(file, source);
} else if file.extension().map_or(false, |e| e == "sol") {
} else if file.extension().is_some_and(|e| e == "sol") {
solidity_sources.insert(file, source);
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/artifacts/solc/src/output_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ impl OutputSelection {
/// TODO: correctly process wildcard keys to reduce false negatives
pub fn is_subset_of(&self, other: &Self) -> bool {
self.0.iter().all(|(file, selection)| {
other.0.get(file).map_or(false, |other_selection| {
other.0.get(file).is_some_and(|other_selection| {
selection.iter().all(|(contract, outputs)| {
other_selection.get(contract).map_or(false, |other_outputs| {
other_selection.get(contract).is_some_and(|other_outputs| {
outputs.iter().all(|output| other_outputs.contains(output))
})
})
Expand Down
2 changes: 1 addition & 1 deletion crates/artifacts/vyper/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl VyperInput {
let mut interfaces = Sources::new();

for (path, content) in sources {
if path.extension().map_or(false, |ext| ext == VYPER_INTERFACE_EXTENSION) {
if path.extension().is_some_and(|ext| ext == VYPER_INTERFACE_EXTENSION) {
// Interface .vyi files should be removed from the output selection.
settings.output_selection.0.remove(path.to_string_lossy().as_ref());
interfaces.insert(path, content);
Expand Down
6 changes: 2 additions & 4 deletions crates/compilers/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ impl GroupedSources {

/// Returns true if the file was included with the given version.
pub fn contains(&self, file: &Path, version: &Version) -> bool {
self.inner.get(file).map_or(false, |versions| versions.contains(version))
self.inner.get(file).is_some_and(|versions| versions.contains(version))
}
}

Expand Down Expand Up @@ -783,9 +783,7 @@ impl<T: ArtifactOutput, C: Compiler> ArtifactsCacheInner<'_, T, C> {

let mut dirty_profiles = HashSet::new();
for (profile, settings) in &self.cache.profiles {
if !existing_profiles
.get(profile.as_str())
.map_or(false, |p| p.can_use_cached(settings))
if !existing_profiles.get(profile.as_str()).is_some_and(|p| p.can_use_cached(settings))
{
trace!("dirty profile: {}", profile);
dirty_profiles.insert(profile.clone());
Expand Down
2 changes: 1 addition & 1 deletion crates/compilers/src/compile/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ impl<C: Compiler> AggregatedCompilerOutput<C> {

self.contracts.contracts_with_files().filter(|(path, _, _)| *path == contract_path).any(
|(_, _, contract)| {
contract.abi.as_ref().map_or(false, |abi| abi.functions.contains_key("IS_TEST"))
contract.abi.as_ref().is_some_and(|abi| abi.functions.contains_key("IS_TEST"))
},
)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/compilers/src/compilers/solc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ impl<V: Ord + Copy> Restriction<V> {
///
/// If given None, only returns true if no restrictions are set
pub fn satisfies(&self, value: Option<V>) -> bool {
self.min.map_or(true, |min| value.map_or(false, |v| v >= min))
&& self.max.map_or(true, |max| value.map_or(false, |v| v <= max))
self.min.map_or(true, |min| value.is_some_and(|v| v >= min))
&& self.max.map_or(true, |max| value.is_some_and(|v| v <= max))
}

/// Combines two restrictions into a new one
Expand Down
2 changes: 1 addition & 1 deletion crates/compilers/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl<'a> SparseOutputFilter<'a> {
.collect();

// Remove clean sources, those will be read from cache.
full_compilation.retain(|file| sources.0.get(file).map_or(false, |s| s.is_dirty()));
full_compilation.retain(|file| sources.0.get(file).is_some_and(|s| s.is_dirty()));

settings.update_output_selection(|selection| {
trace!(
Expand Down
2 changes: 1 addition & 1 deletion crates/compilers/src/resolver/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl SolData {
/// This will attempt to parse the solidity AST and extract the imports and version pragma. If
/// parsing fails, we'll fall back to extract that info via regex
pub fn parse(content: &str, file: &Path) -> Self {
let is_yul = file.extension().map_or(false, |ext| ext == "yul");
let is_yul = file.extension().is_some_and(|ext| ext == "yul");
let mut version = None;
let mut experimental = None;
let mut imports = Vec::<Spanned<SolImport>>::new();
Expand Down

0 comments on commit e4c5c8e

Please sign in to comment.