Skip to content

ICE: is not an ADT #121151

Closed
Closed

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

struct D {
    _: i32,
}

original:

// Test to ensure that there is no ICE when normalizing a projection
// which is invalid (from <https://github.com/rust-lang/rust/pull/106938>).

#![crate_type = "lib"]

trait Identity {
    type Identity;
}
trait NotImplemented {}

impl<T: NotImplemented> Identity for T {
    type Identity = Self;
}

type Foo = u8;

union D { //~ ERROR union with unnamed fields must have `#[repr(C)]` representation
          //~^ NOTE union `D` defined here
    _: Foo, //~ NOTE unnamed field defined here
}

Version information

rustc 1.78.0-nightly (4ae1e7987 2024-02-15)
binary: rustc
commit-hash: 4ae1e79876fcee94a56c1edf7c029a677084d7fc
commit-date: 2024-02-15
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0412]: cannot find type `Foo` in this scope
 --> /tmp/icemaker_global_tempdir.PsY4g7WJv2in/rustc_testrunner_tmpdir_reporting.BtIZwWFLl4Dp/mvce.rs:2:8
  |
2 |     _: Foo,
  |        ^^^ not found in this scope

error[E0658]: unnamed fields are not yet fully implemented
 --> /tmp/icemaker_global_tempdir.PsY4g7WJv2in/rustc_testrunner_tmpdir_reporting.BtIZwWFLl4Dp/mvce.rs:2:5
  |
2 |     _: Foo,
  |     ^
  |
  = 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
  = note: this compiler was built on 2024-02-15; consider upgrading it if it is out of date

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

thread 'rustc' panicked at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/compiler/rustc_hir/src/def.rs:653:45:
attempted .def_id() on invalid res: Err
stack backtrace:
   0:     0x7f28d2bbee46 - std::backtrace_rs::backtrace::libunwind::trace::hcc3d90ef12e96b5c
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f28d2bbee46 - std::backtrace_rs::backtrace::trace_unsynchronized::h9e44c795d3a32a31
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f28d2bbee46 - std::sys_common::backtrace::_print_fmt::h06f6a85e1f7bfe6a
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f28d2bbee46 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3a0e4a97abc24368
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f28d2c0f46c - core::fmt::rt::Argument::fmt::hf9d66c2ae68e512f
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/core/src/fmt/rt.rs:142:9
   5:     0x7f28d2c0f46c - core::fmt::write::h255428336c5c4d68
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f28d2bb27ef - std::io::Write::write_fmt::h8df21bf872710cca
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/std/src/io/mod.rs:1854:15
   7:     0x7f28d2bbebf4 - std::sys_common::backtrace::_print::hdba8a076d62b5a13
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f28d2bbebf4 - std::sys_common::backtrace::print::h3796ba41287d5e8f
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f28d2bc193b - std::panicking::default_hook::{{closure}}::hf33809fe69ce2a32
  10:     0x7f28d2bc1689 - std::panicking::default_hook::h2139224d4049251f
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/std/src/panicking.rs:292:9
  11:     0x7f28cf9f3dec - std[8987fc0b08a76998]::panicking::update_hook::<alloc[7b677b30fb9d50db]::boxed::Box<rustc_driver_impl[cba9acd42ce093f7]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f28d2bc20a0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::he963d7bf45d9f2f8
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/alloc/src/boxed.rs:2030:9
  13:     0x7f28d2bc20a0 - std::panicking::rust_panic_with_hook::hed73a13dc766f57e
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/std/src/panicking.rs:785:13
  14:     0x7f28d2bc1de2 - std::panicking::begin_panic_handler::{{closure}}::hfee7e5c160ef18d6
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/std/src/panicking.rs:659:13
  15:     0x7f28d2bbf326 - std::sys_common::backtrace::__rust_end_short_backtrace::h99608b782830294c
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f28d2bc1b14 - rust_begin_unwind
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/std/src/panicking.rs:647:5
  17:     0x7f28d2c0b975 - core::panicking::panic_fmt::hd77d60d7e0b5325a
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/core/src/panicking.rs:72:14
  18:     0x7f28cfad5183 - <rustc_hir[e2f191fafc321d5f]::def::Res>::def_id
  19:     0x7f28d2131ce1 - <rustc_hir_analysis[47139fb5b7dde87e]::collect::FieldUniquenessCheckContext>::check_field.cold.0
  20:     0x7f28d15cc9fc - rustc_hir_analysis[47139fb5b7dde87e]::collect::convert_variant
  21:     0x7f28d15cc319 - rustc_hir_analysis[47139fb5b7dde87e]::collect::adt_def
  22:     0x7f28d0c90915 - rustc_query_impl[473ff90346133de9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[473ff90346133de9]::query_impl::adt_def::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a3fb61e483312760]::query::erase::Erased<[u8; 8usize]>>
  23:     0x7f28d0c90fe0 - rustc_query_system[583d5dc4e07867b4]::query::plumbing::try_execute_query::<rustc_query_impl[473ff90346133de9]::DynamicConfig<rustc_query_system[583d5dc4e07867b4]::query::caches::DefIdCache<rustc_middle[a3fb61e483312760]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[473ff90346133de9]::plumbing::QueryCtxt, false>
  24:     0x7f28d0c902de - rustc_query_impl[473ff90346133de9]::query_impl::adt_def::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7f28d0e5f192 - rustc_middle[a3fb61e483312760]::query::plumbing::query_get_at::<rustc_query_system[583d5dc4e07867b4]::query::caches::DefIdCache<rustc_middle[a3fb61e483312760]::query::erase::Erased<[u8; 8usize]>>>
  26:     0x7f28ceff9869 - rustc_hir_analysis[47139fb5b7dde87e]::collect::type_of::type_of
  27:     0x7f28d0c9233a - rustc_query_impl[473ff90346133de9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[473ff90346133de9]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a3fb61e483312760]::query::erase::Erased<[u8; 8usize]>>
  28:     0x7f28d0c90fe0 - rustc_query_system[583d5dc4e07867b4]::query::plumbing::try_execute_query::<rustc_query_impl[473ff90346133de9]::DynamicConfig<rustc_query_system[583d5dc4e07867b4]::query::caches::DefIdCache<rustc_middle[a3fb61e483312760]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[473ff90346133de9]::plumbing::QueryCtxt, false>
  29:     0x7f28d0c90add - rustc_query_impl[473ff90346133de9]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f28d0fe79e3 - <rustc_hir_analysis[47139fb5b7dde87e]::collect::CollectItemTypesVisitor as rustc_hir[e2f191fafc321d5f]::intravisit::Visitor>::visit_item
  31:     0x7f28d0fe69f6 - rustc_hir_analysis[47139fb5b7dde87e]::collect::collect_mod_item_types
  32:     0x7f28d0fe6989 - rustc_query_impl[473ff90346133de9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[473ff90346133de9]::query_impl::collect_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a3fb61e483312760]::query::erase::Erased<[u8; 0usize]>>
  33:     0x7f28d1889c6d - rustc_query_system[583d5dc4e07867b4]::query::plumbing::try_execute_query::<rustc_query_impl[473ff90346133de9]::DynamicConfig<rustc_query_system[583d5dc4e07867b4]::query::caches::DefaultCache<rustc_span[2b05593b68d237f9]::def_id::LocalModDefId, rustc_middle[a3fb61e483312760]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[473ff90346133de9]::plumbing::QueryCtxt, false>
  34:     0x7f28d1889797 - rustc_query_impl[473ff90346133de9]::query_impl::collect_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f28d0d88528 - rustc_hir_analysis[47139fb5b7dde87e]::check_crate
  36:     0x7f28d1622093 - rustc_interface[f5e508595022ee61]::passes::analysis
  37:     0x7f28d1621ce9 - rustc_query_impl[473ff90346133de9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[473ff90346133de9]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a3fb61e483312760]::query::erase::Erased<[u8; 1usize]>>
  38:     0x7f28d1bb6fe5 - rustc_query_system[583d5dc4e07867b4]::query::plumbing::try_execute_query::<rustc_query_impl[473ff90346133de9]::DynamicConfig<rustc_query_system[583d5dc4e07867b4]::query::caches::SingleCache<rustc_middle[a3fb61e483312760]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[473ff90346133de9]::plumbing::QueryCtxt, false>
  39:     0x7f28d1bb6d49 - rustc_query_impl[473ff90346133de9]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7f28d1a45fd5 - rustc_interface[f5e508595022ee61]::interface::run_compiler::<core[2325a369051f62f2]::result::Result<(), rustc_span[2b05593b68d237f9]::ErrorGuaranteed>, rustc_driver_impl[cba9acd42ce093f7]::run_compiler::{closure#0}>::{closure#0}
  41:     0x7f28d1bceb98 - std[8987fc0b08a76998]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f5e508595022ee61]::util::run_in_thread_with_globals<rustc_interface[f5e508595022ee61]::util::run_in_thread_pool_with_globals<rustc_interface[f5e508595022ee61]::interface::run_compiler<core[2325a369051f62f2]::result::Result<(), rustc_span[2b05593b68d237f9]::ErrorGuaranteed>, rustc_driver_impl[cba9acd42ce093f7]::run_compiler::{closure#0}>::{closure#0}, core[2325a369051f62f2]::result::Result<(), rustc_span[2b05593b68d237f9]::ErrorGuaranteed>>::{closure#0}, core[2325a369051f62f2]::result::Result<(), rustc_span[2b05593b68d237f9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2325a369051f62f2]::result::Result<(), rustc_span[2b05593b68d237f9]::ErrorGuaranteed>>
  42:     0x7f28d1bce9c4 - <<std[8987fc0b08a76998]::thread::Builder>::spawn_unchecked_<rustc_interface[f5e508595022ee61]::util::run_in_thread_with_globals<rustc_interface[f5e508595022ee61]::util::run_in_thread_pool_with_globals<rustc_interface[f5e508595022ee61]::interface::run_compiler<core[2325a369051f62f2]::result::Result<(), rustc_span[2b05593b68d237f9]::ErrorGuaranteed>, rustc_driver_impl[cba9acd42ce093f7]::run_compiler::{closure#0}>::{closure#0}, core[2325a369051f62f2]::result::Result<(), rustc_span[2b05593b68d237f9]::ErrorGuaranteed>>::{closure#0}, core[2325a369051f62f2]::result::Result<(), rustc_span[2b05593b68d237f9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2325a369051f62f2]::result::Result<(), rustc_span[2b05593b68d237f9]::ErrorGuaranteed>>::{closure#1} as core[2325a369051f62f2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f28d2bcb1e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hba395c219cfd5449
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/alloc/src/boxed.rs:2016:9
  44:     0x7f28d2bcb1e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0c162d42937122ed
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/alloc/src/boxed.rs:2016:9
  45:     0x7f28d2bcb1e5 - std::sys::pal::unix::thread::Thread::new::thread_start::ha2ad7390a99d7476
                               at /rustc/4ae1e79876fcee94a56c1edf7c029a677084d7fc/library/std/src/sys/pal/unix/thread.rs:108:17
  46:     0x7f28cca749eb - <unknown>
  47:     0x7f28ccaf87cc - <unknown>
  48:                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.78.0-nightly (4ae1e7987 2024-02-15) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [adt_def] computing ADT definition for `D`
#1 [type_of] computing type of `D`
#2 [collect_mod_item_types] collecting item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

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

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Feb 15, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 15, 2024
  3. compiler-errors commented on Feb 15, 2024

    @compiler-errors
    Contributor

    Actually nvm, don't want to work on this.

    @frank-king: heads up that this code is broken. It does not verify that the unnamed field is an ADT:

    #![feature(unnamed_fields)]
    
    #[repr(C)]
    struct D {
        _: i32,
    }
    
    fn main() {}
  4. removed their assignment
    on Feb 15, 2024
  5. added and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 15, 2024
  6. self-assigned this
    on Feb 16, 2024
  7. added a commit that references this issue on Feb 17, 2024
    f4f2a75
  8. added a commit that references this issue on Feb 17, 2024
    f7e435b
  9. added a commit that references this issue on Feb 18, 2024
    68cf537
  10. added a commit that references this issue on Feb 18, 2024
    ededfc3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-type-systemArea: Type systemC-bugCategory: This is a bug.F-unnamed_fields`#![feature(unnamed_fields)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions