blob: 6cb3e694ea145ce26523fa3c66cc63e5fe48eb4a (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
//@aux-build:proc_macros.rs
#![allow(clippy::no_effect, deprecated, unused)]
#![allow(clippy::legacy_numeric_constants)] // For imports.
#[macro_use]
extern crate proc_macros;
pub mod a {
pub use std::u128;
}
macro_rules! b {
() => {
mod b {
#[warn(clippy::legacy_numeric_constants)]
fn b() {
let x = std::u64::MAX;
//~^ ERROR: usage of a legacy numeric constant
//~| HELP: use the associated constant instead
}
}
};
}
use std::u8::MIN;
use std::u32::MAX;
use std::{f64, u32};
#[warn(clippy::legacy_numeric_constants)]
fn main() {
std::f32::EPSILON;
//~^ ERROR: usage of a legacy numeric constant
//~| HELP: use the associated constant instead
std::u8::MIN;
//~^ ERROR: usage of a legacy numeric constant
//~| HELP: use the associated constant instead
std::usize::MIN;
//~^ ERROR: usage of a legacy numeric constant
//~| HELP: use the associated constant instead
std::u32::MAX;
//~^ ERROR: usage of a legacy numeric constant
//~| HELP: use the associated constant instead
core::u32::MAX;
//~^ ERROR: usage of a legacy numeric constant
//~| HELP: use the associated constant instead
MAX;
//~^ ERROR: usage of a legacy numeric constant
//~| HELP: use the associated constant instead
i32::max_value();
//~^ ERROR: usage of a legacy numeric method
//~| HELP: use the associated constant instead
u8::max_value();
//~^ ERROR: usage of a legacy numeric method
//~| HELP: use the associated constant instead
u8::min_value();
//~^ ERROR: usage of a legacy numeric method
//~| HELP: use the associated constant instead
::std::u8::MIN;
//~^ ERROR: usage of a legacy numeric constant
//~| HELP: use the associated constant instead
::std::primitive::u8::min_value();
//~^ ERROR: usage of a legacy numeric method
//~| HELP: use the associated constant instead
std::primitive::i32::max_value();
//~^ ERROR: usage of a legacy numeric method
//~| HELP: use the associated constant instead
self::a::u128::MAX;
//~^ ERROR: usage of a legacy numeric constant
//~| HELP: use the associated constant instead
u32::MAX;
u128::MAX;
f32::EPSILON;
::std::primitive::u8::MIN;
std::f32::consts::E;
f64::consts::E;
u8::MIN;
std::f32::consts::E;
f64::consts::E;
b!();
[(0, "", std::i128::MAX)];
//~^ ERROR: usage of a legacy numeric constant
//~| HELP: use the associated constant instead
}
#[warn(clippy::legacy_numeric_constants)]
fn ext() {
external! {
::std::primitive::u8::MIN;
::std::u8::MIN;
::std::primitive::u8::min_value();
use std::u64;
use std::u8::MIN;
}
}
#[allow(clippy::legacy_numeric_constants)]
fn allow() {
::std::primitive::u8::MIN;
::std::u8::MIN;
::std::primitive::u8::min_value();
use std::u8::MIN;
use std::u64;
}
#[warn(clippy::legacy_numeric_constants)]
#[clippy::msrv = "1.42.0"]
fn msrv_too_low() {
std::u32::MAX;
}
#[warn(clippy::legacy_numeric_constants)]
#[clippy::msrv = "1.43.0"]
fn msrv_juust_right() {
std::u32::MAX;
//~^ ERROR: usage of a legacy numeric constant
}
|