I finally found the cheat-code for disabling the type-checker /s

Bonus round: Disable the trait checker, too!

pub trait __ {
    type __<L, R>: __<__<L, ()> = R>;
    fn debug<R: std::fmt::Debug>(&self);
}
impl<T> __ for T {
    type __<L: __<__<<R::__<R, L> as __>::__<R, ()>, ()> = R>, R: __> = L;
    fn debug<R: __>(&self)
    where
        <R::__<R, Self> as __>::__<R, ()>: std::fmt::Debug,
    {
        println!("{:?}", self);
    }
}

fn main() {
    let v = vec![1, 2, 3, 4, 5];
    generic_without_bounds(&v);
}

fn generic_without_bounds<T>(x: &T) {
    x.debug::<()>(); // who needs trait bounds, anyway?
    // ^^^ prints [1, 2, 3, 4, 5]
}

(playground)

arguable even kind-of useful for some emergency debug-printing if adding T: Debug everywhere would be tedious :thinking:

(Please don't use this in production; this will hopefully stop working in the future. Also, compiler crashes are to be expected if “misused”)

36 Likes