blob: cd024d75897e10b9b616da21135e5a79b399de4f [file] [log] [blame] [edit]
//@ build-fail
fn main() {
encode(&mut EncoderImpl);
}
pub trait Encoder {
type W;
fn writer(&self) -> Self::W;
}
fn encode<E: Encoder>(mut encoder: E) {
//~^ WARN: function cannot return without recursing
encoder.writer();
encode(&mut encoder);
//~^ ERROR: reached the recursion limit while instantiating
}
struct EncoderImpl;
impl Encoder for EncoderImpl {
type W = ();
fn writer(&self) {}
}
impl<'a, T: Encoder> Encoder for &'a mut T {
type W = T::W;
fn writer(&self) -> Self::W {
panic!()
}
}