summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/extra_unused_type_parameters.fixed
blob: 8420df6634d9049134a3de8cbda87d0f738283e4 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//@run-rustfix
//@aux-build:proc_macros.rs:proc-macro

#![allow(unused, clippy::needless_lifetimes)]
#![warn(clippy::extra_unused_type_parameters)]

extern crate proc_macros;
use proc_macros::with_span;

fn unused_ty(x: u8) {
    unimplemented!()
}

fn unused_multi(x: u8) {
    unimplemented!()
}

fn unused_with_lt<'a>(x: &'a u8) {
    unimplemented!()
}

fn used_ty<T>(x: T, y: u8) {}

fn used_ref<'a, T>(x: &'a T) {}

fn used_ret<T: Default>(x: u8) -> T {
    T::default()
}

fn unused_bounded<U>(x: U) {
    unimplemented!();
}

fn some_unused<B, C>(b: B, c: C) {
    unimplemented!();
}

fn used_opaque<A>(iter: impl Iterator<Item = A>) -> usize {
    iter.count()
}

fn used_ret_opaque<A>() -> impl Iterator<Item = A> {
    std::iter::empty()
}

fn used_vec_box<T>(x: Vec<Box<T>>) {}

fn used_body<T: Default + ToString>() -> String {
    T::default().to_string()
}

fn used_closure<T: Default + ToString>() -> impl Fn() {
    || println!("{}", T::default().to_string())
}

struct S;

impl S {
    fn unused_ty_impl(&self) {
        unimplemented!()
    }
}

// Don't lint on trait methods
trait Foo {
    fn bar<T>(&self);
}

impl Foo for S {
    fn bar<T>(&self) {}
}

fn skip_index<A, Iter>(iter: Iter, index: usize) -> impl Iterator<Item = A>
where
    Iter: Iterator<Item = A>,
{
    iter.enumerate()
        .filter_map(move |(i, a)| if i == index { None } else { Some(a) })
}

fn unused_opaque(dummy: impl Default) {
    unimplemented!()
}

mod unexported_trait_bounds {
    mod private {
        pub trait Private {}
    }

    fn priv_trait_bound<T: private::Private>() {
        unimplemented!();
    }

    fn unused_with_priv_trait_bound<T: private::Private>() {
        unimplemented!();
    }
}

mod issue10319 {
    fn assert_send<T: Send>() {}

    fn assert_send_where<T>()
    where
        T: Send,
    {
    }
}

with_span!(
    span

    fn should_not_lint<T>(x: u8) {
        unimplemented!()
    }
);

fn main() {}