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: thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', compiler/rustc_middle/src/ty/mod.rs:893:14 #78008

Closed
chengniansun opened this issue Oct 16, 2020 · 1 comment
Labels
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.

Comments

@chengniansun
Copy link

Code

fn sof<T>() -> T {}
fn test<T>() {
    let _: [u8; sof::<T>()];
}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (adef9da30 2020-10-13)

binary: rustc

commit-hash: adef9da30f1ecbfeb81312d01ed94ac53f7161ba

commit-date: 2020-10-13

host: x86_64-unknown-linux-gnu

release: 1.49.0-nightly

LLVM version: 11.0

Error output

error[E0601]: `main` function not found in crate `reduced_mutant`
 --> reduced_mutant.rs:1:1
  |
1 | / fn sof<T>() -> T {}
2 | | fn test<T>() {
3 | |     let _: [u8; sof::<T>()];
4 | | }
  | |_^ consider adding a `main` function to `reduced_mutant.rs`

error[E0308]: mismatched types
 --> reduced_mutant.rs:1:16
  |
1 | fn sof<T>() -> T {}
  |    --- -       ^ expected type parameter `T`, found `()`
  |    |   |
  |    |   this type parameter
  |    implicitly returns `()` as its body has no tail or `return` expression
  |
  = note: expected type parameter `T`
                  found unit type `()`

error[E0277]: the size for values of type `T` cannot be known at compilation time
 --> reduced_mutant.rs:3:23
  |
1 | fn sof<T>() -> T {}
  |        - required by this bound in `sof`
2 | fn test<T>() {
  |         - this type parameter needs to be `Sized`
3 |     let _: [u8; sof::<T>()];
  |                       ^ doesn't have a size known at compile-time
  |
help: consider relaxing the implicit `Sized` restriction
  |
1 | fn sof<T: ?Sized>() -> T {}
  |         ^^^^^^^^

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', compiler/rustc_middle/src/ty/mod.rs:893:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.49.0-nightly (dd7fc54eb 2020-10-15) running on x86_64-unknown-linux-gnu

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0277, E0308, E0601.
For more information about an error, try `rustc --explain E0277`.
Backtrace

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', compiler/rustc_middle/src/ty/mod.rs:893:14
stack backtrace:
   0: rust_begin_unwind
             at /rustc/dd7fc54ebdca419ad9d3ab1e9f5ed14e770768ea/library/std/src/panicking.rs:483:5
   1: core::panicking::panic_fmt
             at /rustc/dd7fc54ebdca419ad9d3ab1e9f5ed14e770768ea/library/core/src/panicking.rs:85:14
   2: core::panicking::panic_bounds_check
             at /rustc/dd7fc54ebdca419ad9d3ab1e9f5ed14e770768ea/library/core/src/panicking.rs:62:5
   3: rustc_middle::ty::Generics::param_at
   4: rustc_middle::ty::error::<impl rustc_middle::ty::context::TyCtxt>::note_and_explain_type_err
   5: rustc_infer::infer::error_reporting::<impl rustc_infer::infer::InferCtxt>::note_type_err
   6: rustc_infer::infer::error_reporting::<impl rustc_infer::infer::InferCtxt>::report_and_explain_type_error
   7: rustc_infer::infer::InferCtxt::report_mismatched_types
   8: rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::demand_coerce_diag
   9: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_coercable_to_type
  10: rustc_infer::infer::InferCtxtBuilder::enter
  11: rustc_typeck::check::typeck
  12: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  13: rustc_data_structures::stack::ensure_sufficient_stack
  14: rustc_query_system::query::plumbing::get_query_impl
  15: rustc_middle::ty::context::TyCtxt::typeck_opt_const_arg
  16: rustc_mir::const_eval::eval_queries::eval_to_allocation_raw_provider
  17: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::eval_to_allocation_raw>::compute
  18: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  19: rustc_data_structures::stack::ensure_sufficient_stack
  20: rustc_query_system::query::plumbing::get_query_impl
  21: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  22: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::eval_to_const_value_raw>::compute
  23: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  24: rustc_data_structures::stack::ensure_sufficient_stack
  25: rustc_query_system::query::plumbing::get_query_impl
  26: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  27: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::eval_to_const_value_raw>::compute
  28: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  29: rustc_data_structures::stack::ensure_sufficient_stack
  30: rustc_query_system::query::plumbing::get_query_impl
  31: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  32: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_resolve
  33: <rustc_trait_selection::traits::project::AssocTypeNormalizer as rustc_middle::ty::fold::TypeFolder>::fold_const
  34: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
  35: <rustc_trait_selection::traits::project::AssocTypeNormalizer as rustc_middle::ty::fold::TypeFolder>::fold_ty
  36: rustc_data_structures::stack::ensure_sufficient_stack
  37: rustc_trait_selection::traits::project::normalize
  38: <rustc_infer::infer::InferCtxt as rustc_trait_selection::infer::InferCtxtExt>::partially_normalize_associated_types_in
  39: rustc_typeck::check::inherited::Inherited::normalize_associated_types_in
  40: <rustc_typeck::check::fn_ctxt::FnCtxt as rustc_typeck::astconv::AstConv>::normalize_ty
  41: <dyn rustc_typeck::astconv::AstConv>::ast_ty_to_ty_inner
  42: <rustc_typeck::check::gather_locals::GatherLocalsVisitor as rustc_hir::intravisit::Visitor>::visit_local
  43: rustc_hir::intravisit::walk_expr
  44: rustc_typeck::check::check::check_fn
  45: rustc_infer::infer::InferCtxtBuilder::enter
  46: rustc_typeck::check::typeck
  47: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute
  48: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  49: rustc_data_structures::stack::ensure_sufficient_stack
  50: rustc_query_system::query::plumbing::get_query_impl
  51: rustc_query_system::query::plumbing::ensure_query_impl
  52: rustc_typeck::check::typeck_item_bodies
  53: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
  54: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  55: rustc_data_structures::stack::ensure_sufficient_stack
  56: rustc_query_system::query::plumbing::get_query_impl
  57: rustc_typeck::check_crate
  58: rustc_interface::passes::analysis
  59: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  60: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  61: rustc_data_structures::stack::ensure_sufficient_stack
  62: rustc_query_system::query::plumbing::get_query_impl
  63: rustc_interface::passes::QueryContext::enter
  64: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  65: rustc_span::with_source_map
  66: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@chengniansun chengniansun 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 Oct 16, 2020
@jonas-schievink
Copy link
Contributor

Duplicate of #43408

@jonas-schievink jonas-schievink marked this as a duplicate of #43408 Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

No branches or pull requests

2 participants