Files
rust/tests/ui/default_numeric_fallback.rs

19 lines
333 B
Rust
Raw Normal View History

2021-02-02 12:26:20 +09:00
#![warn(clippy::default_numeric_fallback)]
#![allow(unused)]
fn main() {
// Bad.
2021-02-07 18:00:08 +09:00
let x = 1;
let x = 0.1;
let x = if true { 1 } else { 2 };
2021-02-02 12:26:20 +09:00
// Good.
2021-02-07 18:00:08 +09:00
let x = 1_i32;
let x: i32 = 1;
let x: _ = 1;
let x = 0.1_f64;
let x: f64 = 0.1;
let x: _ = 0.1;
let x: _ = if true { 1 } else { 2 };
2021-02-02 12:26:20 +09:00
}