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

Internal compiler error with labeled break inside closure #62480

Closed
Undin opened this issue Jul 7, 2019 · 3 comments · Fixed by #65518 or #66535
Closed

Internal compiler error with labeled break inside closure #62480

Undin opened this issue Jul 7, 2019 · 3 comments · Fixed by #65518 or #66535
Labels
A-closures Area: closures (`|args| { .. }`) A-typesystem Area: The type system C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Undin
Copy link
Contributor

Undin commented Jul 7, 2019

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

@Centril Centril added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-typesystem Area: The type system A-closures Area: closures (`|args| { .. }`) P-medium Medium priority labels Jul 8, 2019
@Patryk27
Copy link
Contributor

Patryk27 commented Jul 8, 2019

Simplified, FWIW:

#![feature(label_break_value)]

fn main() {
    'a: {
        || break 'a
    }
}

@jonas-schievink
Copy link
Contributor

jonas-schievink commented Aug 24, 2019

Another instance: #63837

(the feature gate isn't needed to trigger this)

@JohnTitor
Copy link
Member

The original example is no longer ICE but the minified example is still ICE on the latest master (on my local). We should re-open this or file it as a new issue? CC: @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-typesystem Area: The type system C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
6 participants