about summary refs log tree commit diff
path: root/tests/ui/suggestions/no-method-found-suggest-trait-args.rs
blob: d51f86b29e81dfd9567081f38779d85f169a442c (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
/// Tests that suggestions to add trait bounds that would enable using a method include appropriate
/// placeholder arguments for that trait.

trait Trait<I> {
    fn method(&self) {}
}

trait Trait2<'a, A, const B: u8, C = (), const D: u8 = 0> {
    fn method2(&self) {}
}

fn foo<T>(value: T) {
    //~^ SUGGESTION : Trait</* I */>
    //~| SUGGESTION : Trait2</* 'a, A, B */>
    value.method();
    //~^ ERROR no method named `method` found for type parameter `T` in the current scope [E0599]
    value.method2();
    //~^ ERROR no method named `method2` found for type parameter `T` in the current scope [E0599]
}

fn bar(value: impl Copy) {
    //~^ SUGGESTION + Trait</* I */>
    //~| SUGGESTION + Trait2</* 'a, A, B */>
    value.method();
    //~^ ERROR no method named `method` found for type parameter `impl Copy` in the current scope [E0599]
    value.method2();
    //~^ ERROR no method named `method2` found for type parameter `impl Copy` in the current scope [E0599]
}

fn main() {}