]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/issue-58435-ice-with-assoc-const.rs
Auto merge of #106711 - albertlarsan68:use-ci-llvm-when-lld, r=jyn514
[rust.git] / tests / ui / consts / issue-58435-ice-with-assoc-const.rs
1 // run-pass
2 // The const-evaluator was at one point ICE'ing while trying to
3 // evaluate the body of `fn id` during the `s.id()` call in main.
4
5 struct S<T>(T);
6
7 impl<T> S<T> {
8     const ID: fn(&S<T>) -> &S<T> = |s| s;
9     pub fn id(&self) -> &Self {
10         Self::ID(self) // This, plus call below ...
11     }
12 }
13
14 fn main() {
15     let s = S(10u32);
16     assert!(S::<u32>::ID(&s).0 == 10); // Works fine
17     assert!(s.id().0 == 10); // ... causes compiler to panic
18 }