Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue Jul 26, 2021 · 4 comments · Fixed by #90023
Closed

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

ghost opened this issue Jul 26, 2021 · 4 comments · Fixed by #90023
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@ghost
Copy link

ghost commented Jul 26, 2021

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>

@ghost ghost added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 26, 2021
@bjorn3 bjorn3 added A-const-generics Area: const generics (parameters and arguments) F-generic_const_exprs `#![feature(generic_const_exprs)]` F-const_generics `#![feature(const_generics)]` labels Jul 26, 2021
@jyn514 jyn514 added A-edition-2021 Area: The 2021 edition requires-nightly This issue requires a nightly compiler in some way. labels Jul 26, 2021
@jyn514
Copy link
Member

jyn514 commented Jul 26, 2021

This is unrelated to 2021. The ICE happens with or without the edition.

@jyn514 jyn514 removed the A-edition-2021 Area: The 2021 edition label Jul 26, 2021
@jyn514
Copy link
Member

jyn514 commented Jul 26, 2021

Here's a more helpful backtrace:

thread 'rustc' panicked at 'aborting due to `-Z treat-err-as-bug=1`', compiler/rustc_errors/src/lib.rs:1066:27
stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_errors::HandlerInner::emit_diagnostic
   2: rustc_errors::HandlerInner::emit_diag_at_span
   3: rustc_errors::HandlerInner::span_bug
   4: rustc_errors::Handler::delay_span_bug
   5: rustc_infer::infer::InferCtxtBuilder::enter
   6: rustc_trait_selection::traits::codegen::codegen_fulfill_obligation
   7: rustc_query_system::query::plumbing::get_query_impl
   8: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::codegen_fulfill_obligation
   9: rustc_ty_utils::instance::inner_resolve_instance
  10: rustc_ty_utils::instance::resolve_instance
  11: rustc_query_system::query::plumbing::get_query_impl
  12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::resolve_instance
  13: rustc_middle::ty::instance::Instance::resolve_opt_const_arg
  14: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_resolve
  15: <rustc_trait_selection::traits::query::normalize::QueryNormalizer as rustc_middle::ty::fold::TypeFolder>::fold_const
  16: <rustc_trait_selection::traits::query::normalize::QueryNormalizer as rustc_middle::ty::fold::TypeFolder>::fold_mir_const
  17: <rustc_infer::infer::at::At as rustc_trait_selection::traits::query::normalize::AtExt>::normalize
  18: rustc_infer::infer::InferCtxtBuilder::enter
  19: core::ops::function::FnOnce::call_once
  20: rustc_query_system::query::plumbing::get_query_impl
  21: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::normalize_mir_const_after_erasing_regions
  22: rustc_middle::ty::normalize_erasing_regions::<impl rustc_middle::ty::context::TyCtxt>::normalize_erasing_regions
  23: rustc_mir::interpret::eval_context::InterpCx<M>::push_stack_frame
  24: rustc_mir::const_eval::eval_queries::eval_to_allocation_raw_provider
  25: rustc_query_system::query::plumbing::get_query_impl
  26: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_allocation_raw
  27: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  28: rustc_query_system::query::plumbing::get_query_impl
  29: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_const_value_raw
  30: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  31: rustc_query_system::query::plumbing::get_query_impl
  32: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_const_value_raw
  33: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  34: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_resolve
  35: <&rustc_middle::ty::TyS as rustdoc::clean::Clean<rustdoc::clean::types::Type>>::clean
  36: <(rustc_span::def_id::DefId,rustc_middle::ty::sty::Binder<rustc_middle::ty::sty::FnSig>) as rustdoc::clean::Clean<rustdoc::clean::types::FnDecl>>::clean
  37: <rustc_middle::ty::assoc::AssocItem as rustdoc::clean::Clean<rustdoc::clean::types::Item>>::clean
  38: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  39: rustdoc::clean::inline::build_external_trait
  40: rustdoc::clean::inline::record_extern_trait
  41: rustdoc::clean::inline::build_impl
  42: rustdoc::passes::collect_trait_impls::collect_trait_impls
  43: rustdoc::core::run_global_ctxt
  44: rustc_interface::interface::create_compiler_and_run
  45: rustdoc::main_options
  46: scoped_tls::ScopedKey<T>::set

@jyn514
Copy link
Member

jyn514 commented Jul 26, 2021

Probably the issue is in

n = n.eval(cx.tcx, ty::ParamEnv::reveal_all());
somehow.

@ghost ghost changed the title ICE in rustdoc running cargo doc 2021 edition w/ trait's containing associated consts ICE in rustdoc running cargo doc w/ trait's containing associated consts Jul 26, 2021
@ghost
Copy link
Author

ghost commented Jul 26, 2021

Thanks for following up on the issue. Idk how I missed that it wasn't 2021-related, but I've since removed those parts of the issue and the linked repo as well, if its of any use.

@camelid camelid added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 18, 2021
@bors bors closed this as completed in 1f2a26e Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants