rust/src/test/ui/infinite/infinite-autoderef.rs

28 lines
342 B
Rust
Raw Normal View History

// error-pattern: reached the recursion limit while auto-dereferencing
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();
}