about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2018-09-22 09:56:39 +0200
committerGitHub <noreply@github.com>2018-09-22 09:56:39 +0200
commit0bf52b3a5be7f0b6aa38779b0d78d5469b93494f (patch)
tree16bd73caa374ccbeedd0d2ad33ddadc60e003786
parent394d687121edbef644c158e6dcfacdb0f88c9618 (diff)
parent70da203259360b12d871c043d9eab327034785d6 (diff)
downloadrust-0bf52b3a5be7f0b6aa38779b0d78d5469b93494f.tar.gz
rust-0bf52b3a5be7f0b6aa38779b0d78d5469b93494f.zip
Rollup merge of #54413 - memoryruins:deref-error-twice, r=estebank
Add UI test for deref recursion limit printing twice

Closes #38940

Does ``NOTE`` in the test need to be changed to ``HELP`` if its in the stderr?
``help: consider adding a `#![recursion_limit="20"]` attribute to your crate``

It doesn't appear to complaining locally that the line isn't set to ``HELP`` in the test, and the guide says
 > HELP and SUGGESTION*
> * Note: SUGGESTION must follow immediately after HELP.

yet there's no concrete suggestion emitted.

r? @estebank
-rw-r--r--src/test/ui/issues/issue-38940.rs46
-rw-r--r--src/test/ui/issues/issue-38940.stderr21
2 files changed, 67 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-38940.rs b/src/test/ui/issues/issue-38940.rs
new file mode 100644
index 00000000000..7f9b141e02e
--- /dev/null
+++ b/src/test/ui/issues/issue-38940.rs
@@ -0,0 +1,46 @@
+// issue-38940: error printed twice for deref recursion limit exceeded
+// Test that the recursion limit can be changed. In this case, we have
+// deeply nested types that will fail the `Send` check by overflow
+// when the recursion limit is set very low.
+#![allow(dead_code)]
+#![recursion_limit="10"]
+macro_rules! link {
+    ($outer:ident, $inner:ident) => {
+        struct $outer($inner);
+        impl $outer {
+            fn new() -> $outer {
+                $outer($inner::new())
+            }
+        }
+        impl std::ops::Deref for $outer {
+            type Target = $inner;
+            fn deref(&self) -> &$inner {
+                &self.0
+            }
+        }
+    }
+}
+struct Bottom;
+impl Bottom {
+    fn new() -> Bottom {
+        Bottom
+    }
+}
+link!(Top, A);
+link!(A, B);
+link!(B, C);
+link!(C, D);
+link!(D, E);
+link!(E, F);
+link!(F, G);
+link!(G, H);
+link!(H, I);
+link!(I, J);
+link!(J, K);
+link!(K, Bottom);
+fn main() {
+    let t = Top::new();
+    let x: &Bottom = &t;
+    //~^ ERROR mismatched types
+    //~| ERROR reached the recursion limit while auto-dereferencing I
+}
diff --git a/src/test/ui/issues/issue-38940.stderr b/src/test/ui/issues/issue-38940.stderr
new file mode 100644
index 00000000000..2d3cfda9a5f
--- /dev/null
+++ b/src/test/ui/issues/issue-38940.stderr
@@ -0,0 +1,21 @@
+error[E0055]: reached the recursion limit while auto-dereferencing I
+  --> $DIR/issue-38940.rs:43:22
+   |
+LL |     let x: &Bottom = &t;
+   |                      ^^ deref recursion limit reached
+   |
+   = help: consider adding a `#![recursion_limit="20"]` attribute to your crate
+
+error[E0308]: mismatched types
+  --> $DIR/issue-38940.rs:43:22
+   |
+LL |     let x: &Bottom = &t;
+   |                      ^^ expected struct `Bottom`, found struct `Top`
+   |
+   = note: expected type `&Bottom`
+              found type `&Top`
+
+error: aborting due to 2 previous errors
+
+Some errors occurred: E0055, E0308.
+For more information about an error, try `rustc --explain E0055`.