about summary refs log tree commit diff
path: root/tests/ui/methods/tuple-suggestions-issue-142488.rs
blob: f6c58fce9a1a7cb96c2520dca0f49641bcc89b43 (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
// Regression test for issue #142488, a diagnostics ICE when trying to suggest missing methods
// present in similar tuple types.
// This is a few of the MCVEs from the issues and its many duplicates.

// 1
fn main() {
    for a in x {
        //~^ ERROR: cannot find value `x` in this scope
        (a,).to_string()
        //~^ ERROR: the method `to_string` exists for tuple
    }
}

// 2
trait Trait {
    fn meth(self);
}

impl<T, U: Trait> Trait for (T, U) {
    fn meth(self) {}
}

fn mcve2() {
    ((), std::collections::HashMap::new()).meth()
    //~^ ERROR: the method `meth` exists for tuple
}

// 3
trait I {}

struct Struct;
impl I for Struct {}

trait Tr {
    fn f<A>(self) -> (A,)
    where
        Self: Sized,
    {
        loop {}
    }
}

impl<T> Tr for T where T: I {}

fn mcve3() {
    Struct.f().f();
    //~^ ERROR: the method `f` exists for tuple
}