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

break inside closure argument inside loop causes an ICE: Assertion failed #51707

Closed
DutchGhost opened this issue Jun 22, 2018 · 2 comments
Closed
Labels
A-closures Area: closures (`|args| { .. }`) A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@DutchGhost
Copy link
Contributor

DutchGhost commented Jun 22, 2018

The following code crashes on stable, beta and rustc 1.28.0-nightly (f28c7ae 2018-06-19):

fn main() {
    while |_: [_; break]| {} {}
}

Playground link: https://play.rust-lang.org/?gist=c7f1efed4ebee041118d2b292c562674&version=nightly&mode=release
Backtrace:

thread 'main' panicked at 'assertion failed: self.tcx.sess.err_count() > 0', librustc_typeck\check\mod.rs:3828:19
stack backtrace:
   0: <std::sync::mpsc::select::Select as core::fmt::Debug>::fmt
   1: std::stdsimd::arch::detect::os::check_for
   2: std::panicking::take_hook
   3: std::panicking::take_hook
   4: <rustc::ty::query::on_disk_cache::CacheEncoder<'enc, 'a, 'tcx, serialize::opaque::Encoder<'enc>> as serialize::serialize::SpecializedEncoder<rustc::ich::fingerprint::Fingerprint>>::specialized_encode
   5: std::panicking::rust_panic_with_hook
   6: <rustc_typeck::namespace::Namespace as core::fmt::Debug>::fmt
   7: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
   8: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
   9: <rustc_typeck::collect::has_late_bound_regions::LateBoundRegionsDetector<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_lifetime
  10: <rustc_typeck::check_unused::CollectExternCrateVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  11: <rustc_typeck::coherence::unsafety::UnsafetyChecker<'cx, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_trait_item
  12: rustc::ty::query::on_disk_cache::__ty_decoder_impl::<impl serialize::serialize::Decoder for rustc::ty::query::on_disk_cache::CacheDecoder<'a, 'tcx, 'x>>::read_str
  13: rustc::ty::context::tls::track_diagnostic
  14: rustc::ty::context::tls::track_diagnostic
  15: rustc::dep_graph::graph::DepGraph::assert_ignored
  16: rustc::ty::context::tls::track_diagnostic
  17: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  18: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  19: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
  20: rustc_mir::interpret::const_eval::const_eval_provider
  21: rustc::ty::query::on_disk_cache::__ty_decoder_impl::<impl serialize::serialize::Decoder for rustc::ty::query::on_disk_cache::CacheDecoder<'a, 'tcx, 'x>>::read_str
  22: rustc::ty::context::tls::track_diagnostic
  23: rustc::ty::context::tls::track_diagnostic
  24: rustc::dep_graph::graph::DepGraph::assert_ignored
  25: rustc::ty::context::tls::track_diagnostic
  26: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  27: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  28: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_const
  29: rustc::ty::structural_impls::<impl rustc::ty::context::Lift<'tcx> for rustc::middle::const_val::ErrKind<'a>>::lift_to_tcx
  30: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  31: <rustc_typeck::check_unused::CollectExternCrateVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  32: <rustc_typeck::check_unused::CollectExternCrateVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  33: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::normalize_ty
  34: <rustc_typeck::check::autoderef::AutoderefKind as core::fmt::Debug>::fmt
  35: <rustc_typeck::collect::has_late_bound_regions::LateBoundRegionsDetector<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_lifetime
  36: <rustc_typeck::collect::has_late_bound_regions::LateBoundRegionsDetector<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_lifetime
  37: <unknown>
  38: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  39: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  40: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  41: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  42: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  43: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  44: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  45: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  46: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  47: <rustc_typeck::check::GatherLocalsVisitor<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_pat
  48: <rustc_typeck::collect::has_late_bound_regions::LateBoundRegionsDetector<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_lifetime
  49: <rustc_typeck::check_unused::CollectExternCrateVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  50: <rustc_typeck::coherence::unsafety::UnsafetyChecker<'cx, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_trait_item
  51: rustc::ty::query::on_disk_cache::__ty_decoder_impl::<impl serialize::serialize::Decoder for rustc::ty::query::on_disk_cache::CacheDecoder<'a, 'tcx, 'x>>::read_str
  52: rustc::ty::context::tls::track_diagnostic
  53: rustc::ty::context::tls::track_diagnostic
  54: rustc::dep_graph::graph::DepGraph::assert_ignored
  55: rustc::ty::context::tls::track_diagnostic
  56: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  57: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  58: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  59: <rustc_typeck::check::Diverges as core::fmt::Debug>::fmt
  60: <rustc_typeck::coherence::unsafety::UnsafetyChecker<'cx, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_trait_item
  61: rustc::ty::context::tls::track_diagnostic
  62: rustc::ty::context::tls::track_diagnostic
  63: rustc::dep_graph::graph::DepGraph::assert_ignored
  64: rustc::ty::context::tls::track_diagnostic
  65: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  66: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  67: rustc_typeck::check_crate
  68: <rustc_driver::Compilation as core::fmt::Debug>::fmt
  69: rustc_driver::set_sigpipe_handler
  70: <unknown>
  71: rustc_driver::driver::compile_input
  72: rustc_driver::run_compiler
  73: rustc_driver::target_features::add_configuration
  74: rustc_driver::set_sigpipe_handler
  75: _rust_maybe_catch_panic
  76: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  77: rustc_driver::main
  78: <unknown>
  79: std::panicking::update_panic_count
  80: _rust_maybe_catch_panic
  81: std::rt::lang_start_internal
  82: <unknown>
  83: <unknown>
  84: BaseThreadInitThunk
  85: RtlUserThreadStart
query stack during panic:
#0 [typeck_tables_of] processing `main::{{closure}}::{{constant}}`
#1 [const_eval] const-evaluating `main::{{closure}}::{{constant}}`
#2 [typeck_tables_of] processing `main`
#3 [typeck_item_bodies] type-checking all item bodies
end of query stack

error: internal compiler error: unexpected panic

this might be related to #50581, but has been resolved in #51070

@DutchGhost DutchGhost changed the title break inside closure argument inside loop causes an ICE break inside closure argument inside loop causes an ICE: Assertion failed Jun 22, 2018
@stokhos stokhos added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-closures Area: closures (`|args| { .. }`) labels Jun 22, 2018
@KamilaBorowska
Copy link
Contributor

Replace break with continue, and it will create a different error message.

   Compiling playground v0.0.1 (file:///playground)
error: internal compiler error: librustc_mir/hair/cx/expr.rs:554: invalid loop id for continue: not inside loop scope

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error


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.27.0 (3eda71b00 2018-06-19) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `playground`.

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

@DutchGhost
Copy link
Contributor Author

@xfix , see #51708

@estebank estebank added the A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html label Jun 22, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this issue Jun 26, 2018
…r=estebank

Fix ICEs when using continue as an array length inside closures (inside loop conditions)

Fixes rust-lang#51707.
Fixes rust-lang#51708.

r? @estebank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: closures (`|args| { .. }`) A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants