Skip to content

rustc panics when doctest cannot compile #48394

Closed
@tforgione

Description

@tforgione

I'm not sure if this is really a bug or not, but in CONTRIBUTING.md there is

If you're not sure if something is a bug or not, feel free to file a bug anyway.

so I might as well open this issue.

Basically, my MCVE is the following: run cargo init hello, and in lib.rs, and add the following:

/// This is a function
///
/// ```
/// no
/// ```
pub fn foo() {}

So, this doc comment should not compile, but when I run cargo test, I get (among other things) the following:

thread 'rustc' panicked at 'couldn't compile the test', /checkout/src/librustdoc/test.rs:286:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at /checkout/src/libstd/sys_common/backtrace.rs:68
             at /checkout/src/libstd/sys_common/backtrace.rs:57
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:391
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:538
   6: rustdoc::test::run_test
             at /checkout/src/librustdoc/test.rs:286

If I understood things well, I think rustc should never panics (but I could be wrong) and that's why I opened this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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