]> git.proxmox.com Git - rustc.git/blob - tests/ui/const-generics/occurs-check/unused-substs-2.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / const-generics / occurs-check / unused-substs-2.rs
1 #![feature(generic_const_exprs)]
2 #![allow(incomplete_features)]
3
4 // The goal 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 }