]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/occurs-check/unused-substs-2.rs
Auto merge of #74430 - Manishearth:stabilize-intra-doc, r=Manishearth
[rust.git] / src / test / ui / const-generics / occurs-check / unused-substs-2.rs
1 // check-pass
2 #![feature(const_generics)]
3 #![allow(incomplete_features)]
4
5 // The goal is is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst.
6 //
7 // If we are then able to infer `ty::Infer(TyVar(_#1t) := Ty<ct>` we introduced an
8 // artificial inference cycle.
9 struct Foo<const N: usize>;
10
11 trait Bind<T> {
12     fn bind() -> (T, Self);
13 }
14
15 // `N` has to be `ConstKind::Unevaluated`.
16 impl<T> Bind<T> for Foo<{ 6 + 1 }> {
17     fn bind() -> (T, Self) {
18         (panic!(), Foo)
19     }
20 }
21
22 fn main() {
23     let (mut t, foo) = Foo::bind();
24     // `t` is `ty::Infer(TyVar(_#1t))`
25     // `foo` contains `ty::Infer(TyVar(_#1t))` in its substs
26     t = foo;
27 }