3 #![warn(clippy::must_use_candidate)]
5 use std::sync::atomic::{AtomicBool, Ordering};
8 pub struct MyAtomic(AtomicBool);
11 #[must_use] pub fn pure(i: u8) -> u8 {
16 #[must_use] pub fn inherent_pure(&self) -> u8 {
21 pub trait MyPureTrait {
22 fn trait_pure(&self, i: u32) -> u32 {
23 self.trait_impl_pure(i) + 1
26 fn trait_impl_pure(&self, i: u32) -> u32;
29 impl MyPureTrait for MyPure {
30 fn trait_impl_pure(&self, i: u32) -> u32 {
35 pub fn without_result() {
39 pub fn impure_primitive(i: &mut u8) -> u8 {
43 pub fn with_callback<F: Fn(u32) -> bool>(f: &F) -> bool {
47 #[must_use] pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool {
51 pub fn quoth_the_raven(_more: !) -> u32 {
55 pub fn atomics(b: &AtomicBool) -> bool {
56 b.load(Ordering::SeqCst)
59 #[must_use] pub fn rcd(_x: Rc<u32>) -> bool {
63 pub fn rcmut(_x: Rc<&mut u32>) -> bool {
67 #[must_use] pub fn arcd(_x: Arc<u32>) -> bool {
71 pub fn inner_types(_m: &MyAtomic) -> bool {
75 static mut COUNTER: usize = 0;
79 /// Don't ever call this from multiple threads
80 pub unsafe fn mutates_static() -> usize {
86 assert_eq!(1, pure(1));