Skip to content

ICE: lifetime in type in const-expr in len of array-type [T; len]: cannot convert ReEarlyBound #66152

Closed
@lambinoo

Description

@lambinoo

When trying to compile the following code, a panic occurs on librustc_mir:

use core::mem::size_of;    
    
struct Foo<'a> {    
    foo0: Option<Foo<'a>>,    
    foo1: Option<Foo<'a>>,    
    lots_of_foos: [u64; size_of::<Option<Foo<'a>>>()]    
}    
fn main() {} 

Backtrace

RUST_BACKTRACE=1 cargo run +stable --verbose

   Compiling compiler_panic v0.1.0 (/rust/compiler_panic)
     Running `rustc --edition=2018 --crate-name compiler_panic src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=74430e226fab29eb -C extra-filename=-74430e226fab29eb --out-dir /rust/compiler_panic/target/debug/deps -C incremental=/rust/compiler_panic/target/debug/incremental -L dependency=/rust/compiler_panic/target/debug/deps`
error: internal compiler error: src/librustc_mir/borrow_check/nll/universal_regions.rs:741: cannot convert `ReEarlyBound(0, 'a)` to a region vid

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:644:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: rustc::util::common::panic_hook
   7: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
   8: std::panicking::begin_panic
   9: rustc_errors::Handler::bug
  10: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  11: rustc::ty::context::tls::with_opt::{{closure}}
  12: rustc::ty::context::tls::with_context_opt
  13: rustc::ty::context::tls::with_opt
  14: rustc::util::bug::opt_span_bug_fmt
  15: rustc::util::bug::bug_fmt
  16: rustc_mir::borrow_check::nll::universal_regions::UniversalRegionIndices::to_region_vid::{{closure}}
  17: rustc_mir::borrow_check::nll::type_check::constraint_conversion::ConstraintConversion::to_region_vid
  18: rustc_mir::borrow_check::nll::type_check::constraint_conversion::ConstraintConversion::convert_all
  19: rustc_mir::borrow_check::nll::type_check::TypeChecker::fully_perform_op
  20: rustc_mir::borrow_check::nll::type_check::type_check
  21: rustc_mir::borrow_check::nll::compute_regions
  22: rustc_mir::borrow_check::do_mir_borrowck
  23: rustc::ty::context::GlobalCtxt::enter_local
  24: rustc_mir::borrow_check::mir_borrowck
  25: rustc::ty::query::__query_compute::mir_borrowck
  26: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::mir_borrowck>::compute
  27: rustc::dep_graph::graph::DepGraph::with_task_impl
  28: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  29: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  30: rustc_mir::transform::optimized_mir
  31: rustc::ty::query::__query_compute::optimized_mir
  32: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute
  33: rustc::dep_graph::graph::DepGraph::with_task_impl
  34: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  35: rustc_mir::interpret::eval_context::InterpCx<M>::load_mir
  36: rustc_mir::const_eval::const_eval_raw_provider
  37: rustc::ty::query::__query_compute::const_eval_raw
  38: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval_raw>::compute
  39: rustc::dep_graph::graph::DepGraph::with_task_impl
  40: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  41: rustc_mir::const_eval::const_eval_provider
  42: rustc::ty::query::__query_compute::const_eval
  43: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute
  44: rustc::dep_graph::graph::DepGraph::with_task_impl
  45: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  46: <rustc::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_const
  47: <rustc::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty
  48: rustc::traits::project::normalize
  49: rustc_typeck::check::FnCtxt::normalize_associated_types_in
  50: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  51: rustc::ty::context::GlobalCtxt::enter_local
  52: rustc_typeck::check::wfcheck::check_item_well_formed
  53: rustc::ty::query::__query_compute::check_item_well_formed
  54: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::check_item_well_formed>::compute
  55: rustc::dep_graph::graph::DepGraph::with_task_impl
  56: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  57: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  58: std::panicking::try::do_call
  59: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  60: rustc_data_structures::sync::par_for_each_in
  61: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  62: rustc::hir::Crate::par_visit_all_item_likes
  63: rustc::util::common::time
  64: rustc_typeck::check_crate
  65: rustc_interface::passes::analysis
  66: rustc::ty::query::__query_compute::analysis
  67: rustc::dep_graph::graph::DepGraph::with_task_impl
  68: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  69: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  70: rustc_interface::passes::create_global_ctxt::{{closure}}
  71: rustc_interface::interface::run_compiler_in_existing_thread_pool
  72: std::thread::local::LocalKey<T>::with
  73: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [mir_borrowck] processing `Foo::lots_of_foos::{{constant}}#0`
#1 [optimized_mir] processing `Foo::lots_of_foos::{{constant}}#0`
 --> src/main.rs:6:25
  |
6 |     lots_of_foos: [u64; size_of::<Option<Foo<'a>>>()]
  |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#2 [const_eval_raw] const-evaluating `Foo::lots_of_foos::{{constant}}#0`
#3 [const_eval] const-evaluating + checking `Foo::lots_of_foos::{{constant}}#0`
#4 [check_item_well_formed] processing `Foo`
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error


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: rustc 1.38.0 (625451e37 2019-09-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `compiler_panic`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name compiler_panic src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=74430e226fab29eb -C extra-filename=-74430e226fab29eb --out-dir /rust/compiler_panic/target/debug/deps -C incremental=/rust/compiler_panic/target/debug/incremental -L dependency=/rust/compiler_panic/target/debug/deps` (exit code: 101)

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)A-borrow-checkerArea: The borrow checkerA-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions