about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui-toml/excessive_precision/excessive_precision.rs
blob: 121448ed540dc0c8a092ce137db8f2ebb1cfd689 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#![warn(clippy::excessive_precision)]
#![allow(
    dead_code,
    overflowing_literals,
    unused_variables,
    clippy::print_literal,
    clippy::useless_vec
)]

fn main() {
    // Overly specified constants
    let _: f32 = 1.012345678901234567890;
    //~^ excessive_precision
    let _: f64 = 1.012345678901234567890;
    //~^ excessive_precision
    const _: f32 = 1.012345678901234567890;
    const _: f64 = 1.012345678901234567890;

    static STATIC1: f32 = 1.012345678901234567890;
    static STATIC2: f64 = 1.012345678901234567890;

    static mut STATIC_MUT1: f32 = 1.012345678901234567890;
    static mut STATIC_MUT2: f64 = 1.012345678901234567890;
}

trait ExcessivelyPreciseTrait {
    // Overly specified constants
    const GOOD1: f32 = 1.012345678901234567890;
    const GOOD2: f64 = 1.012345678901234567890;
}

struct ExcessivelyPreciseStruct;

impl ExcessivelyPreciseStruct {
    // Overly specified constants
    const GOOD1: f32 = 1.012345678901234567890;
    const GOOD2: f64 = 1.012345678901234567890;
}