Closed
Description
The following code causes a stack overflow:
Also here:
// compiling all this presents a stack overflow. But removing any trait or impl fixes it
pub trait SimpleTrait {
type SimpleT;
}
impl<Inner: SimpleTrait, Outer: Deref<Target = Inner>> SimpleTrait for Outer {
type SimpleT = Inner::SimpleT;
}
pub trait AnotherTrait {
type AnotherT;
}
impl<T, Simple: SimpleTrait<SimpleT = Vec<T>>> AnotherTrait for Simple {
type AnotherT = T;
}
// this code block seems completely unrelated to the above, however Unrelated compiles alone, and SimpleTrait/AnotherTrait compile alone.
// But the combination won't compile.
pub struct Unrelated<Inner, UnrelatedT: DerefMut<Target = Vec<Inner>>>(UnrelatedT);
impl<Inner, UnrelatedT: DerefMut<Target = Vec<Inner>>> Deref for Unrelated<Inner, UnrelatedT> {
type Target = Vec<Inner>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
pub fn main() { }
The output:
$ cargo doc
Documenting overflow-example v0.1.0 (/private/tmp/overflow_example)
thread '<unknown>' has overflowed its stack
fatal runtime error: stack overflow
error: Could not document `overflow-example`.
Caused by:
process didn't exit successfully: `rustdoc --edition=2018 --crate-name overflow_example src/main.rs --color always -o /private/tmp/overflow_example/target/doc -L dependency=/private/tmp/overflow_example/target/debug/deps` (signal: 6, SIGABRT: process abort signal)
$ cargo --version
cargo 1.31.0 (339d9f9c8 2018-11-16)
$ rustc --version
rustc 1.31.0 (abe02cefd 2018-12-04)