Skip to content
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

Enable various new clippy lints #1025

Open
wants to merge 7 commits into
base: rust-next
Choose a base branch
from

Commits on Jul 16, 2023

  1. rust: move 'rust_common_flags' to a separate configuration file

    Currently, 'rustc_common_flags' lives in the top-level 'Makefile'.
    This means that we need to touch this whenever adjustments to Rust's CLI
    configuration are desired, such as changing what lints Clippy should
    emit.
    
    This patch moves these flags to a separate file within 'rust/' so that
    necessary changes can be made without affecting 'Makefile'. It copies
    the behavior currently used with 'bindgen_parameters', which accepts
    comments.
    
    Additionally, 'let_unit_value` is no longer specifically named as it is
    now part of the 'style' group [1].
    
    [1]: rust-lang/rust-clippy#8563
    
    Signed-off-by: Trevor Gross <[email protected]>
    tgross35 committed Jul 16, 2023
    Configuration menu
    Copy the full SHA
    3754849 View commit details
    Browse the repository at this point in the history
  2. rust: clippy: enable lints from 'pedantic' that have no errors

    This patch selects a subset of lints from Clippy's 'pedantic' group and
    enables them. The only lints enabled here are those that do not show any
    errors with any of the files we currently have.
    
    Signed-off-by: Trevor Gross <[email protected]>
    tgross35 committed Jul 16, 2023
    Configuration menu
    Copy the full SHA
    82157b8 View commit details
    Browse the repository at this point in the history
  3. rust: clippy: enable 'undocumented_unsafe_blocks' lint

    This patch enables the 'undocumented_unsafe_blocks' lint and adds
    comments where needed for this lint to pass. Clippy will now deny unsafe
    code that does not have an associated '// SAFETY: ' comment, which helps
    improve the maintainability of potentially dangerous code.
    
    Signed-off-by: Trevor Gross <[email protected]>
    tgross35 committed Jul 16, 2023
    Configuration menu
    Copy the full SHA
    bbc6d1c View commit details
    Browse the repository at this point in the history
  4. rust: clippy: enable three trivial lints with corrections

    This patch enables three trivial lints and adds corrections so existing
    code passes. Lints added were:
    
    -   'expl_impl_clone_on_copy': check for implementing `Clone` when
        `Copy` already exists.
    -   'explicit_deref_methods': check for usage of `.deref()` to encourage
        cleaner code.
    -   'trivially_copy_pass_by_ref': check for small types that would be
        easier passed by value than by reference.
    
    Signed-off-by: Trevor Gross <[email protected]>
    tgross35 committed Jul 16, 2023
    Configuration menu
    Copy the full SHA
    8f4700d View commit details
    Browse the repository at this point in the history
  5. rust: clippy: enable two pointer-related lints

    -   'ptr_as_ptr': enforce that '*const -> *const' and '*mut -> *mut'
        conversions be done via '.cast()' rather than 'as', to avoid
        accidental changes in mutability.
    -   'transmute_ptr_to_ptr': detect transumtes that could be written as
        lessi dangerous casts.
    
    Signed-off-by: Trevor Gross <[email protected]>
    tgross35 committed Jul 16, 2023
    Configuration menu
    Copy the full SHA
    a764f0a View commit details
    Browse the repository at this point in the history
  6. rust: clippy: enable lints related to improving style

    -   'manual_assert': detect combined usage of 'if' and 'panic' when
        'assert' would have been more straightforward.
    -   'redundant_else': enforce that blocks are not nested within 'else'
        after conditional control flow statments.
    -   'semicolon_if_nothing_returned': enforce consistent style that
        makes it more clear that a statement is not used.
    
    Signed-off-by: Trevor Gross <[email protected]>
    tgross35 committed Jul 16, 2023
    Configuration menu
    Copy the full SHA
    2118d15 View commit details
    Browse the repository at this point in the history
  7. rust: clippy: enable 'items_after_statements' and 'redundant_closure_…

    …for_...'
    
    -   'items_after_statements': prevent confusing scope since items and
        statements do not follow the same rules.
    -   'redundant_closure_for_method_calls': simplify closures that call a
        single method. This is the associated function equivalent of
        'redundant_closure'.
    
    Signed-off-by: Trevor Gross <[email protected]>
    tgross35 committed Jul 16, 2023
    Configuration menu
    Copy the full SHA
    b2d5dbc View commit details
    Browse the repository at this point in the history