Skip to content

Commit 91feb7b

Browse files
authored
Fix rust 1.88.0 clippies (#1818)
Signed-off-by: Sean Young <sean@mess.org>
1 parent b85f19d commit 91feb7b

File tree

34 files changed

+112
-129
lines changed

34 files changed

+112
-129
lines changed

src/bin/idl/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ fn write_solidity(idl: &Idl, mut f: File) -> Result<(), std::io::Error> {
205205
docs(&mut f, 0, &idl.docs)?;
206206

207207
if let Some(program_id) = program_id(idl) {
208-
writeln!(f, "@program_id(\"{}\")", program_id)?;
208+
writeln!(f, "@program_id(\"{program_id}\")")?;
209209
}
210210
writeln!(f, "interface {} {{", idl.name)?;
211211

src/bin/languageserver/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2739,7 +2739,7 @@ impl LanguageServer for SolangServer {
27392739
let source = std::fs::read_to_string(source_path).map_err(|err| Error {
27402740
code: ErrorCode::InternalError,
27412741
message: format!("Failed to read file: {uri}").into(),
2742-
data: Some(Value::String(format!("{:?}", err))),
2742+
data: Some(Value::String(format!("{err:?}"))),
27432743
})?;
27442744
let source_parsed = parse(&source).map_err(|err| {
27452745
let err = err
@@ -2763,7 +2763,7 @@ impl LanguageServer for SolangServer {
27632763
format_to(&mut source_formatted, source_parsed, config).map_err(|err| Error {
27642764
code: ErrorCode::InternalError,
27652765
message: format!("Failed to format file: {uri}").into(),
2766-
data: Some(Value::String(format!("{:?}", err))),
2766+
data: Some(Value::String(format!("{err:?}"))),
27672767
})?;
27682768

27692769
// create a `TextEdit` instance that replaces the contents of the file with the formatted text

src/bin/solang.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,7 @@ fn compile(compile_args: &Compile) {
251251

252252
let authors = if let Some(authors) = &compile_args.package.authors {
253253
if !target.is_polkadot() {
254-
eprintln!(
255-
"warning: the `authors` flag will be ignored for {} target",
256-
target
257-
)
254+
eprintln!("warning: the `authors` flag will be ignored for {target} target")
258255
}
259256
authors.clone()
260257
} else {

src/codegen/cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ impl ControlFlowGraph {
12751275
None => "_".to_string(),
12761276
},
12771277
if let Some(no) = constructor_no {
1278-
format!("{}", no)
1278+
format!("{no}")
12791279
} else {
12801280
String::new()
12811281
},

src/codegen/encoding/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,9 +1103,7 @@ pub(crate) trait AbiEncoding {
11031103
// allocated the outer dimension, i.e., we are about to read a 'int[3][4]' item.
11041104
// Arrays whose elements are dynamic cannot be verified.
11051105
if validator.validation_necessary()
1106-
&& !dims[0..(dimension + 1)]
1107-
.iter()
1108-
.any(|d| *d == ArrayLength::Dynamic)
1106+
&& !dims[0..(dimension + 1)].contains(&ArrayLength::Dynamic)
11091107
&& !elem_ty.is_dynamic(ns)
11101108
{
11111109
let mut elems = BigInt::one();

src/codegen/events/polkadot.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,8 @@ impl EventEmitter for PolkadotEventEmitter<'_> {
148148
.iter()
149149
.map(|e| expression(e, cfg, contract_no, Some(func), self.ns, vartab, opt))
150150
.collect::<Vec<_>>();
151-
let encoded_data = data
152-
.is_empty()
153-
.then(|| Expression::AllocDynamicBytes {
151+
let encoded_data = if data.is_empty() {
152+
Expression::AllocDynamicBytes {
154153
loc,
155154
ty: Type::DynamicBytes,
156155
size: Expression::NumberLiteral {
@@ -160,8 +159,10 @@ impl EventEmitter for PolkadotEventEmitter<'_> {
160159
}
161160
.into(),
162161
initializer: Vec::new().into(),
163-
})
164-
.unwrap_or_else(|| abi_encode(&loc, data, self.ns, vartab, cfg, false).0);
162+
}
163+
} else {
164+
abi_encode(&loc, data, self.ns, vartab, cfg, false).0
165+
};
165166

166167
cfg.add(
167168
vartab,

src/codegen/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ fn layout(contract_no: usize, ns: &mut Namespace) {
413413
if slot > value {
414414
ns.diagnostics.push(Diagnostic::error(
415415
exp.loc(),
416-
format!("contract requires at least {} bytes of space", slot),
416+
format!("contract requires at least {slot} bytes of space"),
417417
));
418418
} else if value > BigInt::from(MAXIMUM_ACCOUNT_SIZE) {
419419
ns.diagnostics.push(Diagnostic::error(

src/codegen/revert.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub(crate) const PANIC_SELECTOR: [u8; 4] = [0x4e, 0x48, 0x7b, 0x71];
3232
///
3333
/// Marked as non-exhaustive because Solidity may add more variants in the future.
3434
#[non_exhaustive]
35+
#[allow(clippy::large_enum_variant)]
3536
#[derive(Debug, PartialEq, Clone)]
3637
pub enum SolidityError {
3738
/// Reverts with "empty error data"; stems from `revert()` or `require()` without string arguments.
@@ -399,7 +400,7 @@ pub(super) fn revert(
399400
let error_ty = error_no
400401
.map(|n| ns.errors[n].name.as_str())
401402
.unwrap_or("unspecified");
402-
let reason = format!("{} revert encountered", error_ty);
403+
let reason = format!("{error_ty} revert encountered");
403404
log_runtime_error(opt.log_runtime_errors, &reason, *loc, cfg, vartab, ns);
404405
}
405406
}

src/codegen/solana_accounts/account_collection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl RecurseData<'_> {
7575

7676
fn add_program_id(&mut self, contract_name: &String) {
7777
self.add_account(
78-
format!("{}_programId", contract_name),
78+
format!("{contract_name}_programId"),
7979
&SolanaAccount {
8080
loc: Loc::Codegen,
8181
is_signer: false,

src/codegen/statements/try_catch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ fn insert_catch_clauses(
446446
.iter()
447447
.enumerate()
448448
.map(|(n, clause)| {
449-
let clause_body_block = cfg.new_basic_block(format!("catch_error_{}", n));
449+
let clause_body_block = cfg.new_basic_block(format!("catch_error_{n}"));
450450

451451
cfg.set_basic_block(clause_body_block);
452452
let types = &[Type::Bytes(4), clause.param.as_ref().unwrap().ty.clone()];

0 commit comments

Comments
 (0)