Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: Shadowing a unit-like enum in a closure crashes compiler #33504

Closed
Moredread opened this issue May 8, 2016 · 5 comments
Closed

ICE: Shadowing a unit-like enum in a closure crashes compiler #33504

Moredread opened this issue May 8, 2016 · 5 comments
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Moredread
Copy link

Shadowing a unit-like enum in a closure crashes compiler.

I tried this code:

struct Test;

fn main() {
    || {
        let Test = 1;
    };
}

I expected to see this happen: Failure message E0413

Instead, this happened: Compiler crash

driver.rs:5:13: 5:17 error: declaration of `Test` shadows an enum variant or unit-like struct in scope [E0413]
driver.rs:5         let Test = 1;
                        ^~~~
driver.rs:5:13: 5:17 help: run `rustc --explain E0413` to see a detailed explanation
error: internal compiler error: ../src/librustc/middle/mem_categorization.rs:614: Def::Err in memory categorization
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
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/errors/mod.rs:576
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Meta

rustc --version --verbose:

rustc 1.10.0-nightly (62e2b2fb7 2016-05-06)
binary: rustc
commit-hash: 62e2b2fb7acf5f8331781cd7128c754ed1b66c4f
commit-date: 2016-05-06
host: x86_64-unknown-linux-gnu
release: 1.10.0-nightly

Backtrace:

thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/errors/mod.rs:576
stack backtrace:
   1:     0x7f95e967bd10 - std::sys::backtrace::tracing::imp::write::h9fb600083204ae7f
   2:     0x7f95e968958b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hca543c34f11229ac
   3:     0x7f95e968912c - std::panicking::default_hook::hc2c969e7453d080c
   4:     0x7f95e964e8cf - std::sys_common::unwind::begin_unwind_inner::h30e12d15ce2b2e25
   5:     0x7f95e4ca6717 - std::sys_common::unwind::begin_unwind::h24c4c0fa2cfe995a
   6:     0x7f95e4ca607e - syntax::errors::Handler::bug::h4846e60601033e50
   7:     0x7f95e5d2fab2 - rustc::session::opt_span_bug_fmt::_$u7b$$u7b$closure$u7d$$u7d$::hf0fb5697f8f25f40
   8:     0x7f95e5d2f942 - rustc::session::opt_span_bug_fmt::hc581ba88c4e2ec53
   9:     0x7f95e5d47826 - rustc::session::bug_fmt::had96c08cb43bd8a1
  10:     0x7f95e5ebecb0 - rustc::middle::mem_categorization::MemCategorizationContext::cat_def::h1e6d1d71a3ac3d06
  11:     0x7f95e5ebcce9 - rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_::h688ac5141fed7601
  12:     0x7f95e5eba413 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_pat::h95254f9d39fba4a1
  13:     0x7f95e5eb5cf3 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_irrefutable_pat::h7304094e79d13564
  14:     0x7f95e5eb8d46 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_stmt::h8bc9b54fe3fcb6f0
  15:     0x7f95e5eb7f0e - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr::h9cca31560139037e
  16:     0x7f95e5eb5e84 - rustc::middle::expr_use_visitor::ExprUseVisitor::consume_expr::ha16e99aa14e61262
  17:     0x7f95e5eb5b65 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_fn::h5a4a2ab4ebcdb73a
  18:     0x7f95e6cb635d - _<check..upvar..AdjustBorrowKind<'a, 'tcx> as rustc..hir..intravisit..Visitor<'v>>::visit_fn::hba13755c61d6d401
  19:     0x7f95e6cb5e48 - rustc::hir::intravisit::walk_expr::h4743b97a2ee4072c
  20:     0x7f95e6c14a5a - rustc_typeck::check::check_bare_fn::h7e4c2ad58d1814dd
  21:     0x7f95e6c12196 - rustc_typeck::check::check_item_body::h7ffec660fc242796
  22:     0x7f95e6c0a011 - rustc_typeck::check::check_item_bodies::ha729008a2e67410e
  23:     0x7f95e6c02012 - rustc_typeck::check_crate::hb08ba31a6a5f65b5
  24:     0x7f95e9bd0860 - rustc_driver::driver::phase_3_run_analysis_passes::_$u7b$$u7b$closure$u7d$$u7d$::hfdd8d88ff571b474
  25:     0x7f95e9bce8be - rustc::ty::context::TyCtxt::create_and_enter::ha551c2427049829f
  26:     0x7f95e9b9a285 - rustc_driver::driver::compile_input::h0629572e6f316b31
  27:     0x7f95e9b8a4fd - rustc_driver::run_compiler::h8902aebf8b1849a8
  28:     0x7f95e9b877bd - std::sys_common::unwind::try::try_fn::h4c74456035d0fcc7
  29:     0x7f95e96794eb - __rust_try
  30:     0x7f95e967947d - std::sys_common::unwind::inner_try::h47a4d9cd4a369dcd
  31:     0x7f95e9b881ea - _<F as std..boxed..FnBox<A>>::call_box::h27f542a39f1d61ef
  32:     0x7f95e96876f4 - std::sys::thread::Thread::new::thread_start::h6f266e069bf4ec2b
  33:     0x7f95e1424473 - start_thread
  34:     0x7f95e92e5acc - clone
  35:                0x0 - <unknown>

@Moredread
Copy link
Author

Moredread commented May 8, 2016

The same code crashes also on stable, at a different code point.

thread 'rustc' panicked at 'Def::Err in memory categorization', ../src/librustc/middle/mem_categorization.rs:613
stack backtrace:
   1:     0x7fb3f2270330 - sys::backtrace::tracing::imp::write::h3675b4f0ca767761Xcv
   2:     0x7fb3f227968b - panicking::default_handler::_$u7b$$u7b$closure$u7d$$u7d$::closure.44519
   3:     0x7fb3f22791e3 - panicking::default_handler::h18faf4fbd296d909lSz
   4:     0x7fb3f223d9ac - sys_common::unwind::begin_unwind_inner::hfb5d07d6e405c6bbg1t
   5:     0x7fb3ef4c120f - sys_common::unwind::begin_unwind::h17349651284183375827
   6:     0x7fb3ef4ffc45 - middle::mem_categorization::MemCategorizationContext<'t, 'a, 'tcx>::cat_def::hdeb344a5491bba80aeK
   7:     0x7fb3ef4fdbc2 - middle::mem_categorization::MemCategorizationContext<'t, 'a, 'tcx>::cat_pattern_::h2171199047159068738
   8:     0x7fb3ef4fa833 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::walk_pat::hf4d5b3d8cb6f67ecUgh
   9:     0x7fb3ef4f5353 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::walk_irrefutable_pat::h5668c6e2ce3263877bh
  10:     0x7fb3ef4f8ad6 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::walk_stmt::h3e8eaabe6a16d9c1lKg
  11:     0x7fb3ef4f7c3e - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::walk_expr::he2c7af9ebce7c88agsg
  12:     0x7fb3ef4f54de - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::consume_expr::h1393a4fb15fc5089Xjg
  13:     0x7fb3ef4f5155 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::walk_fn::h8572ed4d964016a4Xeg
  14:     0x7fb3f18af490 - check::upvar::AdjustBorrowKind<'a, 'tcx>.Visitor<'v>::visit_fn::h029e8800c7c40314P4j
  15:     0x7fb3f18af213 - intravisit::walk_expr::h6226208990425569121
  16:     0x7fb3f17f7b0a - check::check_bare_fn::h846d602fffbab51bLDo
  17:     0x7fb3f17f2876 - check::check_item_body::h1bc79a321f78eb96h3o
  18:     0x7fb3f17e932b - check::check_item_bodies::h5671f35c802ef7c1yBo
  19:     0x7fb3f17e0bb3 - check_crate::h7bb847abc9f256eeeCC
  20:     0x7fb3f279c667 - driver::phase_3_run_analysis_passes::_$u7b$$u7b$closure$u7d$$u7d$::closure.28550
  21:     0x7fb3f279ac04 - middle::ty::context::ctxt<'tcx>::create_and_enter::h16192426302205697189
  22:     0x7fb3f27976ef - driver::phase_3_run_analysis_passes::h10920926650053012691
  23:     0x7fb3f276aa15 - driver::compile_input::h7ae6a86e23de0774Hca
  24:     0x7fb3f2759b47 - run_compiler::hb0408bcf47642fe6mPc
  25:     0x7fb3f27572c1 - sys_common::unwind::try::try_fn::h7614151098073783683
  26:     0x7fb3f226dd1b - __rust_try
  27:     0x7fb3f22661fd - sys_common::unwind::inner_try::hadd81c754a64f07ciYt
  28:     0x7fb3f2757b10 - boxed::F.FnBox<A>::call_box::h18261575856772421581
  29:     0x7fb3f2277c59 - sys::thread::Thread::new::thread_start::h9bc812305b5e01feFPy
  30:     0x7fb3eb541473 - start_thread
  31:     0x7fb3f1eefacc - clone
  32:                0x0 - <unknown>

@sanxiyn sanxiyn added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 9, 2016
@Moredread
Copy link
Author

This seems to have been fixed, I don't get the error on nightly anymore. I haven't bisected what fixed it though.

@jseyfried
Copy link
Contributor

cc me

@Stebalien
Copy link
Contributor

@sanxiyn this appears to have been fixed.

@Mark-Simulacrum
Copy link
Member

E-needstest.

@Mark-Simulacrum Mark-Simulacrum added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 20, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants