Skip to content

ICE on nightly when calling method on an enum #39544

Closed
@drbawb

Description

@drbawb

I'm trying to use the multipart crate (v0.9) which has an enum and an impl:

pub enum SaveDir {
    Temp(TempDir),
    Perm(PathBuf),
}

impl SaveDir {
 pub fn keep(&mut self) {
        use self::SaveDir::*;
        *self = match mem::replace(self, Perm(PathBuf::new())) {
            Temp(tempdir) => Perm(tempdir.into_path()),
            old_self => old_self,
        };
    }
}

Calling the #keep() method in my own code results in an ICE:

$ rustc -V
rustc 1.16.0-nightly (24055d0f2 2017-01-31)

$ cargo build

   Compiling aqua-web v0.1.0 (file:///C:/Users/drbawb/dev/rust/aqua/aqua-web)
error: internal compiler error: unexpected panic

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: run with `RUST_BACKTRACE=1` for a 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:1473
stack backtrace:
   0:     0x7ffaccff0a18 - std::panicking::Location::line::ha91c35bc276d0b51
   1:     0x7ffaccfefea2 - std::panicking::Location::line::ha91c35bc276d0b51
   2:     0x7ffaccff38dd - std::panicking::rust_panic_with_hook::h9cf2c5a21e80091a
   3:     0x7ffab9072793 - <unknown>
   4:     0x7ffab920706a - rustc::middle::mem_categorization::cmt_::get_field::h9f2d931f17fc448b
   5:     0x7ffae0b074c5 - rustc_borrowck::borrowck::BorrowckCtxt::bckerr_to_diag::h2d7af69a90ae95ba
   6:     0x7ffae0b03326 - rustc_borrowck::borrowck::BorrowckCtxt::report::hbef36ce271ed8d47
   7:     0x7ffae0acefd0 - <rustc_borrowck::borrowck::gather_loans::GatherLoanCtxt<'a, 'tcx> as rustc::middle::expr_use_visitor::Delegate<'tcx>>::decl_without_init::h7e93ca90da0aab5f
   8:     0x7ffae0acdb62 - <rustc_borrowck::borrowck::gather_loans::GatherLoanCtxt<'a, 'tcx> as rustc::middle::expr_use_visitor::Delegate<'tcx>>::borrow::h3a777fcf8d947b45
   9:     0x7ffab91e968f - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr::h40c0cf34345c8812
  10:     0x7ffab91e9ace - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr::h40c0cf34345c8812
  11:     0x7ffab91e9891 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr::h40c0cf34345c8812
  12:     0x7ffab91e9f74 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr::h40c0cf34345c8812
  13:     0x7ffab91eb540 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr::h40c0cf34345c8812
  14:     0x7ffab91e98b3 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr::h40c0cf34345c8812
  15:     0x7ffab91eb540 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr::h40c0cf34345c8812
  16:     0x7ffab91e98b3 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr::h40c0cf34345c8812
  17:     0x7ffab91e9f74 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr::h40c0cf34345c8812
  18:     0x7ffab91e8e7b - rustc::middle::expr_use_visitor::ExprUseVisitor::consume_body::hcdc8c8f5b35232c5
  19:     0x7ffae0aca119 - <rustc::mir::Operand<'tcx> as rustc_borrowck::borrowck::mir::abs_domain::Lift>::lift::h707cd2026e8d8954
  20:     0x7ffae0b000d1 - rustc_borrowck::borrowck::check_crate::h8fccd59355eb5e14
  21:     0x7ffae0afdb3b - rustc_borrowck::borrowck::check_crate::h8fccd59355eb5e14
  22:     0x7ffae0afb38b - <rustc_borrowck::borrowck::BorrowckCtxt<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn::h7b19d6cf263b349a
  23:     0x7ffae0afb93b - <rustc_borrowck::borrowck::BorrowckCtxt<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_impl_item::h934600d3986e7c8d
  24:     0x7ffae0afc511 - rustc_borrowck::borrowck::check_crate::h8fccd59355eb5e14
  25:     0x7ffae268836c - rustc_driver::driver::count_nodes::h80b2ce48c34d37f0
  26:     0x7ffae25d621f - <unknown>
  27:     0x7ffae2661308 - rustc_driver::driver::compile_input::h332507cf263d70da
  28:     0x7ffae26b2cab - rustc_driver::run_compiler::hcb93be779576dd68
  29:     0x7ffae258f0be - <unknown>
  30:     0x7ffaccff6981 - _rust_maybe_catch_panic
  31:     0x7ffae25bc7b6 - <unknown>
  32:     0x7ffaccfedeee - std::sys::imp::thread::Thread::new::h3473f0391636b6af
  33:     0x7ffb029c8101 - BaseThreadInitThunk

error: Could not compile `aqua-web`.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions