File: well-formed-recursion-limit.rs

package info (click to toggle)
rustc-web 1.85.0%2Bdfsg3-1~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-proposed-updates
  • size: 1,759,988 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,056; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (27 lines) | stat: -rw-r--r-- 812 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Regression test for #117151, this used to hang the compiler

pub type ISO<A: 'static, B: 'static> = (Box<dyn Fn(A) -> B>, Box<dyn Fn(B) -> A>);
pub fn iso<A: 'static, B: 'static, F1, F2>(a: F1, b: F2) -> ISO<A, B>
where
    F1: 'static + Fn(A) -> B,
    F2: 'static + Fn(B) -> A,
{
    (Box::new(a), Box::new(b))
}
pub fn iso_un_option<A: 'static, B: 'static>(i: ISO<Option<A>, Option<B>>) -> ISO<A, B> {
    let (ab, ba) = (i.ab, i.ba);
    //~^ ERROR no field `ab` on type
    //~| ERROR no field `ba` on type
    let left = move |o_a| match o_a {
        //~^ ERROR overflow assigning `_` to `Option<_>`
        None => panic!("absurd"),
        Some(a) => a,
    };
    let right = move |o_b| match o_b {
        None => panic!("absurd"),
        Some(b) => b,
    };
    iso(left, right)
}

fn main() {}