[][src]Static rustc_ap_rustc_session::lint::builtin::TRIVIAL_NUMERIC_CASTS

pub static  TRIVIAL_NUMERIC_CASTS: &Lint

The trivial_numeric_casts lint detects trivial numeric casts of types which could be removed.

Example

This example deliberately fails to compile
#![deny(trivial_numeric_casts)]
let x = 42_i32 as i32;

{{produces}}

Explanation

A trivial numeric cast is a cast of a numeric type to the same numeric type. This type of cast is usually unnecessary.

This lint is "allow" by default because there are situations, such as with FFI interfaces or complex type aliases, where it triggers incorrectly, or in situations where it will be more difficult to clearly express the intent. It may be possible that this will become a warning in the future, possibly with type ascription providing a convenient way to work around the current issues. See RFC 401 for historical context.