about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/consts/recursive-const-in-impl.rs12
-rw-r--r--tests/ui/consts/recursive-const-in-impl.stderr11
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/consts/recursive-const-in-impl.rs b/tests/ui/consts/recursive-const-in-impl.rs
new file mode 100644
index 00000000000..93f7201f921
--- /dev/null
+++ b/tests/ui/consts/recursive-const-in-impl.rs
@@ -0,0 +1,12 @@
+//@ build-fail
+#![recursion_limit = "7"]
+
+struct Thing<T>(T);
+
+impl<T> Thing<T> {
+    const X: usize = Thing::<Option<T>>::X;
+}
+
+fn main() {
+    println!("{}", Thing::<i32>::X); //~ ERROR: queries overflow the depth limit!
+}
diff --git a/tests/ui/consts/recursive-const-in-impl.stderr b/tests/ui/consts/recursive-const-in-impl.stderr
new file mode 100644
index 00000000000..6175112c8cc
--- /dev/null
+++ b/tests/ui/consts/recursive-const-in-impl.stderr
@@ -0,0 +1,11 @@
+error: queries overflow the depth limit!
+  --> $DIR/recursive-const-in-impl.rs:11:14
+   |
+LL |     println!("{}", Thing::<i32>::X);
+   |              ^^^^
+   |
+   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "14"]` attribute to your crate (`recursive_const_in_impl`)
+   = note: query depth increased by 9 when simplifying constant for the type system `main::promoted[1]`
+
+error: aborting due to 1 previous error
+