Skip to content

Commit f6583be

Browse files
authored
Merge pull request #6231 from hstove/fix/build-clippy-error
fix clippy error and `cargo check` warnings
2 parents 0fa1ff3 + 1507c02 commit f6583be

File tree

24 files changed

+59
-68
lines changed

24 files changed

+59
-68
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[alias]
22
stacks-node = "run --package stacks-node --"
33
fmt-stacks = "fmt -- --config group_imports=StdExternalCrate,imports_granularity=Module"
4-
clippy-stacks = "clippy -p stx-genesis -p libstackerdb -p stacks-signer -p pox-locking -p clarity -p libsigner -p stacks-common --no-deps --tests --all-features -- -D warnings"
4+
clippy-stacks = "clippy -p stx-genesis -p libstackerdb -p stacks-signer -p pox-locking -p clarity -p libsigner -p stacks-common --no-deps --tests --all-features -- -D warnings -A clippy::uninlined-format-args"
55

66
# Uncomment to improve performance slightly, at the cost of portability
77
# * Note that native binaries may not run on CPUs that are different from the build machine

.vscode/settings.json

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
{
2-
"lldb.launch.sourceLanguages": [
3-
"rust"
4-
],
5-
"rust-analyzer.runnables.extraEnv": {
6-
"BITCOIND_TEST": "1"
7-
},
8-
"rust-analyzer.rustfmt.extraArgs": [
9-
"+nightly"
10-
],
11-
"files.eol": "\n"
12-
}
2+
"lldb.launch.sourceLanguages": ["rust"],
3+
"rust-analyzer.runnables.extraEnv": {
4+
"BITCOIND_TEST": "1"
5+
},
6+
"rust-analyzer.rustfmt.extraArgs": ["+nightly"],
7+
"files.eol": "\n"
8+
}

stacks-common/build.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,22 @@ fn main() {
7474
"pub const GIT_COMMIT: Option<&'static str> = {git_commit:?};\n",
7575
));
7676
if let Some(git_commit) = git_commit {
77-
println!("cargo:rustc-env=GIT_COMMIT={}", git_commit);
77+
println!("cargo:rustc-env=GIT_COMMIT={git_commit}");
7878
}
7979

8080
let git_branch = current_git_branch();
8181
rust_code.push_str(&format!(
8282
"pub const GIT_BRANCH: Option<&'static str> = {git_branch:?};\n",
8383
));
8484
if let Some(git_branch) = git_branch {
85-
println!("cargo:rustc-env=GIT_BRANCH={}", git_branch);
85+
println!("cargo:rustc-env=GIT_BRANCH={git_branch}");
8686
}
8787

8888
let is_clean = if is_working_tree_clean() { "" } else { "+" };
8989
rust_code.push_str(&format!(
90-
"pub const GIT_TREE_CLEAN: Option<&'static str> = Some(\"{}\");\n",
91-
is_clean
90+
"pub const GIT_TREE_CLEAN: Option<&'static str> = Some(\"{is_clean}\");\n",
9291
));
93-
println!("cargo:rustc-env=GIT_TREE_CLEAN={}", is_clean);
92+
println!("cargo:rustc-env=GIT_TREE_CLEAN={is_clean}");
9493

9594
let out_dir = env::var_os("OUT_DIR").unwrap();
9695
let dest_path = Path::new(&out_dir).join("versions.rs");

stacks-common/src/address/c32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ pub fn c32_address_decode(c32_address_str: &str) -> Result<(u8, Vec<u8>), Error>
369369

370370
pub fn c32_address(version: u8, data: &[u8]) -> Result<String, Error> {
371371
let c32_string = c32_check_encode(version, data)?;
372-
Ok(format!("S{}", c32_string))
372+
Ok(format!("S{c32_string}"))
373373
}
374374

375375
#[cfg(test)]

stacks-common/src/address/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@ impl fmt::Display for Error {
5656
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5757
match *self {
5858
Error::InvalidCrockford32 => write!(f, "Invalid crockford 32 string"),
59-
Error::InvalidVersion(ref v) => write!(f, "Invalid version {}", v),
59+
Error::InvalidVersion(ref v) => write!(f, "Invalid version {v}"),
6060
Error::EmptyData => f.write_str("Empty data"),
61-
Error::BadByte(b) => write!(f, "invalid base58 character 0x{:x}", b),
61+
Error::BadByte(b) => write!(f, "invalid base58 character 0x{b:x}"),
6262
Error::BadChecksum(exp, actual) => write!(
6363
f,
64-
"base58ck checksum 0x{:x} does not match expected 0x{:x}",
65-
actual, exp
64+
"base58ck checksum 0x{actual:x} does not match expected 0x{exp:x}"
6665
),
67-
Error::InvalidLength(ell) => write!(f, "length {} invalid for this base58 type", ell),
66+
Error::InvalidLength(ell) => write!(f, "length {ell} invalid for this base58 type"),
6867
Error::TooShort(_) => write!(f, "base58ck data not even long enough for a checksum"),
6968
Error::Other(ref s) => f.write_str(s),
7069
}

stacks-common/src/bitvec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl<const MAX_SIZE: u16> BitVec<MAX_SIZE> {
246246
.data
247247
.into_iter()
248248
.fold(String::new(), |acc, byte| {
249-
acc + &format!("{:08b}", byte).chars().rev().collect::<String>()
249+
acc + &format!("{byte:08b}").chars().rev().collect::<String>()
250250
})
251251
.chars()
252252
.take(self.len() as usize)

stacks-common/src/codec/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,13 @@ fn read_next_vec<T: StacksMessageCodec + Sized, R: Read>(
139139
if len > max_items {
140140
// too many items
141141
return Err(Error::DeserializeError(format!(
142-
"Array has too many items ({} > {}",
143-
len, max_items
142+
"Array has too many items ({len} > {max_items})"
144143
)));
145144
}
146145
} else if len != num_items {
147146
// inexact item count
148147
return Err(Error::DeserializeError(format!(
149-
"Array has incorrect number of items ({} != {})",
150-
len, num_items
148+
"Array has incorrect number of items ({len} != {num_items})"
151149
)));
152150
}
153151

stacks-common/src/deps_common/bech32/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,11 @@ pub enum Error {
679679
impl fmt::Display for Error {
680680
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
681681
match *self {
682-
Error::MissingSeparator => write!(f, "missing human-readable separator, \"{}\"", SEP),
682+
Error::MissingSeparator => write!(f, "missing human-readable separator, \"{SEP}\""),
683683
Error::InvalidChecksum => write!(f, "invalid checksum"),
684684
Error::InvalidLength => write!(f, "invalid length"),
685-
Error::InvalidChar(n) => write!(f, "invalid character (code={})", n),
686-
Error::InvalidData(n) => write!(f, "invalid data point ({})", n),
685+
Error::InvalidChar(n) => write!(f, "invalid character (code={n})"),
686+
Error::InvalidData(n) => write!(f, "invalid data point ({n})"),
687687
Error::InvalidPadding => write!(f, "invalid padding"),
688688
Error::MixedCase => write!(f, "mixed-case strings not allowed"),
689689
}

stacks-common/src/deps_common/bitcoin/blockdata/script.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ impl fmt::Debug for Script {
111111
if opcode == opcodes::All::OP_PUSHBYTES_0 {
112112
f.write_str("OP_0")?;
113113
} else {
114-
write!(f, "{:?}", opcode)?;
114+
write!(f, "{opcode:?}")?;
115115
}
116116
// Write any pushdata
117117
if data_len > 0 {
118118
f.write_str(" ")?;
119119
if index + data_len <= self.0.len() {
120120
for ch in &self.0[index..index + data_len] {
121-
write!(f, "{:02x}", ch)?;
121+
write!(f, "{ch:02x}")?;
122122
}
123123
index += data_len;
124124
} else {
@@ -140,7 +140,7 @@ impl fmt::Display for Script {
140140
impl fmt::LowerHex for Script {
141141
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
142142
for &ch in self.0.iter() {
143-
write!(f, "{:02x}", ch)?;
143+
write!(f, "{ch:02x}")?;
144144
}
145145
Ok(())
146146
}
@@ -149,7 +149,7 @@ impl fmt::LowerHex for Script {
149149
impl fmt::UpperHex for Script {
150150
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
151151
for &ch in self.0.iter() {
152-
write!(f, "{:02X}", ch)?;
152+
write!(f, "{ch:02X}")?;
153153
}
154154
Ok(())
155155
}
@@ -677,7 +677,7 @@ impl serde::Serialize for Script {
677677
where
678678
S: serde::Serializer,
679679
{
680-
serializer.serialize_str(&format!("{:x}", self))
680+
serializer.serialize_str(&format!("{self:x}"))
681681
}
682682
}
683683

stacks-common/src/deps_common/bitcoin/network/serialize.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,13 @@ impl fmt::Display for Error {
7777
Error::UnexpectedNetworkMagic {
7878
expected: ref e,
7979
actual: ref a,
80-
} => write!(f, "unexpected network magic: expected {}, actual {}", e, a),
80+
} => write!(f, "unexpected network magic: expected {e}, actual {a}"),
8181
Error::OversizedVectorAllocation {
8282
requested: ref r,
8383
max: ref m,
8484
} => write!(
8585
f,
86-
"allocation of oversized vector requested: requested {}, maximum {}",
87-
r, m
86+
"allocation of oversized vector requested: requested {r}, maximum {m}"
8887
),
8988
Error::InvalidChecksum {
9089
expected: ref e,
@@ -95,18 +94,18 @@ impl fmt::Display for Error {
9594
hex_encode(e),
9695
hex_encode(a)
9796
),
98-
Error::UnknownNetworkMagic(ref m) => write!(f, "unknown network magic: {}", m),
99-
Error::ParseFailed(ref e) => write!(f, "parse failed: {}", e),
97+
Error::UnknownNetworkMagic(ref m) => write!(f, "unknown network magic: {m}"),
98+
Error::ParseFailed(ref e) => write!(f, "parse failed: {e}"),
10099
Error::UnsupportedWitnessVersion(ref wver) => {
101-
write!(f, "unsupported witness version: {}", wver)
100+
write!(f, "unsupported witness version: {wver}")
102101
}
103102
Error::UnsupportedSegwitFlag(ref swflag) => {
104-
write!(f, "unsupported segwit version: {}", swflag)
103+
write!(f, "unsupported segwit version: {swflag}")
105104
}
106105
Error::UnrecognizedNetworkCommand(ref nwcmd) => {
107-
write!(f, "unrecognized network command: {}", nwcmd)
106+
write!(f, "unrecognized network command: {nwcmd}")
108107
}
109-
Error::UnexpectedHexDigit(ref d) => write!(f, "unexpected hex digit: {}", d),
108+
Error::UnexpectedHexDigit(ref d) => write!(f, "unexpected hex digit: {d}"),
110109
}
111110
}
112111
}

0 commit comments

Comments
 (0)