Skip to content

Internal compiler error with labeled break inside closure #62480

Description

Toolchain version: rustc 1.38.0-nightly (dfd52ba 2019-07-06)

The following code produces internal compiler error

#![feature(label_break_value)]

fn main() {
    let a = 'a: {
        let a = |x: i32| break 'a;
        1
    };
}
backtrace

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:649:9
stack backtrace:
error: internal compiler error: src/librustc_typeck/check/mod.rs:509: could not find enclosing breakable with id HirId { owner: DefIndex(12), local_id: 9 }

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:649:9
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   1: std::panicking::default_hook
   2: rustc::util::common::panic_hook
   2: rustc::util::common::panic_hook
   3: std::panicking::rust_panic_with_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   4: std::panicking::begin_panic
   5: rustc_errors::Handler::bug
   5: rustc_errors::Handler::bug
   6: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   6: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   7: rustc::ty::context::tls::with_opt::{{closure}}
   7: rustc::ty::context::tls::with_opt::{{closure}}
   8: rustc::ty::context::tls::with_context_opt
   8: rustc::ty::context::tls::with_context_opt
   9: rustc::ty::context::tls::with_opt
   9: rustc::ty::context::tls::with_opt
  10: rustc::util::bug::opt_span_bug_fmt
  10: rustc::util::bug::opt_span_bug_fmt
  11: rustc::util::bug::bug_fmt
  11: rustc::util::bug::bug_fmt
  12: rustc_typeck::check::EnclosingBreakables::find_breakable::{{closure}}
  12: rustc_typeck::check::EnclosingBreakables::find_breakable::{{closure}}
  13: rustc_typeck::check::EnclosingBreakables::find_breakable
  13: rustc_typeck::check::EnclosingBreakables::find_breakable
  14: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  14: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  15: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  16: rustc_typeck::check::check_fn
  15: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  16: rustc_typeck::check::check_fn
  17: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt>::check_expr_closure
  17: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt>::check_expr_closure
  18: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  18: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  19: rustc_typeck::check::FnCtxt::check_decl_initializer
  19: rustc_typeck::check::FnCtxt::check_decl_initializer
  20: rustc_typeck::check::FnCtxt::check_decl_local
  21: rustc_typeck::check::FnCtxt::check_stmt
  20: rustc_typeck::check::FnCtxt::check_decl_local
  22: rustc_typeck::check::FnCtxt::check_block_with_expected
  21: rustc_typeck::check::FnCtxt::check_stmt
  22: rustc_typeck::check::FnCtxt::check_block_with_expected
  23: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  23: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  24: rustc_typeck::check::FnCtxt::check_decl_initializer
  24: rustc_typeck::check::FnCtxt::check_decl_initializer
  25: rustc_typeck::check::FnCtxt::check_decl_local
  25: rustc_typeck::check::FnCtxt::check_decl_local
  26: rustc_typeck::check::FnCtxt::check_stmt
  26: rustc_typeck::check::FnCtxt::check_stmt
  27: rustc_typeck::check::FnCtxt::check_block_with_expected
  27: rustc_typeck::check::FnCtxt::check_block_with_expected
  28: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  28: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  29: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  29: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  30: rustc_typeck::check::check_fn
  30: rustc_typeck::check::check_fn
  31: rustc::ty::context::GlobalCtxt::enter_local
  31: rustc::ty::context::GlobalCtxt::enter_local
  32: rustc_typeck::check::typeck_tables_of
  32: rustc_typeck::check::typeck_tables_of
  33: rustc::ty::query::__query_compute::typeck_tables_of
  33: rustc::ty::query::__query_compute::typeck_tables_of
  34: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  34: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  35: rustc::dep_graph::graph::DepGraph::with_task_impl
  35: rustc::dep_graph::graph::DepGraph::with_task_impl
  36: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  36: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  37: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  37: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  38: rustc_typeck::check::typeck_item_bodies
  38: rustc_typeck::check::typeck_item_bodies
  39: rustc::ty::query::__query_compute::typeck_item_bodies
  39: rustc::ty::query::__query_compute::typeck_item_bodies
  40: rustc::dep_graph::graph::DepGraph::with_task_impl
  40: rustc::dep_graph::graph::DepGraph::with_task_impl
  41: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  41: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  42: rustc::util::common::time
  42: rustc::util::common::time
  43: rustc_typeck::check_crate
  43: rustc_typeck::check_crate
  44: rustc_interface::passes::analysis
  44: rustc_interface::passes::analysis
  45: rustc::ty::query::__query_compute::analysis
  45: rustc::ty::query::__query_compute::analysis
  46: rustc::dep_graph::graph::DepGraph::with_task_impl
  46: rustc::dep_graph::graph::DepGraph::with_task_impl
  47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  48: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  48: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  49: rustc_interface::passes::create_global_ctxt::{{closure}}
  49: rustc_interface::passes::create_global_ctxt::{{closure}}
  50: rustc_interface::interface::run_compiler_in_existing_thread_pool
  50: rustc_interface::interface::run_compiler_in_existing_thread_pool
  51: std::thread::local::LocalKey<T>::with
  51: std::thread::local::LocalKey<T>::with
  52: scoped_tls::ScopedKey<T>::set
  53: syntax::with_globals
  52: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
  53: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
query stack during panic:
#0 [typeck_tables_of] processing `main`
#0 [typeck_tables_of] processing `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-closuresArea: Closures (`|…| { … }`)A-typesystemArea: The type systemC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium 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