From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/consts/issue-58435-ice-with-assoc-const.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/ui/consts/issue-58435-ice-with-assoc-const.rs (limited to 'tests/ui/consts/issue-58435-ice-with-assoc-const.rs') diff --git a/tests/ui/consts/issue-58435-ice-with-assoc-const.rs b/tests/ui/consts/issue-58435-ice-with-assoc-const.rs new file mode 100644 index 000000000..fac727d2d --- /dev/null +++ b/tests/ui/consts/issue-58435-ice-with-assoc-const.rs @@ -0,0 +1,18 @@ +// run-pass +// 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 +} -- cgit v1.2.3