about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2019-03-04 13:16:49 +0100
committerFelix S. Klock II <pnkfelix@pnkfx.org>2019-03-04 13:16:49 +0100
commitb129de47a0a1fbb387510da72b90d9035fd2e4fe (patch)
treeb68f91c2d16fc78eb1d2178b5801066ad8aefd6b
parenta9da8fc9c267c08cfdb8cf5b39da14f154d12939 (diff)
Regression test for #58435.
-rw-r--r--src/test/run-pass/issues/issue-58435-ice-with-assoc-const.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/run-pass/issues/issue-58435-ice-with-assoc-const.rs b/src/test/run-pass/issues/issue-58435-ice-with-assoc-const.rs
new file mode 100644
index 00000000000..94e2b2563df
--- /dev/null
+++ b/src/test/run-pass/issues/issue-58435-ice-with-assoc-const.rs
@@ -0,0 +1,17 @@
+// The const-evaluator was at one point ICE'ing while trying to
+// evaluate the body of `fn id` during the `s.id()` call in main.
+
+struct S<T>(T);
+
+impl<T> S<T> {
+    const ID: fn(&S<T>) -> &S<T> = |s| s;
+    pub fn id(&self) -> &Self {
+        Self::ID(self) // This, plus call below ...
+    }
+}
+
+fn main() {
+    let s = S(10u32);
+    assert!(S::<u32>::ID(&s).0 == 10); // Works fine
+    assert!(s.id().0 == 10); // ... causes compiler to panic
+}