Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
mmastrac committed Aug 17, 2024
1 parent 960d28f commit fb539d3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 18 deletions.
6 changes: 3 additions & 3 deletions edb/server/pgrust/examples/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
args.database = conn.database;
args.username = conn.user;
args.password = conn.password.password().unwrap_or_default().to_string();
match conn.hosts.get(0).unwrap() {
match conn.hosts.first().unwrap() {
Host::Path(path, port) => {
args.unix = Some(format!("{path}/.s.PGSQL.{port}"));
}
Expand Down Expand Up @@ -117,7 +117,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
for field in rows.fields() {
eprint!(" {:?}", field.name());
}
eprintln!("");
eprintln!();
let guard = scopeguard::guard((), |_| {
eprintln!("Done");
});
Expand All @@ -128,7 +128,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
for field in row.values() {
eprint!(" {:?}", field);
}
eprintln!("");
eprintln!();
}
}
},
Expand Down
1 change: 1 addition & 0 deletions edb/server/pgrust/src/auth/scram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
//!
//! * `v=` (verifier): The server’s verifier, which is used to prove that the server also knows the shared secret.
//! This parameter is included in the server’s final message to confirm successful authentication.
#![allow(unused)]

use base64::{prelude::BASE64_STANDARD, Engine};
use hmac::{Hmac, Mac};
Expand Down
16 changes: 8 additions & 8 deletions edb/server/pgrust/src/conn_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl Password {
} else {
*self = Password::Unspecified;
}
return Ok(None);
Ok(None)
}
}

Expand Down Expand Up @@ -680,7 +680,7 @@ fn read_password_file(
user: &str,
reader: impl Iterator<Item = impl AsRef<str>>,
) -> Option<String> {
'outer: for line in reader {
for line in reader {
let line = line.as_ref().trim();

if line.is_empty() || line.starts_with('#') {
Expand Down Expand Up @@ -711,31 +711,31 @@ fn read_password_file(
let port = match host {
Host::Hostname(hostname, port) => {
if parts[0] != "*" && parts[0] != hostname.as_str() {
continue 'outer;
continue;
}
*port
}
Host::IP(hostname, port, _) => {
if parts[0] != "*" && str::parse(&parts[0]) != Ok(*hostname) {
continue 'outer;
continue;
}
*port
}
Host::Path(_, port) | Host::Abstract(_, port) => {
if parts[0] != "*" && parts[0] != "localhost" {
continue 'outer;
continue;
}
*port
}
};
if parts[1] != "*" && str::parse(&parts[1]) != Ok(port) {
continue 'outer;
continue;
}
if parts[2] != "*" && parts[2] != database {
continue 'outer;
continue;
}
if parts[3] != "*" && parts[3] != user {
continue 'outer;
continue;
}
return Some(parts.pop().unwrap());
}
Expand Down
3 changes: 2 additions & 1 deletion edb/server/pgrust/src/protocol/arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ macro_rules! array_access {
size
}
#[inline(always)]
pub fn copy_to_buf<'a>(buf: &mut $crate::protocol::writer::BufWriter, value: &[<$ty as $crate::protocol::Enliven>::ForBuilder<'a>]) {
pub fn copy_to_buf(buf: &mut $crate::protocol::writer::BufWriter, value: &[<$ty as $crate::protocol::Enliven>::ForBuilder<'_>]) {
for elem in value {
$crate::protocol::FieldAccess::<$ty>::copy_to_buf_ref(buf, elem);
}
Expand All @@ -330,6 +330,7 @@ impl<T> AsRef<[u8]> for Array<'_, T, u8> {

// Arrays of fixed-size elements can extract elements in O(1).
impl<'a, L: TryInto<usize>, T: FixedSize + FieldAccessArray> Array<'a, L, T> {
#[allow(unused)]
fn get(&self, index: L) -> Option<<T as Enliven>::WithLifetime<'a>> {
let Ok(index) = index.try_into() else {
return None;
Expand Down
2 changes: 1 addition & 1 deletion edb/server/pgrust/src/protocol/datatypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl FieldAccess<RestMeta> {
buf.len()
}
#[inline(always)]
pub const fn extract<'a>(buf: &'a [u8]) -> Rest<'a> {
pub const fn extract(buf: &[u8]) -> Rest<'_> {
Rest { buf }
}
#[inline(always)]
Expand Down
7 changes: 4 additions & 3 deletions edb/server/pgrust/src/protocol/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ macro_rules! struct_elaborate {
// patterns in `__builder_type__`
type( $ty $(<$($generics),+>)? )( $ty $(<$($generics),+>)? ),
value($($value)?),
docs($($fdoc)*),
docs(r#if!(__is_empty__ [$($fdoc)*] {concat!("`", stringify!($field), "` field.")} else {$($fdoc)*})),
name($field),
]
)*)
Expand Down Expand Up @@ -117,7 +117,7 @@ macro_rules! struct_elaborate {

// Push down the field to the accumulator
(__builder__ fixed($fixed:ident=>$fixed_new:ident) fields([
type($ty:ty), size($($size:tt)*), value($($value:tt)*), docs($($fdoc:tt),*), name($field:ident),
type($ty:ty), size($($size:tt)*), value($($value:tt)*), docs($($fdoc:tt)*), name($field:ident),
] $($frest:tt)*) accum($($faccum:tt)*) original($($original:tt)*)) => {
struct_elaborate!(__builder_type__ fixed($fixed_new) fields($($frest)*) accum(
$($faccum)*
Expand Down Expand Up @@ -181,6 +181,7 @@ macro_rules! protocol {

/// A slice containing the metadata references for all structs in
/// this definition.
#[allow(unused)]
pub const ALL: &'static [&'static dyn $crate::protocol::Meta] = &[
$(
&$name {}
Expand Down Expand Up @@ -544,7 +545,7 @@ macro_rules! protocol_builder {
/// Convert this builder into a vector of bytes. This is generally
/// not the most efficient way to perform serialization.
#[allow(unused)]
pub fn to_vec(self) -> Vec<u8> {
pub fn to_vec(&self) -> Vec<u8> {
let mut vec = Vec::with_capacity(256);
let mut buf = $crate::protocol::writer::BufWriter::new(&mut vec);
self.copy_to_buf(&mut buf);
Expand Down
4 changes: 2 additions & 2 deletions edb/server/pgrust/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl std::fmt::Debug for dyn Meta {
pub(crate) trait FieldAccessArray: Enliven {
const META: &'static dyn Meta;
fn size_of_field_at(buf: &[u8]) -> usize;
fn extract<'a>(buf: &'a [u8]) -> <Self as Enliven>::WithLifetime<'a>;
fn extract(buf: &[u8]) -> <Self as Enliven>::WithLifetime<'_>;
}

/// This struct is specialized for each type we want to extract data from. We
Expand All @@ -125,7 +125,7 @@ macro_rules! field_access {
$crate::protocol::FieldAccess::<$ty>::size_of_field_at(buf)
}
#[inline(always)]
fn extract<'a>(buf: &'a [u8]) -> <Self as $crate::protocol::Enliven>::WithLifetime<'a> {
fn extract(buf: &[u8]) -> <Self as $crate::protocol::Enliven>::WithLifetime<'_> {
$crate::protocol::FieldAccess::<$ty>::extract(buf)
}
}
Expand Down

0 comments on commit fb539d3

Please sign in to comment.