Skip to content

ICE in nightly with patterns and nested enums #39362

Closed

Description

enum Foo {
    Bar { bar: Bar, id: usize }
}

enum Bar {
    A, B, C, D, E, F
}

fn test(f: Foo) {
    match f {
        Foo::Bar { bar: Bar::A, .. } => (),
        Foo::Bar { bar: Bar::B, .. } => (),
    }
}

The match doesn't cover all patterns, but instead of triggering an error (like stable does) it panics.

Playpen link
Version: c8af93f 2017-01-18
Backtrace:

thread 'rustc' panicked at 'assertion failed: !self.is_enum()', C:\bot\slave\nightly-dist-rustc-win-msvc-64\build\src\librustc\ty/mod.rs:1497
stack backtrace:
   0:     0x7ffa070208f8 - std::panicking::Location::line::h8c528bbdf4eef8a3
   1:     0x7ffa0701fd82 - std::panicking::Location::line::h8c528bbdf4eef8a3
   2:     0x7ffa070237bd - std::panicking::rust_panic_with_hook::h7abc6e334345e341
   3:     0x7ffa00a82293 - <unknown>
   4:     0x7ffa00cfe5d1 - rustc::ty::AdtDef::struct_variant::h3407c5d1765959c4
   5:     0x7ffa14c5bbf2 - <rustc_const_eval::pattern::Pattern<'tcx> as core::fmt::Display>::fmt::hd436f1763f102376
   6:     0x7ffa07036f31 - core::fmt::write::h17329881d672cff3
   7:     0x7ffa14c5617d - <rustc_const_eval::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body::heaaeacf8d46cf425
   8:     0x7ffa14c52dc9 - <rustc_const_eval::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr::h8a811e2d6152dd49
   9:     0x7ffa14c51ae5 - <rustc_const_eval::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr::h8a811e2d6152dd49
  10:     0x7ffa14c54130 - <rustc_const_eval::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body::heaaeacf8d46cf425
  11:     0x7ffa14c5056d - <rustc_const_eval::check_match::OuterVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn::he57f23671b55c8bb
  12:     0x7ffa14c3042f - <unknown>
  13:     0x7ffa14c3009e - <unknown>
  14:     0x7ffa14c2e8d5 - <unknown>
  15:     0x7ffa14c50503 - <rustc_const_eval::check_match::OuterVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn::he57f23671b55c8bb
  16:     0x7ffa14c31ad3 - <unknown>
  17:     0x7ffa14c50a7a - rustc_const_eval::check_match::check_crate::h80f0ce25c2e773dc
  18:     0x7ffa0cbf6c0e - rustc_driver::driver::count_nodes::h761a1dba824a4f1e
  19:     0x7ffa0cb3ad9b - <unknown>
  20:     0x7ffa0cbd137c - rustc_driver::driver::compile_input::h44e43be0fc34a1a1
  21:     0x7ffa0cc22cdb - rustc_driver::run_compiler::h5e34a930c0929e5c
  22:     0x7ffa0caff0ae - <unknown>
  23:     0x7ffa07026801 - _rust_maybe_catch_panic
  24:     0x7ffa0cb2c6e6 - <unknown>
  25:     0x7ffa0701dd2e - std::sys::imp::thread::Thread::new::h7a1b2b1b6bab390a
  26:     0x7ffa2a998363 - BaseThreadInitThunk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call 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) ❄️Issue: 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