Skip to content

Commit ac79ef3

Browse files
authored
Add unused_qualifications with deny level to linter. Fix unused_qualifications violations." (#13086)
1 parent 4e38abd commit ac79ef3

File tree

170 files changed

+865
-1003
lines changed

Some content is hidden

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

170 files changed

+865
-1003
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,4 @@ large_futures = "warn"
169169

170170
[workspace.lints.rust]
171171
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(tarpaulin)"] }
172+
unused_qualifications = "deny"

datafusion-examples/examples/advanced_udaf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl Accumulator for GeometricMean {
193193
}
194194

195195
fn size(&self) -> usize {
196-
std::mem::size_of_val(self)
196+
size_of_val(self)
197197
}
198198
}
199199

@@ -394,8 +394,8 @@ impl GroupsAccumulator for GeometricMeanGroupsAccumulator {
394394
}
395395

396396
fn size(&self) -> usize {
397-
self.counts.capacity() * std::mem::size_of::<u32>()
398-
+ self.prods.capacity() * std::mem::size_of::<Float64Type>()
397+
self.counts.capacity() * size_of::<u32>()
398+
+ self.prods.capacity() * size_of::<Float64Type>()
399399
}
400400
}
401401

datafusion-examples/examples/custom_datasource.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct CustomDataSourceInner {
110110
}
111111

112112
impl Debug for CustomDataSource {
113-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
113+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
114114
f.write_str("custom_db")
115115
}
116116
}
@@ -220,7 +220,7 @@ impl CustomExec {
220220
}
221221

222222
impl DisplayAs for CustomExec {
223-
fn fmt_as(&self, _t: DisplayFormatType, f: &mut fmt::Formatter) -> std::fmt::Result {
223+
fn fmt_as(&self, _t: DisplayFormatType, f: &mut Formatter) -> fmt::Result {
224224
write!(f, "CustomExec")
225225
}
226226
}

datafusion-examples/examples/custom_file_format.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ impl FileFormat for TSVFileFormat {
7474
"tsv".to_string()
7575
}
7676

77-
fn get_ext_with_compression(
78-
&self,
79-
c: &FileCompressionType,
80-
) -> datafusion::error::Result<String> {
77+
fn get_ext_with_compression(&self, c: &FileCompressionType) -> Result<String> {
8178
if c == &FileCompressionType::UNCOMPRESSED {
8279
Ok("tsv".to_string())
8380
} else {

datafusion-examples/examples/flight/flight_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl FlightService for FlightServiceImpl {
105105
}
106106

107107
// add an initial FlightData message that sends schema
108-
let options = datafusion::arrow::ipc::writer::IpcWriteOptions::default();
108+
let options = arrow::ipc::writer::IpcWriteOptions::default();
109109
let schema_flight_data = SchemaAsIpc::new(&schema, &options);
110110

111111
let mut flights = vec![FlightData::from(schema_flight_data)];

datafusion-examples/examples/function_factory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl ScalarUDFImpl for ScalarFunctionWrapper {
121121
&self.name
122122
}
123123

124-
fn signature(&self) -> &datafusion_expr::Signature {
124+
fn signature(&self) -> &Signature {
125125
&self.signature
126126
}
127127

datafusion-examples/examples/simple_udaf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl Accumulator for GeometricMean {
131131
}
132132

133133
fn size(&self) -> usize {
134-
std::mem::size_of_val(self)
134+
size_of_val(self)
135135
}
136136
}
137137

datafusion-examples/examples/simplify_udaf_expression.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl AggregateUDFImpl for BetterAvgUdaf {
7070
unimplemented!("should not be invoked")
7171
}
7272

73-
fn state_fields(&self, _args: StateFieldsArgs) -> Result<Vec<arrow_schema::Field>> {
73+
fn state_fields(&self, _args: StateFieldsArgs) -> Result<Vec<Field>> {
7474
unimplemented!("should not be invoked")
7575
}
7676

@@ -90,8 +90,7 @@ impl AggregateUDFImpl for BetterAvgUdaf {
9090
fn simplify(&self) -> Option<AggregateFunctionSimplification> {
9191
// as an example for this functionality we replace UDF function
9292
// with build-in aggregate function to illustrate the use
93-
let simplify = |aggregate_function: datafusion_expr::expr::AggregateFunction,
94-
_: &dyn SimplifyInfo| {
93+
let simplify = |aggregate_function: AggregateFunction, _: &dyn SimplifyInfo| {
9594
Ok(Expr::AggregateFunction(AggregateFunction::new_udf(
9695
avg_udaf(),
9796
// yes it is the same Avg, `BetterAvgUdaf` was just a

datafusion-examples/examples/simplify_udwf_expression.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ impl WindowUDFImpl for SimplifySmoothItUdf {
7070

7171
/// this function will simplify `SimplifySmoothItUdf` to `SmoothItUdf`.
7272
fn simplify(&self) -> Option<WindowFunctionSimplification> {
73-
let simplify = |window_function: datafusion_expr::expr::WindowFunction,
74-
_: &dyn SimplifyInfo| {
73+
let simplify = |window_function: WindowFunction, _: &dyn SimplifyInfo| {
7574
Ok(Expr::WindowFunction(WindowFunction {
7675
fun: datafusion_expr::WindowFunctionDefinition::AggregateUDF(avg_udaf()),
7776
args: window_function.args,

datafusion/common/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ pub trait ConfigExtension: ExtensionOptions {
876876
}
877877

878878
/// An object-safe API for storing arbitrary configuration
879-
pub trait ExtensionOptions: Send + Sync + std::fmt::Debug + 'static {
879+
pub trait ExtensionOptions: Send + Sync + fmt::Debug + 'static {
880880
/// Return `self` as [`Any`]
881881
///
882882
/// This is needed until trait upcasting is stabilised

datafusion/common/src/join_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub enum JoinConstraint {
9797
}
9898

9999
impl Display for JoinSide {
100-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
100+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
101101
match self {
102102
JoinSide::Left => write!(f, "left"),
103103
JoinSide::Right => write!(f, "right"),

datafusion/common/src/parsers.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
//! Interval parsing logic
1919
2020
use std::fmt::Display;
21-
use std::result;
2221
use std::str::FromStr;
2322

2423
use sqlparser::parser::ParserError;
@@ -41,7 +40,7 @@ pub enum CompressionTypeVariant {
4140
impl FromStr for CompressionTypeVariant {
4241
type Err = ParserError;
4342

44-
fn from_str(s: &str) -> result::Result<Self, ParserError> {
43+
fn from_str(s: &str) -> Result<Self, ParserError> {
4544
let s = s.to_uppercase();
4645
match s.as_str() {
4746
"GZIP" | "GZ" => Ok(Self::GZIP),

datafusion/common/src/pyarrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl From<DataFusionError> for PyErr {
3434
}
3535

3636
impl FromPyArrow for ScalarValue {
37-
fn from_pyarrow_bound(value: &pyo3::Bound<'_, pyo3::PyAny>) -> PyResult<Self> {
37+
fn from_pyarrow_bound(value: &Bound<'_, PyAny>) -> PyResult<Self> {
3838
let py = value.py();
3939
let typ = value.getattr("type")?;
4040
let val = value.call_method0("as_py")?;

datafusion/common/src/scalar/mod.rs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use std::fmt;
2828
use std::hash::Hash;
2929
use std::hash::Hasher;
3030
use std::iter::repeat;
31+
use std::mem::{size_of, size_of_val};
3132
use std::str::FromStr;
3233
use std::sync::Arc;
3334

@@ -691,8 +692,8 @@ hash_float_value!((f64, u64), (f32, u32));
691692
// # Panics
692693
//
693694
// Panics if there is an error when creating hash values for rows
694-
impl std::hash::Hash for ScalarValue {
695-
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
695+
impl Hash for ScalarValue {
696+
fn hash<H: Hasher>(&self, state: &mut H) {
696697
use ScalarValue::*;
697698
match self {
698699
Decimal128(v, p, s) => {
@@ -768,7 +769,7 @@ impl std::hash::Hash for ScalarValue {
768769
}
769770
}
770771

771-
fn hash_nested_array<H: std::hash::Hasher>(arr: ArrayRef, state: &mut H) {
772+
fn hash_nested_array<H: Hasher>(arr: ArrayRef, state: &mut H) {
772773
let arrays = vec![arr.to_owned()];
773774
let hashes_buffer = &mut vec![0; arr.len()];
774775
let random_state = ahash::RandomState::with_seeds(0, 0, 0, 0);
@@ -802,7 +803,7 @@ fn dict_from_scalar<K: ArrowDictionaryKeyType>(
802803
let values_array = value.to_array_of_size(1)?;
803804

804805
// Create a key array with `size` elements, each of 0
805-
let key_array: PrimitiveArray<K> = std::iter::repeat(if value.is_null() {
806+
let key_array: PrimitiveArray<K> = repeat(if value.is_null() {
806807
None
807808
} else {
808809
Some(K::default_value())
@@ -2043,7 +2044,7 @@ impl ScalarValue {
20432044
scale: i8,
20442045
size: usize,
20452046
) -> Result<Decimal256Array> {
2046-
Ok(std::iter::repeat(value)
2047+
Ok(repeat(value)
20472048
.take(size)
20482049
.collect::<Decimal256Array>()
20492050
.with_precision_and_scale(precision, scale)?)
@@ -2512,7 +2513,7 @@ impl ScalarValue {
25122513
}
25132514

25142515
fn list_to_array_of_size(arr: &dyn Array, size: usize) -> Result<ArrayRef> {
2515-
let arrays = std::iter::repeat(arr).take(size).collect::<Vec<_>>();
2516+
let arrays = repeat(arr).take(size).collect::<Vec<_>>();
25162517
let ret = match !arrays.is_empty() {
25172518
true => arrow::compute::concat(arrays.as_slice())?,
25182519
false => arr.slice(0, 0),
@@ -3083,7 +3084,7 @@ impl ScalarValue {
30833084
/// Estimate size if bytes including `Self`. For values with internal containers such as `String`
30843085
/// includes the allocated size (`capacity`) rather than the current length (`len`)
30853086
pub fn size(&self) -> usize {
3086-
std::mem::size_of_val(self)
3087+
size_of_val(self)
30873088
+ match self {
30883089
ScalarValue::Null
30893090
| ScalarValue::Boolean(_)
@@ -3137,12 +3138,12 @@ impl ScalarValue {
31373138
ScalarValue::Map(arr) => arr.get_array_memory_size(),
31383139
ScalarValue::Union(vals, fields, _mode) => {
31393140
vals.as_ref()
3140-
.map(|(_id, sv)| sv.size() - std::mem::size_of_val(sv))
3141+
.map(|(_id, sv)| sv.size() - size_of_val(sv))
31413142
.unwrap_or_default()
31423143
// `fields` is boxed, so it is NOT already included in `self`
3143-
+ std::mem::size_of_val(fields)
3144-
+ (std::mem::size_of::<Field>() * fields.len())
3145-
+ fields.iter().map(|(_idx, field)| field.size() - std::mem::size_of_val(field)).sum::<usize>()
3144+
+ size_of_val(fields)
3145+
+ (size_of::<Field>() * fields.len())
3146+
+ fields.iter().map(|(_idx, field)| field.size() - size_of_val(field)).sum::<usize>()
31463147
}
31473148
ScalarValue::Dictionary(dt, sv) => {
31483149
// `dt` and `sv` are boxed, so they are NOT already included in `self`
@@ -3155,35 +3156,35 @@ impl ScalarValue {
31553156
///
31563157
/// Includes the size of the [`Vec`] container itself.
31573158
pub fn size_of_vec(vec: &Vec<Self>) -> usize {
3158-
std::mem::size_of_val(vec)
3159-
+ (std::mem::size_of::<ScalarValue>() * vec.capacity())
3159+
size_of_val(vec)
3160+
+ (size_of::<ScalarValue>() * vec.capacity())
31603161
+ vec
31613162
.iter()
3162-
.map(|sv| sv.size() - std::mem::size_of_val(sv))
3163+
.map(|sv| sv.size() - size_of_val(sv))
31633164
.sum::<usize>()
31643165
}
31653166

31663167
/// Estimates [size](Self::size) of [`VecDeque`] in bytes.
31673168
///
31683169
/// Includes the size of the [`VecDeque`] container itself.
31693170
pub fn size_of_vec_deque(vec_deque: &VecDeque<Self>) -> usize {
3170-
std::mem::size_of_val(vec_deque)
3171-
+ (std::mem::size_of::<ScalarValue>() * vec_deque.capacity())
3171+
size_of_val(vec_deque)
3172+
+ (size_of::<ScalarValue>() * vec_deque.capacity())
31723173
+ vec_deque
31733174
.iter()
3174-
.map(|sv| sv.size() - std::mem::size_of_val(sv))
3175+
.map(|sv| sv.size() - size_of_val(sv))
31753176
.sum::<usize>()
31763177
}
31773178

31783179
/// Estimates [size](Self::size) of [`HashSet`] in bytes.
31793180
///
31803181
/// Includes the size of the [`HashSet`] container itself.
31813182
pub fn size_of_hashset<S>(set: &HashSet<Self, S>) -> usize {
3182-
std::mem::size_of_val(set)
3183-
+ (std::mem::size_of::<ScalarValue>() * set.capacity())
3183+
size_of_val(set)
3184+
+ (size_of::<ScalarValue>() * set.capacity())
31843185
+ set
31853186
.iter()
3186-
.map(|sv| sv.size() - std::mem::size_of_val(sv))
3187+
.map(|sv| sv.size() - size_of_val(sv))
31873188
.sum::<usize>()
31883189
}
31893190
}
@@ -4445,7 +4446,7 @@ mod tests {
44454446
let right_array = right.to_array().expect("Failed to convert to array");
44464447
let arrow_left_array = left_array.as_primitive::<T>();
44474448
let arrow_right_array = right_array.as_primitive::<T>();
4448-
let arrow_result = kernels::numeric::add(arrow_left_array, arrow_right_array);
4449+
let arrow_result = add(arrow_left_array, arrow_right_array);
44494450

44504451
assert_eq!(scalar_result.is_ok(), arrow_result.is_ok());
44514452
}
@@ -5060,13 +5061,13 @@ mod tests {
50605061
// thus the size of the enum appears to as well
50615062

50625063
// The value may also change depending on rust version
5063-
assert_eq!(std::mem::size_of::<ScalarValue>(), 64);
5064+
assert_eq!(size_of::<ScalarValue>(), 64);
50645065
}
50655066

50665067
#[test]
50675068
fn memory_size() {
50685069
let sv = ScalarValue::Binary(Some(Vec::with_capacity(10)));
5069-
assert_eq!(sv.size(), std::mem::size_of::<ScalarValue>() + 10,);
5070+
assert_eq!(sv.size(), size_of::<ScalarValue>() + 10,);
50705071
let sv_size = sv.size();
50715072

50725073
let mut v = Vec::with_capacity(10);
@@ -5075,9 +5076,7 @@ mod tests {
50755076
assert_eq!(v.capacity(), 10);
50765077
assert_eq!(
50775078
ScalarValue::size_of_vec(&v),
5078-
std::mem::size_of::<Vec<ScalarValue>>()
5079-
+ (9 * std::mem::size_of::<ScalarValue>())
5080-
+ sv_size,
5079+
size_of::<Vec<ScalarValue>>() + (9 * size_of::<ScalarValue>()) + sv_size,
50815080
);
50825081

50835082
let mut s = HashSet::with_capacity(0);
@@ -5087,8 +5086,8 @@ mod tests {
50875086
let s_capacity = s.capacity();
50885087
assert_eq!(
50895088
ScalarValue::size_of_hashset(&s),
5090-
std::mem::size_of::<HashSet<ScalarValue>>()
5091-
+ ((s_capacity - 1) * std::mem::size_of::<ScalarValue>())
5089+
size_of::<HashSet<ScalarValue>>()
5090+
+ ((s_capacity - 1) * size_of::<ScalarValue>())
50925091
+ sv_size,
50935092
);
50945093
}

datafusion/common/src/stats.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl Precision<ScalarValue> {
190190
}
191191
}
192192

193-
impl<T: fmt::Debug + Clone + PartialEq + Eq + PartialOrd> Debug for Precision<T> {
193+
impl<T: Debug + Clone + PartialEq + Eq + PartialOrd> Debug for Precision<T> {
194194
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
195195
match self {
196196
Precision::Exact(inner) => write!(f, "Exact({:?})", inner),
@@ -200,7 +200,7 @@ impl<T: fmt::Debug + Clone + PartialEq + Eq + PartialOrd> Debug for Precision<T>
200200
}
201201
}
202202

203-
impl<T: fmt::Debug + Clone + PartialEq + Eq + PartialOrd> Display for Precision<T> {
203+
impl<T: Debug + Clone + PartialEq + Eq + PartialOrd> Display for Precision<T> {
204204
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
205205
match self {
206206
Precision::Exact(inner) => write!(f, "Exact({:?})", inner),
@@ -341,7 +341,7 @@ fn check_num_rows(value: Option<usize>, is_exact: bool) -> Precision<usize> {
341341
}
342342

343343
impl Display for Statistics {
344-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
344+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
345345
// string of column statistics
346346
let column_stats = self
347347
.column_statistics

datafusion/common/src/utils/memory.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//! This module provides a function to estimate the memory size of a HashTable prior to alloaction
1919
2020
use crate::{DataFusionError, Result};
21+
use std::mem::size_of;
2122

2223
/// Estimates the memory size required for a hash table prior to allocation.
2324
///
@@ -87,7 +88,7 @@ pub fn estimate_memory_size<T>(num_elements: usize, fixed_size: usize) -> Result
8788
// + size of entry * number of buckets
8889
// + 1 byte for each bucket
8990
// + fixed size of collection (HashSet/HashTable)
90-
std::mem::size_of::<T>()
91+
size_of::<T>()
9192
.checked_mul(estimated_buckets)?
9293
.checked_add(estimated_buckets)?
9394
.checked_add(fixed_size)
@@ -108,7 +109,7 @@ mod tests {
108109
#[test]
109110
fn test_estimate_memory() {
110111
// size (bytes): 48
111-
let fixed_size = std::mem::size_of::<HashSet<u32>>();
112+
let fixed_size = size_of::<HashSet<u32>>();
112113

113114
// estimated buckets: 16 = (8 * 8 / 7).next_power_of_two()
114115
let num_elements = 8;
@@ -126,7 +127,7 @@ mod tests {
126127
#[test]
127128
fn test_estimate_memory_overflow() {
128129
let num_elements = usize::MAX;
129-
let fixed_size = std::mem::size_of::<HashSet<u32>>();
130+
let fixed_size = size_of::<HashSet<u32>>();
130131
let estimated = estimate_memory_size::<u32>(num_elements, fixed_size);
131132

132133
assert!(estimated.is_err());

0 commit comments

Comments
 (0)