Closed
Description
@jimtla pasted his code he was working with on IRC and I simplified it a bit:
#[derive(Clone)]
struct A (B);
impl A {
pub fn matches<F: Fn()>(&self, f: &F) {
let &A(ref term) = self;
term.matches(f);
}
}
#[derive(Clone)]
enum B {
Variant1,
Variant2(C),
}
impl B {
pub fn matches<F: Fn()>(&self, f: &F) {
match self {
&B::Variant2(ref factor) => {
factor.matches(&|| ())
}
_ => unreachable!("")
}
}
}
#[derive(Clone)]
struct C (D);
impl C {
pub fn matches<F: Fn()>(&self, f: &F) {
let &C(ref base) = self;
base.matches(&|| {
C(base.clone()).matches(f)
})
}
}
#[derive(Clone)]
struct D (Box<A>);
impl D {
pub fn matches<F: Fn()>(&self, f: &F) {
let &D(ref a) = self;
a.matches(f)
}
}
pub fn matches() {
A(B::Variant1).matches(&(|| ()))
}
fn main() {}
/t/m/h/src (master|…) $ rustc lib.rs
lib.rs:18:36: 18:37 warning: unused variable: `f`, #[warn(unused_variables)] on by default
lib.rs:18 pub fn matches<F: Fn()>(&self, f: &F) {
^
thread 'rustc' has overflowed its stack
fish: Job 1, 'rustc lib.rs ' terminated by signal SIGILL (Illegal instruction)
This might be a duplicate of #21410