Skip to content

Commit

Permalink
Fix new clippy lints. (FuelLabs#2192)
Browse files Browse the repository at this point in the history
appease clippy
  • Loading branch information
sezna authored Jun 30, 2022
1 parent c3869c9 commit 2e9c381
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 27 deletions.
4 changes: 2 additions & 2 deletions forc-pkg/src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ where
for pkg in removed {
if pkg.name != proj_name {
let name = name_or_git_unique_string(pkg);
let _ = println_red(&format!(" Removing {}", name));
println_red(&format!(" Removing {}", name));
}
}
}
Expand All @@ -269,7 +269,7 @@ where
for pkg in removed {
if pkg.name != proj_name {
let name = name_or_git_unique_string(pkg);
let _ = println_green(&format!(" Adding {}", name));
println_green(&format!(" Adding {}", name));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion forc-plugins/forc-explore/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async fn run(app: App) -> Result<()> {
.ok_or_else(|| anyhow!("no releases to select from"))?;
let version = release.name.as_str();
let message = format!("Fuel Network Explorer {}", version);
let _ = println_green(&message);
println_green(&message);

// Download and unpack the latest release if we don't have it yet.
let is_downloaded = check_version_path(version);
Expand Down
8 changes: 4 additions & 4 deletions forc-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ pub fn print_on_success(
}

if warnings.is_empty() {
let _ = println_green_err(&format!(" Compiled {} {:?}.", type_str, proj_name));
println_green_err(&format!(" Compiled {} {:?}.", type_str, proj_name));
} else {
let _ = println_yellow_err(&format!(
println_yellow_err(&format!(
" Compiled {} {:?} with {} {}.",
type_str,
proj_name,
Expand All @@ -170,9 +170,9 @@ pub fn print_on_success_library(silent_mode: bool, proj_name: &str, warnings: &[
}

if warnings.is_empty() {
let _ = println_green_err(&format!(" Compiled library {:?}.", proj_name));
println_green_err(&format!(" Compiled library {:?}.", proj_name));
} else {
let _ = println_yellow_err(&format!(
println_yellow_err(&format!(
" Compiled library {:?} with {} {}.",
proj_name,
warnings.len(),
Expand Down
2 changes: 1 addition & 1 deletion forc-util/src/restricted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn is_conflicting_artifact_name(name: &str) -> bool {
pub fn contains_invalid_char(name: &str, use_case: &str) -> Result<()> {
let mut chars = name.chars();
if let Some(ch) = chars.next() {
if ch.is_digit(10) {
if ch.is_ascii_digit() {
// A specific error for a potentially common case.
bail!(
"the name `{name}` cannot be used as a {use_case}, \
Expand Down
4 changes: 2 additions & 2 deletions forc/src/ops/forc_abi_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ pub fn build(command: JsonAbiCommand) -> Result<Value> {
let json_abi = json!(compiled.json_abi);

if let Some(outfile) = command.json_outfile {
let file = File::create(outfile).map_err(|e| e)?;
let file = File::create(outfile)?;
let res = if command.minify {
serde_json::to_writer(&file, &json_abi)
} else {
serde_json::to_writer_pretty(&file, &json_abi)
};
res.map_err(|e| e)?;
res?;
} else if command.minify {
info!("{json_abi}");
} else {
Expand Down
3 changes: 1 addition & 2 deletions forc/src/ops/forc_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ pub fn clean(command: CleanCommand) -> Result<()> {
.arg("clean")
.stderr(process::Stdio::inherit())
.stdout(process::Stdio::inherit())
.output()
.map_err(|e| e)?;
.output()?;
}

Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ impl fmt::Display for EnumPattern {
builder.push_str("::");
builder.push_str(self.variant_name.as_str());
builder.push('(');
builder.push_str(&format!("{}", self.value));
builder.push_str(&self.value.to_string());
builder.push(')');
write!(f, "{}", builder)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ impl TypedExpression {
};
let type_id = typed_value.return_type;

let _ = check!(
check!(
look_up_type_id(type_id).expect_is_supported_in_match_expressions(&typed_value.span),
return err(warnings, errors),
warnings,
Expand Down
4 changes: 2 additions & 2 deletions sway-core/src/semantic_analysis/ast_node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ impl TypedAstNode {
);
let name = enum_decl.name.clone();
let decl = TypedDeclaration::EnumDeclaration(enum_decl);
let _ = check!(
check!(
ctx.namespace.insert_symbol(name, decl.clone()),
return err(warnings, errors),
warnings,
Expand Down Expand Up @@ -407,7 +407,7 @@ impl TypedAstNode {
let name = decl.name.clone();
let decl = TypedDeclaration::StructDeclaration(decl);
// insert the struct decl into namespace
let _ = check!(
check!(
ctx.namespace.insert_symbol(name, decl.clone()),
return err(warnings, errors),
warnings,
Expand Down
6 changes: 3 additions & 3 deletions sway-fmt/src/traversal_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::code_builder_helpers::clean_all_whitespace;
use crate::constants::{ALREADY_FORMATTED_LINE_PATTERN, NEW_LINE_PATTERN};
use std::iter::{Enumerate, Peekable};
use std::slice::Iter;
use std::str::Chars;
use std::{fmt::Write, str::Chars};

/// Performs the formatting of the `comments` section in your code.
/// Takes in a function that provides the logic to handle the rest of the code.
Expand Down Expand Up @@ -222,7 +222,7 @@ fn format_use_statement_length(s: &str, max_length: usize, level: usize) -> Stri

match token {
"," => {
line.push_str(&format!("{} ", token));
let _ = write!(line, "{} ", token).map_err(|_| ());
if *open_brackets == 1 {
is_line = true;
}
Expand All @@ -245,7 +245,7 @@ fn format_use_statement_length(s: &str, max_length: usize, level: usize) -> Stri
}
}
"as" => {
line.push_str(&format!(" {} ", token));
let _ = write!(line, " {} ", token);
}
_ => {
line.push_str(token);
Expand Down
14 changes: 6 additions & 8 deletions test/src/e2e_vm_tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use forc_pkg::Compiled;
use fuel_tx::Transaction;
use fuel_vm::interpreter::Interpreter;
use fuel_vm::prelude::*;
use std::fs;
use std::{fmt::Write, fs};

pub(crate) fn deploy_contract(file_name: &str, locked: bool) -> ContractId {
// build the contract
Expand Down Expand Up @@ -121,7 +121,7 @@ pub(crate) fn does_not_compile(file_name: &str, locked: bool) -> Result<String,
Err(e) => {
// Capture the result of the compilation (i.e., any errors Forc produces) and append to
// the stdout from the compiler.
output.push_str(&format!("\n{e}"));
write!(output, "\n{}", e).map_err(|_| ())?;
Ok(output)
}
}
Expand Down Expand Up @@ -185,10 +185,9 @@ fn emit_json_abi(file_name: &str, compiled: &Compiled) -> Result<()> {
let file = std::fs::File::create(format!(
"{}/src/e2e_vm_tests/test_programs/{}/{}",
manifest_dir, file_name, "json_abi_output.json"
))
.map_err(|e| e)?;
))?;
let res = serde_json::to_writer_pretty(&file, &json_abi);
res.map_err(|e| e)?;
res?;
Ok(())
}

Expand Down Expand Up @@ -226,10 +225,9 @@ fn emit_json_storage_slots(file_name: &str, compiled: &Compiled) -> Result<()> {
let file = std::fs::File::create(format!(
"{}/src/e2e_vm_tests/test_programs/{}/{}",
manifest_dir, file_name, "json_storage_slots_output.json"
))
.map_err(|e| e)?;
))?;
let res = serde_json::to_writer_pretty(&file, &json_storage_slots);
res.map_err(|e| e)?;
res?;
Ok(())
}

Expand Down

0 comments on commit 2e9c381

Please sign in to comment.