Skip to content

trivial_numeric_casts warning incorrect when casting between type aliases #23739

Closed
@lilyball

Description

@lilyball

The new trivial_numeric_casts lint incorrectly warns when casting between two types that happen to be type aliases. This is incorrect because the types may not actually be type aliases under all build configurations. Case in point, libc::c_long is i32 on some architectures and i64 on others. If I believe the trivial_numeric_casts warning when casting from an i64 to a libc::c_long, that breaks compilation on 32-bit architectures.

#![feature(libc)]

extern crate libc;

fn main() {
    let x: i64 = 1;
    let _y = x as libc::c_long;
//           ^~~~~~~~~~~~~~~~~
// warning: trivial numeric cast: `i64` as `i64`, #[warn(trivial_numeric_casts)] on by default
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions