Open
Description
I've got a crate that doesn't compile, it just starts eating memory until it stops without an error message. Only passing the --verbose
flag to cargo build
tells me
error: Could not compile `the-crate`.
Caused by:
process didn't exit successfully: `rustc …` (exit code: 3221225501)
Seems to be the same exit code as in #42544.
Here's the (not exactly minimal) example to reproduce the issue:
pub struct Example<A, B, D>
where
A: StrategyA<Example<A, B, D>>,
B: StrategyB<Example<A, B, D>> {
pub a: A,
pub b: B,
pub element: B::Element,
pub data: D,
}
pub trait StrategyA<T: HasData> {
fn do_a(&self, &T::Data);
}
pub trait StrategyB<T> {
type Element;
fn do_b(&self, &T);
}
impl<A: StrategyA<Self>, B: StrategyB<Self>, D> Example<A, B, D> {
pub fn do_it(&self, args: bool) {
if args {
self.a.do_a(self.get_data());
} else {
self.b.do_b(self);
}
}
}
pub trait HasData {
type Data;
fn get_data(&self) -> &Self::Data;
}
impl<A: StrategyA<Self>, B: StrategyB<Self>, D> HasData for Example<A, B, D> {
type Data = D;
fn get_data(&self) -> &D {
&self.data
}
}
pub struct ExampleA;
pub struct ExampleB;
pub struct ExampleData;
impl<E: HasData<Data=ExampleData>> StrategyA<E> for ExampleA {
fn do_a(&self, e: &ExampleData) {
e; // using ExampleData here
}
}
impl<E: HasData<Data=ExampleData>> StrategyB<E> for ExampleB {
type Element = ExampleData;
fn do_b(&self, e: &E) { /* same */}
}
fn x() {
let example = Example { a: ExampleA, b: ExampleB, data: ExampleData };
example.sized.do_it(true);
example.sized.do_it(false);
}
Removing the StrategyA
parts causes it to produce an "overflow evaluating the requirement …" error, not sure whether related.