From 02219cd634a509268cbca93aa9513c1108e7293f Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Fri, 26 Jul 2024 19:40:34 -0700 Subject: [PATCH] fix new warnings --- sqlx-core/src/net/socket/buffered.rs | 10 +++++----- sqlx-postgres/src/copy.rs | 9 +++++---- sqlx-postgres/src/message/parse.rs | 2 -- sqlx-sqlite/src/statement/virtual.rs | 4 ++-- sqlx-sqlite/src/types/mod.rs | 10 +++++----- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/sqlx-core/src/net/socket/buffered.rs b/sqlx-core/src/net/socket/buffered.rs index c66a7fa803..5e032e2b1d 100644 --- a/sqlx-core/src/net/socket/buffered.rs +++ b/sqlx-core/src/net/socket/buffered.rs @@ -4,7 +4,7 @@ use std::{cmp, io}; use crate::error::Error; -use crate::io::{Decode, Encode, AsyncRead, AsyncReadExt}; +use crate::io::{AsyncRead, AsyncReadExt, Decode, Encode}; // Tokio, async-std, and std all use this as the default capacity for their buffered I/O. const DEFAULT_BUF_SIZE: usize = 8192; @@ -167,9 +167,9 @@ impl WriteBuffer { self.sanity_check(); } - + /// Read into the buffer from `source`, returning the number of bytes read. - /// + /// /// The buffer is automatically advanced by the number of bytes read. pub async fn read_from(&mut self, mut source: impl AsyncRead + Unpin) -> io::Result { let read = match () { @@ -179,11 +179,11 @@ impl WriteBuffer { #[cfg(not(feature = "_rt-tokio"))] _ => source.read(self.init_remaining_mut()).await?, }; - + if read > 0 { self.advance(read); } - + Ok(read) } diff --git a/sqlx-postgres/src/copy.rs b/sqlx-postgres/src/copy.rs index b3c64e6ce7..98efbba051 100644 --- a/sqlx-postgres/src/copy.rs +++ b/sqlx-postgres/src/copy.rs @@ -1,14 +1,15 @@ -use futures_core::future::BoxFuture; use std::borrow::Cow; use std::ops::{Deref, DerefMut}; +use futures_core::future::BoxFuture; use futures_core::stream::BoxStream; + use sqlx_core::bytes::{BufMut, Bytes}; use crate::connection::PgConnection; use crate::error::{Error, Result}; use crate::ext::async_stream::TryAsyncStream; -use crate::io::{AsyncRead, AsyncReadExt}; +use crate::io::AsyncRead; use crate::message::{ CommandComplete, CopyData, CopyDone, CopyFail, CopyResponse, MessageFormat, Query, }; @@ -45,7 +46,7 @@ impl PgConnection { /// /// 1. by closing the connection, or: /// 2. by using another connection to kill the server process that is sending the data as shown - /// [in this StackOverflow answer](https://stackoverflow.com/a/35319598). + /// [in this StackOverflow answer](https://stackoverflow.com/a/35319598). /// /// If you don't read the stream to completion, the next time the connection is used it will /// need to read and discard all the remaining queued data, which could take some time. @@ -98,7 +99,7 @@ pub trait PgPoolCopyExt { /// /// 1. by closing the connection, or: /// 2. by using another connection to kill the server process that is sending the data as shown - /// [in this StackOverflow answer](https://stackoverflow.com/a/35319598). + /// [in this StackOverflow answer](https://stackoverflow.com/a/35319598). /// /// If you don't read the stream to completion, the next time the connection is used it will /// need to read and discard all the remaining queued data, which could take some time. diff --git a/sqlx-postgres/src/message/parse.rs b/sqlx-postgres/src/message/parse.rs index bf5e3363bf..6bcbdb6bb0 100644 --- a/sqlx-postgres/src/message/parse.rs +++ b/sqlx-postgres/src/message/parse.rs @@ -1,5 +1,3 @@ -use std::i16; - use crate::io::PgBufMutExt; use crate::io::{BufMutExt, Encode}; use crate::types::Oid; diff --git a/sqlx-sqlite/src/statement/virtual.rs b/sqlx-sqlite/src/statement/virtual.rs index e37215bc9e..3c17428912 100644 --- a/sqlx-sqlite/src/statement/virtual.rs +++ b/sqlx-sqlite/src/statement/virtual.rs @@ -1,9 +1,9 @@ #![allow(clippy::rc_buffer)] +use std::cmp; use std::os::raw::c_char; use std::ptr::{null, null_mut, NonNull}; use std::sync::Arc; -use std::{cmp, i32}; use libsqlite3_sys::{ sqlite3, sqlite3_prepare_v3, sqlite3_stmt, SQLITE_OK, SQLITE_PREPARE_PERSISTENT, @@ -56,7 +56,7 @@ impl VirtualStatement { pub(crate) fn new(mut query: &str, persistent: bool) -> Result { query = query.trim(); - if query.len() > i32::max_value() as usize { + if query.len() > i32::MAX as usize { return Err(err_protocol!( "query string must be smaller than {} bytes", i32::MAX diff --git a/sqlx-sqlite/src/types/mod.rs b/sqlx-sqlite/src/types/mod.rs index e0604cd6bf..eae1c59c4d 100644 --- a/sqlx-sqlite/src/types/mod.rs +++ b/sqlx-sqlite/src/types/mod.rs @@ -124,11 +124,11 @@ //! [Datatypes in SQLite: Type Affinity][type-affinity] (accessed 2023/11/20): //! //! > A column with NUMERIC affinity may contain values using all five storage classes. -//! When text data is inserted into a NUMERIC column, the storage class of the text is converted to -//! INTEGER or REAL (in order of preference) if the text is a well-formed integer or real literal, -//! respectively. If the TEXT value is a well-formed integer literal that is too large to fit in a -//! 64-bit signed integer, it is converted to REAL. For conversions between TEXT and REAL storage -//! classes, only the first 15 significant decimal digits of the number are preserved. +//! > When text data is inserted into a NUMERIC column, the storage class of the text is converted to +//! > INTEGER or REAL (in order of preference) if the text is a well-formed integer or real literal, +//! > respectively. If the TEXT value is a well-formed integer literal that is too large to fit in a +//! > 64-bit signed integer, it is converted to REAL. For conversions between TEXT and REAL storage +//! > classes, only the first 15 significant decimal digits of the number are preserved. //! //! With the SQLite3 interactive CLI, we can see that a higher-precision value //! (20 digits in this case) is rounded off: