Skip to content

Commit

Permalink
ARROW-11137: [Rust][DataFusion] Clippy needless_range_loop,needless_l…
Browse files Browse the repository at this point in the history
…ifetimes

Fixes:
* clippy::needless_lifetimes,
 * clippy::needless_range_loop

Closes apache#9106 from Dandandan/clippy_5

Authored-by: Heres, Daniel <[email protected]>
Signed-off-by: Andrew Lamb <[email protected]>
  • Loading branch information
Dandandan authored and alamb committed Jan 5, 2021
1 parent 5f2495d commit fdf5e88
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 24 deletions.
2 changes: 0 additions & 2 deletions rust/datafusion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#![allow(
clippy::float_cmp,
clippy::module_inception,
clippy::needless_lifetimes,
clippy::needless_range_loop,
clippy::new_without_default,
clippy::ptr_arg,
clippy::type_complexity
Expand Down
2 changes: 1 addition & 1 deletion rust/datafusion/src/logical_plan/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<'a, 'b> PlanVisitor for IndentVisitor<'a, 'b> {
/// format!("{}", display_schema(&schema))
/// );
/// ```
pub fn display_schema<'a>(schema: &'a Schema) -> impl fmt::Display + 'a {
pub fn display_schema(schema: &Schema) -> impl fmt::Display + '_ {
struct Wrapper<'a>(&'a Schema);

impl<'a> fmt::Display for Wrapper<'a> {
Expand Down
16 changes: 8 additions & 8 deletions rust/datafusion/src/logical_plan/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ impl LogicalPlan {
/// \n TableScan: foo.csv projection=None",
/// display_string);
/// ```
pub fn display_indent<'a>(&'a self) -> impl fmt::Display + 'a {
pub fn display_indent(&self) -> impl fmt::Display + '_ {
// Boilerplate structure to wrap LogicalPlan with something
// that that can be formatted
struct Wrapper<'a>(&'a LogicalPlan);
Expand Down Expand Up @@ -382,7 +382,7 @@ impl LogicalPlan {
/// \n TableScan: foo.csv projection=None [id:Int32]",
/// display_string);
/// ```
pub fn display_indent_schema<'a>(&'a self) -> impl fmt::Display + 'a {
pub fn display_indent_schema(&self) -> impl fmt::Display + '_ {
// Boilerplate structure to wrap LogicalPlan with something
// that that can be formatted
struct Wrapper<'a>(&'a LogicalPlan);
Expand Down Expand Up @@ -426,7 +426,7 @@ impl LogicalPlan {
/// dot -Tpdf < /tmp/example.dot > /tmp/example.pdf
/// ```
///
pub fn display_graphviz<'a>(&'a self) -> impl fmt::Display + 'a {
pub fn display_graphviz(&self) -> impl fmt::Display + '_ {
// Boilerplate structure to wrap LogicalPlan with something
// that that can be formatted
struct Wrapper<'a>(&'a LogicalPlan);
Expand Down Expand Up @@ -478,7 +478,7 @@ impl LogicalPlan {
///
/// assert_eq!("TableScan: foo.csv projection=None", display_string);
/// ```
pub fn display<'a>(&'a self) -> impl fmt::Display + 'a {
pub fn display(&self) -> impl fmt::Display + '_ {
// Boilerplate structure to wrap LogicalPlan with something
// that that can be formatted
struct Wrapper<'a>(&'a LogicalPlan);
Expand Down Expand Up @@ -507,11 +507,11 @@ impl LogicalPlan {
}
LogicalPlan::Projection { ref expr, .. } => {
write!(f, "Projection: ")?;
for i in 0..expr.len() {
for (i, expr_item) in expr.iter().enumerate() {
if i > 0 {
write!(f, ", ")?;
}
write!(f, "{:?}", expr[i])?;
write!(f, "{:?}", expr_item)?;
}
Ok(())
}
Expand All @@ -530,11 +530,11 @@ impl LogicalPlan {
),
LogicalPlan::Sort { ref expr, .. } => {
write!(f, "Sort: ")?;
for i in 0..expr.len() {
for (i, expr_item) in expr.iter().enumerate() {
if i > 0 {
write!(f, ", ")?;
}
write!(f, "{:?}", expr[i])?;
write!(f, "{:?}", expr_item)?;
}
Ok(())
}
Expand Down
8 changes: 4 additions & 4 deletions rust/datafusion/src/physical_plan/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2458,8 +2458,8 @@ mod tests {
.as_any()
.downcast_ref::<BooleanArray>()
.expect("failed to downcast to BooleanArray");
for i in 0..5 {
assert_eq!(result.value(i), expected[i]);
for (i, &expected_item) in expected.iter().enumerate().take(5) {
assert_eq!(result.value(i), expected_item);
}

Ok(())
Expand Down Expand Up @@ -2492,8 +2492,8 @@ mod tests {
.as_any()
.downcast_ref::<BooleanArray>()
.expect("failed to downcast to BooleanArray");
for i in 0..5 {
assert_eq!(result.value(i), expected[i]);
for (i, &expected_item) in expected.iter().enumerate().take(5) {
assert_eq!(result.value(i), expected_item);
}

Ok(())
Expand Down
3 changes: 1 addition & 2 deletions rust/datafusion/src/physical_plan/hash_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ pub(crate) fn create_key(
vec: &mut Vec<u8>,
) -> Result<()> {
vec.clear();
for i in 0..group_by_keys.len() {
let col = &group_by_keys[i];
for col in group_by_keys {
match col.data_type() {
DataType::UInt8 => {
let array = col.as_any().downcast_ref::<UInt8Array>().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions rust/datafusion/src/physical_plan/repartition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ impl ExecutionPlan for RepartitionExec {
}

// notify each output partition that this input partition has no more data
for i in 0..num_output_partitions {
let tx = &mut channels[i].0;
for channel in channels.iter_mut().take(num_output_partitions) {
let tx = &mut channel.0;
tx.send(None)
.map_err(|e| DataFusionError::Execution(e.to_string()))?;
}
Expand Down
8 changes: 3 additions & 5 deletions rust/datafusion/src/sql/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {

let mut all_join_keys = vec![];
let mut left = plans[0].clone();
for i in 1..plans.len() {
let right = &plans[i];
for right in plans.iter().skip(1) {
let left_schema = left.schema();
let right_schema = right.schema();
let mut join_keys = vec![];
Expand Down Expand Up @@ -644,9 +643,8 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {

SQLExpr::CompoundIdentifier(ids) => {
let mut var_names = vec![];
for i in 0..ids.len() {
let id = ids[i].clone();
var_names.push(id.value);
for id in ids {
var_names.push(id.value.clone());
}
if &var_names[0][0..1] == "@" {
Ok(Expr::ScalarVariable(var_names))
Expand Down

0 comments on commit fdf5e88

Please sign in to comment.