Skip to content

Rustdoc ICE when stripping doc comment decorations #47197

Closed
@mystor

Description

/**
* a

* b
*/
pub fn x() { }

Running rustdoc on this causes an ICE.

quicksilver[Jan 04@15:31:19] rustdoc-test
$ RUST_BACKTRACE=1 cargo doc
 Documenting rustdoc-test v0.1.0 (file:///home/nika/Code/rustdoc-test)
error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.24.0-nightly (2dad872a2 2017-12-29) running on x86_64-unknown-linux-gnu

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'byte index 1 is out of bounds of ``', /checkout/src/libcore/str/mod.rs:2217:9
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: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:522
   7: rust_begin_unwind
             at /checkout/src/libstd/panicking.rs:498
   8: core::panicking::panic_fmt
             at /checkout/src/libcore/panicking.rs:71
   9: core::str::slice_error_fail
             at /checkout/src/libcore/str/mod.rs:0
  10: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  11: syntax::parse::lexer::comments::strip_doc_comment_decoration
  12: syntax::attr::<impl syntax::ast::Attribute>::with_desugared_doc
             at /checkout/src/libsyntax/attr.rs:373
  13: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
             at /checkout/src/librustdoc/clean/mod.rs:727
             at /checkout/src/libcore/iter/mod.rs:1497
             at /checkout/src/liballoc/vec.rs:1801
  14: rustdoc::clean::Attributes::from_ast
             at /checkout/src/liballoc/vec.rs:1713
             at /checkout/src/libcore/iter/iterator.rs:1298
             at /checkout/src/librustdoc/clean/mod.rs:726
  15: <rustdoc::doctree::Function as rustdoc::clean::Clean<rustdoc::clean::Item>>::clean
             at /checkout/src/librustdoc/clean/mod.rs:800
             at /checkout/src/librustdoc/clean/mod.rs:1357
  16: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::spec_extend
             at /checkout/src/librustdoc/clean/mod.rs:475
             at /checkout/src/libcore/ops/function.rs:271
             at /checkout/src/libcore/option.rs:404
             at /checkout/src/libcore/iter/mod.rs:1251
             at /checkout/src/liballoc/vec.rs:1844
  17: <rustdoc::doctree::Module as rustdoc::clean::Clean<rustdoc::clean::Item>>::clean
             at /checkout/src/liballoc/vec.rs:1782
             at /checkout/src/librustdoc/clean/mod.rs:475
  18: <rustdoc::visit_ast::RustdocVisitor<'a, 'tcx> as rustdoc::clean::Clean<rustdoc::clean::Crate>>::clean
             at /checkout/src/librustdoc/clean/mod.rs:148
  19: rustdoc::core::run_core::{{closure}}
             at /checkout/src/librustdoc/core.rs:218
  20: <std::thread::local::LocalKey<T>>::with
             at /checkout/src/librustc_driver/driver.rs:1101
             at /checkout/src/librustc/ty/context.rs:1573
             at /checkout/src/libstd/thread/local.rs:377
             at /checkout/src/libstd/thread/local.rs:288
  21: <std::thread::local::LocalKey<T>>::with
             at /checkout/src/librustc/ty/context.rs:1570
             at /checkout/src/librustc/ty/context.rs:1557
             at /checkout/src/libstd/thread/local.rs:377
             at /checkout/src/libstd/thread/local.rs:288
  22: rustc::ty::context::TyCtxt::create_and_enter
             at /checkout/src/librustc/ty/context.rs:1554
             at /checkout/src/librustc/ty/context.rs:1197
  23: rustc_driver::driver::phase_3_run_analysis_passes
             at /checkout/src/librustc_driver/driver.rs:1024
  24: rustdoc::core::run_core
             at /checkout/src/librustdoc/core.rs:180

error: Could not document `rustdoc-test`.

Caused by:
  process didn't exit successfully: `rustdoc --crate-name rustdoc_test src/lib.rs -o /home/nika/Code/rustdoc-test/target/doc -L dependency=/home/nika/Code/rustdoc-test/target/debug/deps` (exit code: 101)

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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