Skip to content

the naive layout isn't refined by the actual layout #113941

Closed

Description

@j0lol

Code

unsure, happened in crate inventory when compiling my project

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (0308df23e 2023-07-21)
binary: rustc
commit-hash: 0308df23e621e783e31a27ca5beaa01b9df60d4a
commit-date: 2023-07-21
host: aarch64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5

Error output

   Compiling inventory v0.3.9
error: internal compiler error: compiler/rustc_ty_utils/src/layout_sanity_check.rs:25:9: the naive layout isn't refined by the actual layout:
                                NaiveLayout {
                                    abi: Sized,
                                    niches: Maybe,
                                    size: Size(0 bytes),
                                    align: Align(4 bytes),
                                    exact: false,
                                }
                                TyAndLayout {
                                    ty: iter<T>,
                                    layout: Layout {
                                        size: Size(0 bytes),
                                        align: AbiAndPrefAlign {
                                            abi: Align(1 bytes),
                                            pref: Align(8 bytes),
                                        },
                                        abi: Aggregate {
                                            sized: true,
                                        },
                                        fields: Arbitrary {
                                            offsets: [],
                                            memory_index: [],
                                        },
                                        largest_niche: None,
                                        variants: Single {
                                            index: 1,
                                        },
                                        max_repr_align: None,
                                        unadjusted_abi_align: Align(1 bytes),
                                    },
                                }

   Compiling leptos_macro v0.4.5
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/compiler/rustc_errors/src/lib.rs:1663:9
stack backtrace:
<SNIP>
error: could not compile `inventory` (lib)
Backtrace

   0:     0xffffaabff5c4 - std::backtrace_rs::backtrace::libunwind::trace::h64c27d8061185cee
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0xffffaabff5c4 - std::backtrace_rs::backtrace::trace_unsynchronized::h6b74b1bc14295ff4
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0xffffaabff5c4 - std::sys_common::backtrace::_print_fmt::h8f459cd181b04614
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/std/src/sys_common/backtrace.rs:65:5
   3:     0xffffaabff5c4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0840aa2c1f6c02b3
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/std/src/sys_common/backtrace.rs:44:22
   4:     0xffffaac5b194 - core::fmt::rt::Argument::fmt::hcbce529d895fb3a4
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/core/src/fmt/rt.rs:138:9
   5:     0xffffaac5b194 - core::fmt::write::h84b535bfe0c3925b
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/core/src/fmt/mod.rs:1094:21
   6:     0xffffaabf3f68 - std::io::Write::write_fmt::h31fe50bd51cf41dc
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/std/src/io/mod.rs:1714:15
   7:     0xffffaabff414 - std::sys_common::backtrace::_print::hea8ee6a4ed78ee7f
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/std/src/sys_common/backtrace.rs:47:5
   8:     0xffffaabff414 - std::sys_common::backtrace::print::h373a8ff7dd9a5b09
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/std/src/sys_common/backtrace.rs:34:9
   9:     0xffffaac020a4 - std::panicking::panic_hook_with_disk_dump::{{closure}}::hc1337a36b6032f4e
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/std/src/panicking.rs:278:22
  10:     0xffffaac01d7c - std::panicking::panic_hook_with_disk_dump::he3d4cf8fe1f1b2d3
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/std/src/panicking.rs:312:9
  11:     0xffffab99fe48 - rustc_driver_impl[82f35ce1073496e1]::install_ice_hook::{closure#0}
  12:     0xffffaac028fc - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h045e5ad2fca6d060
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/alloc/src/boxed.rs:2021:9
  13:     0xffffaac028fc - std::panicking::rust_panic_with_hook::h4181bd553b86022d
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/std/src/panicking.rs:733:13
  14:     0xffffb03998a4 - std[62788c2d563118c6]::panicking::begin_panic::<rustc_errors[985b626586fcb10c]::ExplicitBug>::{closure#0}
  15:     0xffffb0395f60 - std[62788c2d563118c6]::sys_common::backtrace::__rust_end_short_backtrace::<std[62788c2d563118c6]::panicking::begin_panic<rustc_errors[985b626586fcb10c]::ExplicitBug>::{closure#0}, !>
  16:     0xffffab8c0504 - std[62788c2d563118c6]::panicking::begin_panic::<rustc_errors[985b626586fcb10c]::ExplicitBug>
  17:     0xffffb041d5c0 - <rustc_errors[985b626586fcb10c]::HandlerInner>::bug::<alloc[d98521ecd4ce54c6]::string::String>
  18:     0xffffb041d424 - <rustc_errors[985b626586fcb10c]::Handler>::bug::<alloc[d98521ecd4ce54c6]::string::String>
  19:     0xffffb03142d4 - rustc_middle[d6524ddd23000e63]::util::bug::opt_span_bug_fmt::<rustc_span[5869028186ac036]::span_encoding::Span>::{closure#0}
  20:     0xffffb0312714 - rustc_middle[d6524ddd23000e63]::ty::context::tls::with_opt::<rustc_middle[d6524ddd23000e63]::util::bug::opt_span_bug_fmt<rustc_span[5869028186ac036]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0xffffb03126e0 - rustc_middle[d6524ddd23000e63]::ty::context::tls::with_context_opt::<rustc_middle[d6524ddd23000e63]::ty::context::tls::with_opt<rustc_middle[d6524ddd23000e63]::util::bug::opt_span_bug_fmt<rustc_span[5869028186ac036]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0xffffab8c5f50 - rustc_middle[d6524ddd23000e63]::util::bug::bug_fmt
  23:     0xffffae754848 - rustc_ty_utils[9bb1f0496e50022a]::layout_sanity_check::sanity_check_layout
  24:     0xffffae76ff50 - rustc_ty_utils[9bb1f0496e50022a]::layout::layout_of
  25:     0xffffaf56a504 - rustc_query_impl[5790540113a7ca7c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5790540113a7ca7c]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d6524ddd23000e63]::query::erase::Erased<[u8; 16usize]>>
  26:     0xffffaf6d10a4 - <rustc_query_impl[5790540113a7ca7c]::query_impl::layout_of::dynamic_query::{closure#2} as core[b2a4bb11906303c2]::ops::function::FnOnce<(rustc_middle[d6524ddd23000e63]::ty::context::TyCtxt, rustc_middle[d6524ddd23000e63]::ty::ParamEnvAnd<rustc_middle[d6524ddd23000e63]::ty::Ty>)>>::call_once
  27:     0xffffaf73e69c - rustc_query_system[9a5635129a437fda]::query::plumbing::try_execute_query::<rustc_query_impl[5790540113a7ca7c]::DynamicConfig<rustc_query_system[9a5635129a437fda]::query::caches::DefaultCache<rustc_middle[d6524ddd23000e63]::ty::ParamEnvAnd<rustc_middle[d6524ddd23000e63]::ty::Ty>, rustc_middle[d6524ddd23000e63]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[5790540113a7ca7c]::plumbing::QueryCtxt, false>
  28:     0xffffaf5b1194 - rustc_query_impl[5790540113a7ca7c]::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
  29:     0xffffaeb9e8fc - rustc_middle[d6524ddd23000e63]::query::plumbing::query_get_at::<rustc_query_system[9a5635129a437fda]::query::caches::DefaultCache<rustc_middle[d6524ddd23000e63]::ty::ParamEnvAnd<rustc_middle[d6524ddd23000e63]::ty::Ty>, rustc_middle[d6524ddd23000e63]::query::erase::Erased<[u8; 16usize]>>>
  30:     0xffffaeba36d4 - <rustc_mir_transform[aafc68bfa3433c5c]::const_prop::CanConstProp>::check
  31:     0xffffaeba6dd8 - <rustc_mir_transform[aafc68bfa3433c5c]::const_prop_lint::ConstProp as rustc_mir_transform[aafc68bfa3433c5c]::pass_manager::MirLint>::run_lint
  32:     0xffffaeb2d794 - <rustc_session[55fdf58aae6cd726]::session::Session>::time::<(), rustc_mir_transform[aafc68bfa3433c5c]::pass_manager::run_passes_inner::{closure#3}>
  33:     0xffffaebf8188 - rustc_mir_transform[aafc68bfa3433c5c]::pass_manager::run_passes_inner
  34:     0xffffaec13ad4 - rustc_mir_transform[aafc68bfa3433c5c]::run_analysis_to_runtime_passes
  35:     0xffffaec13708 - rustc_mir_transform[aafc68bfa3433c5c]::mir_drops_elaborated_and_const_checked
  36:     0xffffaf569dac - rustc_query_impl[5790540113a7ca7c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5790540113a7ca7c]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d6524ddd23000e63]::query::erase::Erased<[u8; 8usize]>>
  37:     0xffffaf63bbb0 - <rustc_query_impl[5790540113a7ca7c]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2} as core[b2a4bb11906303c2]::ops::function::FnOnce<(rustc_middle[d6524ddd23000e63]::ty::context::TyCtxt, rustc_span[5869028186ac036]::def_id::LocalDefId)>>::call_once
  38:     0xffffaf78dea8 - rustc_query_system[9a5635129a437fda]::query::plumbing::try_execute_query::<rustc_query_impl[5790540113a7ca7c]::DynamicConfig<rustc_query_system[9a5635129a437fda]::query::caches::VecCache<rustc_span[5869028186ac036]::def_id::LocalDefId, rustc_middle[d6524ddd23000e63]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5790540113a7ca7c]::plumbing::QueryCtxt, false>
  39:     0xffffaf599954 - rustc_query_impl[5790540113a7ca7c]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  40:     0xffffabb27a58 - <rustc_session[55fdf58aae6cd726]::session::Session>::time::<(), rustc_interface[a76e8fb20eb955f]::passes::analysis::{closure#2}>
  41:     0xffffabb011f0 - rustc_interface[a76e8fb20eb955f]::passes::analysis
  42:     0xffffaf56a248 - rustc_query_impl[5790540113a7ca7c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5790540113a7ca7c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d6524ddd23000e63]::query::erase::Erased<[u8; 1usize]>>
  43:     0xffffaf5919b4 - <rustc_query_impl[5790540113a7ca7c]::query_impl::analysis::dynamic_query::{closure#2} as core[b2a4bb11906303c2]::ops::function::FnOnce<(rustc_middle[d6524ddd23000e63]::ty::context::TyCtxt, ())>>::call_once
  44:     0xffffaf739318 - rustc_query_system[9a5635129a437fda]::query::plumbing::try_execute_query::<rustc_query_impl[5790540113a7ca7c]::DynamicConfig<rustc_query_system[9a5635129a437fda]::query::caches::SingleCache<rustc_middle[d6524ddd23000e63]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5790540113a7ca7c]::plumbing::QueryCtxt, false>
  45:     0xffffaf5951f4 - rustc_query_impl[5790540113a7ca7c]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  46:     0xffffab9b87a4 - <rustc_middle[d6524ddd23000e63]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[82f35ce1073496e1]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[b2a4bb11906303c2]::result::Result<(), rustc_span[5869028186ac036]::ErrorGuaranteed>>
  47:     0xffffab9dbf34 - rustc_span[5869028186ac036]::set_source_map::<core[b2a4bb11906303c2]::result::Result<(), rustc_span[5869028186ac036]::ErrorGuaranteed>, rustc_interface[a76e8fb20eb955f]::interface::run_compiler<core[b2a4bb11906303c2]::result::Result<(), rustc_span[5869028186ac036]::ErrorGuaranteed>, rustc_driver_impl[82f35ce1073496e1]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  48:     0xffffab9aa724 - std[62788c2d563118c6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a76e8fb20eb955f]::util::run_in_thread_pool_with_globals<rustc_interface[a76e8fb20eb955f]::interface::run_compiler<core[b2a4bb11906303c2]::result::Result<(), rustc_span[5869028186ac036]::ErrorGuaranteed>, rustc_driver_impl[82f35ce1073496e1]::run_compiler::{closure#1}>::{closure#0}, core[b2a4bb11906303c2]::result::Result<(), rustc_span[5869028186ac036]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b2a4bb11906303c2]::result::Result<(), rustc_span[5869028186ac036]::ErrorGuaranteed>>
  49:     0xffffab9ab8f0 - <<std[62788c2d563118c6]::thread::Builder>::spawn_unchecked_<rustc_interface[a76e8fb20eb955f]::util::run_in_thread_pool_with_globals<rustc_interface[a76e8fb20eb955f]::interface::run_compiler<core[b2a4bb11906303c2]::result::Result<(), rustc_span[5869028186ac036]::ErrorGuaranteed>, rustc_driver_impl[82f35ce1073496e1]::run_compiler::{closure#1}>::{closure#0}, core[b2a4bb11906303c2]::result::Result<(), rustc_span[5869028186ac036]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b2a4bb11906303c2]::result::Result<(), rustc_span[5869028186ac036]::ErrorGuaranteed>>::{closure#1} as core[b2a4bb11906303c2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  50:     0xffffaac0c354 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::haea932353066af49
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/alloc/src/boxed.rs:2007:9
  51:     0xffffaac0c354 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3ab43f4a76e7006f
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/alloc/src/boxed.rs:2007:9
  52:     0xffffaac0c354 - std::sys::unix::thread::Thread::new::thread_start::h8175a8cdc7fbbf76
                               at /rustc/0308df23e621e783e31a27ca5beaa01b9df60d4a/library/std/src/sys/unix/thread.rs:108:17
  53:     0xffffaa974624 - start_thread
  54:     0xffffaaaa749c - <unknown>
  55:                0x0 - <unknown>

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 `/home/tilde/.cargo/registry/src/index.crates.io-6f17d22bba15001f/inventory-0.3.9/rustc-ice-2023-07-22T01:09:03.554883194Z-3312353.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [layout_of] computing layout of `iter<T>`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `ITER::<impl at /home/tilde/.cargo/registry/src/index.crates.io-6f17d22bba15001f/inventory-0.3.9/src/lib.rs:284:5: 284:46>::into_iter`
#2 [analysis] running analysis passes on this crate
end of query stack

File attached as instructed: rustc-ice-2023-07-22T01:09:03.554883194Z-3312353.txt

Activity

  1. added
    C-bugCategory: This is a bug.
    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.
    on Jul 22, 2023
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jul 22, 2023
  3. pinned this issue on Jul 22, 2023
  4. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jul 22, 2023
  5. dtolnay commented on Jul 22, 2023

    @dtolnay
    Member

    I can repro at https://github.com/dtolnay/inventory/tree/b5c9757fb621f8e429b623d70acfb8ac01238b01 using cargo build. Bisects to #113166 according to cargo-bisect-rustc --start 2023-07-21 --end 2023-07-22 -- build.

    @moulins @oli-obk PTAL

  6. 63 remaining items

  7. dtolnay commented on Jul 22, 2023

    @dtolnay
    Member

    Minimized:

    enum Void {}
    
    pub struct Struct([*const (); 0], Void);
    
    pub enum Enum {
        Variant(Struct),
    }
  8. thomcc commented on Jul 22, 2023

    @thomcc
    Member
  9. added a commit that references this issue on Jul 22, 2023
    a876552
  10. pinned this issue on Jul 22, 2023
  11. added a commit that references this issue on Jul 22, 2023
  12. RalfJung commented on Jul 22, 2023

    @RalfJung
    Member

    It also seems to break miri's stdlib tests: https://github.com/rust-lang/miri-test-libstd/actions/runs/5628275531

    miri-test-stdlib sets -Zrandomize-layout so that checks out with the observations above

  13. added a commit that references this issue on Jul 22, 2023
  14. added a commit that references this issue on Jul 22, 2023
  15. removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jul 24, 2023
  16. unpinned this issue on Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions