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

continue inside closure argument inside loop causes an ICE: Invalid loop id for continue #51708

Closed
DutchGhost opened this issue Jun 22, 2018 · 1 comment
Labels
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

this code causes an ICE on stable, beta, and rustc 1.28.0-nightly (f28c7ae 2018-06-19):

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

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

Backtrace:

error: internal compiler error: librustc_mir\hair\cx\expr.rs:551: invalid loop id for continue: not inside loop scope

thread 'main' panicked at 'Box<Any>', librustc_errors\lib.rs:554:9
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_errors::emitter::ColorConfig as core::fmt::Debug>::fmt
   7: rustc_errors::Handler::bug
   8: rustc::session::config::OutputTypes::values
   9: rustc::ty::context::tls::track_diagnostic
  10: rustc::ty::context::tls::track_diagnostic
  11: rustc::ty::context::tls::track_diagnostic
  12: rustc::session::bug_fmt
  13: rustc::session::bug_fmt
  14: <rustc_mir::dataflow::impls::EverInitializedPlaces<'a, 'gcx, 'tcx> as rustc_mir::dataflow::BitDenotation>::propagate_call_return
  15: rustc_mir::hair::cx::expr::<impl rustc_mir::hair::Mirror<'tcx> for &'tcx rustc::hir::Expr>::make_mirror
  16: <rustc_mir::build::GlobalizeMir<'a, 'gcx> as rustc::mir::visit::MutVisitor<'tcx>>::visit_substs
  17: <rustc_mir::monomorphize::collector::MonoItemCollectionMode as core::fmt::Debug>::fmt
  18: rustc_mir::build::mir_build
  19: rustc_mir::transform::mir_built
  20: 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
  21: rustc::ty::context::tls::track_diagnostic
  22: rustc::ty::context::tls::track_diagnostic
  23: rustc::dep_graph::graph::DepGraph::assert_ignored
  24: rustc::ty::context::tls::track_diagnostic
  25: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  26: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  27: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_built
  28: <rustc_mir::transform::check_unsafety::UnusedUnsafeVisitor<'a> as rustc::hir::intravisit::Visitor<'tcx>>::visit_block
  29: 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
  30: rustc::ty::context::tls::track_diagnostic
  31: rustc::ty::context::tls::track_diagnostic
  32: rustc::dep_graph::graph::DepGraph::assert_ignored
  33: rustc::ty::context::tls::track_diagnostic
  34: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  35: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  36: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::unsafety_check_result
  37: rustc_mir::transform::mir_const
  38: 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
  39: rustc::ty::context::tls::track_diagnostic
  40: rustc::ty::context::tls::track_diagnostic
  41: rustc::dep_graph::graph::DepGraph::assert_ignored
  42: rustc::ty::context::tls::track_diagnostic
  43: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  44: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  45: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_const
  46: rustc_mir::transform::qualify_consts::provide
  47: rustc::ty::context::tls::track_diagnostic
  48: rustc::ty::context::tls::track_diagnostic
  49: rustc::dep_graph::graph::DepGraph::assert_ignored
  50: rustc::ty::context::tls::track_diagnostic
  51: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  52: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  53: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_const_qualif
  54: rustc_mir::interpret::const_eval::const_eval_provider
  55: 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
  56: rustc::ty::context::tls::track_diagnostic
  57: rustc::ty::context::tls::track_diagnostic
  58: rustc::dep_graph::graph::DepGraph::assert_ignored
  59: rustc::ty::context::tls::track_diagnostic
  60: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  61: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  62: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_const
  63: rustc::ty::structural_impls::<impl rustc::ty::context::Lift<'tcx> for rustc::middle::const_val::ErrKind<'a>>::lift_to_tcx
  64: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  65: <rustc_typeck::check_unused::CollectExternCrateVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  66: <rustc_typeck::check_unused::CollectExternCrateVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  67: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::normalize_ty
  68: <rustc_typeck::check::autoderef::AutoderefKind as core::fmt::Debug>::fmt
  69: <rustc_typeck::collect::has_late_bound_regions::LateBoundRegionsDetector<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_lifetime
  70: <rustc_typeck::collect::has_late_bound_regions::LateBoundRegionsDetector<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_lifetime
  71: <unknown>
  72: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  73: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  74: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  75: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  76: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  77: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  78: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  79: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  80: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  81: <rustc_typeck::check::GatherLocalsVisitor<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_pat
  82: <rustc_typeck::collect::has_late_bound_regions::LateBoundRegionsDetector<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_lifetime
  83: <rustc_typeck::check_unused::CollectExternCrateVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  84: <rustc_typeck::coherence::unsafety::UnsafetyChecker<'cx, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_trait_item
  85: 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
  86: rustc::ty::context::tls::track_diagnostic
  87: rustc::ty::context::tls::track_diagnostic
  88: rustc::dep_graph::graph::DepGraph::assert_ignored
  89: rustc::ty::context::tls::track_diagnostic
  90: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  91: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  92: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  93: <rustc_typeck::check::Diverges as core::fmt::Debug>::fmt
  94: <rustc_typeck::coherence::unsafety::UnsafetyChecker<'cx, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_trait_item
  95: rustc::ty::context::tls::track_diagnostic
  96: rustc::ty::context::tls::track_diagnostic
  97: rustc::dep_graph::graph::DepGraph::assert_ignored
  98: rustc::ty::context::tls::track_diagnostic
  99: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
query stack during panic:
#0 [mir_built] processing `main::{{closure}}::{{constant}}`
#1 [unsafety_check_result] processing `main::{{closure}}::{{constant}}`
#2 [mir_const] processing `main::{{closure}}::{{constant}}`
#3 [mir_const_qualif] processing `main::{{closure}}::{{constant}}`
#4 [const_eval] const-evaluating `main::{{closure}}::{{constant}}`
#5 [typeck_tables_of] processing `main`
#6 [typeck_item_bodies] type-checking all item bodies
end of query stack
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.28.0-nightly (f28c7aef7 2018-06-19) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

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

This might be related to #50576, but has been resolved in #51070

@DutchGhost DutchGhost changed the title continue inside closure inside loop causes an ICE continue inside closure argument inside loop causes an ICE Jun 22, 2018
@DutchGhost DutchGhost changed the title continue inside closure argument inside loop causes an ICE continue inside closure argument inside loop causes an ICE: Invalid loop id for continue Jun 22, 2018
@estebank estebank added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html labels Jun 22, 2018
@varkor
Copy link
Member

varkor commented Jun 23, 2018

Also ICEs with a different error using break instead of continue.

Edit: oh, I see that's #51707.

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

3 participants