summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/rc_mutex.rs
blob: 432972bbc31757e75681163fff8b4d9dd9774b1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#![warn(clippy::rc_mutex)]
#![allow(unused, clippy::disallowed_names)]

use std::rc::Rc;
use std::sync::Mutex;

pub struct MyStructWithPrivItem {
    foo: Rc<Mutex<i32>>,
}

pub struct MyStructWithPubItem {
    pub foo: Rc<Mutex<i32>>,
}

pub struct SubT<T> {
    foo: T,
}

pub enum MyEnum {
    One,
    Two,
}

// All of these test should be trigger the lint because they are not
// part of the public api
fn test1<T>(foo: Rc<Mutex<T>>) {}
fn test2(foo: Rc<Mutex<MyEnum>>) {}
fn test3(foo: Rc<Mutex<SubT<usize>>>) {}

// All of these test should be allowed because they are part of the
// public api and `avoid_breaking_exported_api` is `false` by default.
pub fn pub_test1<T>(foo: Rc<Mutex<T>>) {}
pub fn pub_test2(foo: Rc<Mutex<MyEnum>>) {}
pub fn pub_test3(foo: Rc<Mutex<SubT<usize>>>) {}

fn main() {}