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: None in compiler/rustc_mir_build/src/build/matches/mod.rs #119786

Open
matthiaskrgr opened this issue Jan 9, 2024 · 11 comments
Open

ICE: None in compiler/rustc_mir_build/src/build/matches/mod.rs #119786

matthiaskrgr opened this issue Jan 9, 2024 · 11 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

snippet:

fn enum_upvar() {
    type T = impl Copy;
    let foo: T = Some((1u32, 2u32));
    let x = move || {
        match foo {
            None => (),
            Some(yield) => (),
        }
    };
}

Version information

rustc 1.77.0-nightly (ae9d24de8 2024-01-09)
binary: rustc
commit-hash: ae9d24de80b00b4158d1a29a212a6b02aeda0e75
commit-date: 2024-01-09
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2021

Program output

error: expected identifier, found reserved keyword `yield`
 --> /tmp/icemaker_global_tempdir.x6UZht6u4SjU/rustc_testrunner_tmpdir_reporting.JA7y372p2elJ/mvce.rs:7:18
  |
7 |             Some(yield) => (),
  |                  ^^^^^ expected identifier, found reserved keyword
  |
help: escape `yield` to use it as an identifier
  |
7 |             Some(r#yield) => (),
  |                  ++

error[E0658]: `impl Trait` in type aliases is unstable
 --> /tmp/icemaker_global_tempdir.x6UZht6u4SjU/rustc_testrunner_tmpdir_reporting.JA7y372p2elJ/mvce.rs:2:14
  |
2 |     type T = impl Copy;
  |              ^^^^^^^^^
  |
  = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
  = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.x6UZht6u4SjU/rustc_testrunner_tmpdir_reporting.JA7y372p2elJ/mvce.rs:10:2
   |
10 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.x6UZht6u4SjU/rustc_testrunner_tmpdir_reporting.JA7y372p2elJ/mvce.rs`

warning: unused variable: `x`
 --> /tmp/icemaker_global_tempdir.x6UZht6u4SjU/rustc_testrunner_tmpdir_reporting.JA7y372p2elJ/mvce.rs:4:9
  |
4 |     let x = move || {
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

thread 'rustc' panicked at compiler/rustc_mir_build/src/build/expr/as_place.rs:253:31:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7f3a2358c7e6 - std::backtrace_rs::backtrace::libunwind::trace::h5bb3bcbd9bf843dc
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f3a2358c7e6 - std::backtrace_rs::backtrace::trace_unsynchronized::h2be7c62a2fc2f0ae
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f3a2358c7e6 - std::sys_common::backtrace::_print_fmt::h0eb797837574729c
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f3a2358c7e6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9cfb89fe3b10d684
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f3a235deed0 - core::fmt::rt::Argument::fmt::h05c1336e950869a8
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/core/src/fmt/rt.rs:142:9
   5:     0x7f3a235deed0 - core::fmt::write::hf9ed93bf0be8a0ba
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f3a2358014f - std::io::Write::write_fmt::h575af11d100da1a8
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/std/src/io/mod.rs:1810:15
   7:     0x7f3a2358c5c4 - std::sys_common::backtrace::_print::h4efb82e5b25d472e
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f3a2358c5c4 - std::sys_common::backtrace::print::h6788dd5df6617703
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f3a2358f357 - std::panicking::default_hook::{{closure}}::hfa58db406ef5c661
  10:     0x7f3a2358f0b9 - std::panicking::default_hook::h60a66ef279ae47ef
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/std/src/panicking.rs:292:9
  11:     0x7f3a2635c9bc - std[6b9fb5ba93d727e9]::panicking::update_hook::<alloc[30b92f95685fae2c]::boxed::Box<rustc_driver_impl[54e7dbd11c712533]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f3a2358faa6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h37eedb2cb21c4dfc
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/alloc/src/boxed.rs:2030:9
  13:     0x7f3a2358faa6 - std::panicking::rust_panic_with_hook::hbea871998462fd45
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/std/src/panicking.rs:785:13
  14:     0x7f3a2358f7b9 - std::panicking::begin_panic_handler::{{closure}}::h45ad8d6a57ea4023
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/std/src/panicking.rs:651:13
  15:     0x7f3a2358cce6 - std::sys_common::backtrace::__rust_end_short_backtrace::h6e4a62ed56190aa9
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f3a2358f550 - rust_begin_unwind
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/std/src/panicking.rs:647:5
  17:     0x7f3a235db5d5 - core::panicking::panic_fmt::hfc52fd0216040145
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/core/src/panicking.rs:72:14
  18:     0x7f3a235db693 - core::panicking::panic::h37bd7f6a16f3c553
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/core/src/panicking.rs:144:5
  19:     0x7f3a2802fef5 - <rustc_mir_build[a392e445574d452]::build::Builder>::match_simplified_candidates
  20:     0x7f3a27b0f562 - <rustc_mir_build[a392e445574d452]::build::Builder>::lower_match_tree
  21:     0x7f3a27fbb5c1 - <rustc_mir_build[a392e445574d452]::build::Builder>::match_expr
  22:     0x7f3a27b06905 - <rustc_mir_build[a392e445574d452]::build::Builder>::expr_into_dest
  23:     0x7f3a27b06d05 - <rustc_mir_build[a392e445574d452]::build::Builder>::expr_into_dest
  24:     0x7f3a249a92dd - <rustc_mir_build[a392e445574d452]::build::Builder>::ast_block_stmts
  25:     0x7f3a27b05ca3 - <rustc_mir_build[a392e445574d452]::build::Builder>::expr_into_dest
  26:     0x7f3a27b06d05 - <rustc_mir_build[a392e445574d452]::build::Builder>::expr_into_dest
  27:     0x7f3a27dfe87e - rustc_mir_build[a392e445574d452]::build::mir_build::{closure#0}
  28:     0x7f3a27b019b0 - rustc_mir_build[a392e445574d452]::build::mir_built
  29:     0x7f3a27b01633 - rustc_query_impl[aafdc9ab48500bbf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aafdc9ab48500bbf]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>
  30:     0x7f3a27affd39 - rustc_query_system[5609ae2ca0b8284d]::query::plumbing::try_execute_query::<rustc_query_impl[aafdc9ab48500bbf]::DynamicConfig<rustc_query_system[5609ae2ca0b8284d]::query::caches::VecCache<rustc_span[79961d1f3d44db5f]::def_id::LocalDefId, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[aafdc9ab48500bbf]::plumbing::QueryCtxt, false>
  31:     0x7f3a27aff910 - rustc_query_impl[aafdc9ab48500bbf]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7f3a27732b30 - rustc_mir_transform[a66e1bf0036969f9]::ffi_unwind_calls::has_ffi_unwind_calls
  33:     0x7f3a2773269d - rustc_query_impl[aafdc9ab48500bbf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aafdc9ab48500bbf]::query_impl::has_ffi_unwind_calls::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 1usize]>>
  34:     0x7f3a27a51007 - rustc_query_system[5609ae2ca0b8284d]::query::plumbing::try_execute_query::<rustc_query_impl[aafdc9ab48500bbf]::DynamicConfig<rustc_query_system[5609ae2ca0b8284d]::query::caches::VecCache<rustc_span[79961d1f3d44db5f]::def_id::LocalDefId, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[aafdc9ab48500bbf]::plumbing::QueryCtxt, false>
  35:     0x7f3a27a50c03 - rustc_query_impl[aafdc9ab48500bbf]::query_impl::has_ffi_unwind_calls::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f3a27a02c83 - rustc_mir_transform[a66e1bf0036969f9]::mir_const
  37:     0x7f3a27a02baf - rustc_query_impl[aafdc9ab48500bbf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aafdc9ab48500bbf]::query_impl::mir_const::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>
  38:     0x7f3a27affd39 - rustc_query_system[5609ae2ca0b8284d]::query::plumbing::try_execute_query::<rustc_query_impl[aafdc9ab48500bbf]::DynamicConfig<rustc_query_system[5609ae2ca0b8284d]::query::caches::VecCache<rustc_span[79961d1f3d44db5f]::def_id::LocalDefId, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[aafdc9ab48500bbf]::plumbing::QueryCtxt, false>
  39:     0x7f3a27aff850 - rustc_query_impl[aafdc9ab48500bbf]::query_impl::mir_const::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7f3a2587a5e2 - rustc_mir_transform[a66e1bf0036969f9]::mir_promoted
  41:     0x7f3a27b732e0 - rustc_query_impl[aafdc9ab48500bbf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aafdc9ab48500bbf]::query_impl::mir_promoted::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 16usize]>>
  42:     0x7f3a27b735aa - rustc_query_system[5609ae2ca0b8284d]::query::plumbing::try_execute_query::<rustc_query_impl[aafdc9ab48500bbf]::DynamicConfig<rustc_query_system[5609ae2ca0b8284d]::query::caches::VecCache<rustc_span[79961d1f3d44db5f]::def_id::LocalDefId, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[aafdc9ab48500bbf]::plumbing::QueryCtxt, false>
  43:     0x7f3a284e3853 - rustc_query_impl[aafdc9ab48500bbf]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace
  44:     0x7f3a284e3970 - rustc_borrowck[df3a95fa1272e840]::mir_borrowck
  45:     0x7f3a284e3899 - rustc_query_impl[aafdc9ab48500bbf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aafdc9ab48500bbf]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>
  46:     0x7f3a27affd39 - rustc_query_system[5609ae2ca0b8284d]::query::plumbing::try_execute_query::<rustc_query_impl[aafdc9ab48500bbf]::DynamicConfig<rustc_query_system[5609ae2ca0b8284d]::query::caches::VecCache<rustc_span[79961d1f3d44db5f]::def_id::LocalDefId, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[aafdc9ab48500bbf]::plumbing::QueryCtxt, false>
  47:     0x7f3a27aff794 - rustc_query_impl[aafdc9ab48500bbf]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  48:     0x7f3a281f3fc9 - <rustc_borrowck[df3a95fa1272e840]::type_check::TypeChecker>::prove_closure_bounds
  49:     0x7f3a284a10ae - <rustc_borrowck[df3a95fa1272e840]::type_check::TypeChecker>::typeck_mir
  50:     0x7f3a252e86d1 - rustc_borrowck[df3a95fa1272e840]::type_check::type_check
  51:     0x7f3a252ccc09 - rustc_borrowck[df3a95fa1272e840]::nll::compute_regions
  52:     0x7f3a284f3b97 - rustc_borrowck[df3a95fa1272e840]::do_mir_borrowck
  53:     0x7f3a284e3e51 - rustc_borrowck[df3a95fa1272e840]::mir_borrowck
  54:     0x7f3a284e3899 - rustc_query_impl[aafdc9ab48500bbf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aafdc9ab48500bbf]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>
  55:     0x7f3a27affd39 - rustc_query_system[5609ae2ca0b8284d]::query::plumbing::try_execute_query::<rustc_query_impl[aafdc9ab48500bbf]::DynamicConfig<rustc_query_system[5609ae2ca0b8284d]::query::caches::VecCache<rustc_span[79961d1f3d44db5f]::def_id::LocalDefId, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[aafdc9ab48500bbf]::plumbing::QueryCtxt, false>
  56:     0x7f3a27aff794 - rustc_query_impl[aafdc9ab48500bbf]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  57:     0x7f3a28ad1259 - rustc_middle[d060b801b30d0b16]::query::plumbing::query_get_at::<rustc_query_system[5609ae2ca0b8284d]::query::caches::VecCache<rustc_span[79961d1f3d44db5f]::def_id::LocalDefId, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>>.llvm.9191639156879714653.cold.0
  58:     0x7f3a2649dfbd - <rustc_hir_analysis[c481e10dc51c4446]::collect::type_of::opaque::TaitConstraintLocator>::check
  59:     0x7f3a2648bf20 - <rustc_hir_analysis[c481e10dc51c4446]::collect::type_of::opaque::TaitConstraintLocator as rustc_hir[a3b1848d05e218a2]::intravisit::Visitor>::visit_item
  60:     0x7f3a286098fc - rustc_hir_analysis[c481e10dc51c4446]::collect::type_of::type_of_opaque
  61:     0x7f3a28608e5b - rustc_query_impl[aafdc9ab48500bbf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aafdc9ab48500bbf]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>
  62:     0x7f3a2765ef54 - rustc_query_system[5609ae2ca0b8284d]::query::plumbing::try_execute_query::<rustc_query_impl[aafdc9ab48500bbf]::DynamicConfig<rustc_query_system[5609ae2ca0b8284d]::query::caches::DefaultCache<rustc_span[79961d1f3d44db5f]::def_id::DefId, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[aafdc9ab48500bbf]::plumbing::QueryCtxt, false>
  63:     0x7f3a2864321e - rustc_query_impl[aafdc9ab48500bbf]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
  64:     0x7f3a2765dbae - rustc_middle[d060b801b30d0b16]::query::plumbing::query_get_at::<rustc_query_system[5609ae2ca0b8284d]::query::caches::DefaultCache<rustc_span[79961d1f3d44db5f]::def_id::DefId, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>>
  65:     0x7f3a258a3678 - rustc_hir_analysis[c481e10dc51c4446]::collect::type_of::type_of
  66:     0x7f3a276600be - rustc_query_impl[aafdc9ab48500bbf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aafdc9ab48500bbf]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>
  67:     0x7f3a2765ef54 - rustc_query_system[5609ae2ca0b8284d]::query::plumbing::try_execute_query::<rustc_query_impl[aafdc9ab48500bbf]::DynamicConfig<rustc_query_system[5609ae2ca0b8284d]::query::caches::DefaultCache<rustc_span[79961d1f3d44db5f]::def_id::DefId, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[aafdc9ab48500bbf]::plumbing::QueryCtxt, false>
  68:     0x7f3a2765eb1d - rustc_query_impl[aafdc9ab48500bbf]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  69:     0x7f3a2765dbae - rustc_middle[d060b801b30d0b16]::query::plumbing::query_get_at::<rustc_query_system[5609ae2ca0b8284d]::query::caches::DefaultCache<rustc_span[79961d1f3d44db5f]::def_id::DefId, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 8usize]>>>
  70:     0x7f3a28144033 - rustc_hir_analysis[c481e10dc51c4446]::check::check::check_item_type
  71:     0x7f3a27d9d0d9 - rustc_hir_analysis[c481e10dc51c4446]::check::wfcheck::check_well_formed
  72:     0x7f3a27d9bf73 - rustc_query_impl[aafdc9ab48500bbf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aafdc9ab48500bbf]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 1usize]>>
  73:     0x7f3a27d9b671 - rustc_query_system[5609ae2ca0b8284d]::query::plumbing::try_execute_query::<rustc_query_impl[aafdc9ab48500bbf]::DynamicConfig<rustc_query_system[5609ae2ca0b8284d]::query::caches::VecCache<rustc_hir[a3b1848d05e218a2]::hir_id::OwnerId, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[aafdc9ab48500bbf]::plumbing::QueryCtxt, false>
  74:     0x7f3a27d9b3db - rustc_query_impl[aafdc9ab48500bbf]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  75:     0x7f3a27d98d77 - rustc_hir_analysis[c481e10dc51c4446]::check::wfcheck::check_mod_type_wf
  76:     0x7f3a27d98cbb - rustc_query_impl[aafdc9ab48500bbf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aafdc9ab48500bbf]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 1usize]>>
  77:     0x7f3a27d97e7b - rustc_query_system[5609ae2ca0b8284d]::query::plumbing::try_execute_query::<rustc_query_impl[aafdc9ab48500bbf]::DynamicConfig<rustc_query_system[5609ae2ca0b8284d]::query::caches::DefaultCache<rustc_span[79961d1f3d44db5f]::def_id::LocalModDefId, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[aafdc9ab48500bbf]::plumbing::QueryCtxt, false>
  78:     0x7f3a27d97c09 - rustc_query_impl[aafdc9ab48500bbf]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  79:     0x7f3a27d97b1a - <rustc_middle[d060b801b30d0b16]::hir::map::Map>::try_par_for_each_module::<rustc_hir_analysis[c481e10dc51c4446]::check_crate::{closure#4}::{closure#0}>::{closure#0}
  80:     0x7f3a27afd9dc - rustc_hir_analysis[c481e10dc51c4446]::check_crate
  81:     0x7f3a28037559 - rustc_interface[82b52b903971ad5b]::passes::analysis
  82:     0x7f3a2803719f - rustc_query_impl[aafdc9ab48500bbf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aafdc9ab48500bbf]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 1usize]>>
  83:     0x7f3a285c3824 - rustc_query_system[5609ae2ca0b8284d]::query::plumbing::try_execute_query::<rustc_query_impl[aafdc9ab48500bbf]::DynamicConfig<rustc_query_system[5609ae2ca0b8284d]::query::caches::SingleCache<rustc_middle[d060b801b30d0b16]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[aafdc9ab48500bbf]::plumbing::QueryCtxt, false>
  84:     0x7f3a285c3615 - rustc_query_impl[aafdc9ab48500bbf]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  85:     0x7f3a2835d708 - rustc_interface[82b52b903971ad5b]::interface::run_compiler::<core[ea75208d289faa44]::result::Result<(), rustc_span[79961d1f3d44db5f]::ErrorGuaranteed>, rustc_driver_impl[54e7dbd11c712533]::run_compiler::{closure#0}>::{closure#0}
  86:     0x7f3a285e8fc6 - std[6b9fb5ba93d727e9]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[82b52b903971ad5b]::util::run_in_thread_with_globals<rustc_interface[82b52b903971ad5b]::util::run_in_thread_pool_with_globals<rustc_interface[82b52b903971ad5b]::interface::run_compiler<core[ea75208d289faa44]::result::Result<(), rustc_span[79961d1f3d44db5f]::ErrorGuaranteed>, rustc_driver_impl[54e7dbd11c712533]::run_compiler::{closure#0}>::{closure#0}, core[ea75208d289faa44]::result::Result<(), rustc_span[79961d1f3d44db5f]::ErrorGuaranteed>>::{closure#0}, core[ea75208d289faa44]::result::Result<(), rustc_span[79961d1f3d44db5f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ea75208d289faa44]::result::Result<(), rustc_span[79961d1f3d44db5f]::ErrorGuaranteed>>
  87:     0x7f3a285e8df3 - <<std[6b9fb5ba93d727e9]::thread::Builder>::spawn_unchecked_<rustc_interface[82b52b903971ad5b]::util::run_in_thread_with_globals<rustc_interface[82b52b903971ad5b]::util::run_in_thread_pool_with_globals<rustc_interface[82b52b903971ad5b]::interface::run_compiler<core[ea75208d289faa44]::result::Result<(), rustc_span[79961d1f3d44db5f]::ErrorGuaranteed>, rustc_driver_impl[54e7dbd11c712533]::run_compiler::{closure#0}>::{closure#0}, core[ea75208d289faa44]::result::Result<(), rustc_span[79961d1f3d44db5f]::ErrorGuaranteed>>::{closure#0}, core[ea75208d289faa44]::result::Result<(), rustc_span[79961d1f3d44db5f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ea75208d289faa44]::result::Result<(), rustc_span[79961d1f3d44db5f]::ErrorGuaranteed>>::{closure#1} as core[ea75208d289faa44]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  88:     0x7f3a235999d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h646d8cfdd583ca20
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/alloc/src/boxed.rs:2016:9
  89:     0x7f3a235999d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h79a5366d4b935d3e
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/alloc/src/boxed.rs:2016:9
  90:     0x7f3a235999d5 - std::sys::unix::thread::Thread::new::thread_start::h1e5e13c4b7d7a988
                               at /rustc/ae9d24de80b00b4158d1a29a212a6b02aeda0e75/library/std/src/sys/unix/thread.rs:108:17
  91:     0x7f3a233859eb - <unknown>
  92:     0x7f3a234097cc - <unknown>
  93:                0x0 - <unknown>

error: 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.77.0-nightly (ae9d24de8 2024-01-09) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

query stack during panic:
#0 [mir_built] building MIR for `enum_upvar::{closure#0}`
#1 [has_ffi_unwind_calls] checking if `enum_upvar::{closure#0}` contains FFI-unwind calls
#2 [mir_const] preparing `enum_upvar::{closure#0}` for borrow checking
#3 [mir_promoted] promoting constants in MIR for `enum_upvar::{closure#0}`
#4 [mir_borrowck] borrow-checking `enum_upvar::{closure#0}`
#5 [mir_borrowck] borrow-checking `enum_upvar`
#6 [type_of_opaque] computing type of opaque `enum_upvar::T::{opaque#0}`
#7 [type_of] computing type of `enum_upvar::T::{opaque#0}`
#8 [check_well_formed] checking that `enum_upvar::T::{opaque#0}` is well-formed
#9 [check_mod_type_wf] checking that types are well-formed in top-level module
#10 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.

@matthiaskrgr matthiaskrgr 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. C-bug Category: This is a bug. labels Jan 9, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 9, 2024
@matthiaskrgr
Copy link
Member Author

Hmm, this bisects to #117565 cc @estebank

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 11, 2024
@Noratrieb
Copy link
Member

This is really weird, it only happens when the binding is a keyword..., is the PR doing recovery incorrectly?

@compiler-errors
Copy link
Member

compiler-errors commented Jan 25, 2024

@Nilstrieb: It's recovering the keyword as a wildcard. This also ICEs, probably doesn't bisect to that PR but before it:

#![feature(type_alias_impl_trait)]

fn enum_upvar() {
    type T = impl Copy;
    let foo: T = Some((1u32, 2u32));
    let x = move || {
        match foo {
            None => (),
            Some(_) => (),
        }
    };
}

@Noratrieb
Copy link
Member

Haha, I was trying to properly minimize this to be able to properly bisect it and turned it into an ident pattern which was fine, it didn't occur to me that it would recover to a wildcard :D.

@Noratrieb Noratrieb added the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Jan 25, 2024
@matthiaskrgr matthiaskrgr changed the title ICE: None in as_place.rs ICE: None in compiler/rustc_mir_build/src/build/matches/mod.rs Mar 28, 2024
@matthiaskrgr
Copy link
Member Author

#119786 (comment) this
bisects to

Regression in nightly-2022-03-31

fetching (via remote github) commits from max(9c06e1b, 2022-03-28) to c5cf08d
ending github query because we found starting sha: 9c06e1b
get_commits_between returning commits, len: 8
commit[0] 2022-03-29: Auto merge of #95448 - Dylan-DPC:rollup-wpj5yto, r=Dylan-DPC
commit[1] 2022-03-30: Auto merge of #95455 - RalfJung:miri, r=RalfJung
commit[2] 2022-03-30: Auto merge of #94081 - oli-obk:lazy_tait_take_two, r=nikomatsakis
commit[3] 2022-03-30: Auto merge of #95466 - Dylan-DPC:rollup-g7ddr8y, r=Dylan-DPC
commit[4] 2022-03-30: Auto merge of #95241 - Gankra:cleaned-provenance, r=workingjubilee
commit[5] 2022-03-30: Auto merge of #94963 - lcnr:inherent-impls-std, r=oli-obk,m-ou-se
commit[6] 2022-03-30: Auto merge of #95458 - calebcartwright:sync-rustfmt-subtree, r=calebcartwright
commit[7] 2022-03-30: Auto merge of #95425 - nnethercote:yet-more-parse_tt-improvements, r=petrochenkov
ERROR: no CI builds available between 9c06e1b and c5cf08d within last 167 days

which is probably also #94081 ? cc @oli-obk

@matthiaskrgr matthiaskrgr removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Mar 29, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
@Nadrieril
Copy link
Member

Fun fact: this is edition-specific. Works on 2018, ICEs on 2021.

@Nadrieril
Copy link
Member

The bug is due to a PlaceBuilder.try_to_place() call that returns None somewhere unexpected. Normally this only returns None within closures when we're capturing only a subplace of the place in question. This is not case here: we should be capturing the whole place given that we read its discriminant. The opaque type must have introduced confusion. My best guess is that this has to do with this (the place_builder involved is the one we care about):

// Only add the OpaqueCast projection if the given place is an opaque type and the
// expected type from the pattern is not.
let may_need_cast = match place_builder.base() {
PlaceBase::Local(local) => {
let ty =
Place::ty_from(local, place_builder.projection(), &cx.local_decls, cx.tcx).ty;
ty != pattern.ty && ty.has_opaque_types()
}
_ => true,
};
if may_need_cast {
place_builder = place_builder.project(ProjectionElem::OpaqueCast(pattern.ty));
}

@compiler-errors
Copy link
Member

@Nadrieril: There's also a fair chance this has to do not with mir building, but with capture analysis. I've observed that try_to_place can fail when we don't actually record the right set of captures in upvar.rs in hir typeck. This may be happening due to the opaque.

@compiler-errors
Copy link
Member

Especially so because this is 2021-edition dependent, so something may be wrong with the edition 2021 precise closure capturing logic.

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Jul 19, 2024

the fact that this crashes in 2021 is probably related to 2021 closure capture

edit https://doc.rust-lang.org/edition-guide/rust-2021/disjoint-capture-in-closures.html ?

@oli-obk
Copy link
Contributor

oli-obk commented Jul 19, 2024

I really dislike the opaque type cast projection. I mean, I wrote it, but everything needed to carefully be tuned around it. It may just be easier to rip it out and instead reject these code patterns with opaques

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants