Skip to content

cargo doc stack overflow (1.31) #56701

Closed
@rusty-objects

Description

@rusty-objects

The following code causes a stack overflow:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=df017106fc6a032b1b0959b1701b9781

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-synthetic-implsArea: Synthetic impls, used by rustdoc to document auto traits and traits with blanket implsI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions