Skip to content

Move the trivial_numeric_casts lint to allow-by-default #1020

Closed
@alexcrichton

Description

@alexcrichton

This lint was recently added in rust-lang/rust#23630 as part of #803 and it disallows casts such as foo as i64 when foo has the type i64.

In theory this does sound like a lint which is nice to have, but I've found that in the context of FFI it's doesn't always play out so well. Because libc::c_int is simply an alias of some concrete primitive type, it is typically casted out into a known integer to be worked with in Rust. In this specific case the target type of i32 is frequently chosen, triggering this lint. Having to annotate crates with #[allow(trivial_numeric_casts)] is somewhat annoying for this common use case, and the broader lint (trivial_casts) seems more relevant to remain as warn-by-default.

cc @nrc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions