Skip to content

ICE "no enclosing breakable scope found" when using continue with a label in a macro in a different loop inside an async block #73541

Closed

Description

I tried this code:

async fn c() {
    'a: loop {
        macro_rules! b {
            () => {
                continue 'a
            }
        }
        
        async {
            loop {
                b!();
            }
        };
        
    }
}

fn main() {
}

I expected to see this happen: Not an ICE.

Instead, this happened: an ICE

Meta

rustc --version --verbose:

rustc 1.44.1 (c7087fe00 2020-06-17)
binary: rustc
commit-hash: c7087fe00d2ba919df1d813c040a5d47e43b0fe7
commit-date: 2020-06-17
host: x86_64-apple-darwin
release: 1.44.1
LLVM version: 9.0

rustup run nightly rustc --version --verbose:

rustc 1.46.0-nightly (2d8bd9b74 2020-06-19)
binary: rustc
commit-hash: 2d8bd9b74dc0cf06d881bac645698ccbcf9d9c5e
commit-date: 2020-06-19
host: x86_64-apple-darwin
release: 1.46.0-nightly
LLVM version: 10.0

Backtrace:

error: internal compiler error: src/librustc_mir_build/build/scope.rs:313: no enclosing breakable scope found
  --> src/main.rs:6:17
   |
6  |                 continue 'a
   |                 ^^^^^^^^^^^
...
12 |                 b!();
   |                 ----- in this macro invocation
   |
   = note: this error: internal compiler error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at 'Box<Any>', /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libstd/macros.rs:13:23
stack backtrace:
   0:        0x1032099ff - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8ad47541fb823094
   1:        0x10324380e - core::fmt::write::he23e9bd6497f06c3
   2:        0x1031fa997 - std::io::Write::write_fmt::h91528f1131e6004e
   3:        0x10320e51a - std::panicking::default_hook::{{closure}}::h1983f014a45a477e
   4:        0x10320e25c - std::panicking::default_hook::hb0d9b93b5be8b120
   5:        0x105c03468 - rustc_driver::report_ice::h84533b6a88900192
   6:        0x10320ec35 - std::panicking::rust_panic_with_hook::h9f3faafe0983de5c
   7:        0x109b4a8f6 - std::panicking::begin_panic::hfcdd5302107a6956
   8:        0x1083b32f1 - rustc_errors::HandlerInner::span_bug::h26868a96db11bd44
   9:        0x1083b36e7 - rustc_errors::Handler::span_bug::h4dd69703227c775e
  10:        0x1083a16ce - rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}::h4fdbe899034202d7
  11:        0x10839fe86 - rustc_middle::ty::context::tls::with_opt::{{closure}}::hbc63bfd003e23afa
  12:        0x10839fe43 - rustc_middle::ty::context::tls::with_opt::h4cbaa9b33938f9a9
  13:        0x1083a15b8 - rustc_middle::util::bug::opt_span_bug_fmt::h3fe4e74d2dc9a85e
  14:        0x109b4644f - rustc_middle::util::bug::span_bug_fmt::hf05783165aa9c97b
  15:        0x1083a5603 - rustc_mir_build::build::scope::Scopes::find_breakable_scope::{{closure}}::{{closure}}::h9920291919ca053c
  16:        0x1083a5549 - rustc_mir_build::build::scope::Scopes::find_breakable_scope::h06b25b15841526d7
  17:        0x10840269f - rustc_mir_build::build::scope::<impl rustc_mir_build::build::Builder>::break_scope::hc240c2dc32428c0b
  18:        0x1083f37f3 - rustc_mir_build::build::expr::stmt::<impl rustc_mir_build::build::Builder>::stmt_expr::ha75df511f9cf7140
  19:        0x1083f458d - rustc_mir_build::build::expr::stmt::<impl rustc_mir_build::build::Builder>::stmt_expr::ha75df511f9cf7140
  20:        0x1083e1bd0 - rustc_mir_build::build::block::<impl rustc_mir_build::build::Builder>::ast_block_stmts::h42b869be645cdbb9
  21:        0x1083f029b - rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::into_expr::hbcfbbeb6e11c5f9a
  22:        0x1083ef2f5 - rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::into_expr::hbcfbbeb6e11c5f9a
  23:        0x1083ec007 - rustc_mir_build::build::expr::as_temp::<impl rustc_mir_build::build::Builder>::expr_as_temp::h97acc754983adf0c
  24:        0x1083efc87 - rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::into_expr::hbcfbbeb6e11c5f9a
  25:        0x1083f0996 - rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::into_expr::hbcfbbeb6e11c5f9a
  26:        0x1083e335b - rustc_mir_build::build::block::<impl rustc_mir_build::build::Builder>::ast_block_stmts::h42b869be645cdbb9
  27:        0x1083f029b - rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::into_expr::hbcfbbeb6e11c5f9a
  28:        0x1083f0996 - rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::into_expr::hbcfbbeb6e11c5f9a
  29:        0x1083f0996 - rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::into_expr::hbcfbbeb6e11c5f9a
  30:        0x1083df1f0 - rustc_mir_build::build::construct_fn::h5d4896ab7b7c9d03
  31:        0x108414d7e - rustc_infer::infer::InferCtxtBuilder::enter::h46eb56ca1a74cb21
  32:        0x1083de119 - rustc_mir_build::build::mir_built::h5730dcfec65d99b1
  33:        0x1084c1e13 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_built>::compute::hab196b19f500fe30
  34:        0x108488a59 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::hec6c009d5c4b63ff
  35:        0x1085cf648 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h28b12b97aad90304
  36:        0x1084c8216 - rustc_query_system::query::plumbing::get_query::h01c86b7ceed3cdaa
  37:        0x108895e0e - rustc_mir::transform::check_unsafety::unsafety_check_result::hc7d9ccb792951fee
  38:        0x1084c3cdb - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::unsafety_check_result>::compute::hb1093880013afb2e
  39:        0x108486494 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h7018d7cd3f9f416a
  40:        0x1085cff83 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h361b1acad55cb699
  41:        0x1084d9155 - rustc_query_system::query::plumbing::get_query::h2d65628973e005cf
  42:        0x1088949a5 - <rustc_mir::transform::check_unsafety::UnsafetyChecker as rustc_middle::mir::visit::Visitor>::visit_rvalue::h98debe5df30a2217
  43:        0x1088946c7 - <rustc_mir::transform::check_unsafety::UnsafetyChecker as rustc_middle::mir::visit::Visitor>::visit_statement::hfa76a4fbfec9fc7b
  44:        0x1088961a0 - rustc_mir::transform::check_unsafety::unsafety_check_result::hc7d9ccb792951fee
  45:        0x1084c3cdb - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::unsafety_check_result>::compute::hb1093880013afb2e
  46:        0x108486494 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h7018d7cd3f9f416a
  47:        0x1085cff83 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h361b1acad55cb699
  48:        0x1084d9155 - rustc_query_system::query::plumbing::get_query::h2d65628973e005cf
  49:        0x1088949a5 - <rustc_mir::transform::check_unsafety::UnsafetyChecker as rustc_middle::mir::visit::Visitor>::visit_rvalue::h98debe5df30a2217
  50:        0x1088946c7 - <rustc_mir::transform::check_unsafety::UnsafetyChecker as rustc_middle::mir::visit::Visitor>::visit_statement::hfa76a4fbfec9fc7b
  51:        0x1088961a0 - rustc_mir::transform::check_unsafety::unsafety_check_result::hc7d9ccb792951fee
  52:        0x1084c3cdb - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::unsafety_check_result>::compute::hb1093880013afb2e
  53:        0x108486494 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h7018d7cd3f9f416a
  54:        0x1085cff83 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h361b1acad55cb699
  55:        0x1084d9155 - rustc_query_system::query::plumbing::get_query::h2d65628973e005cf
  56:        0x1087ee637 - rustc_mir::transform::mir_const::hca8f8c5c296f20f4
  57:        0x1084c1ed3 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_const>::compute::hddcc70cb64119613
  58:        0x108488a59 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::hec6c009d5c4b63ff
  59:        0x1085d73f8 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hbd42bf632b920f4b
  60:        0x108513336 - rustc_query_system::query::plumbing::get_query::he5783e1f7096502e
  61:        0x1087ee8e3 - rustc_mir::transform::mir_validated::h226903a865d94253
  62:        0x1084c2693 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_validated>::compute::h436bdbaf3a948029
  63:        0x10848c189 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::hfa6bb2ac42dff0b5
  64:        0x1085d85a1 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hc3c10f1ff15f0c48
  65:        0x108509a1d - rustc_query_system::query::plumbing::get_query::hbaf892ec736da24f
  66:        0x10888a435 - rustc_mir::borrow_check::mir_borrowck::h831eb004cb4b6ea8
  67:        0x1080a64c3 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute::h02106bdea03c2bb7
  68:        0x10812ef6d - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::hb707c7436aa298fa
  69:        0x107f700d8 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hc8ad4f14cd4e9788
  70:        0x1080d54b0 - rustc_query_system::query::plumbing::get_query::h80ad8b6a56aead75
  71:        0x107f89092 - rustc_typeck::collect::type_of::type_of::hd567d98bc4492704
  72:        0x109391cad - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::ha8f14d32cae32e98
  73:        0x10955e8a6 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hddb8e9930de3c246
  74:        0x1096ba97c - rustc_query_system::query::plumbing::get_query::h2e9b8410d0cc4e36
  75:        0x1093bad94 - rustc_middle::ty::util::<impl rustc_middle::ty::context::TyCtxt>::try_expand_impl_trait_type::OpaqueTypeExpander::expand_opaque_ty::ha07b959d94c7c909
  76:        0x1093baa5c - rustc_middle::ty::util::<impl rustc_middle::ty::context::TyCtxt>::try_expand_impl_trait_type::heaf17b0f0fefd7fe
  77:        0x107f2fafc - rustc_typeck::check::check_item_type::hbe8b3faae3aee04a
  78:        0x107faa3dc - rustc_middle::hir::map::Map::visit_item_likes_in_module::h26f611113e377977
  79:        0x107f2b7ed - rustc_typeck::check::check_mod_item_types::hc6f8bce828504167
  80:        0x1080a7893 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_mod_item_types>::compute::h57566dd45551ccb1
  81:        0x10812660c - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h1007299e44c918a3
  82:        0x107f72dc5 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::he6e900c0c1d302ed
  83:        0x10810430e - rustc_query_system::query::plumbing::get_query::hf87e1ec783ea8bd6
  84:        0x1080a967f - rustc_query_system::query::plumbing::ensure_query::hf9eacaeb7017b25e
  85:        0x108053694 - rustc_typeck::check_crate::ha4a8d5daf03e4a99
  86:        0x105f0649a - rustc_interface::passes::analysis::h9b092de259214855
  87:        0x105c17eaa - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute::h75f206b40aba29be
  88:        0x105d58b94 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::ha921b3c75d411a61
  89:        0x105d48f25 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hb41faff2a249d29e
  90:        0x105c19a19 - rustc_query_system::query::plumbing::get_query::hcb8e878a74426463
  91:        0x105d8375c - rustc_middle::ty::context::tls::enter_global::h4aaa6da9cc7f2706
  92:        0x105d5b461 - rustc_interface::interface::run_compiler_in_existing_thread_pool::hd829e895df89177a
  93:        0x105c0bbd9 - scoped_tls::ScopedKey<T>::set::h6f8ab04b28c4ee8b
  94:        0x105c089f5 - rustc_ast::attr::with_globals::h060f2af0de393ae8
  95:        0x105c10bf7 - std::sys_common::backtrace::__rust_begin_short_backtrace::h64c714e2f59a2735
  96:        0x105d5dd5c - core::ops::function::FnOnce::call_once{{vtable.shim}}::h4c8339bc7eb21f00
  97:        0x10321d26d - std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7
  98:     0x7fff730fd109 - _ZL12preoptimized

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.44.1 (c7087fe00 2020-06-17) running on x86_64-apple-darwin

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

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

query stack during panic:
#0 [mir_built] building MIR for
#1 [unsafety_check_result] unsafety-checking `c::{{closure}}#0::{{closure}}#0`
#2 [unsafety_check_result] unsafety-checking `c::{{closure}}#0`
#3 [unsafety_check_result] unsafety-checking `c`
#4 [mir_const] processing `c`
#5 [mir_validated] processing `c`
#6 [mir_borrowck] borrow-checking `c`
#7 [type_of] processing `c::{{opaque}}#0`
#8 [check_mod_item_types] checking item types in top-level module
#9 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions