Files
rust/tests/ui/codegen/normalization-overflow/recursion-issue-92470.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
557 B
Rust
Raw Normal View History

//@ build-fail
2024-04-26 17:20:16 +02:00
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
2024-04-26 17:20:16 +02:00
encoder.writer();
encode(&mut encoder);
//~^ ERROR: reached the recursion limit while instantiating
2024-04-26 17:20:16 +02:00
}
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!()
}
}