mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-18 00:53:31 +00:00
118 lines
3.1 KiB
Rust
118 lines
3.1 KiB
Rust
|
//@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 = u64::MAX;
|
||
|
//~^ ERROR: usage of a legacy numeric constant
|
||
|
//~| HELP: use the associated constant instead
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
use std::u32::MAX;
|
||
|
use std::u8::MIN;
|
||
|
use std::{f64, u32};
|
||
|
|
||
|
#[warn(clippy::legacy_numeric_constants)]
|
||
|
fn main() {
|
||
|
f32::EPSILON;
|
||
|
//~^ ERROR: usage of a legacy numeric constant
|
||
|
//~| HELP: use the associated constant instead
|
||
|
u8::MIN;
|
||
|
//~^ ERROR: usage of a legacy numeric constant
|
||
|
//~| HELP: use the associated constant instead
|
||
|
usize::MIN;
|
||
|
//~^ ERROR: usage of a legacy numeric constant
|
||
|
//~| HELP: use the associated constant instead
|
||
|
u32::MAX;
|
||
|
//~^ ERROR: usage of a legacy numeric constant
|
||
|
//~| HELP: use the associated constant instead
|
||
|
u32::MAX;
|
||
|
//~^ ERROR: usage of a legacy numeric constant
|
||
|
//~| HELP: use the associated constant instead
|
||
|
u32::MAX;
|
||
|
//~^ ERROR: usage of a legacy numeric constant
|
||
|
//~| HELP: use the associated constant instead
|
||
|
i32::MAX;
|
||
|
//~^ ERROR: usage of a legacy numeric method
|
||
|
//~| HELP: use the associated constant instead
|
||
|
u8::MAX;
|
||
|
//~^ ERROR: usage of a legacy numeric method
|
||
|
//~| HELP: use the associated constant instead
|
||
|
u8::MIN;
|
||
|
//~^ ERROR: usage of a legacy numeric method
|
||
|
//~| HELP: use the associated constant instead
|
||
|
u8::MIN;
|
||
|
//~^ ERROR: usage of a legacy numeric constant
|
||
|
//~| HELP: use the associated constant instead
|
||
|
::std::primitive::u8::MIN;
|
||
|
//~^ ERROR: usage of a legacy numeric method
|
||
|
//~| HELP: use the associated constant instead
|
||
|
std::primitive::i32::MAX;
|
||
|
//~^ ERROR: usage of a legacy numeric method
|
||
|
//~| HELP: use the associated constant instead
|
||
|
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, "", 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::u64;
|
||
|
use std::u8::MIN;
|
||
|
}
|
||
|
|
||
|
#[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() {
|
||
|
u32::MAX;
|
||
|
//~^ ERROR: usage of a legacy numeric constant
|
||
|
}
|