pub static TRIVIAL_NUMERIC_CASTS: &'static Lint
Expand description

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

§Example

#![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 an explicit syntax for coercions providing a convenient way to work around the current issues. See RFC 401 (coercions), RFC 803 (type ascription) and RFC 3307 (remove type ascription) for historical context.