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

nightly ICEs on invalid code with break outside of loop #43162

Closed
zhendongsu opened this issue Jul 11, 2017 · 6 comments · Fixed by #43745
Closed

nightly ICEs on invalid code with break outside of loop #43162

zhendongsu opened this issue Jul 11, 2017 · 6 comments · Fixed by #43745
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@zhendongsu
Copy link

$ rustc --version
rustc 1.20.0-nightly (bf0a9e0b4 2017-07-10)
$ 
$ rustc tmp.rs
error[E0268]: `break` outside of loop
 --> tmp.rs:2:3
  |
2 |   break {};
  |   ^^^^^^^^ cannot break outside of a loop

error: internal compiler error: /checkout/src/librustc_typeck/check/mod.rs:1981: no type for node 8: expr { } (id=8) in fcx 0x7f60ae1f3870

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.20.0-nightly (bf0a9e0b4 2017-07-10) running on x86_64-unknown-linux-gnu

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:489:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.

$ 
$ cat tmp.rs
fn main () {
  break {};
} 
$ 
@sanxiyn sanxiyn added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jul 11, 2017
@DanielJin21
Copy link

This is present in 1.19.0-beta.3 as well, here is the backtrace:

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:480
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:355
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:365
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:549
   5: std::panicking::begin_panic
   6: rustc_errors::Handler::bug
   7: rustc::session::opt_span_bug_fmt::{{closure}}
   8: rustc::session::opt_span_bug_fmt
   9: rustc::session::bug_fmt
  10: rustc_typeck::check::FnCtxt::node_ty
  11: <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
  12: <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
  13: rustc::hir::intravisit::walk_expr
  14: <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
  15: rustc_typeck::check::regionck::RegionCtxt::visit_fn_body
  16: rustc_typeck::check::typeck_tables_of::{{closure}}
  17: rustc_typeck::check::typeck_tables_of
  18: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  19: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  20: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
  21: rustc_typeck::check::typeck_item_bodies
  22: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get
  23: rustc::ty::maps::TyCtxtAt::typeck_item_bodies
  24: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies
  25: rustc_typeck::check_crate
  26: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
  27: rustc_driver::driver::phase_3_run_analysis_passes
  28: rustc_driver::driver::compile_input
  29: rustc_driver::run_compiler

@est31
Copy link
Member

est31 commented Jul 11, 2017

Bisecting using bisect-rust without any #![feature] annotation turned up 852b7cb (#42165), but this was only the commit this issue was introduced into stable Rust.

Bisecting after I've annotated the test case with #![feature(loop_break_value)] gave me no commit since 927c55d which introduced this, so this is probably an issue since the initial implementation of loop_break_value.

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@killercup
Copy link
Member

killercup commented Aug 7, 2017

I'm curios… do you think keeping fn main() { break rust } an ICE requires an RFC? :trollface:

@mauro-balades
Copy link

this is gold

@manfredbrandl
Copy link

I love rust:

fn main() {
break rust;
}

...
error: internal compiler error: It looks like you're trying to break rust; would you like some ICE?
note: the compiler expectedly panicked. this is a feature.
note: we would appreciate a joke overview: #43162 (comment)
note: rustc 1.72.0 (5680fa1 2023-08-23) running on x86_64-unknown-linux-gnu
...

@CEbbinghaus
Copy link

Please never delete this feature. By far the most fun ICE I have encountered :3

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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants