rust/tests/ui/infinite/infinite-autoderef.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
388 B
Rust
Raw Normal View History

// error-pattern: reached the recursion limit while auto-dereferencing
2022-03-20 19:02:18 +00:00
// compile-flags: -Zdeduplicate-diagnostics=yes
2015-01-08 02:53:58 +00:00
use std::ops::Deref;
struct Foo;
2015-01-01 19:53:20 +00:00
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();
}