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: self.is_struct() || self.is_union() #121757

Closed
matthiaskrgr opened this issue Feb 28, 2024 · 0 comments · Fixed by #121975
Closed

ICE: self.is_struct() || self.is_union() #121757

matthiaskrgr opened this issue Feb 28, 2024 · 0 comments · Fixed by #121975
Labels
C-bug Category: This is a bug. F-unnamed_fields `#![feature(unnamed_fields)]` 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

@matthiaskrgr
Copy link
Member

Code

type Ast<'ast> = &'ast AstStructure<'ast>;

struct AstStructure<'ast> {
    id: NodeId,
    _: AstKind<'ast>
}

enum AstKind<'ast> {
    ExprInt,
    ExprLambda(Ast<'ast>),
}

fn compute_types<'tcx,'ast>(ast: Ast<'ast>) -> Type<'tcx>
{
    match ast.kind {}
}

Meta

rustc --version --verbose:


Error output

<output>
Backtrace

thread 'rustc' panicked at compiler/rustc_middle/src/ty/adt.rs:395:9:
assertion failed: self.is_struct() || self.is_union()
stack backtrace:
   0:     0x7f64eaa17c46 - std::backtrace_rs::backtrace::libunwind::trace::hcd31ff68bb8eb3c8
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f64eaa17c46 - std::backtrace_rs::backtrace::trace_unsynchronized::h14d76bd5509bf096
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f64eaa17c46 - std::sys_common::backtrace::_print_fmt::hccb1d92c773f2e33
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f64eaa17c46 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::haec236aae0c71094
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f64eaa68bcc - core::fmt::rt::Argument::fmt::hfe5c81d163ead061
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/core/src/fmt/rt.rs:142:9
   5:     0x7f64eaa68bcc - core::fmt::write::hae70f68f90cda8d6
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f64eaa0c4cf - std::io::Write::write_fmt::h2920683ffc23d04e
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/std/src/io/mod.rs:1846:15
   7:     0x7f64eaa179f4 - std::sys_common::backtrace::_print::h5625fa16158ef797
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f64eaa179f4 - std::sys_common::backtrace::print::h736502c57d395fe5
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f64eaa1a73b - std::panicking::default_hook::{{closure}}::hd092ecfc821f695b
  10:     0x7f64eaa1a489 - std::panicking::default_hook::h7f251f2c2a8aa52c
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/std/src/panicking.rs:292:9
  11:     0x7f64e76a5d3c - std[578157ee06130f18]::panicking::update_hook::<alloc[1f5b0d5bc2928dda]::boxed::Box<rustc_driver_impl[58539505cbc2faf7]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f64eaa1aea0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hc774e046b4082d87
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/alloc/src/boxed.rs:2030:9
  13:     0x7f64eaa1aea0 - std::panicking::rust_panic_with_hook::h50c9145ee7057605
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/std/src/panicking.rs:783:13
  14:     0x7f64eaa1aba9 - std::panicking::begin_panic_handler::{{closure}}::h94d2e31aacd46455
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/std/src/panicking.rs:649:13
  15:     0x7f64eaa18126 - std::sys_common::backtrace::__rust_end_short_backtrace::h38d64ea497d2de47
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f64eaa1a914 - rust_begin_unwind
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/std/src/panicking.rs:645:5
  17:     0x7f64eaa650e5 - core::panicking::panic_fmt::ha1515334750a7e83
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/core/src/panicking.rs:72:14
  18:     0x7f64eaa651a3 - core::panicking::panic::h13c3c16b9e1955d9
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/core/src/panicking.rs:144:5
  19:     0x7f64e921e28a - rustc_hir_analysis[b9c969b446149ad8]::collect::find_field
  20:     0x7f64e921df9f - rustc_query_impl[ba88ac09c9d7b12d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ba88ac09c9d7b12d]::query_impl::find_field::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2ebf57413533262e]::query::erase::Erased<[u8; 4usize]>>
  21:     0x7f64e921df61 - <rustc_query_impl[ba88ac09c9d7b12d]::query_impl::find_field::dynamic_query::{closure#2} as core[6cbd71b2db6ebc95]::ops::function::FnOnce<(rustc_middle[2ebf57413533262e]::ty::context::TyCtxt, (rustc_span[20f1163f305bb5ee]::def_id::DefId, rustc_span[20f1163f305bb5ee]::symbol::Ident))>>::call_once
  22:     0x7f64e921d350 - rustc_query_system[cf6fea66217b4faa]::query::plumbing::try_execute_query::<rustc_query_impl[ba88ac09c9d7b12d]::DynamicConfig<rustc_query_system[cf6fea66217b4faa]::query::caches::DefaultCache<(rustc_span[20f1163f305bb5ee]::def_id::DefId, rustc_span[20f1163f305bb5ee]::symbol::Ident), rustc_middle[2ebf57413533262e]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[ba88ac09c9d7b12d]::plumbing::QueryCtxt, false>
  23:     0x7f64e921d0a0 - rustc_query_impl[ba88ac09c9d7b12d]::query_impl::find_field::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7f64e921e247 - rustc_hir_analysis[b9c969b446149ad8]::collect::find_field
  25:     0x7f64e921df9f - rustc_query_impl[ba88ac09c9d7b12d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ba88ac09c9d7b12d]::query_impl::find_field::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2ebf57413533262e]::query::erase::Erased<[u8; 4usize]>>
  26:     0x7f64e921df61 - <rustc_query_impl[ba88ac09c9d7b12d]::query_impl::find_field::dynamic_query::{closure#2} as core[6cbd71b2db6ebc95]::ops::function::FnOnce<(rustc_middle[2ebf57413533262e]::ty::context::TyCtxt, (rustc_span[20f1163f305bb5ee]::def_id::DefId, rustc_span[20f1163f305bb5ee]::symbol::Ident))>>::call_once
  27:     0x7f64e921d350 - rustc_query_system[cf6fea66217b4faa]::query::plumbing::try_execute_query::<rustc_query_impl[ba88ac09c9d7b12d]::DynamicConfig<rustc_query_system[cf6fea66217b4faa]::query::caches::DefaultCache<(rustc_span[20f1163f305bb5ee]::def_id::DefId, rustc_span[20f1163f305bb5ee]::symbol::Ident), rustc_middle[2ebf57413533262e]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[ba88ac09c9d7b12d]::plumbing::QueryCtxt, false>
  28:     0x7f64e921d0a0 - rustc_query_impl[ba88ac09c9d7b12d]::query_impl::find_field::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7f64e8c4a252 - <rustc_hir_typeck[12acd77aad38ccf6]::fn_ctxt::FnCtxt>::check_field
  30:     0x7f64e9482294 - <rustc_hir_typeck[12acd77aad38ccf6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  31:     0x7f64e94716f6 - <rustc_hir_typeck[12acd77aad38ccf6]::fn_ctxt::FnCtxt>::check_match
  32:     0x7f64e948248e - <rustc_hir_typeck[12acd77aad38ccf6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  33:     0x7f64e8f9dd49 - <rustc_hir_typeck[12acd77aad38ccf6]::fn_ctxt::FnCtxt>::check_block_with_expected
  34:     0x7f64e94819a5 - <rustc_hir_typeck[12acd77aad38ccf6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  35:     0x7f64e94916f8 - rustc_hir_typeck[12acd77aad38ccf6]::check::check_fn
  36:     0x7f64e8dc38f1 - rustc_hir_typeck[12acd77aad38ccf6]::typeck
  37:     0x7f64e8dc2bb5 - rustc_query_impl[ba88ac09c9d7b12d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ba88ac09c9d7b12d]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2ebf57413533262e]::query::erase::Erased<[u8; 8usize]>>
  38:     0x7f64e8b78eb0 - rustc_query_system[cf6fea66217b4faa]::query::plumbing::try_execute_query::<rustc_query_impl[ba88ac09c9d7b12d]::DynamicConfig<rustc_query_system[cf6fea66217b4faa]::query::caches::VecCache<rustc_span[20f1163f305bb5ee]::def_id::LocalDefId, rustc_middle[2ebf57413533262e]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[ba88ac09c9d7b12d]::plumbing::QueryCtxt, false>
  39:     0x7f64e8b789cc - rustc_query_impl[ba88ac09c9d7b12d]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7f64e92c6a52 - <rustc_middle[2ebf57413533262e]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[b9c969b446149ad8]::check_crate::{closure#6}>::{closure#0}
  41:     0x7f64e92c531d - rustc_hir_analysis[b9c969b446149ad8]::check_crate
  42:     0x7f64e9565bef - rustc_interface[549d5cba17650390]::passes::analysis
  43:     0x7f64e9565859 - rustc_query_impl[ba88ac09c9d7b12d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ba88ac09c9d7b12d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2ebf57413533262e]::query::erase::Erased<[u8; 1usize]>>
  44:     0x7f64e9739325 - rustc_query_system[cf6fea66217b4faa]::query::plumbing::try_execute_query::<rustc_query_impl[ba88ac09c9d7b12d]::DynamicConfig<rustc_query_system[cf6fea66217b4faa]::query::caches::SingleCache<rustc_middle[2ebf57413533262e]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[ba88ac09c9d7b12d]::plumbing::QueryCtxt, false>
  45:     0x7f64e9739089 - rustc_query_impl[ba88ac09c9d7b12d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  46:     0x7f64e9740c16 - rustc_interface[549d5cba17650390]::interface::run_compiler::<core[6cbd71b2db6ebc95]::result::Result<(), rustc_span[20f1163f305bb5ee]::ErrorGuaranteed>, rustc_driver_impl[58539505cbc2faf7]::run_compiler::{closure#0}>::{closure#0}
  47:     0x7f64e99e7dc5 - std[578157ee06130f18]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[549d5cba17650390]::util::run_in_thread_with_globals<rustc_interface[549d5cba17650390]::util::run_in_thread_pool_with_globals<rustc_interface[549d5cba17650390]::interface::run_compiler<core[6cbd71b2db6ebc95]::result::Result<(), rustc_span[20f1163f305bb5ee]::ErrorGuaranteed>, rustc_driver_impl[58539505cbc2faf7]::run_compiler::{closure#0}>::{closure#0}, core[6cbd71b2db6ebc95]::result::Result<(), rustc_span[20f1163f305bb5ee]::ErrorGuaranteed>>::{closure#0}, core[6cbd71b2db6ebc95]::result::Result<(), rustc_span[20f1163f305bb5ee]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6cbd71b2db6ebc95]::result::Result<(), rustc_span[20f1163f305bb5ee]::ErrorGuaranteed>>
  48:     0x7f64e99e7bf2 - <<std[578157ee06130f18]::thread::Builder>::spawn_unchecked_<rustc_interface[549d5cba17650390]::util::run_in_thread_with_globals<rustc_interface[549d5cba17650390]::util::run_in_thread_pool_with_globals<rustc_interface[549d5cba17650390]::interface::run_compiler<core[6cbd71b2db6ebc95]::result::Result<(), rustc_span[20f1163f305bb5ee]::ErrorGuaranteed>, rustc_driver_impl[58539505cbc2faf7]::run_compiler::{closure#0}>::{closure#0}, core[6cbd71b2db6ebc95]::result::Result<(), rustc_span[20f1163f305bb5ee]::ErrorGuaranteed>>::{closure#0}, core[6cbd71b2db6ebc95]::result::Result<(), rustc_span[20f1163f305bb5ee]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6cbd71b2db6ebc95]::result::Result<(), rustc_span[20f1163f305bb5ee]::ErrorGuaranteed>>::{closure#1} as core[6cbd71b2db6ebc95]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7f64eaa24875 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbfe673f8fb6b1f32
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/alloc/src/boxed.rs:2016:9
  50:     0x7f64eaa24875 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h91a1aab6b746134a
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/alloc/src/boxed.rs:2016:9
  51:     0x7f64eaa24875 - std::sys::pal::unix::thread::Thread::new::thread_start::h8e91ee627a6e8489
                               at /rustc/ef324565d071c6d7e2477a195648549e33d6a465/library/std/src/sys/pal/unix/thread.rs:108:17
  52:     0x7f64e46a955a - <unknown>
  53:     0x7f64e4726a3c - <unknown>
  54:                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: please attach the file at `/tmp/im/rustc-ice-2024-02-28T18_12_39-499816.txt` to your bug report

query stack during panic:
#0 [find_field] find the index of maybe nested field `kind` in `AstKind`
#1 [find_field] find the index of maybe nested field `kind` in `AstStructure`
#2 [typeck] type-checking `compute_types`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors

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

@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 Feb 28, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 28, 2024
@fmease fmease added F-unnamed_fields `#![feature(unnamed_fields)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 28, 2024
jhpratt added a commit to jhpratt/rust that referenced this issue Mar 5, 2024
…nkov

hir_analysis: enums return `None` in `find_field`

Fixes rust-lang#121757.

Unnamed union fields with enums are checked for, but if `find_field` causes an ICE then the compiler won't get to that point.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 5, 2024
…nkov

hir_analysis: enums return `None` in `find_field`

Fixes rust-lang#121757.

Unnamed union fields with enums are checked for, but if `find_field` causes an ICE then the compiler won't get to that point.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 5, 2024
…nkov

hir_analysis: enums return `None` in `find_field`

Fixes rust-lang#121757.

Unnamed union fields with enums are checked for, but if `find_field` causes an ICE then the compiler won't get to that point.
@bors bors closed this as completed in f560806 Mar 6, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 6, 2024
Rollup merge of rust-lang#121975 - davidtwco:issue-121757, r=petrochenkov

hir_analysis: enums return `None` in `find_field`

Fixes rust-lang#121757.

Unnamed union fields with enums are checked for, but if `find_field` causes an ICE then the compiler won't get to that point.
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. F-unnamed_fields `#![feature(unnamed_fields)]` 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.

3 participants