2019-01-13 18:38:43 +00:00
|
|
|
// run-rustfix
|
|
|
|
#![feature(integer_atomics)]
|
|
|
|
#![allow(unused_variables, clippy::blacklisted_name)]
|
|
|
|
#![deny(clippy::replace_consts)]
|
|
|
|
|
|
|
|
use std::sync::atomic::*;
|
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
fn bad() {
|
|
|
|
// Min
|
|
|
|
{ let foo = isize::min_value(); };
|
|
|
|
{ let foo = i8::min_value(); };
|
|
|
|
{ let foo = i16::min_value(); };
|
|
|
|
{ let foo = i32::min_value(); };
|
|
|
|
{ let foo = i64::min_value(); };
|
|
|
|
{ let foo = i128::min_value(); };
|
|
|
|
{ let foo = usize::min_value(); };
|
|
|
|
{ let foo = u8::min_value(); };
|
|
|
|
{ let foo = u16::min_value(); };
|
|
|
|
{ let foo = u32::min_value(); };
|
|
|
|
{ let foo = u64::min_value(); };
|
|
|
|
{ let foo = u128::min_value(); };
|
|
|
|
// Max
|
|
|
|
{ let foo = isize::max_value(); };
|
|
|
|
{ let foo = i8::max_value(); };
|
|
|
|
{ let foo = i16::max_value(); };
|
|
|
|
{ let foo = i32::max_value(); };
|
|
|
|
{ let foo = i64::max_value(); };
|
|
|
|
{ let foo = i128::max_value(); };
|
|
|
|
{ let foo = usize::max_value(); };
|
|
|
|
{ let foo = u8::max_value(); };
|
|
|
|
{ let foo = u16::max_value(); };
|
|
|
|
{ let foo = u32::max_value(); };
|
|
|
|
{ let foo = u64::max_value(); };
|
|
|
|
{ let foo = u128::max_value(); };
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
fn good() {
|
|
|
|
// Atomic
|
|
|
|
{ let foo = AtomicBool::new(false); };
|
|
|
|
{ let foo = AtomicIsize::new(0); };
|
|
|
|
{ let foo = AtomicI8::new(0); };
|
|
|
|
{ let foo = AtomicI16::new(0); };
|
|
|
|
{ let foo = AtomicI32::new(0); };
|
|
|
|
{ let foo = AtomicI64::new(0); };
|
|
|
|
{ let foo = AtomicUsize::new(0); };
|
|
|
|
{ let foo = AtomicU8::new(0); };
|
|
|
|
{ let foo = AtomicU16::new(0); };
|
|
|
|
{ let foo = AtomicU32::new(0); };
|
|
|
|
{ let foo = AtomicU64::new(0); };
|
|
|
|
// Min
|
|
|
|
{ let foo = isize::min_value(); };
|
|
|
|
{ let foo = i8::min_value(); };
|
|
|
|
{ let foo = i16::min_value(); };
|
|
|
|
{ let foo = i32::min_value(); };
|
|
|
|
{ let foo = i64::min_value(); };
|
|
|
|
{ let foo = i128::min_value(); };
|
|
|
|
{ let foo = usize::min_value(); };
|
|
|
|
{ let foo = u8::min_value(); };
|
|
|
|
{ let foo = u16::min_value(); };
|
|
|
|
{ let foo = u32::min_value(); };
|
|
|
|
{ let foo = u64::min_value(); };
|
|
|
|
{ let foo = u128::min_value(); };
|
|
|
|
// Max
|
|
|
|
{ let foo = isize::max_value(); };
|
|
|
|
{ let foo = i8::max_value(); };
|
|
|
|
{ let foo = i16::max_value(); };
|
|
|
|
{ let foo = i32::max_value(); };
|
|
|
|
{ let foo = i64::max_value(); };
|
|
|
|
{ let foo = i128::max_value(); };
|
|
|
|
{ let foo = usize::max_value(); };
|
|
|
|
{ let foo = u8::max_value(); };
|
|
|
|
{ let foo = u16::max_value(); };
|
|
|
|
{ let foo = u32::max_value(); };
|
|
|
|
{ let foo = u64::max_value(); };
|
|
|
|
{ let foo = u128::max_value(); };
|
2019-12-31 18:33:15 +00:00
|
|
|
|
2020-01-02 07:22:57 +00:00
|
|
|
let x = 42;
|
|
|
|
|
|
|
|
let _ = match x {
|
2019-12-31 18:33:15 +00:00
|
|
|
std::i8::MIN => -1,
|
|
|
|
1..=std::i8::MAX => 1,
|
|
|
|
_ => 0
|
|
|
|
};
|
2020-01-02 07:22:57 +00:00
|
|
|
|
|
|
|
let _ = if let std::i8::MIN = x {
|
|
|
|
-1
|
|
|
|
} else if let 1..=std::i8::MAX = x {
|
|
|
|
1
|
|
|
|
} else {
|
|
|
|
0
|
|
|
|
};
|
2019-01-13 18:38:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
bad();
|
|
|
|
good();
|
|
|
|
}
|