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

ICE when using pattern and lambda with disjoint_capture_drop_reorder #83176

Closed
dylni opened this issue Mar 16, 2021 · 7 comments · Fixed by #83364
Closed

ICE when using pattern and lambda with disjoint_capture_drop_reorder #83176

dylni opened this issue Mar 16, 2021 · 7 comments · Fixed by #83364
Assignees
Labels
A-closures Area: Closures (`|…| { … }`) 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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dylni
Copy link
Contributor

dylni commented Mar 16, 2021

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

@dylni dylni added C-bug Category: This is a bug. 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. labels Mar 16, 2021
@csmoe csmoe added the A-closures Area: Closures (`|…| { … }`) label Mar 16, 2021
@csmoe
Copy link
Member

csmoe commented Mar 16, 2021

cc @rust-lang/wg-rfc-2229

@arora-aman
Copy link
Member

arora-aman commented Mar 16, 2021

I dont have too much context on how type folding works, but my guess is we are calling fold sooner that we should.

I have added this to the project board for RFC 2229, I'll bring it up during our sync tomorrow.

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 17, 2021
@arora-aman
Copy link
Member

We want to use resolve_vars_if_possible instead of fold_with here.

@arora-aman
Copy link
Member

@rustbot assign

@rustbot
Copy link
Collaborator

rustbot commented Mar 19, 2021

Error: Parsing assign command in comment failed: ...'bot assign' | error: specify user to assign to at >| ''...

Please let @rust-lang/release know if you're having trouble with this bot.

@arora-aman
Copy link
Member

@rustbot claim

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 23, 2021
2229 migration: Don't try resolve regions before writeback

In the analysis use `resolve_vars_if_possible` instead of `fully_resolve`,
because we might not have performed regionck yet.

Fixes: rust-lang#83176

r? `@nikomatsakis`
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 23, 2021
2229 migration: Don't try resolve regions before writeback

In the analysis use `resolve_vars_if_possible` instead of `fully_resolve`,
because we might not have performed regionck yet.

Fixes: rust-lang#83176

r? `@nikomatsakis`
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 24, 2021
2229 migration: Don't try resolve regions before writeback

In the analysis use `resolve_vars_if_possible` instead of `fully_resolve`,
because we might not have performed regionck yet.

Fixes: rust-lang#83176

r? `@nikomatsakis`
@bors bors closed this as completed in 74d7731 Mar 24, 2021
@dylni
Copy link
Contributor Author

dylni commented Mar 28, 2021

Thanks @arora-aman!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`) 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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants