Skip to content

ICE: No move_errors should be allowed in MIR borrowck #67947

Closed
@DutchGhost

Description

@DutchGhost

The following ICE's on stable, beta and nightly:

struct Bug {
    A: [(); { *"" }.len()],
}
Backtrace:
 Compiling playground v0.0.1 (/playground)
error[E0161]: cannot move a value of type str: the size of str cannot be statically determined
 --> src/lib.rs:2:13
  |
2 |     A: [(); { *"" }.len()],
  |             ^^^^^^^

error[E0507]: cannot move out of a shared reference
 --> src/lib.rs:2:15
  |
2 |     A: [(); { *"" }.len()],
  |               ^^^ move occurs because value has type `str`, which does not implement the `Copy` trait

error: internal compiler error: src/librustc_mir/transform/elaborate_drops.rs:31: No `move_errors` should be allowed in MIR borrowck

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:931:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1028
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:188
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:205
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:468
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_context_opt
  18: rustc::ty::context::tls::with_opt
  19: rustc::util::bug::opt_span_bug_fmt
  20: rustc::util::bug::bug_fmt
  21: <rustc_mir::transform::elaborate_drops::ElaborateDrops as rustc_mir::transform::MirPass>::run_pass
  22: rustc_mir::transform::run_passes
  23: rustc_mir::transform::run_optimization_passes
  24: rustc_mir::transform::optimized_mir
  25: rustc::ty::query::__query_compute::optimized_mir
  26: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute
  27: rustc::dep_graph::graph::DepGraph::with_task_impl
  28: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  29: rustc_mir::interpret::eval_context::InterpCx<M>::load_mir
  30: rustc_mir::const_eval::const_eval_raw_provider
  31: rustc::ty::query::__query_compute::const_eval_raw
  32: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval_raw>::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::const_eval::const_eval_provider
  36: rustc::ty::query::__query_compute::const_eval
  37: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute
  38: rustc::dep_graph::graph::DepGraph::with_task_impl
  39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  40: rustc_mir::const_eval::const_eval_provider
  41: rustc::ty::query::__query_compute::const_eval
  42: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute
  43: rustc::dep_graph::graph::DepGraph::with_task_impl
  44: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  45: <rustc::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_const
  46: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with
  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: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  58: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:78
  59: rustc_data_structures::sync::par_for_each_in
  60: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:78
  61: rustc::hir::Crate::par_visit_all_item_likes
  62: rustc::util::common::time
  63: rustc_typeck::check_crate
  64: rustc_interface::passes::analysis
  65: rustc::ty::query::__query_compute::analysis
  66: rustc::dep_graph::graph::DepGraph::with_task_impl
  67: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  68: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  69: rustc_interface::passes::create_global_ctxt::{{closure}}
  70: rustc_interface::passes::BoxedGlobalCtxt::enter
  71: rustc_interface::interface::run_compiler_in_existing_thread_pool
  72: std::thread::local::LocalKey<T>::with
  73: scoped_tls::ScopedKey<T>::set
  74: syntax::with_globals
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.40.0 (73528e339 2019-12-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib

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

query stack during panic:
#0 [optimized_mir] processing `Bug::A::{{constant}}#0`
#1 [const_eval_raw] const-evaluating `Bug::A::{{constant}}#0`
#2 [const_eval] const-evaluating + checking `Bug::A::{{constant}}#0`
#3 [const_eval] const-evaluating + checking `Bug::A::{{constant}}#0`
#4 [check_item_well_formed] processing `Bug`
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0161, E0507.
For more information about an error, try `rustc --explain E0161`.
error: could not compile `playground`.

To learn more, run the command again with --verbose.

Possibly related to #67696, except with a different ICE message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlC-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions