Closed
Description
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>