]> git.lizzy.rs Git - rust.git/blob - tests/ui/replace_consts.rs
Auto merge of #3635 - matthiaskrgr:revert_random_state_3603, r=xfix
[rust.git] / tests / ui / replace_consts.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 #![feature(integer_atomics)]
11 #![allow(clippy::blacklisted_name)]
12 #![deny(clippy::replace_consts)]
13
14 use std::sync::atomic::*;
15 use std::sync::{Once, ONCE_INIT};
16
17 #[rustfmt::skip]
18 fn bad() {
19     // Once
20     { let foo = ONCE_INIT; };
21     // Atomic
22     { let foo = ATOMIC_BOOL_INIT; };
23     { let foo = ATOMIC_ISIZE_INIT; };
24     { let foo = ATOMIC_I8_INIT; };
25     { let foo = ATOMIC_I16_INIT; };
26     { let foo = ATOMIC_I32_INIT; };
27     { let foo = ATOMIC_I64_INIT; };
28     { let foo = ATOMIC_USIZE_INIT; };
29     { let foo = ATOMIC_U8_INIT; };
30     { let foo = ATOMIC_U16_INIT; };
31     { let foo = ATOMIC_U32_INIT; };
32     { let foo = ATOMIC_U64_INIT; };
33     // Min
34     { let foo = std::isize::MIN; };
35     { let foo = std::i8::MIN; };
36     { let foo = std::i16::MIN; };
37     { let foo = std::i32::MIN; };
38     { let foo = std::i64::MIN; };
39     { let foo = std::i128::MIN; };
40     { let foo = std::usize::MIN; };
41     { let foo = std::u8::MIN; };
42     { let foo = std::u16::MIN; };
43     { let foo = std::u32::MIN; };
44     { let foo = std::u64::MIN; };
45     { let foo = std::u128::MIN; };
46     // Max
47     { let foo = std::isize::MAX; };
48     { let foo = std::i8::MAX; };
49     { let foo = std::i16::MAX; };
50     { let foo = std::i32::MAX; };
51     { let foo = std::i64::MAX; };
52     { let foo = std::i128::MAX; };
53     { let foo = std::usize::MAX; };
54     { let foo = std::u8::MAX; };
55     { let foo = std::u16::MAX; };
56     { let foo = std::u32::MAX; };
57     { let foo = std::u64::MAX; };
58     { let foo = std::u128::MAX; };
59 }
60
61 #[rustfmt::skip]
62 fn good() {
63     // Once
64     { let foo = Once::new(); };
65     // Atomic
66     { let foo = AtomicBool::new(false); };
67     { let foo = AtomicIsize::new(0); };
68     { let foo = AtomicI8::new(0); };
69     { let foo = AtomicI16::new(0); };
70     { let foo = AtomicI32::new(0); };
71     { let foo = AtomicI64::new(0); };
72     { let foo = AtomicUsize::new(0); };
73     { let foo = AtomicU8::new(0); };
74     { let foo = AtomicU16::new(0); };
75     { let foo = AtomicU32::new(0); };
76     { let foo = AtomicU64::new(0); };
77     // Min
78     { let foo = isize::min_value(); };
79     { let foo = i8::min_value(); };
80     { let foo = i16::min_value(); };
81     { let foo = i32::min_value(); };
82     { let foo = i64::min_value(); };
83     { let foo = i128::min_value(); };
84     { let foo = usize::min_value(); };
85     { let foo = u8::min_value(); };
86     { let foo = u16::min_value(); };
87     { let foo = u32::min_value(); };
88     { let foo = u64::min_value(); };
89     { let foo = u128::min_value(); };
90     // Max
91     { let foo = isize::max_value(); };
92     { let foo = i8::max_value(); };
93     { let foo = i16::max_value(); };
94     { let foo = i32::max_value(); };
95     { let foo = i64::max_value(); };
96     { let foo = i128::max_value(); };
97     { let foo = usize::max_value(); };
98     { let foo = u8::max_value(); };
99     { let foo = u16::max_value(); };
100     { let foo = u32::max_value(); };
101     { let foo = u64::max_value(); };
102     { let foo = u128::max_value(); };
103 }
104
105 fn main() {
106     bad();
107     good();
108 }