Closed
Description
It seems like a return
in a do catch {}
block can sometimes cause an ICE.
catch.rs
:
#![feature(catch_expr)]
fn main() {
let _: Result<(), ()> = do catch {
let _ = Err(())?;
return;
};
}
I'm using rustc 1.22.0-nightly (150b625a0 2017-10-08)
. Compiling with rustc catch.rs
results in
error: internal compiler error: broken MIR in NodeId(4) (_1 = ()): bad assignment (! = ()): Sorts(ExpectedFound { expected: !, found: () })
--> catch.rs:3:11
|
3 | fn main() {
| ___________^
4 | | let _: Result<(), ()> = do catch {
5 | | let _ = Err(())?;
6 | | return;
7 | | };
8 | | }
| |_^
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.22.0-nightly (150b625a0 2017-10-08) running on x86_64-unknown-linux-gnu
thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:439:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.
The error does not occur with Err(())
in place of the return;
. It also does not occur if a return;
is added after the do catch {}
block (and in that case the compiler correctly warns that the newly-added return
is unreachable).
The backtrace (from RUST_BACKTRACE=full
):
thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:439:8
stack backtrace:
0: 0x7ff89f268e13 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::h6586f2a9393de1d1
at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: 0x7ff89f263560 - std::sys_common::backtrace::_print::h3dec927d50ceb107
at /checkout/src/libstd/sys_common/backtrace.rs:71
2: 0x7ff89f276313 - std::panicking::default_hook::{{closure}}::h83ba37abaee4af2a
at /checkout/src/libstd/sys_common/backtrace.rs:60
at /checkout/src/libstd/panicking.rs:381
3: 0x7ff89f27601a - std::panicking::default_hook::h84414cfb51346d66
at /checkout/src/libstd/panicking.rs:391
4: 0x7ff89f2767d7 - std::panicking::rust_panic_with_hook::hc5becc315f665cab
at /checkout/src/libstd/panicking.rs:577
5: 0x7ff89d931888 - std::panicking::begin_panic::h91a4272b15139aac
6: 0x7ff89d92dce3 - rustc_errors::Handler::span_bug::h818a6980a83a0d6a
7: 0x7ff89d9f5556 - rustc_mir::transform::type_check::TypeChecker::typeck_mir::hc75985338c64e28b
8: 0x7ff89d9f841a - <rustc_mir::transform::type_check::TypeckMir as rustc::mir::transform::MirPass>::run_pass::he658866152be9628
9: 0x7ff89da2084d - rustc_mir::transform::run_suite::h64c28382bd0fe488
10: 0x7ff89da1fc55 - rustc_mir::transform::mir_const::h826db401d1b4585a
11: 0x7ff89c00858f - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::compute_result::h24cb204ad2b3e092
12: 0x7ff89bda732c - rustc::dep_graph::graph::DepGraph::with_task::hd124f2b55ca71aab
13: 0x7ff89c009060 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::force::h45ea49524d78dcc8
14: 0x7ff89c0098c1 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::try_get::hc8452aa8ca69f794
15: 0x7ff89c111c5a - rustc::ty::maps::TyCtxtAt::mir_const::h042b99b5fe2977e6
16: 0x7ff89c10edd3 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_const::h180dddd540d106f8
17: 0x7ff89d9ea182 - rustc_mir::transform::check_unsafety::unsafety_violations::h19de821f0076c27e
18: 0x7ff89c012dbb - rustc::ty::maps::<impl rustc::ty::maps::queries::unsafety_violations<'tcx>>::force::hb7a64ac3b3461f98
19: 0x7ff89c0139f2 - rustc::ty::maps::<impl rustc::ty::maps::queries::unsafety_violations<'tcx>>::try_get::hedb73960c75f9cac
20: 0x7ff89c11210d - rustc::ty::maps::TyCtxtAt::unsafety_violations::h17300d0ec2153f7b
21: 0x7ff89c10ee9a - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::unsafety_violations::h2cc24c67b69a9521
22: 0x7ff89da20448 - rustc_mir::transform::mir_validated::h794c515d623ed355
23: 0x7ff89c00a6bf - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::compute_result::h59f785e0d7f50f2b
24: 0x7ff89bda732c - rustc::dep_graph::graph::DepGraph::with_task::hd124f2b55ca71aab
25: 0x7ff89c00b190 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::force::ha0c601a999645f2f
26: 0x7ff89c00b9f1 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::try_get::h99efb5915f3ac297
27: 0x7ff89c111d8a - rustc::ty::maps::TyCtxtAt::mir_validated::he85faea6b924ec31
28: 0x7ff89c10ee03 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_validated::h89fb2c8b26d004dc
29: 0x7ff89dc9d209 - rustc_borrowck::borrowck::borrowck::h257816007c121805
30: 0x7ff89c0275ef - rustc::ty::maps::<impl rustc::ty::maps::queries::borrowck<'tcx>>::compute_result::h11aa284fc5f2689d
31: 0x7ff89bda3b12 - rustc::dep_graph::graph::DepGraph::with_task::h6efbdc4d292292cb
32: 0x7ff89c02806d - rustc::ty::maps::<impl rustc::ty::maps::queries::borrowck<'tcx>>::force::h0643799d9432c62c
33: 0x7ff89c02887d - rustc::ty::maps::<impl rustc::ty::maps::queries::borrowck<'tcx>>::try_get::he08acc9dd96b1547
34: 0x7ff89c1129ce - rustc::ty::maps::TyCtxtAt::borrowck::h607458e61f03edd5
35: 0x7ff89c10f063 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::borrowck::hccbf7a762d6ad734
36: 0x7ff89dc9d067 - rustc_borrowck::borrowck::check_crate::hf8e143db5104f5f9
37: 0x7ff89f5a4960 - rustc::ty::context::TyCtxt::create_and_enter::hcabbdde20fa10fc4
38: 0x7ff89f618acb - rustc_driver::driver::compile_input::h9793286a10a505ce
39: 0x7ff89f63477e - rustc_driver::run_compiler::h51c96efa7b2ea675
40: 0x7ff89f553607 - std::sys_common::backtrace::__rust_begin_short_backtrace::h19cb26897b35d05c
41: 0x7ff89f2b0bac - __rust_maybe_catch_panic
at /checkout/src/libpanic_unwind/lib.rs:99
42: 0x7ff89f58c630 - <F as alloc::boxed::FnBox<A>>::call_box::h4157afcb57e5a63b
43: 0x7ff89f2751db - std::sys::imp::thread::Thread::new::thread_start::h41d0f90599fa7590
at /checkout/src/liballoc/boxed.rs:736
at /checkout/src/libstd/sys_common/thread.rs:24
at /checkout/src/libstd/sys/unix/thread.rs:90
44: 0x7ff89a14c493 - start_thread
45: 0x7ff89ef44abe - __clone
46: 0x0 - <unknown>
Output of rustc --version --verbose
:
$ rustc --version --verbose
rustc 1.22.0-nightly (150b625a0 2017-10-08)
binary: rustc
commit-hash: 150b625a07f135d0a5e1693adf2b14315709779e
commit-date: 2017-10-08
host: x86_64-unknown-linux-gnu
release: 1.22.0-nightly
LLVM version: 4.0