From e4a9c5ce6eac217e237ba0d96bfb6f0139199058 Mon Sep 17 00:00:00 2001 From: Raminder Singh Date: Sun, 14 Jul 2024 16:50:54 +0530 Subject: [PATCH] fix clippy warnings --- cli/main.rs | 6 +-- core/benches/benchmark.rs | 6 +-- core/io/windows.rs | 6 +-- core/lib.rs | 4 +- core/schema.rs | 8 +++- core/sqlite3_ondisk.rs | 2 +- core/translate.rs | 70 +++++++++++++++----------------- core/vdbe.rs | 58 ++++++++++++++------------ simulator/main.rs | 2 +- sqlite3/include/sqlite3.h | 48 +++++++++++----------- sqlite3/src/lib.rs | 85 ++++++++++++++++++++------------------- 11 files changed, 152 insertions(+), 143 deletions(-) diff --git a/cli/main.rs b/cli/main.rs index d95e0ce99..dfd13ad57 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -171,7 +171,7 @@ fn display_schema( Ok(Some(ref mut rows)) => { let mut found = false; loop { - match rows.next()? { + match rows.next_row()? { RowResult::Row(row) => { if let Some(Value::Text(schema)) = row.values.first() { println!("{};", schema); @@ -216,7 +216,7 @@ fn query( match conn.query(sql) { Ok(Some(ref mut rows)) => match output_mode { OutputMode::Raw => loop { - match rows.next()? { + match rows.next_row()? { RowResult::Row(row) => { for (i, value) in row.values.iter().enumerate() { if i > 0 { @@ -241,7 +241,7 @@ fn query( OutputMode::Pretty => { let mut table_rows: Vec> = vec![]; loop { - match rows.next()? { + match rows.next_row()? { RowResult::Row(row) => { table_rows.push( row.values diff --git a/core/benches/benchmark.rs b/core/benches/benchmark.rs index bb9730188..7dd2658ee 100644 --- a/core/benches/benchmark.rs +++ b/core/benches/benchmark.rs @@ -16,7 +16,7 @@ fn bench(c: &mut Criterion) { let io = io.clone(); b.iter(|| { let mut rows = stmt.query().unwrap(); - match rows.next().unwrap() { + match rows.next_row().unwrap() { limbo_core::RowResult::Row(row) => { assert_eq!(row.get::(0).unwrap(), 1); } @@ -38,7 +38,7 @@ fn bench(c: &mut Criterion) { let io = io.clone(); b.iter(|| { let mut rows = stmt.query().unwrap(); - match rows.next().unwrap() { + match rows.next_row().unwrap() { limbo_core::RowResult::Row(row) => { assert_eq!(row.get::(0).unwrap(), 1); } @@ -61,7 +61,7 @@ fn bench(c: &mut Criterion) { let io = io.clone(); b.iter(|| { let mut rows = stmt.query().unwrap(); - match rows.next().unwrap() { + match rows.next_row().unwrap() { limbo_core::RowResult::Row(row) => { assert_eq!(row.get::(0).unwrap(), 1); } diff --git a/core/io/windows.rs b/core/io/windows.rs index 9e0d22cbd..cdd99a6c0 100644 --- a/core/io/windows.rs +++ b/core/io/windows.rs @@ -1,9 +1,9 @@ use super::{Completion, File, WriteCompletion, IO}; use anyhow::{Ok, Result}; -use std::rc::Rc; +use log::trace; use std::cell::RefCell; use std::io::{Read, Seek, Write}; -use log::trace; +use std::rc::Rc; pub struct WindowsIO {} @@ -48,7 +48,7 @@ impl File for WindowsFile { &self, pos: usize, buffer: Rc>, - c: Rc, + _c: Rc, ) -> Result<()> { let mut file = self.file.borrow_mut(); file.seek(std::io::SeekFrom::Start(pos as u64))?; diff --git a/core/lib.rs b/core/lib.rs index 5a184cc90..af387afd7 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -63,7 +63,7 @@ impl Database { let rows = conn.query("SELECT * FROM sqlite_schema")?; if let Some(mut rows) = rows { loop { - match rows.next()? { + match rows.next_row()? { RowResult::Row(row) => { let ty = row.get::<&str>(0)?; if ty != "table" { @@ -257,7 +257,7 @@ impl Rows { Self { stmt } } - pub fn next(&mut self) -> Result> { + pub fn next_row(&mut self) -> Result> { self.stmt.step() } } diff --git a/core/schema.rs b/core/schema.rs index 0c8e68264..e8a38e49f 100644 --- a/core/schema.rs +++ b/core/schema.rs @@ -177,6 +177,12 @@ impl PseudoTable { } } +impl Default for PseudoTable { + fn default() -> Self { + Self::new() + } +} + fn create_table( tbl_name: QualifiedName, body: CreateTableBody, @@ -271,7 +277,7 @@ fn create_table( }) } -pub fn build_pseudo_table(columns: &[ResultColumn]) -> PseudoTable { +pub fn _build_pseudo_table(columns: &[ResultColumn]) -> PseudoTable { let table = PseudoTable::new(); for column in columns { match column { diff --git a/core/sqlite3_ondisk.rs b/core/sqlite3_ondisk.rs index ae3ec70b1..5afe4b169 100644 --- a/core/sqlite3_ondisk.rs +++ b/core/sqlite3_ondisk.rs @@ -543,7 +543,7 @@ mod tests { #[case(&[0x12, 0x34, 0x56, 0x78], SerialType::BEInt32, OwnedValue::Integer(0x12345678))] #[case(&[0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC], SerialType::BEInt48, OwnedValue::Integer(0x123456789ABC))] #[case(&[0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF], SerialType::BEInt64, OwnedValue::Integer(0x123456789ABCDEFF))] - #[case(&[64, 9, 33, 251, 84, 68, 45, 24], SerialType::BEFloat64, OwnedValue::Float(3.141592653589793))] + #[case(&[64, 9, 33, 251, 84, 68, 45, 24], SerialType::BEFloat64, OwnedValue::Float(std::f64::consts::PI))] #[case(&[], SerialType::ConstInt0, OwnedValue::Integer(0))] #[case(&[], SerialType::ConstInt1, OwnedValue::Integer(1))] #[case(&[1, 2, 3], SerialType::Blob(3), OwnedValue::Blob(vec![1, 2, 3].into()))] diff --git a/core/translate.rs b/core/translate.rs index 9b2ff3ce2..05be3b7da 100644 --- a/core/translate.rs +++ b/core/translate.rs @@ -1,5 +1,4 @@ use std::cell::RefCell; -use std::collections::{HashMap, HashSet}; use std::rc::Rc; use crate::function::{AggFunc, Func, SingleRowFunc}; @@ -38,7 +37,7 @@ struct LoopInfo { struct SrcTable { table: Table, - join_info: Option, // FIXME: preferably this should be a reference with lifetime == Select ast expr + _join_info: Option, // FIXME: preferably this should be a reference with lifetime == Select ast expr } struct ColumnInfo { @@ -57,10 +56,7 @@ impl ColumnInfo { } pub fn is_aggregation_function(&self) -> bool { - match self.func { - Some(Func::Agg(_)) => true, - _ => false, - } + matches!(self.func, Some(Func::Agg(_))) } } @@ -110,30 +106,27 @@ fn build_select(schema: &Schema, select: ast::Select) -> Result