]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | // run-rustfix |
2 | #![feature(never_type)] | |
064997fb | 3 | #![allow(unused_mut, unused_tuple_struct_fields, clippy::redundant_allocation)] |
f20569fa XL |
4 | #![warn(clippy::must_use_candidate)] |
5 | use std::rc::Rc; | |
6 | use std::sync::atomic::{AtomicBool, Ordering}; | |
7 | use std::sync::Arc; | |
8 | ||
9 | pub struct MyAtomic(AtomicBool); | |
10 | pub struct MyPure; | |
11 | ||
12 | pub fn pure(i: u8) -> u8 { | |
13 | i | |
14 | } | |
15 | ||
16 | impl MyPure { | |
17 | pub fn inherent_pure(&self) -> u8 { | |
18 | 0 | |
19 | } | |
20 | } | |
21 | ||
22 | pub trait MyPureTrait { | |
23 | fn trait_pure(&self, i: u32) -> u32 { | |
24 | self.trait_impl_pure(i) + 1 | |
25 | } | |
26 | ||
27 | fn trait_impl_pure(&self, i: u32) -> u32; | |
28 | } | |
29 | ||
30 | impl MyPureTrait for MyPure { | |
31 | fn trait_impl_pure(&self, i: u32) -> u32 { | |
32 | i | |
33 | } | |
34 | } | |
35 | ||
36 | pub fn without_result() { | |
37 | // OK | |
38 | } | |
39 | ||
40 | pub fn impure_primitive(i: &mut u8) -> u8 { | |
41 | *i | |
42 | } | |
43 | ||
44 | pub fn with_callback<F: Fn(u32) -> bool>(f: &F) -> bool { | |
45 | f(0) | |
46 | } | |
47 | ||
48 | pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool { | |
49 | true | |
50 | } | |
51 | ||
52 | pub fn quoth_the_raven(_more: !) -> u32 { | |
53 | unimplemented!(); | |
54 | } | |
55 | ||
56 | pub fn atomics(b: &AtomicBool) -> bool { | |
57 | b.load(Ordering::SeqCst) | |
58 | } | |
59 | ||
60 | pub fn rcd(_x: Rc<u32>) -> bool { | |
61 | true | |
62 | } | |
63 | ||
64 | pub fn rcmut(_x: Rc<&mut u32>) -> bool { | |
65 | true | |
66 | } | |
67 | ||
68 | pub fn arcd(_x: Arc<u32>) -> bool { | |
69 | false | |
70 | } | |
71 | ||
72 | pub fn inner_types(_m: &MyAtomic) -> bool { | |
73 | true | |
74 | } | |
75 | ||
76 | static mut COUNTER: usize = 0; | |
77 | ||
78 | /// # Safety | |
79 | /// | |
80 | /// Don't ever call this from multiple threads | |
81 | pub unsafe fn mutates_static() -> usize { | |
82 | COUNTER += 1; | |
83 | COUNTER | |
84 | } | |
85 | ||
86 | #[no_mangle] | |
87 | pub fn unmangled(i: bool) -> bool { | |
88 | !i | |
89 | } | |
90 | ||
91 | fn main() { | |
92 | assert_eq!(1, pure(1)); | |
93 | } |