From b129de47a0a1fbb387510da72b90d9035fd2e4fe Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 4 Mar 2019 13:16:49 +0100 Subject: [PATCH] Regression test for #58435. --- .../issues/issue-58435-ice-with-assoc-const.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/test/run-pass/issues/issue-58435-ice-with-assoc-const.rs 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 0000000000000..94e2b2563df59 --- /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); + +impl S { + const ID: fn(&S) -> &S = |s| s; + pub fn id(&self) -> &Self { + Self::ID(self) // This, plus call below ... + } +} + +fn main() { + let s = S(10u32); + assert!(S::::ID(&s).0 == 10); // Works fine + assert!(s.id().0 == 10); // ... causes compiler to panic +}