Skip to content

ICE when using pattern and lambda with disjoint_capture_drop_reorder #83176

Closed
@dylni

Description

@dylni

Code

#![warn(disjoint_capture_drop_reorder)]

fn main() {
    if let a = "" {
        drop(|_: ()| drop(a));
    }
}

Removing #![warn(disjoint_capture_drop_reorder)] allows the code to compile successfully.

Playground

https://play.rust-lang.org/?version=beta&mode=debug&edition=2018&gist=cbe7225341877de0871eeb20f5fef3af

Meta

rustc --version --verbose:

rustc 1.51.0-beta.6 (6a1835ad7 2021-03-12)
binary: rustc
commit-hash: 6a1835ad74247c069b0d24703c8267818487d7f5
commit-date: 2021-03-12
host: x86_64-unknown-linux-gnu
release: 1.51.0-beta.6
LLVM version: 11.0.1

Error output

thread 'rustc' panicked at 'region resolution not performed', compiler/rustc_infer/src/infer/resolve.rs:221:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.51.0-beta.6 (6a1835ad7 2021-03-12) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [typeck] type-checking `main`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: could not compile `playground`

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

stack backtrace:
   0: rust_begin_unwind
             at /rustc/6a1835ad74247c069b0d24703c8267818487d7f5/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/6a1835ad74247c069b0d24703c8267818487d7f5/library/core/src/panicking.rs:92:14
   2: core::option::expect_failed
             at /rustc/6a1835ad74247c069b0d24703c8267818487d7f5/library/core/src/option.rs:1292:5
   3: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
   4: <rustc_infer::infer::resolve::FullTypeResolver as rustc_middle::ty::fold::TypeFolder>::fold_ty
   5: <rustc_typeck::check::writeback::Resolver as rustc_middle::ty::fold::TypeFolder>::fold_ty
   6: rustc_typeck::check::upvar::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::compute_2229_migrations_first_pass::resolve_ty
   7: rustc_typeck::check::upvar::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::analyze_closure
   8: rustc_hir::intravisit::walk_expr
   9: rustc_hir::intravisit::walk_stmt
  10: rustc_hir::intravisit::walk_block
  11: rustc_hir::intravisit::walk_arm
  12: rustc_hir::intravisit::walk_expr
  13: rustc_hir::intravisit::walk_block
  14: <rustc_typeck::check::upvar::InferBorrowKindVisitor as rustc_hir::intravisit::Visitor>::visit_expr
  15: rustc_infer::infer::InferCtxtBuilder::enter
  16: rustc_typeck::check::typeck
  17: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute
  18: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  19: rustc_data_structures::stack::ensure_sufficient_stack
  20: rustc_query_system::query::plumbing::force_query_with_job
  21: rustc_query_system::query::plumbing::get_query_impl
  22: rustc_query_system::query::plumbing::ensure_query_impl
  23: rustc_typeck::check::typeck_item_bodies
  24: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
  25: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  26: rustc_data_structures::stack::ensure_sufficient_stack
  27: rustc_query_system::query::plumbing::force_query_with_job
  28: rustc_query_system::query::plumbing::get_query_impl
  29: rustc_typeck::check_crate
  30: rustc_interface::passes::analysis
  31: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  32: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  33: rustc_data_structures::stack::ensure_sufficient_stack
  34: rustc_query_system::query::plumbing::force_query_with_job
  35: rustc_query_system::query::plumbing::get_query_impl
  36: rustc_interface::passes::QueryContext::enter
  37: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  38: rustc_span::with_source_map
  39: rustc_interface::interface::create_compiler_and_run
  40: rustc_span::with_session_globals

Metadata

Metadata

Assignees

Labels

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