From 8b9d61c0b5042abe49414e4de063a9d43355a336 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 18 Aug 2026 10:50:28 +0200 Subject: [PATCH] Enable the `clippy::pedantic` lint group Instead of opting in to pedantic lints one by one, enable the whole group and opt out of the noisy ones, like in https://github.com/emilk/egui/pull/8429. Each opt-out carries its hit count, so the cost of turning one back on is visible. Lints that were already enabled one-by-one here stay on. Co-Authored-By: Claude Opus 5 (1M context) --- Cargo.toml | 121 ++++++++---------------------------- egui_plot/src/items/span.rs | 6 +- 2 files changed, 30 insertions(+), 97 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d877675a..99769fcf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -111,23 +111,18 @@ missing_crate_level_docs = "warn" # See also clippy.toml [workspace.lints.clippy] all = { level = "warn", priority = -1 } +pedantic = { level = "warn", priority = -1 } allow_attributes = "warn" as_ptr_cast_mut = "warn" await_holding_lock = "warn" -bool_to_int_with_if = "warn" branches_sharing_code = "warn" -cast_possible_wrap = "warn" char_lit_as_u8 = "warn" -checked_conversions = "warn" clear_with_drain = "warn" clone_on_ref_ptr = "warn" -cloned_instead_of_copied = "warn" coerce_container_to_any = "warn" -comparison_chain = "warn" dbg_macro = "warn" debug_assert_with_mut_call = "warn" -decimal_bitwise_operands = "warn" default_union_representation = "warn" derive_partial_eq_without_eq = "warn" disallowed_macros = "warn" # See clippy.toml @@ -135,138 +130,65 @@ disallowed_methods = "warn" # See clippy.toml disallowed_names = "warn" # See clippy.toml disallowed_script_idents = "warn" # See clippy.toml disallowed_types = "warn" # See clippy.toml -doc_broken_link = "warn" -doc_comment_double_space_linebreaks = "warn" doc_include_without_cfg = "warn" -doc_link_with_quotes = "warn" -doc_markdown = "warn" -duration_suboptimal_units = "warn" -elidable_lifetime_names = "warn" empty_enum_variants_with_brackets = "warn" -empty_enums = "warn" empty_line_after_outer_attr = "warn" -enum_glob_use = "warn" equatable_if_let = "warn" exit = "warn" -expl_impl_clone_on_copy = "warn" -explicit_deref_methods = "warn" -explicit_into_iter_loop = "warn" -explicit_iter_loop = "warn" expect_used = "warn" fallible_impl_from = "warn" -filter_map_next = "warn" -flat_map_option = "warn" float_cmp_const = "warn" -fn_params_excessive_bools = "warn" fn_to_numeric_cast_any = "warn" -format_push_string = "warn" -from_iter_instead_of_collect = "warn" get_unwrap = "warn" if_let_mutex = "warn" -ignore_without_reason = "warn" -ignored_unit_patterns = "warn" -implicit_clone = "warn" implied_bounds_in_impls = "warn" imprecise_flops = "warn" -inconsistent_struct_constructor = "warn" -index_refutable_slice = "warn" -inefficient_to_string = "warn" infinite_loop = "warn" -into_iter_without_iter = "warn" -invalid_upcast_comparisons = "warn" -ip_constant = "warn" -iter_filter_is_ok = "warn" -iter_filter_is_some = "warn" -iter_not_returning_iterator = "warn" iter_on_empty_collections = "warn" iter_on_single_items = "warn" iter_over_hash_type = "warn" -iter_without_into_iter = "warn" -large_digit_groups = "warn" -large_futures = "warn" large_include_file = "warn" -large_stack_arrays = "warn" large_stack_frames = "warn" -large_types_passed_by_value = "warn" let_underscore_must_use = "warn" let_underscore_untyped = "warn" let_unit_value = "warn" -linkedlist = "warn" literal_string_with_formatting_args = "warn" lossy_float_literal = "warn" -macro_use_imports = "warn" -manual_assert = "warn" manual_clamp = "warn" manual_ilog2 = "warn" -manual_instant_elapsed = "warn" -manual_is_power_of_two = "warn" -manual_is_variant_and = "warn" -manual_let_else = "warn" -manual_midpoint = "warn" manual_ok_or = "warn" -manual_string_new = "warn" map_err_ignore = "warn" map_flatten = "warn" -match_bool = "warn" -match_same_arms = "warn" -match_wild_err_arm = "warn" -match_wildcard_for_single_variants = "warn" mem_forget = "warn" -mismatching_type_param_order = "warn" missing_assert_message = "warn" missing_enforced_import_renames = "warn" -missing_errors_doc = "warn" -missing_fields_in_debug = "warn" missing_safety_doc = "warn" mixed_attributes_style = "warn" -mut_mut = "warn" mutex_integer = "warn" needless_borrow = "warn" -needless_continue = "warn" -needless_for_each = "warn" needless_pass_by_ref_mut = "warn" -needless_pass_by_value = "warn" -needless_raw_string_hashes = "warn" needless_type_cast = "warn" negative_feature_names = "warn" -non_std_lazy_statics = "warn" non_zero_suggestions = "warn" nonstandard_macro_braces = "warn" only_used_in_recursion = "warn" -option_as_ref_cloned = "warn" -option_option = "warn" or_fun_call = "warn" path_buf_push_overwrite = "warn" pathbuf_init_then_push = "warn" precedence_bits = "warn" print_stderr = "warn" print_stdout = "warn" -ptr_as_ptr = "warn" -ptr_cast_constness = "warn" -pub_underscore_fields = "warn" pub_without_shorthand = "warn" rc_mutex = "warn" readonly_write_lock = "warn" redundant_type_annotations = "warn" -ref_as_ptr = "warn" -ref_option = "warn" -ref_option_ref = "warn" ref_patterns = "warn" rest_pat_in_fully_bound_structs = "warn" return_and_then = "warn" -same_functions_in_if_condition = "warn" -same_length_and_capacity = "warn" -self_only_used_in_recursion = "warn" -semicolon_if_nothing_returned = "warn" set_contains_or_insert = "warn" -should_panic_without_expect = "warn" -single_char_pattern = "warn" -single_match_else = "warn" single_option_map = "warn" -str_split_at_newline = "warn" str_to_string = "warn" string_add = "warn" -string_add_assign = "warn" string_lit_as_bytes = "warn" string_lit_chars_any = "warn" suspicious_command_arg_space = "warn" @@ -274,31 +196,18 @@ suspicious_xor_used_as_pow = "warn" todo = "warn" too_long_first_doc_paragraph = "warn" too_many_arguments = "warn" -too_many_lines = "warn" trailing_empty_array = "warn" trait_duplication_in_bounds = "warn" -transmute_ptr_to_ptr = "warn" tuple_array_conversions = "warn" -unchecked_time_subtraction = "warn" undocumented_unsafe_blocks = "warn" unimplemented = "warn" uninhabited_references = "warn" -uninlined_format_args = "warn" -unnecessary_box_returns = "warn" -unnecessary_debug_formatting = "warn" -unnecessary_literal_bound = "warn" unnecessary_safety_comment = "warn" unnecessary_safety_doc = "warn" unnecessary_self_imports = "warn" -unnecessary_semicolon = "warn" unnecessary_struct_initialization = "warn" -unnecessary_trailing_comma = "warn" -unnecessary_wraps = "warn" -unnested_or_patterns = "warn" -unused_async = "warn" unused_peekable = "warn" unused_rounding = "warn" -unused_self = "warn" unused_trait_names = "warn" unwrap_used = "warn" use_self = "warn" @@ -306,12 +215,36 @@ useless_let_if_seq = "warn" useless_transmute = "warn" verbose_file_reads = "warn" wildcard_dependencies = "warn" -wildcard_imports = "warn" -zero_sized_map_values = "warn" +# Pedantic lints we opt out of, with the number of hits at the time we enabled `pedantic`. +# Lints that were already enabled here one-by-one are kept on. +cast_lossless = "allow" # 57 hits +cast_possible_truncation = "allow" # 36 hits +cast_precision_loss = "allow" # 38 hits +cast_sign_loss = "allow" # 9 hits +default_trait_access = "allow" # 12 hits +float_cmp = "allow" # exact float comparisons are usually intentional (`float_cmp_const` is still on) +inline_always = "allow" # we know what we are doing +items_after_statements = "allow" # 3 hits +many_single_char_names = "allow" # `r, g, b, a` and `h, s, v` are fine +missing_panics_doc = "allow" # 2 hits +must_use_candidate = "allow" # 181 hits +redundant_closure_for_method_calls = "allow" # 13 hits +return_self_not_must_use = "allow" # 194 hits +similar_names = "allow" # too many false positives, e.g. `encoder`/`encoded` +struct_excessive_bools = "allow" # 3 hits +struct_field_names = "allow" # 3 hits +trivially_copy_pass_by_ref = "allow" # 3 hits +unreadable_literal = "allow" +used_underscore_binding = "allow" + +# These are meh: assigning_clones = "allow" # No please manual_range_contains = "allow" # this one is just worse imho map_unwrap_or = "allow" # so is this one + +# NOTE: these are in `restriction`/`nursery`, so the `allow` is a no-op today. +# We keep them to record our intent in case we ever enable those groups. self_named_module_files = "allow" # Disabled waiting on https://github.com/rust-lang/rust-clippy/issues/9602 significant_drop_tightening = "allow" # Too many false positives diff --git a/egui_plot/src/items/span.rs b/egui_plot/src/items/span.rs index afc3e799..860ec5bc 100644 --- a/egui_plot/src/items/span.rs +++ b/egui_plot/src/items/span.rs @@ -294,10 +294,10 @@ impl PlotItem for Span { fn initialize(&mut self, _x_range: RangeInclusive) {} fn color(&self) -> Color32 { - if self.fill != Color32::TRANSPARENT { - self.fill - } else { + if self.fill == Color32::TRANSPARENT { self.border_stroke.color + } else { + self.fill } }