summaryrefslogtreecommitdiffstats
path: root/src/test/ui/infinite/infinite-autoderef.rs
blob: cbbe1f81df86f5606872f623a9402af2366b6a4c (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
// error-pattern: reached the recursion limit while auto-dereferencing
// compile-flags: -Zdeduplicate-diagnostics=yes

use std::ops::Deref;

struct Foo;

impl Deref for Foo {
    type Target = Foo;

    fn deref(&self) -> &Foo {
        self
    }
}

pub fn main() {
    let mut x;
    loop {
        x = Box::new(x);
        x.foo;
        x.bar();
    }

    Foo.foo;
    Foo.bar();
}