Skip to content

rustdoc panics when some unstable features is used without #![feature(…)] #36159

Closed
@kennytm

Description

@kennytm

(May be same as #31647?)

With the source:

#[b] struct S;

Running rustdoc 1.rs gives the error:

error: The attribute `b` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
 --> 1.rs:1:1
  |
1 | #[b]
  | ^^^^
  |
  = help: add #![feature(custom_attribute)] to the crate attributes to enable

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: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'phase_2_configure_and_expand aborted in rustdoc!: 1', ../src/libcore/result.rs:783
stack backtrace:
   1:        0x10901be0a - std::sys::backtrace::tracing::imp::write::h46f28e67d38b4637
   2:        0x10902a5cf - std::panicking::default_hook::{{closure}}::h1d3243f546573ff4
   3:        0x109028bcd - std::panicking::default_hook::h96c288d728df3ebf
   4:        0x109029266 - std::panicking::rust_panic_with_hook::hb1322e5f2588b4db
   5:        0x109029104 - std::panicking::begin_panic::hfbeda5aad583dc32
   6:        0x109029022 - std::panicking::begin_panic_fmt::h4fe9fb9d5109c4bf
   7:        0x109028f87 - rust_begin_unwind
   8:        0x109088e50 - core::panicking::panic_fmt::h4395919ece15c671
   9:        0x104989912 - core::result::unwrap_failed::h7169715daa6d1b4b
  10:        0x104a57626 - rustdoc::core::run_core::h3ae16d38e236204c
  11:        0x104981826 - std::panicking::try::do_call::h3d5952fa0eca5ef1
  12:        0x1090311aa - __rust_maybe_catch_panic
  13:        0x1049a7e36 - <F as alloc::boxed::FnBox<A>>::call_box::ha55f7783d6f9e562
  14:        0x109027a44 - std::sys::thread::Thread::new::thread_start::h5b631f48cd23f128
  15:     0x7fff92d3499c - _pthread_body
  16:     0x7fff92d34919 - _pthread_start

Similar for other features like:

  • fn main() { Ok(())?; }
  • fn main() { box 1; }
  • const fn f() {}
  • #[structural_match] struct S;
  • #![no_core]
  • #[naked] fn a() {}
  • #[start] fn start() {}
  • fn b() { 1: i32; }
  • fn b() { let a: ! = 0; }
  • fn a() { 1...2; }
  • trait T { type A = i32; }
  • trait T { const a: i32; }
  • trait T {} impl T for .. {}
  • fn á() {}
  • extern "rust-intrinsic" fn a() {}

But some features are fine (won't panic):

  • unsafe fn main() { std::intrinsics::ctpop(1); } // and other library features
  • fn main() { asm!(""); }
  • #![cfg(target_feature="simd")]
  • fn a() { concat_idents!(a); }

Repro on both stable and nightly (1.11 – 1.13).

Metadata

Metadata

Assignees

No one assigned

    Labels

    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