]> git.lizzy.rs Git - rust.git/blob - src/test/ui/infinite/infinite-autoderef.rs
Rollup merge of #100396 - chenyukang:fix-100394, r=petrochenkov
[rust.git] / src / test / ui / infinite / infinite-autoderef.rs
1 // error-pattern: reached the recursion limit while auto-dereferencing
2 // compile-flags: -Zdeduplicate-diagnostics=yes
3
4 use std::ops::Deref;
5
6 struct Foo;
7
8 impl Deref for Foo {
9     type Target = Foo;
10
11     fn deref(&self) -> &Foo {
12         self
13     }
14 }
15
16 pub fn main() {
17     let mut x;
18     loop {
19         x = Box::new(x);
20         x.foo;
21         x.bar();
22     }
23
24     Foo.foo;
25     Foo.bar();
26 }