Files
rust/tests/ui/mutex_atomic.rs

50 lines
970 B
Rust
Raw Normal View History

2018-07-28 17:34:52 +02:00
#![warn(clippy::all)]
#![warn(clippy::mutex_integer)]
2022-01-10 23:36:13 +09:00
#![warn(clippy::mutex_atomic)]
#![allow(clippy::borrow_as_ptr)]
fn main() {
use std::sync::Mutex;
2017-02-08 14:58:07 +01:00
Mutex::new(true);
2025-02-11 17:57:08 +01:00
//~^ mutex_atomic
2017-02-08 14:58:07 +01:00
Mutex::new(5usize);
2025-02-11 17:57:08 +01:00
//~^ mutex_atomic
2017-02-08 14:58:07 +01:00
Mutex::new(9isize);
2025-02-11 17:57:08 +01:00
//~^ mutex_atomic
let mut x = 4u32;
2017-02-08 14:58:07 +01:00
Mutex::new(&x as *const u32);
2025-02-11 17:57:08 +01:00
//~^ mutex_atomic
2017-02-08 14:58:07 +01:00
Mutex::new(&mut x as *mut u32);
2025-02-11 17:57:08 +01:00
//~^ mutex_atomic
2017-02-08 14:58:07 +01:00
Mutex::new(0u32);
2025-02-11 17:57:08 +01:00
//~^ mutex_integer
2017-02-08 14:58:07 +01:00
Mutex::new(0i32);
2025-02-11 17:57:08 +01:00
//~^ mutex_integer
Mutex::new(0f32); // there are no float atomics, so this should not lint
2023-12-25 14:28:01 +08:00
Mutex::new(0u8);
2025-02-11 17:57:08 +01:00
//~^ mutex_integer
2023-12-25 14:28:01 +08:00
Mutex::new(0i16);
2025-02-11 17:57:08 +01:00
//~^ mutex_integer
2023-12-25 14:28:01 +08:00
let _x: Mutex<i8> = Mutex::new(0);
2025-02-11 17:57:08 +01:00
//~^ mutex_integer
2023-12-25 14:28:01 +08:00
const X: i64 = 0;
Mutex::new(X);
2025-02-11 17:57:08 +01:00
//~^ mutex_integer
2023-12-25 14:28:01 +08:00
// there are no 128 atomics, so these two should not lint
{
Mutex::new(0u128);
let _x: Mutex<i128> = Mutex::new(0);
}
}