about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/impl_trait_in_params.rs
blob: 72e3e068c9c7944a3eaf1d7a465d0cbd23a33a15 (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
#![allow(unused)]
#![warn(clippy::impl_trait_in_params)]

//@no-rustfix: has placeholders
pub trait Trait {}
pub trait AnotherTrait<T> {}

// Should warn
pub fn a(_: impl Trait) {}
//~^ impl_trait_in_params

pub fn c<C: Trait>(_: C, _: impl Trait) {}
//~^ impl_trait_in_params

// Shouldn't warn

pub fn b<B: Trait>(_: B) {}
fn e<T: AnotherTrait<u32>>(_: T) {}
fn d(_: impl AnotherTrait<u32>) {}

//------ IMPLS

pub trait Public {
    // See test in ui-toml for a case where avoid-breaking-exported-api is set to false
    fn t(_: impl Trait);
    fn tt<T: Trait>(_: T) {}
}

trait Private {
    // This shouldn't lint
    fn t(_: impl Trait);
    fn tt<T: Trait>(_: T) {}
}

struct S;
impl S {
    pub fn h(_: impl Trait) {}
    //~^ impl_trait_in_params
    fn i(_: impl Trait) {}
    pub fn j<J: Trait>(_: J) {}
    pub fn k<K: AnotherTrait<u32>>(_: K, _: impl AnotherTrait<u32>) {}
    //~^ impl_trait_in_params
}

// Trying with traits
impl Public for S {
    fn t(_: impl Trait) {}
}

fn main() {}