Skip to content

Commit 703b10d

Browse files
findepiDandandancomphead
authored
Apply clippy fixes for Rust 1.83 (#13596)
* Apply clippy fixes `dev/rust_lint.sh` no longer passes for me, maybe because of `rustup update`. This is first portion of fixes suggested by clippy. * Fix typo Co-authored-by: Oleks V <[email protected]> * Suppress missing docs clippy check in test code * Revert "Temporarily pin toolchain version to avoid clippy (#13598)" This reverts commit 2b37018. Toolchain pinning is no longer needed. --------- Co-authored-by: Daniël Heres <[email protected]> Co-authored-by: Oleks V <[email protected]>
1 parent 3eebc95 commit 703b10d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+102
-133
lines changed

datafusion/catalog/src/catalog.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ use datafusion_common::Result;
101101
/// [`UnityCatalogProvider`]: https://github.com/delta-io/delta-rs/blob/951436ecec476ce65b5ed3b58b50fb0846ca7b91/crates/deltalake-core/src/data_catalog/unity/datafusion.rs#L111-L123
102102
///
103103
/// [`TableProvider`]: crate::TableProvider
104-
105104
pub trait CatalogProvider: Debug + Sync + Send {
106105
/// Returns the catalog provider as [`Any`]
107106
/// so that it can be downcast to a specific implementation.

datafusion/common/src/column.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,23 @@ impl Column {
109109
/// where `"foo.BAR"` would be parsed to a reference to column named `foo.BAR`
110110
pub fn from_qualified_name(flat_name: impl Into<String>) -> Self {
111111
let flat_name = flat_name.into();
112-
Self::from_idents(&mut parse_identifiers_normalized(&flat_name, false))
113-
.unwrap_or_else(|| Self {
112+
Self::from_idents(&mut parse_identifiers_normalized(&flat_name, false)).unwrap_or(
113+
Self {
114114
relation: None,
115115
name: flat_name,
116-
})
116+
},
117+
)
117118
}
118119

119120
/// Deserialize a fully qualified name string into a column preserving column text case
120121
pub fn from_qualified_name_ignore_case(flat_name: impl Into<String>) -> Self {
121122
let flat_name = flat_name.into();
122-
Self::from_idents(&mut parse_identifiers_normalized(&flat_name, true))
123-
.unwrap_or_else(|| Self {
123+
Self::from_idents(&mut parse_identifiers_normalized(&flat_name, true)).unwrap_or(
124+
Self {
124125
relation: None,
125126
name: flat_name,
126-
})
127+
},
128+
)
127129
}
128130

129131
/// return the column's name.

datafusion/common/src/hash_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub trait HashValue {
6363
fn hash_one(&self, state: &RandomState) -> u64;
6464
}
6565

66-
impl<'a, T: HashValue + ?Sized> HashValue for &'a T {
66+
impl<T: HashValue + ?Sized> HashValue for &T {
6767
fn hash_one(&self, state: &RandomState) -> u64 {
6868
T::hash_one(self, state)
6969
}

datafusion/common/src/utils/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,17 +319,13 @@ pub fn longest_consecutive_prefix<T: Borrow<usize>>(
319319
count
320320
}
321321

322-
/// Array Utils
323-
324322
/// Wrap an array into a single element `ListArray`.
325323
/// For example `[1, 2, 3]` would be converted into `[[1, 2, 3]]`
326324
/// The field in the list array is nullable.
327325
pub fn array_into_list_array_nullable(arr: ArrayRef) -> ListArray {
328326
array_into_list_array(arr, true)
329327
}
330328

331-
/// Array Utils
332-
333329
/// Wrap an array into a single element `ListArray`.
334330
/// For example `[1, 2, 3]` would be converted into `[[1, 2, 3]]`
335331
pub fn array_into_list_array(arr: ArrayRef, nullable: bool) -> ListArray {
@@ -569,7 +565,7 @@ pub mod datafusion_strsim {
569565

570566
struct StringWrapper<'a>(&'a str);
571567

572-
impl<'a, 'b> IntoIterator for &'a StringWrapper<'b> {
568+
impl<'b> IntoIterator for &StringWrapper<'b> {
573569
type Item = char;
574570
type IntoIter = Chars<'b>;
575571

datafusion/core/src/datasource/avro_to_arrow/arrow_array_reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub struct AvroArrowArrayReader<'a, R: Read> {
6060
schema_lookup: BTreeMap<String, usize>,
6161
}
6262

63-
impl<'a, R: Read> AvroArrowArrayReader<'a, R> {
63+
impl<R: Read> AvroArrowArrayReader<'_, R> {
6464
pub fn try_new(
6565
reader: R,
6666
schema: SchemaRef,

datafusion/core/src/datasource/avro_to_arrow/reader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub struct Reader<'a, R: Read> {
128128
batch_size: usize,
129129
}
130130

131-
impl<'a, R: Read> Reader<'a, R> {
131+
impl<R: Read> Reader<'_, R> {
132132
/// Create a new Avro Reader from any value that implements the `Read` trait.
133133
///
134134
/// If reading a `File`, you can customise the Reader, such as to enable schema
@@ -157,7 +157,7 @@ impl<'a, R: Read> Reader<'a, R> {
157157
}
158158
}
159159

160-
impl<'a, R: Read> Iterator for Reader<'a, R> {
160+
impl<R: Read> Iterator for Reader<'_, R> {
161161
type Item = ArrowResult<RecordBatch>;
162162

163163
/// Returns the next batch of results (defined by `self.batch_size`), or `None` if there

datafusion/core/src/datasource/file_format/options.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub struct CsvReadOptions<'a> {
8989
pub file_sort_order: Vec<Vec<SortExpr>>,
9090
}
9191

92-
impl<'a> Default for CsvReadOptions<'a> {
92+
impl Default for CsvReadOptions<'_> {
9393
fn default() -> Self {
9494
Self::new()
9595
}
@@ -243,7 +243,7 @@ pub struct ParquetReadOptions<'a> {
243243
pub file_sort_order: Vec<Vec<SortExpr>>,
244244
}
245245

246-
impl<'a> Default for ParquetReadOptions<'a> {
246+
impl Default for ParquetReadOptions<'_> {
247247
fn default() -> Self {
248248
Self {
249249
file_extension: DEFAULT_PARQUET_EXTENSION,
@@ -323,7 +323,7 @@ pub struct ArrowReadOptions<'a> {
323323
pub table_partition_cols: Vec<(String, DataType)>,
324324
}
325325

326-
impl<'a> Default for ArrowReadOptions<'a> {
326+
impl Default for ArrowReadOptions<'_> {
327327
fn default() -> Self {
328328
Self {
329329
schema: None,
@@ -368,7 +368,7 @@ pub struct AvroReadOptions<'a> {
368368
pub table_partition_cols: Vec<(String, DataType)>,
369369
}
370370

371-
impl<'a> Default for AvroReadOptions<'a> {
371+
impl Default for AvroReadOptions<'_> {
372372
fn default() -> Self {
373373
Self {
374374
schema: None,
@@ -420,7 +420,7 @@ pub struct NdJsonReadOptions<'a> {
420420
pub file_sort_order: Vec<Vec<SortExpr>>,
421421
}
422422

423-
impl<'a> Default for NdJsonReadOptions<'a> {
423+
impl Default for NdJsonReadOptions<'_> {
424424
fn default() -> Self {
425425
Self {
426426
schema: None,

datafusion/core/src/datasource/file_format/parquet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ impl<'a> ObjectStoreFetch<'a> {
477477
}
478478
}
479479

480-
impl<'a> MetadataFetch for ObjectStoreFetch<'a> {
480+
impl MetadataFetch for ObjectStoreFetch<'_> {
481481
fn fetch(
482482
&mut self,
483483
range: Range<usize>,

datafusion/core/src/datasource/listing/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub fn split_files(
135135
partitioned_files.sort_by(|a, b| a.path().cmp(b.path()));
136136

137137
// effectively this is div with rounding up instead of truncating
138-
let chunk_size = (partitioned_files.len() + n - 1) / n;
138+
let chunk_size = partitioned_files.len().div_ceil(n);
139139
let mut chunks = Vec::with_capacity(n);
140140
let mut current_chunk = Vec::with_capacity(chunk_size);
141141
for file in partitioned_files.drain(..) {

datafusion/core/src/datasource/physical_plan/file_groups.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ impl FileGroupPartitioner {
217217
return None;
218218
}
219219

220-
let target_partition_size =
221-
(total_size as usize + (target_partitions) - 1) / (target_partitions);
220+
let target_partition_size = (total_size as usize).div_ceil(target_partitions);
222221

223222
let current_partition_index: usize = 0;
224223
let current_partition_size: usize = 0;

datafusion/core/src/datasource/physical_plan/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl DisplayAs for FileScanConfig {
139139
#[derive(Debug)]
140140
struct FileGroupsDisplay<'a>(&'a [Vec<PartitionedFile>]);
141141

142-
impl<'a> DisplayAs for FileGroupsDisplay<'a> {
142+
impl DisplayAs for FileGroupsDisplay<'_> {
143143
fn fmt_as(&self, t: DisplayFormatType, f: &mut Formatter) -> FmtResult {
144144
let n_groups = self.0.len();
145145
let groups = if n_groups == 1 { "group" } else { "groups" };
@@ -171,7 +171,7 @@ impl<'a> DisplayAs for FileGroupsDisplay<'a> {
171171
#[derive(Debug)]
172172
pub(crate) struct FileGroupDisplay<'a>(pub &'a [PartitionedFile]);
173173

174-
impl<'a> DisplayAs for FileGroupDisplay<'a> {
174+
impl DisplayAs for FileGroupDisplay<'_> {
175175
fn fmt_as(&self, t: DisplayFormatType, f: &mut Formatter) -> FmtResult {
176176
write!(f, "[")?;
177177
match t {

datafusion/core/src/datasource/physical_plan/parquet/page_filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ impl<'a> PagesPruningStatistics<'a> {
449449
Some(vec)
450450
}
451451
}
452-
impl<'a> PruningStatistics for PagesPruningStatistics<'a> {
452+
impl PruningStatistics for PagesPruningStatistics<'_> {
453453
fn min_values(&self, _column: &datafusion_common::Column) -> Option<ArrayRef> {
454454
match self.converter.data_page_mins(
455455
self.column_index,

datafusion/core/src/datasource/physical_plan/parquet/row_filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl<'schema> PushdownChecker<'schema> {
336336
}
337337
}
338338

339-
impl<'schema> TreeNodeRewriter for PushdownChecker<'schema> {
339+
impl TreeNodeRewriter for PushdownChecker<'_> {
340340
type Node = Arc<dyn PhysicalExpr>;
341341

342342
fn f_down(

datafusion/core/src/datasource/physical_plan/parquet/row_group_filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl<'a> RowGroupPruningStatistics<'a> {
374374
}
375375
}
376376

377-
impl<'a> PruningStatistics for RowGroupPruningStatistics<'a> {
377+
impl PruningStatistics for RowGroupPruningStatistics<'_> {
378378
fn min_values(&self, column: &Column) -> Option<ArrayRef> {
379379
self.statistics_converter(column)
380380
.and_then(|c| Ok(c.row_group_mins(self.metadata_iter())?))

datafusion/core/src/execution/context/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,7 @@ impl<'a> BadPlanVisitor<'a> {
17641764
}
17651765
}
17661766

1767-
impl<'n, 'a> TreeNodeVisitor<'n> for BadPlanVisitor<'a> {
1767+
impl<'n> TreeNodeVisitor<'n> for BadPlanVisitor<'_> {
17681768
type Node = LogicalPlan;
17691769

17701770
fn f_down(&mut self, node: &'n Self::Node) -> Result<TreeNodeRecursion> {

datafusion/core/src/execution/session_state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,7 @@ struct SessionContextProvider<'a> {
16361636
tables: HashMap<ResolvedTableReference, Arc<dyn TableSource>>,
16371637
}
16381638

1639-
impl<'a> ContextProvider for SessionContextProvider<'a> {
1639+
impl ContextProvider for SessionContextProvider<'_> {
16401640
fn get_expr_planners(&self) -> &[Arc<dyn ExprPlanner>] {
16411641
&self.state.expr_planners
16421642
}
@@ -1931,7 +1931,7 @@ impl<'a> SessionSimplifyProvider<'a> {
19311931
}
19321932
}
19331933

1934-
impl<'a> SimplifyInfo for SessionSimplifyProvider<'a> {
1934+
impl SimplifyInfo for SessionSimplifyProvider<'_> {
19351935
fn is_boolean_type(&self, expr: &Expr) -> datafusion_common::Result<bool> {
19361936
Ok(expr.get_type(self.df_schema)? == DataType::Boolean)
19371937
}

datafusion/core/src/physical_optimizer/test_utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
//! Collection of testing utility functions that are leveraged by the query optimizer rules
1919
20+
#![allow(missing_docs)]
21+
2022
use std::any::Any;
2123
use std::fmt::Formatter;
2224
use std::sync::Arc;

datafusion/core/src/test/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
//! Common unit test utility methods
1919
20+
#![allow(missing_docs)]
21+
2022
use std::any::Any;
2123
use std::fs::File;
2224
use std::io::prelude::*;

datafusion/execution/src/cache/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub mod cache_unit;
2222
/// This interface does not get `mut` references and thus has to handle its own
2323
/// locking via internal mutability. It can be accessed via multiple concurrent queries
2424
/// during planning and execution.
25-
2625
pub trait CacheAccessor<K, V>: Send + Sync {
2726
// Extra info but not part of the cache key or cache value.
2827
type Extra: Clone;

datafusion/expr-common/src/type_coercion/aggregates.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,19 +294,19 @@ pub fn coerce_avg_type(func_name: &str, arg_types: &[DataType]) -> Result<Vec<Da
294294
// Supported types smallint, int, bigint, real, double precision, decimal, or interval
295295
// Refer to https://www.postgresql.org/docs/8.2/functions-aggregate.html doc
296296
fn coerced_type(func_name: &str, data_type: &DataType) -> Result<DataType> {
297-
return match &data_type {
297+
match &data_type {
298298
DataType::Decimal128(p, s) => Ok(DataType::Decimal128(*p, *s)),
299299
DataType::Decimal256(p, s) => Ok(DataType::Decimal256(*p, *s)),
300300
d if d.is_numeric() => Ok(DataType::Float64),
301-
DataType::Dictionary(_, v) => return coerced_type(func_name, v.as_ref()),
301+
DataType::Dictionary(_, v) => coerced_type(func_name, v.as_ref()),
302302
_ => {
303-
return plan_err!(
303+
plan_err!(
304304
"The function {:?} does not support inputs of type {:?}.",
305305
func_name,
306306
data_type
307307
)
308308
}
309-
};
309+
}
310310
}
311311
Ok(vec![coerced_type(func_name, &arg_types[0])?])
312312
}

datafusion/expr/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1852,7 +1852,7 @@ macro_rules! expr_vec_fmt {
18521852
}
18531853

18541854
struct SchemaDisplay<'a>(&'a Expr);
1855-
impl<'a> Display for SchemaDisplay<'a> {
1855+
impl Display for SchemaDisplay<'_> {
18561856
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
18571857
match self.0 {
18581858
// The same as Display

datafusion/expr/src/logical_plan/ddl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl DdlStatement {
125125
/// See [crate::LogicalPlan::display] for an example
126126
pub fn display(&self) -> impl Display + '_ {
127127
struct Wrapper<'a>(&'a DdlStatement);
128-
impl<'a> Display for Wrapper<'a> {
128+
impl Display for Wrapper<'_> {
129129
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
130130
match self.0 {
131131
DdlStatement::CreateExternalTable(CreateExternalTable {

datafusion/expr/src/logical_plan/display.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'a, 'b> IndentVisitor<'a, 'b> {
5959
}
6060
}
6161

62-
impl<'n, 'a, 'b> TreeNodeVisitor<'n> for IndentVisitor<'a, 'b> {
62+
impl<'n> TreeNodeVisitor<'n> for IndentVisitor<'_, '_> {
6363
type Node = LogicalPlan;
6464

6565
fn f_down(
@@ -113,7 +113,7 @@ impl<'n, 'a, 'b> TreeNodeVisitor<'n> for IndentVisitor<'a, 'b> {
113113
pub fn display_schema(schema: &Schema) -> impl fmt::Display + '_ {
114114
struct Wrapper<'a>(&'a Schema);
115115

116-
impl<'a> fmt::Display for Wrapper<'a> {
116+
impl fmt::Display for Wrapper<'_> {
117117
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
118118
write!(f, "[")?;
119119
for (idx, field) in self.0.fields().iter().enumerate() {
@@ -181,7 +181,7 @@ impl<'a, 'b> GraphvizVisitor<'a, 'b> {
181181
}
182182
}
183183

184-
impl<'n, 'a, 'b> TreeNodeVisitor<'n> for GraphvizVisitor<'a, 'b> {
184+
impl<'n> TreeNodeVisitor<'n> for GraphvizVisitor<'_, '_> {
185185
type Node = LogicalPlan;
186186

187187
fn f_down(
@@ -654,7 +654,7 @@ impl<'a, 'b> PgJsonVisitor<'a, 'b> {
654654
}
655655
}
656656

657-
impl<'n, 'a, 'b> TreeNodeVisitor<'n> for PgJsonVisitor<'a, 'b> {
657+
impl<'n> TreeNodeVisitor<'n> for PgJsonVisitor<'_, '_> {
658658
type Node = LogicalPlan;
659659

660660
fn f_down(

datafusion/expr/src/logical_plan/plan.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ impl LogicalPlan {
15361536
// Boilerplate structure to wrap LogicalPlan with something
15371537
// that that can be formatted
15381538
struct Wrapper<'a>(&'a LogicalPlan);
1539-
impl<'a> Display for Wrapper<'a> {
1539+
impl Display for Wrapper<'_> {
15401540
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
15411541
let with_schema = false;
15421542
let mut visitor = IndentVisitor::new(f, with_schema);
@@ -1579,7 +1579,7 @@ impl LogicalPlan {
15791579
// Boilerplate structure to wrap LogicalPlan with something
15801580
// that that can be formatted
15811581
struct Wrapper<'a>(&'a LogicalPlan);
1582-
impl<'a> Display for Wrapper<'a> {
1582+
impl Display for Wrapper<'_> {
15831583
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
15841584
let with_schema = true;
15851585
let mut visitor = IndentVisitor::new(f, with_schema);
@@ -1599,7 +1599,7 @@ impl LogicalPlan {
15991599
// Boilerplate structure to wrap LogicalPlan with something
16001600
// that that can be formatted
16011601
struct Wrapper<'a>(&'a LogicalPlan);
1602-
impl<'a> Display for Wrapper<'a> {
1602+
impl Display for Wrapper<'_> {
16031603
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
16041604
let mut visitor = PgJsonVisitor::new(f);
16051605
visitor.with_schema(true);
@@ -1645,7 +1645,7 @@ impl LogicalPlan {
16451645
// Boilerplate structure to wrap LogicalPlan with something
16461646
// that that can be formatted
16471647
struct Wrapper<'a>(&'a LogicalPlan);
1648-
impl<'a> Display for Wrapper<'a> {
1648+
impl Display for Wrapper<'_> {
16491649
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
16501650
let mut visitor = GraphvizVisitor::new(f);
16511651

@@ -1696,7 +1696,7 @@ impl LogicalPlan {
16961696
// Boilerplate structure to wrap LogicalPlan with something
16971697
// that that can be formatted
16981698
struct Wrapper<'a>(&'a LogicalPlan);
1699-
impl<'a> Display for Wrapper<'a> {
1699+
impl Display for Wrapper<'_> {
17001700
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
17011701
match self.0 {
17021702
LogicalPlan::EmptyRelation(_) => write!(f, "EmptyRelation"),

0 commit comments

Comments
 (0)