Skip to content

Commit

Permalink
bump fmt and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
alecmocatta committed May 20, 2021
1 parent 09ecfba commit 6b22e74
Show file tree
Hide file tree
Showing 34 changed files with 131 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
hard_tabs = true
imports_layout = "Horizontal"
merge_imports = true
imports_granularity = "Crate"
fn_args_layout = "Compressed"
use_field_init_shorthand = true

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
"us-east-1.data-analytics",
"cflogworkshop/optimized/cf-accesslogs/",
AwsCredentials::Anonymous,
)))
)), None)
.await?;
// Note: this isn't yet implemented!
Expand Down Expand Up @@ -222,7 +222,7 @@ fn main() -> Result<(), Box<dyn Error>> {
"us-east-1.data-analytics",
"cflogworkshop/optimized/cf-accesslogs/",
AwsCredentials::Anonymous,
)))
)), None)
.await?;

let top_pages = rows
Expand Down
7 changes: 4 additions & 3 deletions amadeus-aws/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! This is a support crate of [Amadeus](https://github.com/constellation-rs/amadeus) and is not intended to be used directly. These types are re-exposed in [`amadeus::source`](https://docs.rs/amadeus/0.3/amadeus/source/index.html).
#![doc(html_root_url = "https://docs.rs/amadeus-aws/0.4.2")]
#![cfg_attr(nightly, feature(type_alias_impl_trait))]
#![cfg_attr(nightly, feature(min_type_alias_impl_trait))]
#![warn(
// missing_copy_implementations,
// missing_debug_implementations,
Expand All @@ -25,8 +25,9 @@
clippy::too_many_lines,
clippy::must_use_candidate,
clippy::type_repetition_in_bounds,
clippy::filter_map,
clippy::missing_errors_doc
clippy::missing_errors_doc,
clippy::missing_panics_doc,
clippy::let_underscore_drop
)]
#![deny(unsafe_code)]

Expand Down
6 changes: 4 additions & 2 deletions amadeus-commoncrawl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! This is a support crate of [Amadeus](https://github.com/constellation-rs/amadeus) and is not intended to be used directly. These types are re-exposed in [`amadeus::source`](https://docs.rs/amadeus/0.3/amadeus/source/index.html).
#![doc(html_root_url = "https://docs.rs/amadeus-commoncrawl/0.4.2")]
#![cfg_attr(nightly, feature(type_alias_impl_trait))]
#![cfg_attr(nightly, feature(min_type_alias_impl_trait))]
#![warn(
// missing_copy_implementations,
// missing_debug_implementations,
Expand All @@ -22,7 +22,9 @@
#![allow(
clippy::doc_markdown,
clippy::inline_always,
clippy::missing_errors_doc
clippy::missing_errors_doc,
clippy::missing_panics_doc,
clippy::let_underscore_drop
)]
#![deny(unsafe_code)]

Expand Down
5 changes: 1 addition & 4 deletions amadeus-commoncrawl/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ impl<'a> fmt::Debug for Record<'a> {
// write!(form, "\n").unwrap();
// }
writeln!(form, "Content Length:{}", self.content.len()).unwrap();
let s = match str::from_utf8(self.content) {
Ok(s) => s,
Err(_) => "Could not convert",
};
let s = str::from_utf8(self.content).unwrap_or("Could not convert");
writeln!(form, "Content :{:?}", s).unwrap();
writeln!(form)
}
Expand Down
9 changes: 4 additions & 5 deletions amadeus-core/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl OsString {
pub fn to_string_lossy(&self) -> String {
self.buf.to_string_lossy()
}
pub fn display<'a>(&'a self) -> impl fmt::Display + 'a {
pub fn display(&self) -> impl fmt::Display + '_ {
struct Display<'a>(&'a OsString);
impl<'a> fmt::Display for Display<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down Expand Up @@ -160,15 +160,14 @@ impl PathBuf {
pub fn iter<'a>(&'a self) -> impl Iterator<Item = &OsString> + 'a {
self.components.iter()
}
pub fn display<'a>(&'a self) -> impl fmt::Display + 'a {
pub fn display(&self) -> impl fmt::Display + '_ {
struct Display<'a>(&'a PathBuf);
impl<'a> fmt::Display for Display<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut res: fmt::Result = self
.0
.iter()
.map(|component| write!(f, "{}/", component.to_string_lossy()))
.collect();
.try_for_each(|component| write!(f, "{}/", component.to_string_lossy()));
if let Some(file_name) = self.0.file_name() {
res = res.and_then(|()| write!(f, "{}", file_name.to_string_lossy()));
}
Expand Down Expand Up @@ -315,7 +314,7 @@ where
buf_.len()
})
.map_err(Into::into);
*self_.offset += u64::try_from(ret.as_ref().ok().cloned().unwrap_or(0)).unwrap();
*self_.offset += u64::try_from(ret.as_ref().ok().copied().unwrap_or(0)).unwrap();
Poll::Ready(ret)
}
}
Expand Down
6 changes: 4 additions & 2 deletions amadeus-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
clippy::inline_always,
clippy::option_option,
clippy::default_trait_access,
clippy::filter_map,
clippy::wildcard_imports,
clippy::needless_pass_by_value
clippy::needless_pass_by_value,
clippy::unnecessary_wraps,
clippy::missing_panics_doc,
clippy::let_underscore_drop
)]
#![deny(unsafe_code)]

Expand Down
6 changes: 5 additions & 1 deletion amadeus-core/src/par_sink/combiner.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#![allow(unused_imports, clippy::single_component_path_imports, clippy::option_if_let_else)]
#![allow(
unused_imports,
clippy::single_component_path_imports,
clippy::option_if_let_else
)]

use super::FolderSync;

Expand Down
2 changes: 1 addition & 1 deletion amadeus-core/src/par_sink/folder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unused_imports,clippy::single_component_path_imports)]
#![allow(unused_imports, clippy::single_component_path_imports)]

use derive_new::new;
use educe::Educe;
Expand Down
12 changes: 11 additions & 1 deletion amadeus-core/src/par_sink/tuple.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#![allow(non_snake_case, clippy::type_complexity, irrefutable_let_patterns, clippy::new_without_default, unused_mut, unreachable_code, clippy::too_many_arguments)]
#![allow(
non_snake_case,
clippy::type_complexity,
irrefutable_let_patterns,
clippy::new_without_default,
unused_mut,
unreachable_code,
clippy::too_many_arguments
)]

use derive_new::new;
use futures::{pin_mut, ready, stream, Stream, StreamExt};
Expand Down Expand Up @@ -100,6 +108,7 @@ macro_rules! impl_tuple {
type Output = $enum<$($i::Output,)*>;
type Task = ($($i::Task,)*);

#[allow(clippy::unused_unit)]
fn task(&self) -> Self::Task {
($(self.$num.task(),)*)
}
Expand All @@ -111,6 +120,7 @@ macro_rules! impl_tuple {
type Output = $enum<$($i::Output,)*>;
type Task = ($($i::Task,)*);

#[allow(clippy::unused_unit)]
fn task(&self) -> Self::Task {
($(self.$num.task(),)*)
}
Expand Down
8 changes: 4 additions & 4 deletions amadeus-core/src/par_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use futures::{future, pin_mut, stream::StreamExt as _, Stream};
use indexmap::IndexMap;
use serde_closure::{traits, FnOnce};
use std::{
cmp::Ordering, hash::Hash, iter, ops, pin::Pin, task::{Context, Poll}, vec
cmp::Ordering, hash::Hash, iter, ops, pin::Pin, task::{Context, Poll}
};

use super::{par_pipe::*, par_sink::*};
Expand Down Expand Up @@ -434,7 +434,7 @@ stream!(ParallelStream ParallelPipe ParallelSink FromParallelStream IntoParallel
let self_ = self;
pin_mut!(self_);
// TODO: don't buffer tasks before sending. requires changes to ThreadPool
let mut tasks = (0..pool.threads()).map(|_| vec![]).collect::<Vec<_>>();
let mut tasks = (0..pool.threads()).map(|_| Vec::new()).collect::<Vec<_>>();
let mut allocated = 0;
'a: loop {
for i in 0..tasks.len() {
Expand Down Expand Up @@ -597,7 +597,7 @@ stream!(DistributedStream DistributedPipe DistributedSink FromDistributedStream
let self_ = self;
pin_mut!(self_);
// TODO: don't buffer tasks before sending. requires changes to ProcessPool
let mut tasks = (0..pool.processes()).map(|_| vec![]).collect::<Vec<_>>();
let mut tasks = (0..pool.processes()).map(|_| Vec::new()).collect::<Vec<_>>();
let mut allocated = 0;
'a: loop {
for i in 0..tasks.len() {
Expand Down Expand Up @@ -647,7 +647,7 @@ stream!(DistributedStream DistributedPipe DistributedSink FromDistributedStream
pool.spawn(FnOnce!(move |pool: &P::ThreadPool| {
let mut process_tasks = tasks.into_iter();

let mut tasks = (0..pool.threads()).map(|_| vec![]).collect::<Vec<_>>();
let mut tasks = (0..pool.threads()).map(|_| Vec::new()).collect::<Vec<_>>();
let mut allocated = 0;
'a: loop {
for i in 0..tasks.len() {
Expand Down
2 changes: 1 addition & 1 deletion amadeus-core/src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl<S: ?Sized + Sink<Item> + Unpin, St: ?Sized + Stream<Item = Item> + Unpin, I
let items = &mut **self_.items;
let mut given_all = false;
let stream = stream::poll_fn(|cx| match Pin::new(&mut *items).poll_next(cx) {
x @ Poll::Ready(Some(_)) | x @ Poll::Pending => x,
x @ (Poll::Ready(Some(_)) | Poll::Pending) => x,
Poll::Ready(None) => {
given_all = true;
Poll::Pending
Expand Down
6 changes: 2 additions & 4 deletions amadeus-core/src/pipe/flat_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ where
if let Some(s) = self_.next.as_mut().as_pin_mut() {
if let Some(item) = ready!(s.poll_next(cx)) {
break Some(item);
} else {
self_.next.set(None);
}
self_.next.set(None);
} else if let Some(s) = ready!(self_.pipe.as_mut().poll_next(cx)) {
self_.next.set(Some(self_.f.call_mut((s,))));
} else {
Expand All @@ -61,9 +60,8 @@ where
if let Some(s) = self_.next.as_mut().as_pin_mut() {
if let Some(item) = ready!(s.poll_next(cx)) {
break Some(item);
} else {
self_.next.set(None);
}
self_.next.set(None);
} else if let Some(s) = ready!(self_.pipe.as_mut().poll_next(cx, stream.as_mut())) {
self_.next.set(Some(self_.f.call_mut((s,))));
} else {
Expand Down
6 changes: 2 additions & 4 deletions amadeus-core/src/pipe/flat_map_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ where
if let Some(s) = self_.next.as_mut() {
if let Some(item) = s.next() {
break Some(item);
} else {
*self_.next = None;
}
*self_.next = None;
} else if let Some(s) = ready!(self_.pipe.as_mut().poll_next(cx)) {
*self_.next = Some(self_.f.call_mut((s,)));
} else {
Expand All @@ -60,9 +59,8 @@ where
if let Some(s) = self_.next.as_mut() {
if let Some(item) = s.next() {
break Some(item);
} else {
*self_.next = None;
}
*self_.next = None;
} else if let Some(s) = ready!(self_.pipe.as_mut().poll_next(cx, stream.as_mut())) {
*self_.next = Some(self_.f.call_mut((s,)));
} else {
Expand Down
6 changes: 2 additions & 4 deletions amadeus-core/src/pipe/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ where
if let Some(s) = self_.next.as_mut().as_pin_mut() {
if let Some(item) = ready!(s.poll_next(cx)) {
break Some(item);
} else {
self_.next.set(None);
}
self_.next.set(None);
} else if let Some(s) = ready!(self_.pipe.as_mut().poll_next(cx)) {
self_.next.set(Some(s));
} else {
Expand All @@ -57,9 +56,8 @@ where
if let Some(s) = self_.next.as_mut().as_pin_mut() {
if let Some(item) = ready!(s.poll_next(cx)) {
break Some(item);
} else {
self_.next.set(None);
}
self_.next.set(None);
} else if let Some(s) = ready!(self_.pipe.as_mut().poll_next(cx, stream.as_mut())) {
self_.next.set(Some(s));
} else {
Expand Down
4 changes: 2 additions & 2 deletions amadeus-parquet/src/internal/file/statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ macro_rules! statistics_enum_func {
Statistics::Double(ref typed) => typed.$func(),
Statistics::ByteArray(ref typed) => typed.$func(),
Statistics::FixedLenByteArray(ref typed) => typed.$func(),
}
}};
}
}};
}

/// Converts Thrift definition into `Statistics`.
Expand Down
4 changes: 2 additions & 2 deletions amadeus-parquet/src/internal/util/bit_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ macro_rules! read_num_bytes {
let mut data: $ty = Default::default();
unsafe {
::std::ptr::copy_nonoverlapping($src.as_ptr(), &mut data as *mut $ty as *mut u8, $size);
}
}
data
}};
}};
}

/// Converts value `val` of type `T` to a byte vector, by reading `num_bytes` from `val`.
Expand Down
3 changes: 0 additions & 3 deletions amadeus-parquet/src/internal/util/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ impl<R: ParquetReader> Seek for BufReader<R> {
SeekFrom::Current(n) => n,
SeekFrom::End(n) => self.len as i64 + n - self.offset as i64,
};
#[cfg(not(nightly))]
let _ = self.inner.seek(SeekFrom::Current(offset))?;
#[cfg(nightly)]
self.inner.seek_relative(offset)?;
self.offset = (self.offset as i64 + offset) as u64;
Ok(self.offset)
Expand Down
3 changes: 1 addition & 2 deletions amadeus-parquet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
//! This is a support crate of [Amadeus](https://github.com/constellation-rs/amadeus) and is not intended to be used directly. These types are re-exposed in [`amadeus::source`](https://docs.rs/amadeus/0.3/amadeus/source/index.html).
#![doc(html_root_url = "https://docs.rs/amadeus-parquet/0.4.2")]
#![cfg_attr(nightly, feature(bufreader_seek_relative))]
#![cfg_attr(nightly, feature(read_initializer))]
#![cfg_attr(nightly, feature(specialization))]
#![cfg_attr(nightly, feature(type_alias_impl_trait))]
#![cfg_attr(nightly, feature(min_type_alias_impl_trait))]
#![cfg_attr(nightly, feature(test))]
#![warn(
// missing_copy_implementations,
Expand Down
9 changes: 5 additions & 4 deletions amadeus-postgres/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! This is a support crate of [Amadeus](https://github.com/constellation-rs/amadeus) and is not intended to be used directly. These types are re-exposed in [`amadeus::source`](https://docs.rs/amadeus/0.3/amadeus/source/index.html).
#![doc(html_root_url = "https://docs.rs/amadeus-postgres/0.4.2")]
#![cfg_attr(nightly, feature(type_alias_impl_trait))]
#![cfg_attr(nightly, feature(min_type_alias_impl_trait))]
#![warn(
// missing_copy_implementations,
// missing_debug_implementations,
Expand All @@ -24,7 +24,8 @@
clippy::similar_names,
clippy::if_not_else,
clippy::must_use_candidate,
clippy::missing_errors_doc
clippy::missing_errors_doc,
clippy::let_underscore_drop
)]
#![deny(unsafe_code)]

Expand Down Expand Up @@ -160,7 +161,7 @@ impl From<postgres::config::Config> for ConnectParams {
password: from.get_password().map(ToOwned::to_owned),
dbname: from.get_dbname().map(ToOwned::to_owned),
options: from.get_options().map(ToOwned::to_owned),
connect_timeout: from.get_connect_timeout().cloned(),
connect_timeout: from.get_connect_timeout().copied(),
}
}
}
Expand Down Expand Up @@ -415,7 +416,7 @@ where
}
let (head, tail) = buf.split_at(len);
*buf = tail;
Some(&head[..])
Some(head)
};
T::decode(type_, value)
}
Expand Down
5 changes: 3 additions & 2 deletions amadeus-serde/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! This is a support crate of [Amadeus](https://github.com/constellation-rs/amadeus) and is not intended to be used directly. These types are re-exposed in [`amadeus::source`](https://docs.rs/amadeus/0.3/amadeus/source/index.html).
#![doc(html_root_url = "https://docs.rs/amadeus-serde/0.4.2")]
#![cfg_attr(nightly, feature(type_alias_impl_trait))]
#![cfg_attr(nightly, feature(min_type_alias_impl_trait))]
#![warn(
// missing_copy_implementations,
// missing_debug_implementations,
Expand All @@ -26,7 +26,8 @@
clippy::must_use_candidate,
clippy::missing_errors_doc,
clippy::needless_pass_by_value,
clippy::default_trait_access
clippy::default_trait_access,
clippy::needless_question_mark
)]
#![deny(unsafe_code)]

Expand Down
Loading

0 comments on commit 6b22e74

Please sign in to comment.