Exponentially growing impl trait type names

Unfortunately, I think closure is just making thing worse, not better.

Playground link

(I am a bit curious about why I have to use explicit life time for function roll, should it be automated?)

#![feature(core_intrinsics)]

use std::mem::size_of;


trait Reflactable {
    fn size(&self) -> usize;
    fn type_name_len(&self) -> usize;
    fn type_name(&self) -> String;
}

impl<'a,T> Reflactable for T where T:'a
{
    fn size(&self) -> usize {
        size_of::<Self>()
    }
    fn type_name_len(&self) -> usize {
        self.type_name().len()
    }
    fn type_name(&self) -> String {
        format!("{}", unsafe { std::intrinsics::type_name::<Self>() })
    }
}

enum Stuff<T1,T2>
{
    This(T1),
    That(T2)
}
use Stuff::{This,That};

struct W<F, T>
    where F:FnOnce() -> T + Sized {
    f: F        
}

fn roll<'a>(a:impl Reflactable + 'a) -> impl Reflactable + 'a {
    W{ f:|| if true {This(a)} else { That(a) } }
}

fn main() {
    let v = roll(1);
    println!("({},{})", v.size(), v.type_name_len());
    let v = roll(v);
    println!("{}",v.type_name());
    println!("({},{})", v.size(), v.type_name_len());
    let v = roll(v);
    println!("({},{})", v.size(), v.type_name_len());
    let v = roll(v);
    println!("({},{})", v.size(), v.type_name_len());
    let v = roll(v);
    println!("({},{})", v.size(), v.type_name_len());
    let v = roll(v);
    println!("({},{})", v.size(), v.type_name_len());
}

Output:

(4,60)
W<[closure@src/main.rs:38:10: 38:47 a:W<[closure@src/main.rs:38:10: 38:47 a:i32], Stuff<i32, i32>>], Stuff<W<[closure@src/main.rs:38:10: 38:47 a:i32], Stuff<i32, i32>>, W<[closure@src/main.rs:38:10: 38:47 a:i32], Stuff<i32, i32>>>>
(4,231)
(4,744)
(4,2283)
(4,6900)
(4,20751)

The growth rate is even higher… and the closure didn’t hide any types within, so it didn’t resolve anything.