summaryrefslogtreecommitdiffstats
path: root/tests/ui/infinite/infinite-autoderef.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/infinite/infinite-autoderef.rs')
-rw-r--r--tests/ui/infinite/infinite-autoderef.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/ui/infinite/infinite-autoderef.rs b/tests/ui/infinite/infinite-autoderef.rs
new file mode 100644
index 000000000..cbbe1f81d
--- /dev/null
+++ b/tests/ui/infinite/infinite-autoderef.rs
@@ -0,0 +1,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();
+}