Skip to content

ICE: Const generics don't seem to work with rustdoc #77645

Closed
@ghost

Description

This happens when I try to use rustdoc on some basic code (the command was rustdoc bug.rs):

Code

#![feature(min_const_generics)]
/// Doctest.
pub struct X<T, const SIZE: usize> {
    y: [T; {SIZE}]
}

Meta

rustc --version --verbose:

rustc 1.47.0-nightly (bf4342114 2020-08-25)
binary: rustc
commit-hash: bf4342114e357f2934d59e12e31e94532ddb2adf
commit-date: 2020-08-25
host: x86_64-unknown-linux-gnu
release: 1.47.0-nightly
LLVM version: 11.0

Error output

error: internal compiler error: src/librustc_middle/ty/subst.rs:568:17: const parameter `SIZE/#1` (Const { ty: usize, val: Param(SIZE/#1) }/1) out of range when substituting substs=[]
Backtrace

thread 'rustc' panicked at 'Box<Any>', /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf/src/librustc_errors/lib.rs:873:9
stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_errors::HandlerInner::span_bug
   2: rustc_errors::Handler::span_bug
   3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   4: rustc_middle::ty::context::tls::with_opt::{{closure}}
   5: rustc_middle::ty::context::tls::with_opt
   6: rustc_middle::util::bug::opt_span_bug_fmt
   7: rustc_middle::util::bug::span_bug_fmt
   8: <rustc_middle::ty::subst::SubstFolder as rustc_middle::ty::fold::TypeFolder>::fold_const
   9: rustc_middle::ty::normalize_erasing_regions::<impl rustc_middle::ty::context::TyCtxt>::subst_and_normalize_erasing_regions
  10: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_operand
  11: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_rvalue_into_place
  12: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
  13: rustc_mir::const_eval::eval_queries::const_eval_raw_provider
  14: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_raw>::compute
  15: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  16: rustc_data_structures::stack::ensure_sufficient_stack
  17: rustc_query_system::query::plumbing::get_query_impl
  18: rustc_mir::const_eval::eval_queries::const_eval_validated_provider
  19: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_validated>::compute
  20: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  21: rustc_data_structures::stack::ensure_sufficient_stack
  22: rustc_query_system::query::plumbing::get_query_impl
  23: rustc_mir::const_eval::eval_queries::const_eval_validated_provider
  24: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_validated>::compute
  25: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  26: rustc_data_structures::stack::ensure_sufficient_stack
  27: rustc_query_system::query::plumbing::get_query_impl
  28: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  29: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_poly
  30: <rustc_hir::hir::Ty as rustdoc::clean::Clean<rustdoc::clean::types::Type>>::clean
  31: <rustc_hir::hir::StructField as rustdoc::clean::Clean<rustdoc::clean::types::Item>>::clean
  32: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  33: <rustdoc::doctree::Struct as rustdoc::clean::Clean<rustdoc::clean::types::Item>>::clean
  34: <rustdoc::doctree::Module as rustdoc::clean::Clean<rustdoc::clean::types::Item>>::clean
  35: rustdoc::clean::utils::krate
  36: rustdoc::core::run_global_ctxt
  37: rustc_session::utils::<impl rustc_session::session::Session>::time
  38: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  39: rustc_span::with_source_map
  40: rustc_interface::interface::create_compiler_and_run
  41: rustdoc::core::run_core
  42: rustdoc::main_options
  43: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.47.0-nightly (bf4342114 2020-08-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [const_eval_raw] const-evaluating `X::y::{{constant}}#0`
#1 [const_eval_validated] const-evaluating + checking `X::y::{{constant}}#0`
#2 [const_eval_validated] const-evaluating + checking `X::y::{{constant}}#0`
end of query stack
error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.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