Skip to content

Trying to pattern-match field 1 of Box causes an ICE #82772

Closed
@CAD97

Description

@CAD97

Code

fn main() {
    let Box { 1: _, .. }: Box<()>;
}

[playground]

Meta

rustc --version --verbose:

1.52.0-nightly

(2021-03-01 4f20caa6258d4c74ce6b)

Error output

thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs:1346:21
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/4f20caa6258d4c74ce6b316fd347e3efe81cf557/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/4f20caa6258d4c74ce6b316fd347e3efe81cf557/library/core/src/panicking.rs:92:14
   2: core::panicking::panic_bounds_check
             at /rustc/4f20caa6258d4c74ce6b316fd347e3efe81cf557/library/core/src/panicking.rs:69:5
   3: rustc_mir_build::thir::pattern::deconstruct_pat::Fields::replace_with_pattern_arguments
   4: rustc_mir_build::thir::pattern::usefulness::PatStack::pop_head_constructor
   5: rustc_mir_build::thir::pattern::usefulness::is_useful
   6: <core::iter::adapters::copied::Copied<I> as core::iter::traits::iterator::Iterator>::fold
   7: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   8: rustc_mir_build::thir::pattern::usefulness::compute_match_usefulness
   9: rustc_mir_build::thir::pattern::check_match::MatchVisitor::check_irrefutable
  10: <rustc_mir_build::thir::pattern::check_match::MatchVisitor as rustc_hir::intravisit::Visitor>::visit_local
  11: rustc_hir::intravisit::walk_block
  12: <rustc_mir_build::thir::pattern::check_match::MatchVisitor as rustc_hir::intravisit::Visitor>::visit_expr
  13: rustc_mir_build::thir::pattern::check_match::check_match
  14: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  15: rustc_data_structures::stack::ensure_sufficient_stack
  16: rustc_query_system::query::plumbing::force_query_with_job
  17: rustc_query_system::query::plumbing::get_query_impl
  18: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_match
  19: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  20: rustc_session::utils::<impl rustc_session::session::Session>::time
  21: rustc_interface::passes::analysis
  22: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  23: rustc_data_structures::stack::ensure_sufficient_stack
  24: rustc_query_system::query::plumbing::force_query_with_job
  25: rustc_query_system::query::plumbing::get_query_impl
  26: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  27: rustc_interface::passes::QueryContext::enter
  28: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  29: rustc_span::with_source_map
  30: rustc_interface::interface::create_compiler_and_run
  31: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

query stack during panic:
#0 [check_match] match-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions