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 expect Adt for unnamed field #121799

Closed
gurry opened this issue Feb 29, 2024 · 3 comments
Closed

ICE expect Adt for unnamed field #121799

gurry opened this issue Feb 29, 2024 · 3 comments
Labels
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.

Comments

@gurry
Copy link
Contributor

gurry commented Feb 29, 2024

Code

struct S {
    _: str
}

fn func(a: S)
{
    let _x = a.f;
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.78.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-pc-windows-msvc
release: 1.78.0-dev
LLVM version: 18.1.0

Error output

error[E0658]: unnamed fields are not yet fully implemented
  --> ../121757-ice-self-is-struct.rs:21:5
   |
21 |     _: str
   |     ^
   |
   = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information
   = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable

error: struct with unnamed fields must have `#[repr(C)]` representation
  --> ../121757-ice-self-is-struct.rs:20:1
   |
20 | struct S {
   | ^^^^^^^^ struct `S` defined here
   |
note: unnamed field defined here
  --> ../121757-ice-self-is-struct.rs:21:5
   |
21 |     _: str
   |     ^^^^^^
help: add `#[repr(C)]` to this struct
   |
20 + #[repr(C)]
21 | struct S {
   |

error: unnamed fields can only have struct or union types
  --> ../121757-ice-self-is-struct.rs:21:5
   |
21 |     _: str
   |     ^^^^^^
Backtrace

thread 'rustc' panicked at compiler\rustc_hir_analysis\src\collect.rs:797:49:
expect Adt for unnamed field
stack backtrace:
   0:     0x7ffdd1bed08b - std::backtrace_rs::backtrace::trace_unsynchronized::h43b35a566376d8c0
   1:     0x7ffdd1bb9df6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h69aa329c1eebdd12
   2:     0x7ffdd1bff5fa - core::fmt::write::h43e911a4c8eeaf29
   3:     0x7ffdd1be8b31 - std::io::Write::write_fmt::h8014a09f9dbe746f
   4:     0x7ffdd1bb9c49 - std::sys_common::backtrace::print::h011c44e7584b6317
   5:     0x7ffdd1bb3283 - std::panicking::default_hook::h180ba89712984d0e
   6:     0x7ffdd1bb2ffa - std::panicking::default_hook::h180ba89712984d0e
   7:     0x7ffd30696e0a - RNvXsL_NtCs6iaOUQgAX4G_5alloc5boxedINtB5_3BoxNCNvCsaaGoLZrJT1T_17rustc_driver_impl16install_ice_hook0EINtNtNtCsjpBzhLK3VS9_4core3ops8function2FnTRDG0_IB1D_TRL1_INtNtNtB1J_5panic10panic_info9PanicInfoL0_EEEp6OutputuNtNtB1J_6marker4SyncNtB3s_4SendEL_RB2z_EE
   8:     0x7ffdd1bb36f6 - std::panicking::rust_panic_with_hook::h56cbb5b6fc35c3d1
   9:     0x7ffdd1bb63d8 - std::sys_common::backtrace::__rust_end_short_backtrace::he5effd4f04252cad
  10:     0x7ffdd1bb62ff - std::sys_common::backtrace::__rust_end_short_backtrace::he5effd4f04252cad
  11:     0x7ffdd1bb3366 - rust_begin_unwind
  12:     0x7ffdd1c30527 - core::panicking::panic_fmt::h26fb43be4a0382ff
  13:     0x7ffdd1c3045c - core::option::expect_failed::h3577c8f3edbefcf8
  14:     0x7ffd3295088c - RINvXs0_NtNtNtCsjpBzhLK3VS9_4core4iter8adapters3mapINtB6_3MapINtNtB8_9enumerate9EnumerateINtNtNtBc_5slice4iter4IterNtNtCsef3NXIzrFT9_12rustc_middle2ty8FieldDefEENCNvMNtCs329P7cL7PzQ_11rustc_index5sliceINtB2E_10IndexSliceNtNtCs3QpSQfzdkb7_12rustc_target3ab
  15:     0x7ffd3284d89c - <rustc_hir_analysis[45b4dac900b2c2ce]::collect::ItemCtxt as rustc_hir_analysis[45b4dac900b2c2ce]::astconv::AstConv>::set_tainted_by_errors
  16:     0x7ffd33a409f1 - rustc_query_impl[41ff65b64ab350b4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[41ff65b64ab350b4]::query_impl::find_field::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a5e56af6423dad19]::query::erase::Erased<[u8; 4usize]>>
  17:     0x7ffd3398407f - rustc_query_impl[41ff65b64ab350b4]::query_impl::check_unsafety::encode_query_results
  18:     0x7ffd33ae2ef3 - RINvMs2_NtNtCsebAyhQxexiU_3std6thread5localINtB6_8LocalKeyINtNtCsjpBzhLK3VS9_4core4cell4CellPuEE4withNCINvNtNtNtCsef3NXIzrFT9_12rustc_middle2ty7context3tls13enter_contextNCINvNtNtCs1E54DgIQnXd_18rustc_query_system5query8plumbing20execute_job_non_incrINtCs
  19:     0x7ffd33912c3e - RINvNtNtCs1E54DgIQnXd_18rustc_query_system5query8plumbing17try_execute_queryINtCs5FiQgzJqBuW_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheTNtNtCsjXm0eGRgiQS_10rustc_span6def_id5DefIdNtNtB2y_6symbol5IdentEINtNtNtCsef3NXIzrFT9_12rustc_middl
  20:     0x7ffd3398d322 - rustc_query_impl[41ff65b64ab350b4]::query_impl::find_field::get_query_non_incr::__rust_end_short_backtrace
  21:     0x7ffd325bd587 - <rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::check_for_missing_semi
  22:     0x7ffd3262b252 - <rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::check_expr_kind
  23:     0x7ffd325b58d7 - <rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::check_expr_coercible_to_type
  24:     0x7ffd326292be - <rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::check_expr_with_expectation
  25:     0x7ffd325d74df - <rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::check_decl_initializer
  26:     0x7ffd325d7718 - <rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::check_decl_initializer
  27:     0x7ffd325d7a95 - <rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::check_stmt
  28:     0x7ffd326f0cf2 - <rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::with_breakable_ctxt::<<rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::check_block_with_expected::{closure#0}, ()>
  29:     0x7ffd325d7d20 - <rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::check_block_no_value
  30:     0x7ffd32629d52 - <rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::check_expr_kind
  31:     0x7ffd325b58d7 - <rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::check_expr_coercible_to_type
  32:     0x7ffd326292be - <rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::check_expr_with_expectation
  33:     0x7ffd325b6e8c - <rustc_hir_typeck[40cfaf708e23f80b]::fn_ctxt::FnCtxt>::check_return_expr
  34:     0x7ffd327aab3c - rustc_hir_typeck[40cfaf708e23f80b]::check::check_fn
  35:     0x7ffd3268eaf2 - rustc_hir_typeck[40cfaf708e23f80b]::typeck_with_fallback::<rustc_hir_typeck[40cfaf708e23f80b]::inspect_typeck::{closure#0}>        
  36:     0x7ffd3259a33e - rustc_hir_typeck[40cfaf708e23f80b]::primary_body_of
  37:     0x7ffd33a5bd2d - rustc_query_impl[41ff65b64ab350b4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[41ff65b64ab350b4]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a5e56af6423dad19]::query::erase::Erased<[u8; 8usize]>>
  38:     0x7ffd339605de - rustc_query_impl[41ff65b64ab350b4]::query_impl::promoted_mir::encode_query_results
  39:     0x7ffd33ae2a44 - RINvMs2_NtNtCsebAyhQxexiU_3std6thread5localINtB6_8LocalKeyINtNtCsjpBzhLK3VS9_4core4cell4CellPuEE4withNCINvNtNtNtCsef3NXIzrFT9_12rustc_middle2ty7context3tls13enter_contextNCINvNtNtCs1E54DgIQnXd_18rustc_query_system5query8plumbing20execute_job_non_incrINtCs
  40:     0x7ffd3392f122 - RINvNtNtCs1E54DgIQnXd_18rustc_query_system5query8plumbing17try_execute_queryINtCs5FiQgzJqBuW_16rustc_query_impl13DynamicConfigINtNtB4_6caches8VecCacheNtNtCsjXm0eGRgiQS_10rustc_span6def_id10LocalDefIdINtNtNtCsef3NXIzrFT9_12rustc_middle5query5erase6ErasedAh
  41:     0x7ffd33960fe3 - rustc_query_impl[41ff65b64ab350b4]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7ffd32a2c103 - RINvNtCsebAyhQxexiU_3std9panicking3tryuINtNtNtCsjpBzhLK3VS9_4core5panic11unwind_safe16AssertUnwindSafeNCNCNCINvNtNtNtCs8bTriOcSdES_21rustc_data_structures4sync8parallel7enabled15par_for_each_inRNtNtCsjXm0eGRgiQS_10rustc_span6def_id10LocalDefIdRSB36_NCINvM
  43:     0x7ffd32a2b880 - RINvNtCsebAyhQxexiU_3std9panicking3tryuINtNtNtCsjpBzhLK3VS9_4core5panic11unwind_safe16AssertUnwindSafeNCNCNCINvNtNtNtCs8bTriOcSdES_21rustc_data_structures4sync8parallel7enabled15par_for_each_inRNtNtCsjXm0eGRgiQS_10rustc_span6def_id10LocalDefIdRSB36_NCINvM
  44:     0x7ffd329fdf32 - RINvMNtNtCs8bTriOcSdES_21rustc_data_structures4sync8parallelNtB3_13ParallelGuard3runuNCNCNCINvNtB3_7enabled15par_for_each_inRNtNtCsjXm0eGRgiQS_10rustc_span6def_id10LocalDefIdRSB1Z_NCINvMs1_NtNtCsef3NXIzrFT9_12rustc_middle3hir3mapNtB31_3Map15par_body_owner
  45:     0x7ffd328e9ca2 - RINvNtNtNtCs8bTriOcSdES_21rustc_data_structures4sync8parallel7enabled15par_for_each_inRNtNtCsjXm0eGRgiQS_10rustc_span6def_id10LocalDefIdRSB1n_NCINvMs1_NtNtCsef3NXIzrFT9_12rustc_middle3hir3mapNtB2p_3Map15par_body_ownersNCNvCs5Z2QjRJ4hA0_18rustc_hir_analysi
  46:     0x7ffd328196c9 - rustc_hir_analysis[45b4dac900b2c2ce]::check_crate
  47:     0x7ffd308032f9 - rustc_interface[3eeae0d001a4b635]::passes::analysis
  48:     0x7ffd33a5c15c - rustc_query_impl[41ff65b64ab350b4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[41ff65b64ab350b4]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a5e56af6423dad19]::query::erase::Erased<[u8; 1usize]>>
  49:     0x7ffd3399955b - rustc_query_impl[41ff65b64ab350b4]::query_impl::instantiate_and_check_impossible_predicates::alloc_self_profile_query_strings      
  50:     0x7ffd33ae16bd - RINvMs2_NtNtCsebAyhQxexiU_3std6thread5localINtB6_8LocalKeyINtNtCsjpBzhLK3VS9_4core4cell4CellPuEE4withNCINvNtNtNtCsef3NXIzrFT9_12rustc_middle2ty7context3tls13enter_contextNCINvNtNtCs1E54DgIQnXd_18rustc_query_system5query8plumbing20execute_job_non_incrINtCs
  51:     0x7ffd338b2f78 - RINvNtNtCs1E54DgIQnXd_18rustc_query_system5query8plumbing17try_execute_queryINtCs5FiQgzJqBuW_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCsef3NXIzrFT9_12rustc_middle5query5erase6ErasedAhj1_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCt
  52:     0x7ffd33954ff1 - rustc_query_impl[41ff65b64ab350b4]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  53:     0x7ffd306cd676 - RINvMs2_NtNtCsebAyhQxexiU_3std6thread5localINtB6_8LocalKeyINtNtCsjpBzhLK3VS9_4core4cell4CellPuEE4withNCINvNtNtNtCsef3NXIzrFT9_12rustc_middle2ty7context3tls13enter_contextNCINvMs9_B1I_NtB1I_10GlobalCtxt5enterNCNCNCNvCsaaGoLZrJT1T_17rustc_driver_impl12run_c
  54:     0x7ffd306c05ed - <rustc_middle[a5e56af6423dad19]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[767bba05edafb3bb]::run_compiler::{closure#0}::{closure#1}::{closure#3}, core[e21d7e5d074c18ab]::result::Result<(), rustc_span[e874984deae97828]::ErrorGuaranteed>>
  55:     0x7ffd30687b5d - RINvMs5_NtCs5oUjEq15j35_15rustc_interface7queriesNtNtB8_9interface8Compiler5enterNCNCNvCsaaGoLZrJT1T_17rustc_driver_impl12run_compiler0s_0INtNtCsjpBzhLK3VS9_4core6result6ResultINtNtB2h_6option6OptionNtB6_6LinkerENtCsjXm0eGRgiQS_10rustc_span15ErrorGuarante
  56:     0x7ffd306a635b - rustc_span[e874984deae97828]::set_source_map::<core[e21d7e5d074c18ab]::result::Result<(), rustc_span[e874984deae97828]::ErrorGuaranteed>, rustc_interface[3eeae0d001a4b635]::interface::run_compiler<core[e21d7e5d074c18ab]::result::Result<(), rustc_span[e874984deae97828]::ErrorGuaranteed>, rustc_driver_impl[767bba05edafb3bb]::run_compiler::{closure#0}>::{closure#0}::{closure#0}>
  57:     0x7ffd306cf97b - RINvMs_CsgVCJzdmiPiq_10scoped_tlsINtB5_9ScopedKeyNtCsjXm0eGRgiQS_10rustc_span14SessionGlobalsE3setNCINvNtCs5oUjEq15j35_15rustc_interface4util31run_in_thread_pool_with_globalsNCINvNtB1F_9interface12run_compilerINtNtCsjpBzhLK3VS9_4core6result6ResultuNtBN_15
  58:     0x7ffd306a6bf1 - RINvCsjXm0eGRgiQS_10rustc_span27create_session_globals_thenINtNtCsjpBzhLK3VS9_4core6result6ResultuNtB2_15ErrorGuaranteedENCINvNtCs5oUjEq15j35_15rustc_interface4util31run_in_thread_pool_with_globalsNCINvNtB22_9interface12run_compilerBV_NCNvCsaaGoLZrJT1T_17
  59:     0x7ffd306c8c28 - RINvNtNtCsebAyhQxexiU_3std10sys_common9backtrace28___rust_begin_short_backtraceNCNCINvNtCs5oUjEq15j35_15rustc_interface4util26run_in_thread_with_globalsNCINvB1m_31run_in_thread_pool_with_globalsNCINvNtB1o_9interface12run_compilerINtNtCsjpBzhLK3VS9_4core6r
  60:     0x7ffd3069e909 - RINvNtCsebAyhQxexiU_3std9panicking3tryINtNtCsjpBzhLK3VS9_4core6result6ResultuNtCsjXm0eGRgiQS_10rustc_span15ErrorGuaranteedEINtNtNtBF_5panic11unwind_safe16AssertUnwindSafeNCNCINvMNtB4_6threadNtB2Q_7Builder16spawn_unchecked_NCNCINvNtCs5oUjEq15j35_15rustc_in
  61:     0x7ffd306cb7d0 - RINvNtCsebAyhQxexiU_3std6thread5spawnNCNCINvNtCs5oUjEq15j35_15rustc_interface4util31run_in_thread_pool_with_globalsNCINvNtBI_9interface12run_compilerINtNtCsjpBzhLK3VS9_4core6result6ResultuNtCsjXm0eGRgiQS_10rustc_span15ErrorGuaranteedENCNvCsaaGoLZrJT1T_17r
  62:     0x7ffdd1be939b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h374ce232189b6f7d
  63:     0x7ffdd1beee03 - std::sys::pal::windows::thread::Thread::new::h61d19b62b0a4eb25
  64:     0x7ffe7668257d - BaseThreadInitThunk
  65:     0x7ffe778eaa68 - RtlUserThreadStart

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 `D:\Projects\rust_dev\rustc\rust2\rustc-ice-2024-02-29T13_21_44-21284.txt` to your bug report

query stack during panic:
#0 [find_field] find the index of maybe nested field `f` in `S`
#1 [typeck] type-checking `func`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errorsthread 'rustc' panicked at compiler\rustc_hir_analysis\src\collect.rs:797:49:

@gurry gurry 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 Feb 29, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 29, 2024
@gurry
Copy link
Contributor Author

gurry commented Feb 29, 2024

LIkely related to #121757

@matthiaskrgr
Copy link
Member

duplicate of #121263 ?

@compiler-errors
Copy link
Member

Yes, duplicate

@compiler-errors compiler-errors closed this as not planned Won't fix, can't repro, duplicate, stale Feb 29, 2024
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 29, 2024
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) ❄️ 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

5 participants