2019-12-14 07:40:43 -06:00
|
|
|
#![feature(never_type)]
|
2024-08-23 22:49:09 -05:00
|
|
|
#![allow(
|
|
|
|
unused_mut,
|
|
|
|
clippy::redundant_allocation,
|
|
|
|
clippy::needless_pass_by_ref_mut,
|
|
|
|
static_mut_refs
|
|
|
|
)]
|
2019-09-18 01:37:41 -05:00
|
|
|
#![warn(clippy::must_use_candidate)]
|
|
|
|
use std::rc::Rc;
|
|
|
|
use std::sync::Arc;
|
2024-09-22 13:42:10 -05:00
|
|
|
use std::sync::atomic::{AtomicBool, Ordering};
|
2019-09-18 01:37:41 -05:00
|
|
|
|
|
|
|
pub struct MyAtomic(AtomicBool);
|
|
|
|
pub struct MyPure;
|
|
|
|
|
|
|
|
#[must_use] pub fn pure(i: u8) -> u8 {
|
|
|
|
i
|
|
|
|
}
|
|
|
|
|
|
|
|
impl MyPure {
|
|
|
|
#[must_use] pub fn inherent_pure(&self) -> u8 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait MyPureTrait {
|
|
|
|
fn trait_pure(&self, i: u32) -> u32 {
|
|
|
|
self.trait_impl_pure(i) + 1
|
|
|
|
}
|
|
|
|
|
|
|
|
fn trait_impl_pure(&self, i: u32) -> u32;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl MyPureTrait for MyPure {
|
2019-11-12 16:36:22 -06:00
|
|
|
fn trait_impl_pure(&self, i: u32) -> u32 {
|
2019-09-18 01:37:41 -05:00
|
|
|
i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn without_result() {
|
|
|
|
// OK
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn impure_primitive(i: &mut u8) -> u8 {
|
|
|
|
*i
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn with_callback<F: Fn(u32) -> bool>(f: &F) -> bool {
|
|
|
|
f(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[must_use] pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn quoth_the_raven(_more: !) -> u32 {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn atomics(b: &AtomicBool) -> bool {
|
|
|
|
b.load(Ordering::SeqCst)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[must_use] pub fn rcd(_x: Rc<u32>) -> bool {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn rcmut(_x: Rc<&mut u32>) -> bool {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
#[must_use] pub fn arcd(_x: Arc<u32>) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn inner_types(_m: &MyAtomic) -> bool {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
static mut COUNTER: usize = 0;
|
|
|
|
|
|
|
|
/// # Safety
|
|
|
|
///
|
|
|
|
/// Don't ever call this from multiple threads
|
|
|
|
pub unsafe fn mutates_static() -> usize {
|
|
|
|
COUNTER += 1;
|
|
|
|
COUNTER
|
|
|
|
}
|
|
|
|
|
2020-01-03 10:21:36 -06:00
|
|
|
#[no_mangle]
|
2023-02-25 18:08:29 -06:00
|
|
|
pub extern "C" fn unmangled(i: bool) -> bool {
|
2020-01-03 10:21:36 -06:00
|
|
|
!i
|
|
|
|
}
|
|
|
|
|
2019-09-18 01:37:41 -05:00
|
|
|
fn main() {
|
|
|
|
assert_eq!(1, pure(1));
|
|
|
|
}
|