about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/redundant_allocation.rs
blob: 677b3e56d4dcebe5ea58a9996b5cac7c5332cddc (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
37
38
39
40
41
42
43
44
45
46
47
48
// run-rustfix
#![warn(clippy::all)]
#![allow(clippy::boxed_local, clippy::needless_pass_by_value)]
#![allow(clippy::blacklisted_name, unused_variables, dead_code)]

use std::boxed::Box;
use std::rc::Rc;

pub struct MyStruct {}

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

pub enum MyEnum {
    One,
    Two,
}

// Rc<&T>

pub fn test1<T>(foo: Rc<&T>) {}

pub fn test2(foo: Rc<&MyStruct>) {}

pub fn test3(foo: Rc<&MyEnum>) {}

pub fn test4_neg(foo: Rc<SubT<&usize>>) {}

// Rc<Rc<T>>

pub fn test5(a: Rc<Rc<bool>>) {}

// Rc<Box<T>>

pub fn test6(a: Rc<Box<bool>>) {}

// Box<&T>

pub fn test7<T>(foo: Box<&T>) {}

pub fn test8(foo: Box<&MyStruct>) {}

pub fn test9(foo: Box<&MyEnum>) {}

pub fn test10_neg(foo: Box<SubT<&usize>>) {}

fn main() {}