Skip to content

Commit d0030df

Browse files
authored
Merge pull request #6119 from jferrant/chore/fix-clippy-io-errors
Fix clippy on develop branch
2 parents eef9b79 + a28bfe9 commit d0030df

File tree

14 files changed

+30
-45
lines changed

14 files changed

+30
-45
lines changed

clarity/src/vm/analysis/type_checker/v2_05/natives/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ mod maps;
3434
mod options;
3535
mod sequences;
3636

37+
#[allow(clippy::large_enum_variant)]
3738
pub enum TypedNativeFunction {
3839
Special(SpecialNativeFunction),
3940
Simple(SimpleNativeFunction),

clarity/src/vm/analysis/type_checker/v2_1/natives/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ mod maps;
4242
mod options;
4343
mod sequences;
4444

45+
#[allow(clippy::large_enum_variant)]
4546
pub enum TypedNativeFunction {
4647
Special(SpecialNativeFunction),
4748
Simple(SimpleNativeFunction),

clarity/src/vm/callables.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::vm::types::{
3535
};
3636
use crate::vm::{eval, Environment, LocalContext, Value};
3737

38-
#[allow(clippy::type_complexity)]
38+
#[allow(clippy::type_complexity, clippy::large_enum_variant)]
3939
pub enum CallableType {
4040
UserFunction(DefinedFunction),
4141
NativeFunction(&'static str, NativeHandle, ClarityCostFunction),

clarity/src/vm/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ pub struct SnippetEvaluationResult {
109109
}
110110

111111
#[derive(Debug, Clone)]
112+
#[allow(clippy::large_enum_variant)]
112113
pub enum EvaluationResult {
113114
Contract(ContractEvaluationResult),
114115
Snippet(SnippetEvaluationResult),

clarity/src/vm/types/serialization.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,18 +1183,14 @@ struct WriteCounter {
11831183

11841184
impl Write for WriteCounter {
11851185
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
1186-
let input: u32 = buf.len().try_into().map_err(|_e| {
1187-
std::io::Error::new(
1188-
std::io::ErrorKind::Other,
1189-
"Serialization size would overflow u32",
1190-
)
1191-
})?;
1192-
self.count = self.count.checked_add(input).ok_or_else(|| {
1193-
std::io::Error::new(
1194-
std::io::ErrorKind::Other,
1195-
"Serialization size would overflow u32",
1196-
)
1197-
})?;
1186+
let input: u32 = buf
1187+
.len()
1188+
.try_into()
1189+
.map_err(|_e| std::io::Error::other("Serialization size would overflow u32"))?;
1190+
self.count = self
1191+
.count
1192+
.checked_add(input)
1193+
.ok_or_else(|| std::io::Error::other("Serialization size would overflow u32"))?;
11981194
Ok(input as usize)
11991195
}
12001196

pox-locking/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
//! checks if the function called requires applying or updating the
2525
//! `STXBalance` struct's locks, and if the function was successfully
2626
//! invoked. If so, it updates the PoX lock.
27+
#![allow(clippy::result_large_err)]
2728

2829
use clarity::boot_util::boot_code_id;
2930
use clarity::vm::contexts::GlobalContext;
@@ -41,6 +42,7 @@ mod pox_3;
4142
mod pox_4;
4243

4344
#[derive(Debug)]
45+
#[allow(clippy::large_enum_variant)]
4446
pub enum LockingError {
4547
DefunctPoxContract,
4648
PoxAlreadyLocked,

stacks-common/src/deps_common/ctrlc/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Error {
2222

2323
impl From<platform::Error> for Error {
2424
fn from(e: platform::Error) -> Error {
25-
let system_error = std::io::Error::new(std::io::ErrorKind::Other, e);
25+
let system_error = std::io::Error::other(e);
2626
Error::System(system_error)
2727
}
2828
}

stacks-common/src/deps_common/ctrlc/platform/windows/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,8 @@ pub unsafe fn block_ctrl_c() -> Result<SignalId, Error> {
7171
match WaitForSingleObject(SEMAPHORE, INFINITE) {
7272
WAIT_OBJECT_0 => Ok(SignalId::CtrlC),
7373
WAIT_FAILED => Err(io::Error::last_os_error()),
74-
ret => Err(io::Error::new(
75-
io::ErrorKind::Other,
76-
format!(
77-
"WaitForSingleObject(), unexpected return value \"{:x}\"",
78-
ret
79-
),
80-
)),
74+
ret => Err(io::Error::other(format!(
75+
"WaitForSingleObject(), unexpected return value \"{ret:x}\""
76+
))),
8177
}
8278
}

stacks-common/src/util/chunked_encoding.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,9 @@ impl HttpChunkedTransferReaderState {
186186
assert_eq!(self.parse_step, HttpChunkedTransferParseMode::Chunk);
187187

188188
if self.total_size >= self.max_size && self.chunk_size > 0 {
189-
return Err(io::Error::new(
190-
io::ErrorKind::Other,
191-
ChunkedError::OverflowError(
192-
"HTTP body exceeds maximum expected length".to_string(),
193-
),
194-
));
189+
return Err(io::Error::other(ChunkedError::OverflowError(
190+
"HTTP body exceeds maximum expected length".to_string(),
191+
)));
195192
}
196193

197194
let remaining = if self.chunk_size - self.chunk_read <= (self.max_size - self.total_size) {

stacks-common/src/util/retry.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ impl<R: Read> Read for BoundReader<'_, R> {
9999
let intended_read = self
100100
.read_so_far
101101
.checked_add(buf.len() as u64)
102-
.ok_or_else(|| {
103-
io::Error::new(io::ErrorKind::Other, "Read would overflow u64".to_string())
104-
})?;
102+
.ok_or_else(|| io::Error::other("Read would overflow u64".to_string()))?;
105103
let max_read = if intended_read > self.max_len {
106104
self.max_len - self.read_so_far
107105
} else {

0 commit comments

Comments
 (0)