Skip to content

Commit cfd6713

Browse files
committed
fix: more clippy warnings in sqlite and logger modules
- Fix match_like_matches_macro by using is_some() in logger.rs - Fix needless_borrow warnings in sqlite/connection/execute.rs - Fix ptr_arg by using slice instead of Vec reference - Fix clone_on_copy by dereferencing instead of cloning - Fix needless_return by removing redundant return keyword - Fix explicit_counter_loop by using enumerate()
1 parent 41f4475 commit cfd6713

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

sqlx-core/src/logger.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,11 @@ impl<'q, O: Debug + Hash + Eq, R: Debug, P: Debug> QueryPlanLogger<'q, O, R, P>
9999
}
100100

101101
pub(crate) fn log_enabled(&self) -> bool {
102-
if let Some(_lvl) = self
103-
.settings
102+
self.settings
104103
.statements_level
105104
.to_level()
106105
.filter(|lvl| log::log_enabled!(target: "sqlx::explain", *lvl))
107-
{
108-
true
109-
} else {
110-
false
111-
}
106+
.is_some()
112107
}
113108

114109
pub(crate) fn add_result(&mut self, result: R) {

sqlx-core/src/sqlite/connection/execute.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl Iterator for ExecuteIter<'_> {
8383

8484
statement.handle.clear_bindings();
8585

86-
match bind(&mut statement.handle, self.args, self.args_used) {
86+
match bind(statement.handle, &self.args, self.args_used) {
8787
Ok(args_used) => self.args_used += args_used,
8888
Err(e) => return Some(Err(e)),
8989
}
@@ -98,8 +98,8 @@ impl Iterator for ExecuteIter<'_> {
9898
self.logger.increment_rows_returned();
9999

100100
Some(Ok(Either::Right(SqliteRow::current(
101-
&statement.handle,
102-
&statement.columns,
101+
statement.handle,
102+
statement.columns,
103103
statement.column_names,
104104
))))
105105
}

sqlx-core/src/sqlite/connection/explain.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl CursorDataType {
194194
)
195195
}
196196

197-
fn from_dense_record(record: &Vec<ColumnType>) -> Self {
197+
fn from_dense_record(record: &[ColumnType]) -> Self {
198198
Self::Normal((0..).zip(record.iter().copied()).collect())
199199
}
200200

@@ -203,7 +203,7 @@ impl CursorDataType {
203203
Self::Normal(record) => {
204204
let mut rowdata = vec![ColumnType::default(); record.len()];
205205
for (idx, col) in record.iter() {
206-
rowdata[*idx as usize] = col.clone();
206+
rowdata[*idx as usize] = *col;
207207
}
208208
rowdata
209209
}
@@ -306,7 +306,7 @@ fn root_block_columns(
306306
);
307307
}
308308

309-
return Ok(row_info);
309+
Ok(row_info)
310310
}
311311

312312
#[derive(Debug, Clone, PartialEq)]
@@ -666,7 +666,7 @@ pub(super) fn explain(
666666
state.r.insert(
667667
p2,
668668
RegDataType::Single(ColumnType {
669-
datatype: opcode_to_type(&opcode),
669+
datatype: opcode_to_type(opcode),
670670
nullable: Some(false),
671671
}),
672672
);
@@ -784,8 +784,7 @@ pub(super) fn explain(
784784
while let Some(state) = result_states.pop() {
785785
// find the datatype info from each ResultRow execution
786786
if let Some(result) = state.result {
787-
let mut idx = 0;
788-
for (this_type, this_nullable) in result {
787+
for (idx, (this_type, this_nullable)) in result.into_iter().enumerate() {
789788
if output.len() == idx {
790789
output.push(this_type);
791790
} else if output[idx].is_none()
@@ -804,7 +803,6 @@ pub(super) fn explain(
804803
} else {
805804
nullable[idx] = this_nullable;
806805
}
807-
idx += 1;
808806
}
809807
}
810808
}

0 commit comments

Comments
 (0)