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: variable should be placed in scope earlier #78115

Closed
attente opened this issue Oct 19, 2020 · 6 comments · Fixed by #78121
Closed

ICE: variable should be placed in scope earlier #78115

attente opened this issue Oct 19, 2020 · 6 comments · Fixed by #78121
Assignees
Labels
A-async-await Area: Async & Await A-coroutines Area: Coroutines C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@attente
Copy link

attente commented Oct 19, 2020

Code

From #78115 (comment):

fn main() {
    async {
        match foo {
            Foo { a } | Foo { a } if true => {}
        }
    }
}

Meta

It fails at version:

rustc 1.49.0-nightly (adef9da30 2020-10-13)
binary: rustc
commit-hash: adef9da30f1ecbfeb81312d01ed94ac53f7161ba
commit-date: 2020-10-13
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
LLVM version: 11.0

It worked before at version:

rustc 1.49.0-nightly (8dae8cdcc 2020-10-12)
binary: rustc
commit-hash: 8dae8cdcc8fa879cea6a4bbbfa5b32e97be4c306
commit-date: 2020-10-12
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
LLVM version: 11.0

Error output

thread 'rustc' panicked at 'variable should be placed in scope earlier', compiler/rustc_typeck/src/check/generator_interior.rs:253:17
Backtrace

thread 'rustc' panicked at 'variable should be placed in scope earlier', compiler/rustc_typeck/src/check/generator_interior.rs:253:17
stack backtrace:
   0:     0x7f4d75a73410 - std::backtrace_rs::backtrace::libunwind::trace::h622bab51c72c4e69
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/std/src/../../backtrace/src/backtrace/libunwind.rs:100:5
   1:     0x7f4d75a73410 - std::backtrace_rs::backtrace::trace_unsynchronized::h7e820b882ebd41ee
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f4d75a73410 - std::sys_common::backtrace::_print_fmt::h64d46258114db92f
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/std/src/sys_common/backtrace.rs:79:5
   3:     0x7f4d75a73410 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h47111d0c1b5f0da5
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/std/src/sys_common/backtrace.rs:58:22
   4:     0x7f4d75ae1dfc - core::fmt::write::h1857a60b204f1b6a
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/core/src/fmt/mod.rs:1076:17
   5:     0x7f4d75a65222 - std::io::Write::write_fmt::h4604516fed3e5731
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/std/src/io/mod.rs:1516:15
   6:     0x7f4d75a7820d - std::sys_common::backtrace::_print::h785e7a78d5ef272c
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/std/src/sys_common/backtrace.rs:61:5
   7:     0x7f4d75a7820d - std::sys_common::backtrace::print::h108047ac5c4555d5
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/std/src/sys_common/backtrace.rs:48:9
   8:     0x7f4d75a7820d - std::panicking::default_hook::{{closure}}::h1d0c271f0d087ebf
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/std/src/panicking.rs:208:50
   9:     0x7f4d75a77eb8 - std::panicking::default_hook::h692753e26f11b7b7
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/std/src/panicking.rs:227:9
  10:     0x7f4d76373788 - rustc_driver::report_ice::h94e1b9f0f92bafae
  11:     0x7f4d632fd346 - <alloc::boxed::Box<F> as core::ops::function::Fn<A>>::call::hf18d60de8bdf947c
                               at /nix/store/f3vnjjsamvv7y08favd91v5b49rrdh7j-rust-1.49.0-nightly-2020-10-13-adef9da30/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1056:9
  12:     0x7f4d6337362b - proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}::{{closure}}::h04750261f92a2f76
                               at /nix/store/f3vnjjsamvv7y08favd91v5b49rrdh7j-rust-1.49.0-nightly-2020-10-13-adef9da30/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:320:21
  13:     0x7f4d75a78a56 - std::panicking::rust_panic_with_hook::h74ddc20305301cd9
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/std/src/panicking.rs:581:17
  14:     0x7f4d77054d74 - std::panicking::begin_panic::{{closure}}::h4a2658fa82966a9a
  15:     0x7f4d77054d4c - std::sys_common::backtrace::__rust_end_short_backtrace::hed4d41b3585d3722
  16:     0x7f4d77028bec - std::panicking::begin_panic::h95fdecc40cfa9239
  17:     0x7f4d77071857 - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_arm::h94b7f6b234a9b274
  18:     0x7f4d76fdd75d - rustc_hir::intravisit::walk_expr::hd498cca018a87b6a
  19:     0x7f4d77071bdc - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h32f763fae026a435
  20:     0x7f4d77071bdc - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h32f763fae026a435
  21:     0x7f4d77071bdc - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h32f763fae026a435
  22:     0x7f4d7707182d - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_arm::h94b7f6b234a9b274
  23:     0x7f4d76fdd75d - rustc_hir::intravisit::walk_expr::hd498cca018a87b6a
  24:     0x7f4d77071bdc - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h32f763fae026a435
  25:     0x7f4d7707182d - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_arm::h94b7f6b234a9b274
  26:     0x7f4d76fdd75d - rustc_hir::intravisit::walk_expr::hd498cca018a87b6a
  27:     0x7f4d77071bdc - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h32f763fae026a435
  28:     0x7f4d7707182d - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_arm::h94b7f6b234a9b274
  29:     0x7f4d76fdd75d - rustc_hir::intravisit::walk_expr::hd498cca018a87b6a
  30:     0x7f4d77071bdc - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h32f763fae026a435
  31:     0x7f4d77071bdc - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h32f763fae026a435
  32:     0x7f4d76fbd2ba - rustc_hir::intravisit::walk_block::hc189e1162b2ae4e8
  33:     0x7f4d77071bdc - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h32f763fae026a435
  34:     0x7f4d7707182d - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_arm::h94b7f6b234a9b274
  35:     0x7f4d76fdd75d - rustc_hir::intravisit::walk_expr::hd498cca018a87b6a
  36:     0x7f4d77071bdc - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h32f763fae026a435
  37:     0x7f4d76fbd28a - rustc_hir::intravisit::walk_block::hc189e1162b2ae4e8
  38:     0x7f4d77071bdc - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h32f763fae026a435
  39:     0x7f4d77071bdc - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h32f763fae026a435
  40:     0x7f4d77071bdc - <rustc_typeck::check::generator_interior::InteriorVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h32f763fae026a435
  41:     0x7f4d77070bac - rustc_typeck::check::generator_interior::resolve_interior::h9f6503f796e4811d
  42:     0x7f4d76e1df4d - rustc_typeck::check::fn_ctxt::FnCtxt::resolve_generator_interiors::h47b7925cdb3a4a76
  43:     0x7f4d770b6755 - rustc_infer::infer::InferCtxtBuilder::enter::hb26652f4cc0a3585
  44:     0x7f4d77160ead - rustc_typeck::check::typeck::hfc75fba7d10c080a
  45:     0x7f4d791c02f8 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h625c205064841b32
  46:     0x7f4d79300a52 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hd5d7e4be807854ff
  47:     0x7f4d78ee3eb4 - rustc_data_structures::stack::ensure_sufficient_stack::hf0717cfa324b58a6
  48:     0x7f4d78ce3012 - rustc_query_system::query::plumbing::get_query_impl::hda910c4b131c45f9
  49:     0x7f4d78faf977 - rustc_middle::ty::context::TyCtxt::typeck_opt_const_arg::h4499a05eb9ea36c5
  50:     0x7f4d77630088 - rustc_mir_build::thir::cx::Cx::new::h74b89b479cffd7fd
  51:     0x7f4d775f3f48 - rustc_infer::infer::InferCtxtBuilder::enter::h5f228aaae7bfc457
  52:     0x7f4d77530d63 - rustc_mir_build::build::mir_built::h614ae3973841342e
  53:     0x7f4d77ba5df1 - 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::hffb2094c003bb703
  54:     0x7f4d779dbf95 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h9c20e3f215a95c0b
  55:     0x7f4d77a4be83 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h48d83b53377cf2a4
  56:     0x7f4d776bd541 - rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}::h7c679e4ccd6303cb
  57:     0x7f4d77891fb4 - rustc_query_system::query::plumbing::get_query_impl::h6e6e1ee3c4581973
  58:     0x7f4d77bdd72f - rustc_mir::transform::check_unsafety::unsafety_check_result::hcfe9711888c89ead
  59:     0x7f4d77bb8bc5 - core::ops::function::FnOnce::call_once::hd09548458b941eee
  60:     0x7f4d77ba6bce - 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::h78ac1dfa46e35df8
  61:     0x7f4d779dd6f8 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::hb896adda9b6da41d
  62:     0x7f4d77a4769a - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h25d1ae9814596de3
  63:     0x7f4d776d0e71 - rustc_data_structures::stack::ensure_sufficient_stack::hd7bf926590dab0d9
  64:     0x7f4d778a4c82 - rustc_query_system::query::plumbing::get_query_impl::h853be6621a53bed1
  65:     0x7f4d778e45bd - rustc_query_system::query::plumbing::ensure_query_impl::h4f7ad11f1945d0eb
  66:     0x7f4d77beceeb - rustc_mir::transform::mir_const::h6c08547191de2aa8
  67:     0x7f4d77ba5ed1 - 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::h73d5e54d168e9c7b
  68:     0x7f4d779dbf95 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h9c20e3f215a95c0b
  69:     0x7f4d77a4be83 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h48d83b53377cf2a4
  70:     0x7f4d776bd541 - rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}::h7c679e4ccd6303cb
  71:     0x7f4d77891fb4 - rustc_query_system::query::plumbing::get_query_impl::h6e6e1ee3c4581973
  72:     0x7f4d77bed40e - rustc_mir::transform::mir_promoted::h0cc79eee2baede78
  73:     0x7f4d77bfbc31 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_promoted>::compute::hf07dfd62fa1bd93f
  74:     0x7f4d779dde25 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::hc0db1d632bfd9822
  75:     0x7f4d77a46a4b - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h15a7ad4cc0a88ac4
  76:     0x7f4d776c4c97 - rustc_data_structures::stack::ensure_sufficient_stack::h0d2458483a76bfbe
  77:     0x7f4d778ab887 - rustc_query_system::query::plumbing::get_query_impl::h8833547dbc0131af
  78:     0x7f4d77c30394 - rustc_mir::borrow_check::mir_borrowck::h6bb2526a5224ac7b
  79:     0x7f4d77c01d55 - core::ops::function::FnOnce::call_once::ha0fc52f24667e21d
  80:     0x7f4d77138dfe - 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::heea38576bc2d13e0
  81:     0x7f4d76f2b3c8 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::he5acd848f9358a3c
  82:     0x7f4d770037da - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h2abd60179f78c7f2
  83:     0x7f4d7701c611 - rustc_data_structures::stack::ensure_sufficient_stack::h2de0022b5b01d4a4
  84:     0x7f4d76ebbe52 - rustc_query_system::query::plumbing::get_query_impl::hba937082ff871197
  85:     0x7f4d77167be4 - rustc_typeck::collect::type_of::type_of::h74383c484653622d
  86:     0x7f4d76f1fecf - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::type_of>::compute::hfd79d1381924d3f3
  87:     0x7f4d76f27e21 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h623ab536fd446e13
  88:     0x7f4d77002b5f - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h26a5d8549648a6c6
  89:     0x7f4d7701f611 - rustc_data_structures::stack::ensure_sufficient_stack::h61e1796ea93702d9
  90:     0x7f4d76e80f3c - rustc_query_system::query::plumbing::get_query_impl::h558e4dad03e07b80
  91:     0x7f4d76f4213c - rustc_typeck::check::check::check_item_type::h98773239642c80eb
  92:     0x7f4d76ff45f9 - rustc_middle::hir::map::Map::visit_item_likes_in_module::h3b0059be633bc701
  93:     0x7f4d76f4644d - rustc_typeck::check::check::check_mod_item_types::h05209c564fff9b9f
  94:     0x7f4d76ff066e - 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::h688ec518ca5b3446
  95:     0x7f4d76f27736 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h5c9d5e4e9891623e
  96:     0x7f4d77009f07 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h763820e87aeb42a6
  97:     0x7f4d77026584 - rustc_data_structures::stack::ensure_sufficient_stack::hd02e3960b4765973
  98:     0x7f4d76ed47fa - rustc_query_system::query::plumbing::get_query_impl::hd692e841feec859b
  99:     0x7f4d76ee4fee - rustc_query_system::query::plumbing::ensure_query_impl::hfd8292610205e5d4
 100:     0x7f4d76ff6c82 - rustc_session::utils::<impl rustc_session::session::Session>::time::hf8479066877269ae
 101:     0x7f4d77079850 - rustc_typeck::check_crate::hfa26513dd6ccd57c
 102:     0x7f4d765cea4f - rustc_interface::passes::analysis::h0de92c2792188299
 103:     0x7f4d763c08b2 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute::h00d2ec9ff8460c2c
 104:     0x7f4d763022d8 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::hb4079a860e34ece0
 105:     0x7f4d76380f67 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hc5cfe7a3bcd09e8e
 106:     0x7f4d76397a70 - rustc_data_structures::stack::ensure_sufficient_stack::h1e73fd3769ac2d2b
 107:     0x7f4d76331e21 - rustc_query_system::query::plumbing::get_query_impl::h7845c9072f9f47fa
 108:     0x7f4d763c371f - rustc_interface::passes::QueryContext::enter::hf289a5ab7388ed19
 109:     0x7f4d76394c82 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h75641ba8f2c3ef50
 110:     0x7f4d76377c67 - rustc_span::with_source_map::h62a26cc1f538b576
 111:     0x7f4d763903f1 - scoped_tls::ScopedKey<T>::set::h851e47b28a99a947
 112:     0x7f4d76399015 - std::sys_common::backtrace::__rust_begin_short_backtrace::hcc10758615a842a8
 113:     0x7f4d7631f9de - core::ops::function::FnOnce::call_once{{vtable.shim}}::hdee37546948bd4b7
 114:     0x7f4d75a8786a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h588ce842808b3fd0
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/alloc/src/boxed.rs:1042:9
 115:     0x7f4d75a8786a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h46bc655f05471a92
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/alloc/src/boxed.rs:1042:9
 116:     0x7f4d75a8786a - std::sys::unix::thread::Thread::new::thread_start::hb4b79d379b730058
                               at /rustc/adef9da30f1ecbfeb81312d01ed94ac53f7161ba/library/std/src/sys/unix/thread.rs:87:17
 117:     0x7f4d759c5ead - start_thread
 118:     0x7f4d758e5d2f - __clone
 119:                0x0 - <unknown>

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.49.0-nightly (adef9da30 2020-10-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
#0 [typeck] type-checking `player_action::run_player_action`
#1 [mir_built] building MIR for `player_action::run_player_action`
#2 [unsafety_check_result] unsafety-checking `player_action::run_player_action`
#3 [mir_const] processing MIR for `player_action::run_player_action`
#4 [mir_promoted] processing `player_action::run_player_action`
#5 [mir_borrowck] borrow-checking `player_action::run_player_action`
#6 [type_of] computing type of `player_action::run_player_action::{opaque#0}`
#7 [check_mod_item_types] checking item types in module `player_action`
#8 [analysis] running analysis passes on this crate
end of query stack

@attente attente 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 Oct 19, 2020
@jonas-schievink jonas-schievink added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example A-coroutines Area: Coroutines labels Oct 19, 2020
@attente
Copy link
Author

attente commented Oct 19, 2020

Sorry there's no code, but I've narrowed it to somewhere between 8dae8cd (working) and adef9da (broken).

@jonas-schievink
Copy link
Contributor

Likely cause: #75213

cc @dingxiangfei2009 @tmandry

@arilotter
Copy link

arilotter commented Oct 19, 2020

MCVE:

fn main() {
    async {
        match foo {
            Foo { a } | Foo { a } if true => {}
        }
    }
}

The ICE occurs (inside async blocks or functions) if you're using a match guard and binding the same variable name in both sides of an "or" in a match pattern.

@jonas-schievink jonas-schievink added A-async-await Area: Async & Await regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Oct 19, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 19, 2020
@LeSeulArtichaut
Copy link
Contributor

cargo-bisect-rustc finds a regression in adef9da which does correspond to #75213

@LeSeulArtichaut LeSeulArtichaut added P-critical Critical priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Oct 19, 2020
@LeSeulArtichaut
Copy link
Contributor

Assigning P-critical as discussed as part of the Prioritization WG procedure.

@JohnTitor JohnTitor removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Oct 19, 2020
@LeSeulArtichaut
Copy link
Contributor

This ICE is caused here:

if let PatKind::Binding(_, id, ..) = pat.kind {
self.guard_bindings.push(id);
self.guard_bindings_set.insert(id);
}

According to the docs:

The HirId is the canonical ID for the variable being bound, (e.g., in Ok(x) | Err(x), both x use the same canonical ID), which is the pattern ID of the first x.

As we're using a set and a vec in parallel, the ID is pushed twice but stored "only once". Then, we remove it once, and it still exists in the vec but not in the set:

for var_id in scope_var_ids.drain(..) {
assert!(
self.guard_bindings_set.remove(&var_id),
"variable should be placed in scope earlier"
);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-coroutines Area: Coroutines C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. 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.

6 participants