Skip to content

Commit 17547e2

Browse files
emilkclaude
andauthored
Enable more clippy lints (apache#24566)
## Which issue does this PR close? - Part of apache#18467. ## Rationale for this change Continuing apache#24466: turn on more `clippy::pedantic` lints (opt-out list in `Cargo.toml`). ## What changes are included in this PR? One commit per lint, each removing its `"allow"` line from `Cargo.toml` and fixing every site. Review one commit at a time! Let me know if you disagree with any and I'll revert it | Lint | Sites | Fix | | ---------------------------------------------------------------------------------------------------------------------------------- | ----: | --------------------------------------------------------------- | | [`no_effect_underscore_binding`](https://rust-lang.github.io/rust-clippy/master/index.html#no_effect_underscore_binding) | 1 | removed a dead `let _expected = …` binding | | [`case_sensitive_file_extension_comparisons`](https://rust-lang.github.io/rust-clippy/master/index.html#case_sensitive_file_extension_comparisons) | 1 | `Path::extension()` instead of `str::ends_with(".csv")` | | [`cast_ptr_alignment`](https://rust-lang.github.io/rust-clippy/master/index.html#cast_ptr_alignment) | 5 | `#[expect]` on FFI tests that downcast to a concrete, aligned type | | [`doc_link_with_quotes`](https://rust-lang.github.io/rust-clippy/master/index.html#doc_link_with_quotes) | 25 | quoted doc "links" turned into real intra-doc links or backticked code | | [`ref_option`](https://rust-lang.github.io/rust-clippy/master/index.html#ref_option) | 36 | `&Option<T>` params/returns changed to `Option<&T>` | | [`needless_continue`](https://rust-lang.github.io/rust-clippy/master/index.html#needless_continue) | 37 | dropped `continue`s that already ended the loop iteration | | [`cloned_instead_of_copied`](https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied) | 38 | `copied()` instead of `cloned()` for `Copy` types | | [`unnecessary_semicolon`](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_semicolon) | 185 | dropped semicolons after tail `match`/`if` | | [`unnecessary_trailing_comma`](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_trailing_comma) | 49 | dropped trailing commas after single-item parens/brackets | The `ref_option` commit also changes the signature of the public `apply_masking` fn in `datafusion-substrait` (`&Option<MaskExpression>` -> `Option<&MaskExpression>`), since it forwards to an internal fn that was flagged. ## Are these changes tested? `cargo clippy --workspace --all-targets --all-features` reports no warnings. The changes are mechanical and behavior-preserving, so no new tests. ## Are there any user-facing changes? The `ref_option` commit changes the public `apply_masking` signature in `datafusion-substrait`, see above. --------- Co-authored-by: Claude Fable 5 <[email protected]>
1 parent 58ef566 commit 17547e2

197 files changed

Lines changed: 803 additions & 715 deletions

File tree

Some content is hidden

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

‎Cargo.toml‎

Lines changed: 55 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -270,70 +270,61 @@ wildcard_dependencies = "warn"
270270

271271
# Pedantic lints we opt out of, with the number of hits at the time we enabled `pedantic`.
272272
# Some of these we should consider enabling.
273-
borrow_as_ptr = "allow" # 6 hits
274-
case_sensitive_file_extension_comparisons = "allow" # 1 hit
275-
cast_lossless = "allow" # 361 hits
276-
cast_possible_truncation = "allow" # 911 hits
277-
cast_possible_wrap = "allow" # 493 hits
278-
cast_precision_loss = "allow" # 266 hits
279-
cast_ptr_alignment = "allow" # 5 hits
280-
cast_sign_loss = "allow" # 440 hits
281-
cloned_instead_of_copied = "allow" # 38 hits
282-
default_trait_access = "allow" # 221 hits
283-
doc_comment_double_space_linebreaks = "allow" # 6 hits
284-
doc_link_with_quotes = "allow" # 25 hits
285-
doc_markdown = "allow" # 4933 hits; needs a long `doc-valid-idents` list in `clippy.toml`
286-
enum_glob_use = "allow" # 98 hits
287-
explicit_into_iter_loop = "allow" # 55 hits
288-
explicit_iter_loop = "allow" # 189 hits
289-
float_cmp = "allow" # 8 hits; exact float comparisons are often intentional here
290-
format_collect = "allow" # 4 hits
291-
format_push_string = "allow" # 34 hits
292-
from_iter_instead_of_collect = "allow" # 51 hits
293-
if_not_else = "allow" # 133 hits
294-
ignored_unit_patterns = "allow" # 52 hits
295-
implicit_clone = "allow" # 198 hits
296-
implicit_hasher = "allow" # 17 hits
297-
inline_always = "allow" # 45 hits
298-
items_after_statements = "allow" # 171 hits
299-
large_digit_groups = "allow" # 3 hits
300-
manual_string_new = "allow" # 84 hits
301-
many_single_char_names = "allow" # 12 hits; short names are idiomatic in the numeric kernels
302-
map_unwrap_or = "allow" # 198 hits
303-
match_bool = "allow" # 46 hits
304-
match_same_arms = "allow" # 261 hits
305-
match_wildcard_for_single_variants = "allow" # 132 hits
306-
missing_errors_doc = "allow" # 1807 hits
307-
missing_fields_in_debug = "allow" # 29 hits
308-
missing_panics_doc = "allow" # 244 hits
309-
must_use_candidate = "allow" # 2726 hits
310-
needless_bitwise_bool = "allow" # 1 hit
311-
needless_continue = "allow" # 37 hits
312-
needless_raw_string_hashes = "allow" # 540 hits
313-
no_effect_underscore_binding = "allow" # 1 hit
314-
ptr_as_ptr = "allow" # 83 hits
315-
redundant_closure_for_method_calls = "allow" # 686 hits
316-
redundant_else = "allow" # 48 hits
317-
ref_option = "allow" # 36 hits
318-
return_self_not_must_use = "allow" # 644 hits
319-
semicolon_if_nothing_returned = "allow" # 1353 hits
320-
similar_names = "allow" # 228 hits; too many false positives, e.g. `expr`/`exprs`
321-
single_char_pattern = "allow" # 23 hits
322-
single_match_else = "allow" # 155 hits
323-
struct_excessive_bools = "allow" # 24 hits
324-
struct_field_names = "allow" # 14 hits
325-
too_many_lines = "allow" # 484 hits
326-
trivially_copy_pass_by_ref = "allow" # 74 hits
327-
unicode_not_nfc = "allow" # 2 hits
328-
unnecessary_literal_bound = "allow" # 471 hits
329-
unnecessary_semicolon = "allow" # 185 hits
330-
unnecessary_trailing_comma = "allow" # 49 hits
331-
unnecessary_wraps = "allow" # 427 hits
332-
unnested_or_patterns = "allow" # 68 hits
333-
unreadable_literal = "allow" # 502 hits
334-
unused_self = "allow" # 69 hits
335-
used_underscore_items = "allow" # 28 hits
336-
wildcard_imports = "allow" # 48 hits; `use crate::prelude::*` is idiomatic
273+
borrow_as_ptr = "allow" # 6 hits
274+
cast_lossless = "allow" # 361 hits
275+
cast_possible_truncation = "allow" # 911 hits
276+
cast_possible_wrap = "allow" # 493 hits
277+
cast_precision_loss = "allow" # 266 hits
278+
cast_sign_loss = "allow" # 440 hits
279+
default_trait_access = "allow" # 221 hits
280+
doc_comment_double_space_linebreaks = "allow" # 6 hits
281+
doc_markdown = "allow" # 4933 hits; needs a long `doc-valid-idents` list in `clippy.toml`
282+
enum_glob_use = "allow" # 98 hits
283+
explicit_into_iter_loop = "allow" # 55 hits
284+
explicit_iter_loop = "allow" # 189 hits
285+
float_cmp = "allow" # 8 hits; exact float comparisons are often intentional here
286+
format_collect = "allow" # 4 hits
287+
format_push_string = "allow" # 34 hits
288+
from_iter_instead_of_collect = "allow" # 51 hits
289+
if_not_else = "allow" # 133 hits
290+
ignored_unit_patterns = "allow" # 52 hits
291+
implicit_clone = "allow" # 198 hits
292+
implicit_hasher = "allow" # 17 hits
293+
inline_always = "allow" # 45 hits
294+
items_after_statements = "allow" # 171 hits
295+
large_digit_groups = "allow" # 3 hits
296+
manual_string_new = "allow" # 84 hits
297+
many_single_char_names = "allow" # 12 hits; short names are idiomatic in the numeric kernels
298+
map_unwrap_or = "allow" # 198 hits
299+
match_bool = "allow" # 46 hits
300+
match_same_arms = "allow" # 261 hits
301+
match_wildcard_for_single_variants = "allow" # 132 hits
302+
missing_errors_doc = "allow" # 1807 hits
303+
missing_fields_in_debug = "allow" # 29 hits
304+
missing_panics_doc = "allow" # 244 hits
305+
must_use_candidate = "allow" # 2726 hits
306+
needless_bitwise_bool = "allow" # 1 hit
307+
needless_raw_string_hashes = "allow" # 540 hits
308+
ptr_as_ptr = "allow" # 83 hits
309+
redundant_closure_for_method_calls = "allow" # 686 hits
310+
redundant_else = "allow" # 48 hits
311+
return_self_not_must_use = "allow" # 644 hits
312+
semicolon_if_nothing_returned = "allow" # 1353 hits
313+
similar_names = "allow" # 228 hits; too many false positives, e.g. `expr`/`exprs`
314+
single_char_pattern = "allow" # 23 hits
315+
single_match_else = "allow" # 155 hits
316+
struct_excessive_bools = "allow" # 24 hits
317+
struct_field_names = "allow" # 14 hits
318+
too_many_lines = "allow" # 484 hits
319+
trivially_copy_pass_by_ref = "allow" # 74 hits
320+
unicode_not_nfc = "allow" # 2 hits
321+
unnecessary_literal_bound = "allow" # 471 hits
322+
unnecessary_wraps = "allow" # 427 hits
323+
unnested_or_patterns = "allow" # 68 hits
324+
unreadable_literal = "allow" # 502 hits
325+
unused_self = "allow" # 69 hits
326+
used_underscore_items = "allow" # 28 hits
327+
wildcard_imports = "allow" # 48 hits; `use crate::prelude::*` is idiomatic
337328

338329
[workspace.lints.rust]
339330
unexpected_cfgs = { level = "warn", check-cfg = [

‎benchmarks/src/imdb/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ pub fn get_query_sql(query: &str) -> Result<Vec<String>> {
233233
.collect());
234234
}
235235
Err(e) => errors.push(format!("{filename}: {e}")),
236-
};
236+
}
237237
}
238238
plan_err!("invalid query. Could not find query: {:?}", errors)
239239
}

‎benchmarks/src/tpcds/run.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub fn get_query_sql(base_query_path: &str, query: usize) -> Result<Vec<String>>
142142
.collect());
143143
}
144144
Err(e) => errors.push(format!("{filename}: {e}")),
145-
};
145+
}
146146

147147
plan_err!("invalid query. Could not find query: {:?}", errors)
148148
} else {

‎benchmarks/src/tpch/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub fn get_query_sql_for_scale_factor(
209209
.collect());
210210
}
211211
Err(e) => errors.push(format!("{filename}: {e}")),
212-
};
212+
}
213213
}
214214
plan_err!("invalid query. Could not find query: {:?}", errors)
215215
} else {

‎benchmarks/src/util/run.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl BenchmarkRun {
231231
pub fn maybe_write_json(&self, maybe_path: Option<impl AsRef<Path>>) -> Result<()> {
232232
if let Some(path) = maybe_path {
233233
std::fs::write(path, self.to_json())?;
234-
};
234+
}
235235
Ok(())
236236
}
237237
}

‎datafusion-cli/src/catalog.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl SchemaProvider for DynamicObjectStoreSchemaProvider {
180180
}
181181
}
182182
_ => {}
183-
};
183+
}
184184
state = builder.build();
185185
let store = get_object_store(
186186
&state,

‎datafusion-cli/src/exec.rs‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ pub async fn exec_from_lines(
7373

7474
for line in reader.lines() {
7575
match line {
76-
Ok(line) if line.starts_with("#!") => {
77-
continue;
78-
}
79-
Ok(line) if line.starts_with("--") => {
80-
continue;
81-
}
76+
Ok(line) if line.starts_with("#!") || line.starts_with("--") => {}
8277
Ok(line) => {
8378
let line = line.trim_end();
8479
query.push_str(line);
@@ -197,7 +192,6 @@ pub async fn exec_from_repl(
197192
Err(ReadlineError::Interrupted) => {
198193
println!("^C");
199194
rl.helper().unwrap().reset_hint();
200-
continue;
201195
}
202196
Err(ReadlineError::Eof) => {
203197
println!("\\q");

‎datafusion-cli/src/functions.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ impl TableFunctionImpl for ParquetMetadataFunc {
416416
stats_distinct_count_arr.push(None);
417417
stats_min_value_arr.push(None);
418418
stats_max_value_arr.push(None);
419-
};
419+
}
420420
compression_arr.push(format!("{:?}", column.compression()));
421421
// need to collect into Vec to format
422422
let encodings: Vec<_> = column.encodings().collect();

‎datafusion-cli/src/main.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ async fn main_inner() -> Result<()> {
208208
if let Some(ref path) = args.data_path {
209209
let p = Path::new(path);
210210
env::set_current_dir(p).unwrap();
211-
};
211+
}
212212

213213
let session_config = get_session_config(&args)?;
214214

@@ -353,7 +353,7 @@ fn get_session_config(args: &Args) -> Result<SessionConfig> {
353353
}
354354
config_options.execution.batch_size =
355355
datafusion_common::config::ConfigNonZeroUsize::try_new(batch_size)?;
356-
};
356+
}
357357

358358
// use easier to understand "tree" mode by default
359359
// if the user hasn't specified an explain format in the environment

‎datafusion-cli/src/print_options.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl PrintOptions {
151151
return Err(DataFusionError::External(
152152
"PrintFormat::Table is not implemented".to_string().into(),
153153
));
154-
};
154+
}
155155

156156
let stdout = io::stdout();
157157
let mut writer = stdout.lock();

0 commit comments

Comments
 (0)