Skip to content

Commit

Permalink
fix new warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
abonander committed Jul 27, 2024
1 parent fc91f14 commit eebf39a
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 28 deletions.
10 changes: 5 additions & 5 deletions sqlx-core/src/net/socket/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<usize> {
let read = match () {
Expand All @@ -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)
}

Expand Down
5 changes: 5 additions & 0 deletions sqlx-macros-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ syn = { version = "2.0.52", default-features = false, features = ["full", "deriv
tempfile = { version = "3.10.1" }
quote = { version = "1.0.26", default-features = false }
url = { version = "2.2.2", default-features = false }

[lints.rust.unexpected_cfgs]
level = "warn"
# 1.80 will warn without this
check-cfg = ['cfg(sqlx_macros_unstable)', 'cfg(procmacro2_semver_exempt)']
4 changes: 2 additions & 2 deletions sqlx-macros-core/src/derives/attributes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use proc_macro2::{Ident, Span, TokenStream};
use quote::quote;
use quote::quote_spanned;
use syn::{
punctuated::Punctuated, token::Comma, Attribute, DeriveInput, Field, LitStr, Meta, Token, Type,
Variant,
Expand Down Expand Up @@ -36,7 +36,7 @@ pub struct TypeName {
impl TypeName {
pub fn get(&self) -> TokenStream {
let val = &self.val;
quote! { #val }
quote_spanned! { self.span => #val }
}
}

Expand Down
2 changes: 1 addition & 1 deletion sqlx-macros-core/src/query/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl DynQueryData {
return Ok(cached);
}

#[cfg(procmacr2_semver_exempt)]
#[cfg(procmacro2_semver_exempt)]
{
let path = path.as_ref().canonicalize()?;
let path = path.to_str().ok_or_else(|| {
Expand Down
9 changes: 5 additions & 4 deletions sqlx-postgres/src/copy.rs
Original file line number Diff line number Diff line change
@@ -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,
};
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions sqlx-postgres/src/message/parse.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::i16;

use crate::io::PgBufMutExt;
use crate::io::{BufMutExt, Encode};
use crate::types::Oid;
Expand Down
4 changes: 2 additions & 2 deletions sqlx-sqlite/src/statement/virtual.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -56,7 +56,7 @@ impl VirtualStatement {
pub(crate) fn new(mut query: &str, persistent: bool) -> Result<Self, Error> {
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
Expand Down
10 changes: 5 additions & 5 deletions sqlx-sqlite/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 7 additions & 7 deletions src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@
/// † Only callable if the query returns no columns; otherwise it's assumed the query *may* return at least one row.
/// ## Requirements
/// * The `DATABASE_URL` environment variable must be set at build-time to point to a database
/// server with the schema that the query string will be checked against. All variants of `query!()`
/// use [dotenv]<sup>1</sup> so this can be in a `.env` file instead.
/// server with the schema that the query string will be checked against.
/// All variants of `query!()` use [dotenv]<sup>1</sup> so this can be in a `.env` file instead.
///
/// * Or, `.sqlx` must exist at the workspace root. See [Offline Mode](#offline-mode-requires-the-offline-feature)
/// below.
///
/// * The query must be a string literal, or concatenation of string literals using `+` (useful
/// for queries generated by macro), or else it cannot be introspected (and thus cannot be dynamic
/// or the result of another macro).
/// for queries generated by macro), or else it cannot be introspected (and thus cannot be dynamic
/// or the result of another macro).
///
/// * The `QueryAs` instance will be bound to the same database type as `query!()` was compiled
/// against (e.g. you cannot build against a Postgres database and then run the query against
/// a MySQL database).
/// against (e.g. you cannot build against a Postgres database and then run the query against
/// a MySQL database).
///
/// * The schema of the database URL (e.g. `postgres://` or `mysql://`) will be used to
/// determine the database type.
Expand Down Expand Up @@ -426,7 +426,7 @@ macro_rules! query_file_unchecked (
/// * The query must output at least one column.
/// * The column names of the query must match the field names of the struct.
/// * The field types must be the Rust equivalent of their SQL counterparts; see the corresponding
/// module for your database for mappings:
/// module for your database for mappings:
/// * Postgres: [crate::postgres::types]
/// * MySQL: [crate::mysql::types]
/// * Note: due to wire protocol limitations, the query macros do not know when
Expand Down

0 comments on commit eebf39a

Please sign in to comment.