-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consistently naming lints #2845
Comments
you can use |
|
So you all know, I just looked at a bunch of lints and came up with a fair number of new rules. I'd love feedback on some of these. I mostly read down @Manishearth's RFC and figured out new names for lints. |
Not a native English speaker, I wonder if the same would be the case for
Using |
I believe that we should remove |
The typical replacement for those is |
…lints, r=fee1-dead Rename `{drop,forget}_{copy,ref}` lints to more consistent naming This PR renames previous uplifted lints in rust-lang#109732 to more consistent naming. I followed the renaming done [here](rust-lang#53224) and also advocated in this [clippy issue](rust-lang/rust-clippy#2845): - `drop_copy` to `dropping_copy_types` - `forget_copy` to `forgetting_copy_types` - `drop_ref` to `dropping_references` - `forget_ref` to `forgetting_references`
…fee1-dead Rename `{drop,forget}_{copy,ref}` lints to more consistent naming This PR renames previous uplifted lints in rust-lang/rust#109732 to more consistent naming. I followed the renaming done [here](rust-lang/rust#53224) and also advocated in this [clippy issue](rust-lang/rust-clippy#2845): - `drop_copy` to `dropping_copy_types` - `forget_copy` to `forgetting_copy_types` - `drop_ref` to `dropping_references` - `forget_ref` to `forgetting_references`
…fee1-dead Rename `{drop,forget}_{copy,ref}` lints to more consistent naming This PR renames previous uplifted lints in rust-lang/rust#109732 to more consistent naming. I followed the renaming done [here](rust-lang/rust#53224) and also advocated in this [clippy issue](rust-lang/rust-clippy#2845): - `drop_copy` to `dropping_copy_types` - `forget_copy` to `forgetting_copy_types` - `drop_ref` to `dropping_references` - `forget_ref` to `forgetting_references`
…=Nilstrieb Improve `invalid_reference_casting` lint This PR is a follow-up to rust-lang#111567 and rust-lang#113422. This PR does multiple things: - First it adds support for deferred de-reference, the goal is to support code like this, where the casting and de-reference are not done on the same expression ```rust let myself = self as *const Self as *mut Self; *myself = Self::Ready(value); ``` - Second it does not lint anymore on SB/TB UB code by only checking assignments (`=`, `+=`, ...) and creation of mutable references `&mut *` - Thirdly it greatly improves the diagnostics in particular for cast from `&mut` to `&mut` or assignments - ~~And lastly it renames the lint from `cast_ref_to_mut` to `invalid_reference_casting` which is more consistent with the ["rules"](rust-lang/rust-clippy#2845) and also more consistent with what the lint checks~~ *rust-lang#113422 This PR is best reviewed commit by commit. r? compiler
Improve `invalid_reference_casting` lint This PR is a follow-up to rust-lang/rust#111567 and rust-lang/rust#113422. This PR does multiple things: - First it adds support for deferred de-reference, the goal is to support code like this, where the casting and de-reference are not done on the same expression ```rust let myself = self as *const Self as *mut Self; *myself = Self::Ready(value); ``` - Second it does not lint anymore on SB/TB UB code by only checking assignments (`=`, `+=`, ...) and creation of mutable references `&mut *` - Thirdly it greatly improves the diagnostics in particular for cast from `&mut` to `&mut` or assignments - ~~And lastly it renames the lint from `cast_ref_to_mut` to `invalid_reference_casting` which is more consistent with the ["rules"](rust-lang/rust-clippy#2845) and also more consistent with what the lint checks~~ *rust-lang/rust#113422 This PR is best reviewed commit by commit. r? compiler
Improve `invalid_reference_casting` lint This PR is a follow-up to rust-lang/rust#111567 and rust-lang/rust#113422. This PR does multiple things: - First it adds support for deferred de-reference, the goal is to support code like this, where the casting and de-reference are not done on the same expression ```rust let myself = self as *const Self as *mut Self; *myself = Self::Ready(value); ``` - Second it does not lint anymore on SB/TB UB code by only checking assignments (`=`, `+=`, ...) and creation of mutable references `&mut *` - Thirdly it greatly improves the diagnostics in particular for cast from `&mut` to `&mut` or assignments - ~~And lastly it renames the lint from `cast_ref_to_mut` to `invalid_reference_casting` which is more consistent with the ["rules"](rust-lang/rust-clippy#2845) and also more consistent with what the lint checks~~ *rust-lang/rust#113422 This PR is best reviewed commit by commit. r? compiler
RFC 344 mentions a naming convention for lints, and I think that going through the names of the lints clippy offers to be more consistent would be a good idea.
The full list of lints is here: https://rust-lang-nursery.github.io/rust-clippy/master/index.html
I'll be updating this as I go through the lints with what extra conventions on top of what RFC 344 offers should be added to help clippy create better lint names. :)
Lint rules:
unused
is used across Rust lints. For now, I can think ofincorrect
,excessive
,redundant
,temporary
, andundefined
as a few big keywords.val
as a placeholder for a variable name.types
.construct_in_XXX_function
.undefined
.Lint changes:
almost_swapped
, following rule 1, should beincorrect_swaps
approx_constant
should beapproximate_known_constants
assign_op_pattern
definitely should have a different name but I'm not sure whatborrowed_box
should be renamed toredundant_boxes
and include other lints likeboxed_local
for_loop_over_option
andfor_loop_over_result
, following rules 2 and 8, should befor_val_in_option
iter_next_loop
, following rule 2, should befor_val_in_iter_next
deprecated_semver
should benon_semver_deprecations
, because rather thandrop_copy
, following rule 3, should bedrop_copy_types
not_unsafe_ptr_arg_deref
, following rule 4, should bederef_ptr_arg_in_safe_functions
logic_bug
should explain what it's linting and be renamed tounused_short_circuits
possible_missing_comma
, by rule 5, should be renamed tomultiline_binops_in_array
wrong_transmute
, by rule 6, should beundefined_transmutes
invalid_regex
, by rule 1, should beincorrect_regexes
min_max
, following rule 1, should beincorrect_clamps
unit_cmp
should beunit_comparisons
by 7reverse_range_loop
, by 1 should beincorrect_reversed_ranges
suspicious_arithmetic_impl
by 5 should beincorrect_op_in_impl_op
suspicious_op_assign_impl
by 5 should beincorrect_op_in_impl_op_assign
, or combined withincorrect_op_in_impl_op
float_cmp
should befloat_comparisons
by 7zero_width_space
should bezero_width_spaces
fn_to_numeric_cast_with_truncation
should betruncating_fn_ptr_as_int
by 2while_immutable_condition
should bewhile_immutable_val
by 2never_loop
should beinfinite_loops
infinite_iter
should beinfinite_loops
, unless we're still not sure about the quality ofnever_loop
and want to add aninfinite_iter_loops
in the meantimenonsensical_open_options
should beunused_file_options
forget_copy
should beforget_copy_types
if_same_then_else
andifs_same_cond
should be combined intounused_if
cast_ptr_alignment
should beincorrectly_aligned_ptr_casts
modulo_one
,erasing_op
,ineffective_bit_mask
should be combined intounused_operations
inline_fn_without_body
should beempty_inline_fn
mut_from_ref
should bereturning_mut_ref_from_ref
invalid_ref
should beundefined_references
serde_api_misuse
probably needs a different name but idk what it should bematch_bool
should bematch_bool_types
cmp_null
should benull_comparisons
write_with_newline
andprint_with_newline
should beprint_val_newline
unneeded_field_pattern
should beunused_field_patterns
new_without_default_derive
might need a new name or rulezero_ptr
should bezero_as_ptr
wrong_self_convention
should beincorrect_self_conventions
inconsistent_digit_grouping
should beinconsistent_digit_groups
to matchlarge_digit_groups
range_minus_one
should beinclusive_ranges_to_val_minus_one
(I don't like how long it is, but I can't think of anything better?)regex_macro
should beincorrect_regex_macro_calls
op_ref
should bereferencing_comparisons
question_mark
should beincorrect_tries
redundant_closure
should beunused_closures
ptr_arg
should besmart_ptr_arguments
chars_last_cmp
should bechars_last_eq_char
blacklisted_name
should beblacklisted_names
double_neg
should bedouble_negations
unnecessary_fold
should beunspecialized_folds
let_unit_value
should beunit_variables
needless_range_loop
should beredundant_index_loops
excessive_precision
should beexcessive_precision_float_literals
duplicate_underscore_argument
should bedouble_underscore_arguments
panic_params
should bemissing_panic_arguments
writeln_empty_string
should be part ofprintln_empty_string
infallible_destructuring_match
should be part ofinfalliable_matches
block_in_if_condition_stmt
should bestatements_in_if_conditions
unreadable_literal
should beunreadable_literals
unsafe_removed_from_name
should beimport_unsafe_as_safe
builtin_type_shadow
should bebuiltin_type_shadowing
neg_multiply
should betimes_negative_one
const_static_lifetime
should beunused_static_lifetimes
explicit_iter_loop
should beexplicit_for
single_match
should beexplicit_if_let
for_kv_map
should beexcessive_entry_iterators
The text was updated successfully, but these errors were encountered: