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