2023-06-04 12:33:13 -05:00
|
|
|
#![warn(clippy::arc_with_non_send_sync)]
|
|
|
|
#![allow(unused_variables)]
|
|
|
|
use std::cell::RefCell;
|
|
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
|
2023-06-08 02:22:04 -05:00
|
|
|
fn foo<T>(x: T) {
|
|
|
|
// Should not lint - purposefully ignoring generic args.
|
|
|
|
let a = Arc::new(x);
|
|
|
|
}
|
2023-07-03 04:34:02 -05:00
|
|
|
fn issue11076<T>() {
|
|
|
|
let a: Arc<Vec<T>> = Arc::new(Vec::new());
|
|
|
|
}
|
2023-06-08 02:22:04 -05:00
|
|
|
|
2023-06-04 12:33:13 -05:00
|
|
|
fn main() {
|
2023-07-04 11:58:02 -05:00
|
|
|
let _ = Arc::new(42);
|
2023-06-04 12:33:13 -05:00
|
|
|
|
2023-07-04 11:58:02 -05:00
|
|
|
// !Sync
|
|
|
|
let _ = Arc::new(RefCell::new(42));
|
|
|
|
let mutex = Mutex::new(1);
|
|
|
|
// !Send
|
|
|
|
let _ = Arc::new(mutex.lock().unwrap());
|
|
|
|
// !Send + !Sync
|
|
|
|
let _ = Arc::new(&42 as *const i32);
|
2023-06-04 12:33:13 -05:00
|
|
|
}
|