Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix clippy warnings for rust version 1.67.0 #2661

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<'block> BrilligBlock<'block> {
///
/// This is so that during linking there are no duplicates or labels being overwritten.
fn create_block_label(function_id: FunctionId, block_id: BasicBlockId) -> String {
format!("{}-{}", function_id, block_id)
format!("{function_id}-{block_id}")
}

/// Converts an SSA terminator instruction into the necessary opcodes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl DebugToString for BrilligBinaryOp {
if *bit_size >= BRILLIG_MEMORY_ADDRESSING_BIT_SIZE {
op.into()
} else {
format!("{}:{}", op, bit_size)
format!("{op}:{bit_size}")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_evaluator/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub enum RuntimeError {
// assert(foo < bar) fails with "failed constraint: 0 = 1."
fn format_failed_constraint(message: &Option<String>) -> String {
match message {
Some(message) => format!("Failed constraint: '{}'", message),
Some(message) => format!("Failed constraint: '{message}'"),
None => "Failed constraint".to_owned(),
}
}
Expand Down
6 changes: 1 addition & 5 deletions compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,11 +994,7 @@ impl Context {
// If either side is a numeric type, then we expect their types to be
// the same.
(Type::Numeric(lhs_type), Type::Numeric(rhs_type)) => {
assert_eq!(
lhs_type, rhs_type,
"lhs and rhs types in {:?} are not the same",
binary
);
assert_eq!(lhs_type, rhs_type, "lhs and rhs types in {binary:?} are not the same");
Type::Numeric(lhs_type)
}
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ fn create_apply_functions(
for (signature, variants) in variants_map.into_iter() {
assert!(
!variants.is_empty(),
"ICE: at least one variant should exist for a dynamic call {:?}",
signature
"ICE: at least one variant should exist for a dynamic call {signature:?}"
);
let dispatches_to_multiple_functions = variants.len() > 1;

Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/ast/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl Display for UseTree {
write!(f, "{name}")?;

while let Some(alias) = alias {
write!(f, " as {}", alias)?;
write!(f, " as {alias}")?;
}

Ok(())
Expand Down
11 changes: 5 additions & 6 deletions compiler/noirc_frontend/src/ast/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,20 @@ impl Display for TraitItem {

write!(
f,
"fn {name}<{}>({}) -> {} where {}",
generics, parameters, return_type, where_clause
"fn {name}<{generics}>({parameters}) -> {return_type} where {where_clause}"
)?;

if let Some(body) = body {
write!(f, "{}", body)
write!(f, "{body}")
} else {
write!(f, ";")
}
}
TraitItem::Constant { name, typ, default_value } => {
write!(f, "let {}: {}", name, typ)?;
write!(f, "let {name}: {typ}")?;

if let Some(default_value) = default_value {
write!(f, "{};", default_value)
write!(f, "{default_value};")
} else {
write!(f, ";")
}
Expand Down Expand Up @@ -209,7 +208,7 @@ impl Display for TraitImplItem {
TraitImplItem::Function(function) => function.fmt(f),
TraitImplItem::Type { name, alias } => write!(f, "type {name} = {alias};"),
TraitImplItem::Constant(name, typ, value) => {
write!(f, "let {}: {} = {};", name, typ, value)
write!(f, "let {name}: {typ} = {value};")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/hir/def_collector/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl From<DefCollectorErrorKind> for Diagnostic {
),
DefCollectorErrorKind::NonStructTraitImpl { trait_ident, span } => {
Diagnostic::simple_error(
format!("Only struct types may implement trait `{}`", trait_ident),
format!("Only struct types may implement trait `{trait_ident}`"),
"Only struct types may implement traits".into(),
span,
)
Expand All @@ -129,7 +129,7 @@ impl From<DefCollectorErrorKind> for Diagnostic {
span,
),
DefCollectorErrorKind::TraitNotFound { trait_ident } => Diagnostic::simple_error(
format!("Trait {} not found", trait_ident),
format!("Trait {trait_ident} not found"),
"".to_string(),
trait_ident.span(),
),
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/lexer/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl LexerErrorKind {

(
"an unexpected character was found".to_string(),
format!(" expected {expected} , but got {}", found),
format!(" expected {expected} , but got {found}"),
*span,
)
},
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/lexer/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl fmt::Display for TestScope {
match self {
TestScope::None => write!(f, ""),
TestScope::ShouldFailWith { reason } => match reason {
Some(failure_reason) => write!(f, "(should_fail_with = ({}))", failure_reason),
Some(failure_reason) => write!(f, "(should_fail_with = ({failure_reason}))"),
None => write!(f, "should_fail"),
},
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/parser/labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl fmt::Display for ParsingRuleLabel {
ParsingRuleLabel::Statement => write!(f, "statement"),
ParsingRuleLabel::Term => write!(f, "term"),
ParsingRuleLabel::TypeExpression => write!(f, "type expression"),
ParsingRuleLabel::TokenKind(token_kind) => write!(f, "{:?}", token_kind),
ParsingRuleLabel::TokenKind(token_kind) => write!(f, "{token_kind:?}"),
}
}
}
4 changes: 2 additions & 2 deletions tooling/acvm_backend_barretenberg/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ fn main() -> Result<(), String> {
let os = match build_target::target_os().unwrap() {
os @ (Os::Linux | Os::MacOs) => os,
Os::Windows => todo!("Windows is not currently supported"),
os_name => panic!("Unsupported OS {}", os_name),
os_name => panic!("Unsupported OS {os_name}"),
};

let arch = match build_target::target_arch().unwrap() {
arch @ (Arch::X86_64 | Arch::AARCH64) => arch,
arch_name => panic!("Unsupported Architecture {}", arch_name),
arch_name => panic!("Unsupported Architecture {arch_name}"),
};

// Arm builds of linux are not supported
Expand Down
8 changes: 4 additions & 4 deletions tooling/lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ fn on_code_lens_request(
// We can reconsider this when we can build a file without the need for a Nargo.toml file to resolve deps
let _ = state.client.log_message(LogMessageParams {
typ: MessageType::WARNING,
message: format!("{}", err),
message: format!("{err}"),
});
return future::ready(Ok(None));
}
Expand All @@ -181,7 +181,7 @@ fn on_code_lens_request(
// If we found a manifest, but the workspace is invalid, we raise an error about it
return future::ready(Err(ResponseError::new(
ErrorCode::REQUEST_FAILED,
format!("{}", err),
format!("{err}"),
)));
}
};
Expand Down Expand Up @@ -388,7 +388,7 @@ fn on_did_save_text_document(
// We can reconsider this when we can build a file without the need for a Nargo.toml file to resolve deps
let _ = state.client.log_message(LogMessageParams {
typ: MessageType::WARNING,
message: format!("{}", err),
message: format!("{err}"),
});
return ControlFlow::Continue(());
}
Expand All @@ -399,7 +399,7 @@ fn on_did_save_text_document(
// If we found a manifest, but the workspace is invalid, we raise an error about it
return ControlFlow::Break(Err(ResponseError::new(
ErrorCode::REQUEST_FAILED,
format!("{}", err),
format!("{err}"),
)
.into()));
}
Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo/src/ops/foreign_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl ForeignCall {
],
})
}
None => panic!("unexpected foreign call {:?}", foreign_call_name),
None => panic!("unexpected foreign call {foreign_call_name:?}"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo_cli/src/cli/backend_cmd/ls_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) struct LsCommand;

pub(crate) fn run(_args: LsCommand) -> Result<(), CliError> {
for backend in get_available_backends() {
println!("{}", backend);
println!("{backend}");
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo_cli/src/cli/fs/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(crate) fn save_debug_artifact_to_file<P: AsRef<Path>>(
circuit_name: &str,
circuit_dir: P,
) -> PathBuf {
let artifact_name = format!("debug_{}", circuit_name);
let artifact_name = format!("debug_{circuit_name}");
save_build_artifact_to_file(debug_artifact, &artifact_name, circuit_dir)
}

Expand Down