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: entered unreachable code: we captured two identical projections #109188

Closed
matthiaskrgr opened this issue Mar 15, 2023 · 4 comments · Fixed by #109433
Closed

ICE: entered unreachable code: we captured two identical projections #109188

matthiaskrgr opened this issue Mar 15, 2023 · 4 comments · Fixed by #109433
Labels
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) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

enum Either {
    One(X),
    Two(X),
}

struct X(Y);

struct Y;

fn move_into_fnmut() {
    let x = move_into_fnmut();

    consume_fnmut(|| {
        X(_t) = x;

        Either::Two(_t) = x;
    });
}

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (171693274 2023-03-14)
binary: rustc
commit-hash: 1716932743a7b3705cbf0c34db0c4e070ed1930d
commit-date: 2023-03-14
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Error output

<output>
Backtrace

thread 'rustc' panicked at 'internal error: entered unreachable code: we captured two identical projections: capture1 = CapturedPlace { var_ident: x#0, place: Place { base_ty: (), base: Upvar(UpvarId(HirId(DefId(0:15 ~ treereduce[357c]::move_into_fnmut).6);`x`;DefId(0:16 ~ treereduce[357c]::move_into_fnmut::{closure#0}))), projections: [Projection { ty: X, kind: Field(0, 1) }] }, info: CaptureInfo { capture_kind_expr_id: Some(HirId(DefId(0:15 ~ treereduce[357c]::move_into_fnmut).39)), path_expr_id: Some(HirId(DefId(0:15 ~ treereduce[357c]::move_into_fnmut).39)), capture_kind: ByValue }, mutability: Not, region: None }, capture2 = CapturedPlace { var_ident: x#0, place: Place { base_ty: (), base: Upvar(UpvarId(HirId(DefId(0:15 ~ treereduce[357c]::move_into_fnmut).6);`x`;DefId(0:16 ~ treereduce[357c]::move_into_fnmut::{closure#0}))), projections: [Projection { ty: Y, kind: Field(0, 0) }] }, info: CaptureInfo { capture_kind_expr_id: Some(HirId(DefId(0:15 ~ treereduce[357c]::move_into_fnmut).22)), path_expr_id: Some(HirId(DefId(0:15 ~ treereduce[357c]::move_into_fnmut).22)), capture_kind: ByValue }, mutability: Not, region: None }', compiler/rustc_hir_typeck/src/upvar.rs:715:17
stack backtrace:
   0:     0x7f142776651a - std::backtrace_rs::backtrace::libunwind::trace::hb525d69e070ade81
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f142776651a - std::backtrace_rs::backtrace::trace_unsynchronized::hc013ba6c022c8cc0
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f142776651a - std::sys_common::backtrace::_print_fmt::hc99069d428720acc
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f142776651a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6b2dfd5fb54878e3
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f14277c9c5e - core::fmt::write::he277a08b33a83db8
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/core/src/fmt/mod.rs:1232:17
   5:     0x7f1427759375 - std::io::Write::write_fmt::h6a5aa3320aae0280
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/io/mod.rs:1684:15
   6:     0x7f14277662e5 - std::sys_common::backtrace::_print::h763b5adb4e9083ff
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f14277662e5 - std::sys_common::backtrace::print::h5a4028b32a3df8a2
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f142776905f - std::panicking::default_hook::{{closure}}::h0c8c81b9641f8819
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/panicking.rs:271:22
   9:     0x7f1427768d9b - std::panicking::default_hook::h5bf7cd33f355743b
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/panicking.rs:290:9
  10:     0x7f142aa577f5 - rustc_driver_impl[aa1a5107c9e4d916]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f142776989d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h31d3f61cac634989
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/alloc/src/boxed.rs:2002:9
  12:     0x7f142776989d - std::panicking::rust_panic_with_hook::h11aed2986f5c5154
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/panicking.rs:696:13
  13:     0x7f1427769619 - std::panicking::begin_panic_handler::{{closure}}::h5030a267c334a760
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/panicking.rs:583:13
  14:     0x7f1427766986 - std::sys_common::backtrace::__rust_end_short_backtrace::hf19b9029d2a05570
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/sys_common/backtrace.rs:150:18
  15:     0x7f1427769322 - rust_begin_unwind
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/panicking.rs:579:5
  16:     0x7f14277c5fb3 - core::panicking::panic_fmt::hc179041817e007c3
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/core/src/panicking.rs:64:14
  17:     0x7f1429f04c9a - <[rustc_middle[91c99f5af0859808]::ty::closure::CapturedPlace]>::sort_by::<<rustc_hir_typeck[abe2c3cd9c1436d1]::fn_ctxt::FnCtxt>::compute_min_captures::{closure#1}>::{closure#0}
  18:     0x7f1429f04a7f - core[93f4c45d685c579b]::slice::sort::insertion_sort_shift_left::<rustc_middle[91c99f5af0859808]::ty::closure::CapturedPlace, <[rustc_middle[91c99f5af0859808]::ty::closure::CapturedPlace]>::sort_by<<rustc_hir_typeck[abe2c3cd9c1436d1]::fn_ctxt::FnCtxt>::compute_min_captures::{closure#1}>::{closure#0}>
  19:     0x7f1429f01f95 - <rustc_hir_typeck[abe2c3cd9c1436d1]::fn_ctxt::FnCtxt>::compute_min_captures
  20:     0x7f1429efb5fe - <rustc_hir_typeck[abe2c3cd9c1436d1]::fn_ctxt::FnCtxt>::analyze_closure
  21:     0x7f1428ac5e79 - <rustc_hir_typeck[abe2c3cd9c1436d1]::upvar::InferBorrowKindVisitor as rustc_hir[2286395576989f03]::intravisit::Visitor>::visit_expr
  22:     0x7f1428ac6067 - <rustc_hir_typeck[abe2c3cd9c1436d1]::upvar::InferBorrowKindVisitor as rustc_hir[2286395576989f03]::intravisit::Visitor>::visit_expr
  23:     0x7f1428ac60a8 - <rustc_hir_typeck[abe2c3cd9c1436d1]::upvar::InferBorrowKindVisitor as rustc_hir[2286395576989f03]::intravisit::Visitor>::visit_expr
  24:     0x7f142999b7d5 - rustc_hir_typeck[abe2c3cd9c1436d1]::typeck
  25:     0x7f142951c7a6 - rustc_query_system[d086d80e7946fec]::query::plumbing::try_execute_query::<rustc_query_impl[4365cf0f327aa4bf]::queries::typeck, rustc_query_impl[4365cf0f327aa4bf]::plumbing::QueryCtxt>
  26:     0x7f142a1f4402 - rustc_data_structures[fc6c1c49e6433a48]::sync::par_for_each_in::<&[rustc_span[3a8ff7714ec0cd56]::def_id::LocalDefId], <rustc_middle[91c99f5af0859808]::hir::map::Map>::par_body_owners<rustc_hir_typeck[abe2c3cd9c1436d1]::typeck_item_bodies::{closure#0}>::{closure#0}>
  27:     0x7f142a1f41bf - rustc_hir_typeck[abe2c3cd9c1436d1]::typeck_item_bodies
  28:     0x7f142a26ff97 - rustc_query_system[d086d80e7946fec]::query::plumbing::try_execute_query::<rustc_query_impl[4365cf0f327aa4bf]::queries::typeck_item_bodies, rustc_query_impl[4365cf0f327aa4bf]::plumbing::QueryCtxt>
  29:     0x7f142a26fc6c - <rustc_query_impl[4365cf0f327aa4bf]::Queries as rustc_middle[91c99f5af0859808]::ty::query::QueryEngine>::typeck_item_bodies
  30:     0x7f1428e1fb96 - <rustc_session[66f881e4886b517]::session::Session>::time::<(), rustc_hir_analysis[2cd7f2356faca1ef]::check_crate::{closure#7}>
  31:     0x7f1428e1c878 - rustc_hir_analysis[2cd7f2356faca1ef]::check_crate
  32:     0x7f1428e145e2 - rustc_interface[92ae9247c658ed28]::passes::analysis
  33:     0x7f142a27b95c - rustc_query_system[d086d80e7946fec]::query::plumbing::try_execute_query::<rustc_query_impl[4365cf0f327aa4bf]::queries::analysis, rustc_query_impl[4365cf0f327aa4bf]::plumbing::QueryCtxt>
  34:     0x7f142a27b650 - <rustc_query_impl[4365cf0f327aa4bf]::Queries as rustc_middle[91c99f5af0859808]::ty::query::QueryEngine>::analysis
  35:     0x7f142a0a3369 - <rustc_middle[91c99f5af0859808]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[aa1a5107c9e4d916]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[93f4c45d685c579b]::result::Result<(), rustc_span[3a8ff7714ec0cd56]::ErrorGuaranteed>>
  36:     0x7f1429c7cfa8 - rustc_span[3a8ff7714ec0cd56]::with_source_map::<core[93f4c45d685c579b]::result::Result<(), rustc_span[3a8ff7714ec0cd56]::ErrorGuaranteed>, rustc_interface[92ae9247c658ed28]::interface::run_compiler<core[93f4c45d685c579b]::result::Result<(), rustc_span[3a8ff7714ec0cd56]::ErrorGuaranteed>, rustc_driver_impl[aa1a5107c9e4d916]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  37:     0x7f1429c7420c - std[8d53a76fa3b550eb]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[92ae9247c658ed28]::util::run_in_thread_pool_with_globals<rustc_interface[92ae9247c658ed28]::interface::run_compiler<core[93f4c45d685c579b]::result::Result<(), rustc_span[3a8ff7714ec0cd56]::ErrorGuaranteed>, rustc_driver_impl[aa1a5107c9e4d916]::run_compiler::{closure#1}>::{closure#0}, core[93f4c45d685c579b]::result::Result<(), rustc_span[3a8ff7714ec0cd56]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[93f4c45d685c579b]::result::Result<(), rustc_span[3a8ff7714ec0cd56]::ErrorGuaranteed>>
  38:     0x7f1429c73c3a - <<std[8d53a76fa3b550eb]::thread::Builder>::spawn_unchecked_<rustc_interface[92ae9247c658ed28]::util::run_in_thread_pool_with_globals<rustc_interface[92ae9247c658ed28]::interface::run_compiler<core[93f4c45d685c579b]::result::Result<(), rustc_span[3a8ff7714ec0cd56]::ErrorGuaranteed>, rustc_driver_impl[aa1a5107c9e4d916]::run_compiler::{closure#1}>::{closure#0}, core[93f4c45d685c579b]::result::Result<(), rustc_span[3a8ff7714ec0cd56]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[93f4c45d685c579b]::result::Result<(), rustc_span[3a8ff7714ec0cd56]::ErrorGuaranteed>>::{closure#1} as core[93f4c45d685c579b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7f1427773793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb296ec1752427222
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/alloc/src/boxed.rs:1988:9
  40:     0x7f1427773793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha3d23d73a848aedf
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/alloc/src/boxed.rs:1988:9
  41:     0x7f1427773793 - std::sys::unix::thread::Thread::new::thread_start::hdf09fab72a35a799
                               at /rustc/1716932743a7b3705cbf0c34db0c4e070ed1930d/library/std/src/sys/unix/thread.rs:108:17
  42:     0x7f1427505bb5 - <unknown>
  43:     0x7f1427587d90 - <unknown>
  44:                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.70.0-nightly (171693274 2023-03-14) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `move_into_fnmut`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors

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

@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 Mar 15, 2023
@matthiaskrgr
Copy link
Member Author

searched toolchains 0950848 through 1286ee2


Regression in 452cf4f


@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 16, 2023
@bwmf2
Copy link
Contributor

bwmf2 commented Mar 17, 2023

Alternative:

enum Either {
    One(X),
    Two(X),
}

struct X;

fn move_into_fnmut() {
    let x = Either::One(X);

    _ = || {
        let Either::Two(a) = x;
        let Either::One(b) = x;
    };
}

As long as the variants for a and b are different.

@langston-barrett
Copy link

@rustbot label +S-bug-has-mcve

@rustbot rustbot added the S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue label Mar 17, 2023
@chenyukang
Copy link
Member

Alternative:

enum Either {
    One(X),
    Two(X),
}

struct X;

fn move_into_fnmut() {
    let x = Either::One(X);

    _ = || {
        let Either::Two(a) = x;
        let Either::One(b) = x;
    };
}

As long as the variants for a and b are different.

This ICE caused by different root cause.

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. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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