Skip to content

ICE in rustdoc running cargo doc w/ trait's containing associated consts #87470

Closed
@ghost

Description

The example code provided here is also demonstrated in this repo

Code

#![feature(const_generics)]
#![feature(const_evaluatable_checked)]

pub trait TraitWithConst {
    const SOME_CONST: usize;
}

pub trait OtherTrait: TraitWithConst {
    fn some_fn(self) -> [u8 ; <Self as TraitWithConst>::SOME_CONST];
}

impl TraitWithConst for f32 {
    const SOME_CONST: usize = 32;
}

impl OtherTrait for f32 {
    fn some_fn(self) -> [u8 ; <Self as TraitWithConst>::SOME_CONST] {
        [0; 32]
    }
}

Interestingly enough, this alone is not sufficient to trigger the ICE (cargo doc executes successfully). To do so another crate is needed (can be a bin or lib) that depends on the crate containing the above code, running cargo doc in that crate will trigger the ICE. This new crate can be left empty, as even a bare lib.rs triggers the ICE.

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (9c25eb7aa 2021-07-25)
binary: rustc
commit-hash: 9c25eb7aa3a71fb951564b0ddf131be59c2c951d
commit-date: 2021-07-25
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

Error output

Here, ice refers to the crate containing the traits listed above, and empty refers to the empty crate required for triggering the error:

error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<Self as ice::TraitWithConst>, [])` during codegen
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:68:32

error: internal compiler error: ty::ConstKind::Error constructed but no error reported.
  |
  = note: delayed at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/compiler/rustc_middle/src/ty/consts.rs:184:43

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1050:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

error: Unrecognized option: 'crate-version'

error: could not document `empty`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name empty empty/src/lib.rs -o /mnt/Storage/Repos/fluhzar/rustdoc-trait-with-associated-const-ice/target/doc --error-format=json --json=diagnostic-rendered-ansi -L dependency=/mnt/Storage/Repos/fluhzar/rustdoc-trait-with-associated-const-ice/target/debug/deps --extern ice=/mnt/Storage/Repos/fluhzar/rustdoc-trait-with-associated-const-ice/target/debug/deps/libice-8d7efa5ac4b5b13a.rmeta --crate-version 0.1.0` (exit status: 1)
Backtrace

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1050:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/panicking.rs:515:5
   1: std::panicking::begin_panic_fmt
             at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/panicking.rs:457:5
   2: rustc_errors::HandlerInner::flush_delayed
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place<rustc_session::parse::ParseSess>
   5: core::ptr::drop_in_place<alloc::rc::Rc<rustc_session::session::Session>>
   6: core::ptr::drop_in_place<rustc_interface::interface::Compiler>
   7: rustc_interface::interface::create_compiler_and_run
   8: rustdoc::main_options
   9: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Full Backtrace

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1050:13
stack backtrace:
   0:     0x7f0c27d73c10 - std::backtrace_rs::backtrace::libunwind::trace::h0f5cd2ee8b0d7274
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f0c27d73c10 - std::backtrace_rs::backtrace::trace_unsynchronized::h06905b5aeda069a1
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f0c27d73c10 - std::sys_common::backtrace::_print_fmt::h4fe4c7c875072f30
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f0c27d73c10 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hcc0746f004a9b7ef
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f0c27de174c - core::fmt::write::h9a6d9c74526a6c1b
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/core/src/fmt/mod.rs:1115:17
   5:     0x7f0c27d653a5 - std::io::Write::write_fmt::h23dab4cc9ce72ee2
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/io/mod.rs:1665:15
   6:     0x7f0c27d7792b - std::sys_common::backtrace::_print::h173dc702502d65d2
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f0c27d7792b - std::sys_common::backtrace::print::h61bd27c4742ba817
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f0c27d7792b - std::panicking::default_hook::{{closure}}::hcaae87f0495ae613
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/panicking.rs:208:50
   9:     0x7f0c27d77401 - std::panicking::default_hook::h0538e728ee080db0
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/panicking.rs:225:9
  10:     0x7f0c285534b1 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h9137b7ac1a66352b
  11:     0x7f0c27d78159 - std::panicking::rust_panic_with_hook::h3039e236b6ca482c
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/panicking.rs:626:17
  12:     0x7f0c27d77c17 - std::panicking::begin_panic_handler::{{closure}}::h884fbab544ffd91c
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/panicking.rs:519:13
  13:     0x7f0c27d7410c - std::sys_common::backtrace::__rust_end_short_backtrace::hdaf2e18ba3d91210
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7f0c27d77b79 - rust_begin_unwind
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/panicking.rs:515:5
  15:     0x7f0c27d40b7b - std::panicking::begin_panic_fmt::h34884936c58ac1e4
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/panicking.rs:457:5
  16:     0x7f0c2a998919 - rustc_errors::HandlerInner::flush_delayed::hcfbb4755a27b0762
  17:     0x7f0c2a99737d - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::hc1e614a9f2b01df1
  18:     0x5629d3660706 - core::ptr::drop_in_place<rustc_session::parse::ParseSess>::h275b7ce5a04a7926
  19:     0x5629d366dbb6 - core::ptr::drop_in_place<alloc::rc::Rc<rustc_session::session::Session>>::hbff27affca6d45c8
  20:     0x5629d3663fdd - core::ptr::drop_in_place<rustc_interface::interface::Compiler>::h3b9b1823ae20b0af
  21:     0x5629d364927b - rustc_interface::interface::create_compiler_and_run::h86f5a3cc7b573938
  22:     0x5629d3503e17 - rustdoc::main_options::h5dab1140d8275200
  23:     0x5629d36fd300 - scoped_tls::ScopedKey<T>::set::hb081d9600f625950
  24:     0x5629d364b467 - std::sys_common::backtrace::__rust_begin_short_backtrace::h07fbf6938271c35c
  25:     0x5629d3731173 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hf5f159372a3f32d5
  26:     0x7f0c27d846e7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd5b860c6542b008a
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/alloc/src/boxed.rs:1572:9
  27:     0x7f0c27d846e7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc87b98c8a3a585ed
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/alloc/src/boxed.rs:1572:9
  28:     0x7f0c27d846e7 - std::sys::unix::thread::Thread::new::thread_start::ha990175c8f3779cc
                               at /rustc/9c25eb7aa3a71fb951564b0ddf131be59c2c951d/library/std/src/sys/unix/thread.rs:91:17
  29:     0x7f0c27ca2259 - start_thread
  30:     0x7f0c27a585e3 - __GI___clone
  31:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-const_generics`#![feature(const_generics)]`F-generic_const_exprs`#![feature(generic_const_exprs)]`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.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions