Skip to content

ICE: match pairs remaining after simplifying irrefutable pattern #47096

Closed
@goodmanjonathan

Description

@goodmanjonathan

Irrefutable slice patterns with a binding.. may cause the compiler to ICE.

#![feature(slice_patterns)]

fn foo(&[ref _xs..]: &[i32]) {}

fn main() {}

I expected to see this happen: the code compiled (however silly this example is)

Instead, this happened:

error: internal compiler error: /checkout/src/librustc_mir/build/matches/mod.rs:177: match pairs [MatchPair { place: (*_1), pattern: Pattern { ty: [i32], span: slice_patterns_ice.rs:3:9: 3:20, kind: Slice { prefix: [], slice: Some(Pattern { ty: [i32], span: slice_patterns_ice.rs:3:10: 3:17, kind: Binding { mutability: Not, name: _xs, mode: ByRef(ReEmpty, Shared), var: NodeId(9), ty: &'<empty> [i32], subpattern: None } }), suffix: [] } }, slice_len_checked: false }] remaining after simplifying irrefutable pattern
 --> slice_patterns_ice.rs:3:9
  |
3 | fn foo(&[ref _xs..]: &[i32]) {}
  |         ^^^^^^^^^^^

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.24.0-nightly (3f916bd30 2017-12-30) running on x86_64-unknown-linux-gnu

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:451:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Meta

rustc --version --verbose:

rustc 1.24.0-nightly (3f916bd 2017-12-30)
binary: rustc
commit-hash: 3f916bd
commit-date: 2017-12-30
host: x86_64-unknown-linux-gnu
release: 1.24.0-nightly
LLVM version: 4.0

Backtrace:

   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at /checkout/src/libstd/sys_common/backtrace.rs:68
             at /checkout/src/libstd/sys_common/backtrace.rs:57
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:391
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
   6: rustc_errors::Handler::span_bug
   7: rustc::session::opt_span_bug_fmt::{{closure}}
   8: rustc::ty::context::tls::with_opt
   9: rustc::session::span_bug_fmt
  10: rustc_mir::build::matches::<impl rustc_mir::build::Builder<'a, 'gcx, 'tcx>>::place_into_pattern
  11: rustc_mir::build::construct_fn
  12: rustc::ty::context::tls::enter
  13: rustc::infer::InferCtxtBuilder::enter
  14: rustc_mir::build::mir_build
  15: rustc_mir::transform::mir_built
  16: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_built<'tcx>>::compute_result
  17: rustc::dep_graph::graph::DepGraph::with_task_impl
  18: rustc_errors::Handler::track_diagnostics
  19: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  20: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_built<'tcx>>::force
  21: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_built<'tcx>>::try_get
  22: rustc::ty::maps::TyCtxtAt::mir_built
  23: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_built
  24: rustc_mir::transform::check_unsafety::unsafety_check_result
  25: rustc::ty::maps::<impl rustc::ty::maps::queries::unsafety_check_result<'tcx>>::compute_result
  26: rustc::dep_graph::graph::DepGraph::with_task_impl
  27: rustc_errors::Handler::track_diagnostics
  28: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  29: rustc::ty::maps::<impl rustc::ty::maps::queries::unsafety_check_result<'tcx>>::force
  30: rustc::ty::maps::<impl rustc::ty::maps::queries::unsafety_check_result<'tcx>>::try_get
  31: rustc::ty::maps::TyCtxtAt::unsafety_check_result
  32: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::unsafety_check_result
  33: rustc_mir::transform::mir_const
  34: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::compute_result
  35: rustc::dep_graph::graph::DepGraph::with_task_impl
  36: rustc_errors::Handler::track_diagnostics
  37: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  38: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::force
  39: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::try_get
  40: rustc::ty::maps::TyCtxtAt::mir_const
  41: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_const
  42: rustc_mir::transform::mir_validated
  43: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::compute_result
  44: rustc::dep_graph::graph::DepGraph::with_task_impl
  45: rustc_errors::Handler::track_diagnostics
  46: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  47: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::force
  48: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::try_get
  49: rustc::ty::maps::TyCtxtAt::mir_validated
  50: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_validated
  51: rustc_borrowck::borrowck::borrowck
  52: rustc::dep_graph::graph::DepGraph::with_task_impl
  53: rustc_errors::Handler::track_diagnostics
  54: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  55: rustc::ty::maps::<impl rustc::ty::maps::queries::borrowck<'tcx>>::force
  56: rustc::ty::maps::<impl rustc::ty::maps::queries::borrowck<'tcx>>::try_get
  57: rustc::ty::maps::TyCtxtAt::borrowck
  58: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::borrowck
  59: rustc_borrowck::borrowck::check_crate
  60: <std::thread::local::LocalKey<T>>::with
  61: <std::thread::local::LocalKey<T>>::with
  62: rustc::ty::context::TyCtxt::create_and_enter
  63: rustc_driver::driver::compile_input
  64: rustc_driver::run_compiler

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-slice-patternsArea: Slice patterns, https://github.com/rust-lang/rust/issues/23121I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions