chore(clippy): make clippy happy (#1856)
This commit is contained in:
parent
3b52c2fc7e
commit
cba6f071ae
|
@ -493,8 +493,8 @@ mod tests {
|
|||
assert_eq!(parse_units("3_3_0", 3).unwrap(), U256::from(330000), "underscore");
|
||||
assert_eq!(parse_units("330", 0).unwrap(), U256::from(330), "zero decimals");
|
||||
assert_eq!(parse_units(".1234", 3).unwrap(), U256::from(123), "truncate too many decimals");
|
||||
assert_eq!(parse_units("1", 80).is_err(), true, "overflow");
|
||||
assert_eq!(parse_units("1", -1).is_err(), true, "neg units");
|
||||
assert!(parse_units("1", 80).is_err(), "overflow");
|
||||
assert!(parse_units("1", -1).is_err(), "neg units");
|
||||
let two_e30 = U256::from(2) * U256([0x4674edea40000000, 0xc9f2c9cd0, 0x0, 0x0]);
|
||||
assert_eq!(parse_units("2", 30).unwrap(), two_e30, "2e30");
|
||||
assert_eq!(parse_units(".33_319_2", 0).unwrap(), U256::zero(), "mix");
|
||||
|
|
|
@ -400,7 +400,9 @@ impl<T: ArtifactOutput> fmt::Display for ProjectCompileOutput<T> {
|
|||
if self.compiler_output.is_unchanged() {
|
||||
f.write_str("Nothing to compile")
|
||||
} else {
|
||||
self.compiler_output.diagnostics(&self.ignored_error_codes, self.compiler_severity_filter.clone()).fmt(f)
|
||||
self.compiler_output
|
||||
.diagnostics(&self.ignored_error_codes, self.compiler_severity_filter.clone())
|
||||
.fmt(f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -428,15 +430,19 @@ impl AggregatedCompilerOutput {
|
|||
}
|
||||
|
||||
/// Whether the output contains a compiler error
|
||||
pub fn has_error(&self, ignored_error_codes: &[u64], compiler_severity_filter: &Severity) -> bool {
|
||||
pub fn has_error(
|
||||
&self,
|
||||
ignored_error_codes: &[u64],
|
||||
compiler_severity_filter: &Severity,
|
||||
) -> bool {
|
||||
self.errors.iter().any(|err| {
|
||||
if compiler_severity_filter.ge(&err.severity) {
|
||||
if compiler_severity_filter.is_warning() {
|
||||
if compiler_severity_filter.is_warning() {
|
||||
return self.has_warning(ignored_error_codes)
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
false
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -451,7 +457,11 @@ impl AggregatedCompilerOutput {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn diagnostics<'a>(&'a self, ignored_error_codes: &'a [u64], compiler_severity_filter: Severity) -> OutputDiagnostics {
|
||||
pub fn diagnostics<'a>(
|
||||
&'a self,
|
||||
ignored_error_codes: &'a [u64],
|
||||
compiler_severity_filter: Severity,
|
||||
) -> OutputDiagnostics {
|
||||
OutputDiagnostics { compiler_output: self, ignored_error_codes, compiler_severity_filter }
|
||||
}
|
||||
|
||||
|
@ -719,7 +729,7 @@ pub struct OutputDiagnostics<'a> {
|
|||
impl<'a> OutputDiagnostics<'a> {
|
||||
/// Returns true if there is at least one error of high severity
|
||||
pub fn has_error(&self) -> bool {
|
||||
self.compiler_output.has_error(&self.ignored_error_codes, &self.compiler_severity_filter)
|
||||
self.compiler_output.has_error(self.ignored_error_codes, &self.compiler_severity_filter)
|
||||
}
|
||||
|
||||
/// Returns true if there is at least one warning
|
||||
|
|
|
@ -311,7 +311,8 @@ impl<'a, T: ArtifactOutput> CompiledState<'a, T> {
|
|||
ctx,
|
||||
&project.paths,
|
||||
)
|
||||
} else if output.has_error(&project.ignored_error_codes, &project.compiler_severity_filter) {
|
||||
} else if output.has_error(&project.ignored_error_codes, &project.compiler_severity_filter)
|
||||
{
|
||||
trace!("skip writing cache file due to solc errors: {:?}", output.errors);
|
||||
project.artifacts_handler().output_to_artifacts(
|
||||
&output.contracts,
|
||||
|
@ -361,14 +362,15 @@ impl<'a, T: ArtifactOutput> ArtifactsState<'a, T> {
|
|||
let project = cache.project();
|
||||
let ignored_error_codes = project.ignored_error_codes.clone();
|
||||
let compiler_severity_filter = project.compiler_severity_filter.clone();
|
||||
let skip_write_to_disk = project.no_artifacts || output.has_error(&ignored_error_codes, &compiler_severity_filter);
|
||||
let skip_write_to_disk = project.no_artifacts ||
|
||||
output.has_error(&ignored_error_codes, &compiler_severity_filter);
|
||||
let cached_artifacts = cache.consume(&compiled_artifacts, !skip_write_to_disk)?;
|
||||
Ok(ProjectCompileOutput {
|
||||
compiler_output: output,
|
||||
compiled_artifacts,
|
||||
cached_artifacts,
|
||||
ignored_error_codes,
|
||||
compiler_severity_filter
|
||||
compiler_severity_filter,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1623,8 +1623,8 @@ fn test_compiler_severity_filter() {
|
|||
fn gen_test_data_warning_path() -> ProjectPathsConfig {
|
||||
let root =
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("test-data/test-contract-warnings");
|
||||
let paths = ProjectPathsConfig::builder().sources(root).build().unwrap();
|
||||
paths
|
||||
|
||||
ProjectPathsConfig::builder().sources(root).build().unwrap()
|
||||
}
|
||||
|
||||
let project = Project::builder()
|
||||
|
@ -1652,20 +1652,20 @@ fn test_compiler_severity_filter() {
|
|||
#[test]
|
||||
fn test_compiler_severity_filter_and_ignored_error_codes() {
|
||||
fn gen_test_data_licensing_warning() -> ProjectPathsConfig {
|
||||
let root =
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("test-data/test-contract-warnings/LicenseWarning.sol");
|
||||
let paths = ProjectPathsConfig::builder().sources(root).build().unwrap();
|
||||
paths
|
||||
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("test-data/test-contract-warnings/LicenseWarning.sol");
|
||||
|
||||
ProjectPathsConfig::builder().sources(root).build().unwrap()
|
||||
}
|
||||
|
||||
let missing_license_error_code = 1878;
|
||||
|
||||
let project = Project::builder()
|
||||
.no_artifacts()
|
||||
.paths(gen_test_data_licensing_warning())
|
||||
.ephemeral()
|
||||
.build()
|
||||
.unwrap();
|
||||
.no_artifacts()
|
||||
.paths(gen_test_data_licensing_warning())
|
||||
.ephemeral()
|
||||
.build()
|
||||
.unwrap();
|
||||
let compiled = project.compile().unwrap();
|
||||
assert!(compiled.has_compiler_warnings());
|
||||
|
||||
|
@ -1681,13 +1681,13 @@ fn test_compiler_severity_filter_and_ignored_error_codes() {
|
|||
assert!(!compiled.has_compiler_errors());
|
||||
|
||||
let project = Project::builder()
|
||||
.no_artifacts()
|
||||
.paths(gen_test_data_licensing_warning())
|
||||
.ephemeral()
|
||||
.ignore_error_code(missing_license_error_code)
|
||||
.set_compiler_severity_filter(ethers_solc::artifacts::Severity::Warning)
|
||||
.build()
|
||||
.unwrap();
|
||||
.no_artifacts()
|
||||
.paths(gen_test_data_licensing_warning())
|
||||
.ephemeral()
|
||||
.ignore_error_code(missing_license_error_code)
|
||||
.set_compiler_severity_filter(ethers_solc::artifacts::Severity::Warning)
|
||||
.build()
|
||||
.unwrap();
|
||||
let compiled = project.compile().unwrap();
|
||||
assert!(!compiled.has_compiler_warnings());
|
||||
assert!(!compiled.has_compiler_errors());
|
||||
|
|
Loading…
Reference in New Issue