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

error: internal compiler error: broken MIR in DefId #105821

Closed
AuroransSolis opened this issue Dec 17, 2022 · 5 comments · Fixed by #108605
Closed

error: internal compiler error: broken MIR in DefId #105821

AuroransSolis opened this issue Dec 17, 2022 · 5 comments · Fixed by #108605
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-adt_const_params `#![feature(adt_const_params)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` glacier ICE tracked in rust-lang/glacier. 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

@AuroransSolis
Copy link

I'm back. This time I tried concatenating non-literal &'static strs.

Code

#![allow(incomplete_features)]
#![feature(adt_const_params, const_ptr_read, generic_const_exprs)]

use std::mem::ManuallyDrop;

const fn concat_strs<const A: &'static str, const B: &'static str>() -> &'static str
where
    [(); A.len()]:,
    [(); B.len()]:,
    [(); A.len() + B.len()]:,
{
    #[repr(C)]
    struct ConcatJoin<const N: usize, const M: usize> {
        left: [u8; N],
        right: [u8; M],
    }

    #[repr(C)]
    union ConcatJoiner<const N: usize, const M: usize>
    where
        [(); N + M]:,
    {
        whole: ManuallyDrop<[u8; N + M]>,
        split: ManuallyDrop<ConcatJoin<N, M>>,
    }

    const fn concat_arr<const M: usize, const N: usize>(a: [u8; M], b: [u8; N]) -> [u8; M + N]
    where
        [(); M + N]:,
    {
        unsafe {
            let joiner = ConcatJoiner {
                split: ManuallyDrop::new(ConcatJoin { left: a, right: b }),
            };
            let join = joiner.whole;
            ManuallyDrop::into_inner(join)
        }
    }

    struct Inner<const A: &'static str, const B: &'static str>;
    impl<const A: &'static str, const B: &'static str> Inner<A, B>
    where
        [(); A.len()]:,
        [(); B.len()]:,
        [(); A.len() + B.len()]:,
    {
        const ABSTR: &'static str = unsafe {
            std::str::from_utf8_unchecked(&concat_arr(
                A.as_ptr().cast::<[u8; A.len()]>().read(),
                B.as_ptr().cast::<[u8; B.len()]>().read(),
            ))
        };
    }

    Inner::<A, B>::ABSTR
}

const FOO: &str = "foo";
const BAR: &str = "bar";
const FOOBAR: &str = concat_strs::<FOO, BAR>();

Why? Excellent question, next please.

Meta

rustc --version --verbose:

rustc 1.68.0-nightly (9c07efe84 2022-12-16)
binary: rustc
commit-hash: 9c07efe84f28a44f3044237696acc295aa407ee5
commit-date: 2022-12-16
host: x86_64-unknown-linux-gnu
release: 1.68.0-nightly
LLVM version: 15.0.6

Error output

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in DefId(0:41 ~ newice[4270]::concat_strs::{impl#0}::ABSTR) (NoSolution): could not prove Binder(WellFormed([(); _]), [])
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/canonical.rs:148:13

error: internal compiler error: broken MIR in DefId(0:41 ~ newice[4270]::concat_strs::{impl#0}::ABSTR) (NoSolution): could not prove Binder(WellFormed([u8; _]), [])
  --> src/lib.rs:50:17
   |
50 |                 B.as_ptr().cast::<[u8; B.len()]>().read(),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_borrowck/src/type_check/canonical.rs:148:13

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1610:13
stack backtrace:
   0:     0x7f8a020b2d5a - std::backtrace_rs::backtrace::libunwind::trace::hf3e23dba944728e7
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f8a020b2d5a - std::backtrace_rs::backtrace::trace_unsynchronized::ha7a661dbe14f9bec
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8a020b2d5a - std::sys_common::backtrace::_print_fmt::h8bb3e793399a1d31
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f8a020b2d5a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8f001b4156af7ff0
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f89fe03f36e - core::fmt::write::h98c67bacb0ad9cb8
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f8a020a6e35 - std::io::Write::write_fmt::h21d43ee83b8bf3da
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/io/mod.rs:1682:15
   6:     0x7f8a020b2b25 - std::sys_common::backtrace::_print::hed3e659c4722fff2
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f8a020b2b25 - std::sys_common::backtrace::print::hf3af686623d05885
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f8a020b4eaf - std::panicking::default_hook::{{closure}}::hfbc532e2813a4fd8
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/panicking.rs:267:22
   9:     0x7f8a020b4beb - std::panicking::default_hook::hf22d9a6bedeb8cbb
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/panicking.rs:286:9
  10:     0x7f8a012de351 - rustc_driver[8203396c4671b89c]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f8a020b56ad - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h839d8563a5defb2f
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/alloc/src/boxed.rs:2032:9
  12:     0x7f8a020b56ad - std::panicking::rust_panic_with_hook::h2e7c62506c5adf89
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/panicking.rs:692:13
  13:     0x7f8a013174d1 - std[fecc2c98d64c5e20]::panicking::begin_panic::<rustc_errors[6c86e693eff69e36]::ExplicitBug>::{closure#0}
  14:     0x7f8a01315da6 - std[fecc2c98d64c5e20]::sys_common::backtrace::__rust_end_short_backtrace::<std[fecc2c98d64c5e20]::panicking::begin_panic<rustc_errors[6c86e693eff69e36]::ExplicitBug>::{closure#0}, !>
  15:     0x7f8a012f4d66 - std[fecc2c98d64c5e20]::panicking::begin_panic::<rustc_errors[6c86e693eff69e36]::ExplicitBug>
  16:     0x7f8a01313806 - std[fecc2c98d64c5e20]::panic::panic_any::<rustc_errors[6c86e693eff69e36]::ExplicitBug>
  17:     0x7f8a007cc906 - <rustc_errors[6c86e693eff69e36]::HandlerInner>::flush_delayed::<alloc[4e38580f0181725e]::vec::Vec<rustc_errors[6c86e693eff69e36]::diagnostic::Diagnostic>, &str>
  18:     0x7f8a005650ac - <rustc_interface[3feed755d27e3616]::passes::QueryContext>::enter::<<rustc_interface[3feed755d27e3616]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[4c48bf2e04a135c7]::result::Result<alloc[4e38580f0181725e]::boxed::Box<dyn core[4c48bf2e04a135c7]::any::Any>, rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>
  19:     0x7f8a00562586 - <rustc_interface[3feed755d27e3616]::queries::Queries>::ongoing_codegen
  20:     0x7f8a00561aa7 - <rustc_interface[3feed755d27e3616]::interface::Compiler>::enter::<rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}::{closure#2}, core[4c48bf2e04a135c7]::result::Result<core[4c48bf2e04a135c7]::option::Option<rustc_interface[3feed755d27e3616]::queries::Linker>, rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>
  21:     0x7f8a0055ca88 - rustc_span[b683b297262634fe]::with_source_map::<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_interface[3feed755d27e3616]::interface::run_compiler<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  22:     0x7f8a0055c575 - <scoped_tls[b4ee55afb72dd1f]::ScopedKey<rustc_span[b683b297262634fe]::SessionGlobals>>::set::<rustc_interface[3feed755d27e3616]::interface::run_compiler<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}>::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>
  23:     0x7f8a0055bb62 - std[fecc2c98d64c5e20]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3feed755d27e3616]::util::run_in_thread_pool_with_globals<rustc_interface[3feed755d27e3616]::interface::run_compiler<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}>::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>
  24:     0x7f8a00b9c1fe - <<std[fecc2c98d64c5e20]::thread::Builder>::spawn_unchecked_<rustc_interface[3feed755d27e3616]::util::run_in_thread_pool_with_globals<rustc_interface[3feed755d27e3616]::interface::run_compiler<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}>::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>::{closure#1} as core[4c48bf2e04a135c7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f8a020bc923 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha40757527af5f65d
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/alloc/src/boxed.rs:2000:9
  26:     0x7f8a020bc923 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf5bd55cd4ab92745
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/alloc/src/boxed.rs:2000:9
  27:     0x7f8a020bc923 - std::sys::unix::thread::Thread::new::thread_start::h087de3b4a94ba02b
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f89fdd6184a - <unknown>
  29:     0x7f89fdde03ec - <unknown>
  30:                0x0 - <unknown>
Backtrace

RUST_BACKTRACE=1:

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1610:13
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::flush_delayed::<alloc::vec::Vec<rustc_errors::diagnostic::Diagnostic>, &str>
   3: <rustc_interface::passes::QueryContext>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorGuaranteed>>
   4: <rustc_interface::queries::Queries>::ongoing_codegen
   5: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
   6: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
   7: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>

RUST_BACKTRACE=full

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1610:13
stack backtrace:
   0:     0x7f6a03216d5a - std::backtrace_rs::backtrace::libunwind::trace::hf3e23dba944728e7
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f6a03216d5a - std::backtrace_rs::backtrace::trace_unsynchronized::ha7a661dbe14f9bec
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f6a03216d5a - std::sys_common::backtrace::_print_fmt::h8bb3e793399a1d31
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f6a03216d5a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8f001b4156af7ff0
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f69ff1a336e - core::fmt::write::h98c67bacb0ad9cb8
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f6a0320ae35 - std::io::Write::write_fmt::h21d43ee83b8bf3da
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/io/mod.rs:1682:15
   6:     0x7f6a03216b25 - std::sys_common::backtrace::_print::hed3e659c4722fff2
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f6a03216b25 - std::sys_common::backtrace::print::hf3af686623d05885
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f6a03218eaf - std::panicking::default_hook::{{closure}}::hfbc532e2813a4fd8
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/panicking.rs:267:22
   9:     0x7f6a03218beb - std::panicking::default_hook::hf22d9a6bedeb8cbb
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/panicking.rs:286:9
  10:     0x7f6a02442351 - rustc_driver[8203396c4671b89c]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f6a032196ad - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h839d8563a5defb2f
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/alloc/src/boxed.rs:2032:9
  12:     0x7f6a032196ad - std::panicking::rust_panic_with_hook::h2e7c62506c5adf89
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/panicking.rs:692:13
  13:     0x7f6a0247b4d1 - std[fecc2c98d64c5e20]::panicking::begin_panic::<rustc_errors[6c86e693eff69e36]::ExplicitBug>::{closure#0}
  14:     0x7f6a02479da6 - std[fecc2c98d64c5e20]::sys_common::backtrace::__rust_end_short_backtrace::<std[fecc2c98d64c5e20]::panicking::begin_panic<rustc_errors[6c86e693eff69e36]::ExplicitBug>::{closure#0}, !>
  15:     0x7f6a02458d66 - std[fecc2c98d64c5e20]::panicking::begin_panic::<rustc_errors[6c86e693eff69e36]::ExplicitBug>
  16:     0x7f6a02477806 - std[fecc2c98d64c5e20]::panic::panic_any::<rustc_errors[6c86e693eff69e36]::ExplicitBug>
  17:     0x7f6a01930906 - <rustc_errors[6c86e693eff69e36]::HandlerInner>::flush_delayed::<alloc[4e38580f0181725e]::vec::Vec<rustc_errors[6c86e693eff69e36]::diagnostic::Diagnostic>, &str>
  18:     0x7f6a016c90ac - <rustc_interface[3feed755d27e3616]::passes::QueryContext>::enter::<<rustc_interface[3feed755d27e3616]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[4c48bf2e04a135c7]::result::Result<alloc[4e38580f0181725e]::boxed::Box<dyn core[4c48bf2e04a135c7]::any::Any>, rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>
  19:     0x7f6a016c6586 - <rustc_interface[3feed755d27e3616]::queries::Queries>::ongoing_codegen
  20:     0x7f6a016c5aa7 - <rustc_interface[3feed755d27e3616]::interface::Compiler>::enter::<rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}::{closure#2}, core[4c48bf2e04a135c7]::result::Result<core[4c48bf2e04a135c7]::option::Option<rustc_interface[3feed755d27e3616]::queries::Linker>, rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>
  21:     0x7f6a016c0a88 - rustc_span[b683b297262634fe]::with_source_map::<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_interface[3feed755d27e3616]::interface::run_compiler<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  22:     0x7f6a016c0575 - <scoped_tls[b4ee55afb72dd1f]::ScopedKey<rustc_span[b683b297262634fe]::SessionGlobals>>::set::<rustc_interface[3feed755d27e3616]::interface::run_compiler<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}>::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>
  23:     0x7f6a016bfb62 - std[fecc2c98d64c5e20]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3feed755d27e3616]::util::run_in_thread_pool_with_globals<rustc_interface[3feed755d27e3616]::interface::run_compiler<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}>::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>
  24:     0x7f6a01d001fe - <<std[fecc2c98d64c5e20]::thread::Builder>::spawn_unchecked_<rustc_interface[3feed755d27e3616]::util::run_in_thread_pool_with_globals<rustc_interface[3feed755d27e3616]::interface::run_compiler<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}>::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>::{closure#1} as core[4c48bf2e04a135c7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f6a03220923 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha40757527af5f65d
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/alloc/src/boxed.rs:2000:9
  26:     0x7f6a03220923 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf5bd55cd4ab92745
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/alloc/src/boxed.rs:2000:9
  27:     0x7f6a03220923 - std::sys::unix::thread::Thread::new::thread_start::h087de3b4a94ba02b
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f69feec584a - <unknown>
  29:     0x7f69fef443ec - <unknown>
  30:                0x0 - <unknown>

@AuroransSolis AuroransSolis 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 Dec 17, 2022
@BoxyUwU BoxyUwU added A-const-generics Area: const generics (parameters and arguments) F-generic_const_exprs `#![feature(generic_const_exprs)]` F-adt_const_params `#![feature(adt_const_params)]` labels Dec 17, 2022
@terrarier2111
Copy link
Contributor

I got another instance of this here: (sorry for the large producer) terrarier2111/Miri-weirdness@705ced8

And this is the error:


warning: functions generic over types or consts must be mangled
   --> src/fair_mutex_minimal.rs:107:1
    |
106 |   #[no_mangle]
    |   ------------ help: remove this attribute
107 | / pub fn lock_cool_name<T>(slf: &FairMutex<T>) -> Guard<'_, T> {
108 | |     let raw = slf.state.fetch_add(SECOND_CNT_ONE, Ordering::Acquire) & TICKET_MASK;
109 | |     let ticket = raw & TICKET_MASK;
110 | |     // println!("tid: {} ticket: {}", thread_id::get(), ticket);
...   |
120 | |     Guard(slf)
121 | | }
    | |_^

warning: functions generic over types or consts must be mangled
   --> src/fair_mutex_minimal.rs:126:1
    |
124 |   #[no_mangle]
    |   ------------ help: remove this attribute
125 |   #[inline(never)]
126 | / pub fn lock_slow_cool_name<T>(slf: &FairMutex<T>, ticket: usize) {
127 | |     let mut spin_wait = SpinWait::new();
128 | |     let mut state = slf.state.load(Ordering::Relaxed);
129 | |     while (curr_ticket_to_ticket(get_curr_ticket(state)))/*((state & !PARKED_BIT) >> (usize::BITS / 2))*/ != ticket {
...   |
140 | |     }
141 | | }
    | |_^

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: Missing value for constant, but no error reported?
  --> src/inlinable_ptr.rs:24:10
   |
24 |     ptr: [NonNull<T>; const { T::PTRS_LEN }],
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

error: internal compiler error: Missing value for constant, but no error reported?
  --> src/inlinable_ptr.rs:25:10
   |
25 |     val: [ManuallyDrop<Unaligned<T>>; const { T::VALS_LEN }],
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

error: internal compiler error: `report_selection_error` did not emit an error
  --> src/inlinable_ptr.rs:24:10
   |
24 |     ptr: [NonNull<T>; const { T::PTRS_LEN }],
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:592:22

error: internal compiler error: `ErrorGuaranteed` without an error
  --> src/inlinable_ptr.rs:24:10
   |
24 |     ptr: [NonNull<T>; const { T::PTRS_LEN }],
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1372:31

error: internal compiler error: `report_selection_error` did not emit an error
  --> src/inlinable_ptr.rs:25:10
   |
25 |     val: [ManuallyDrop<Unaligned<T>>; const { T::VALS_LEN }],
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:592:22

error: internal compiler error: `ErrorGuaranteed` without an error
  --> src/inlinable_ptr.rs:25:10
   |
25 |     val: [ManuallyDrop<Unaligned<T>>; const { T::VALS_LEN }],
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1372:31

error: internal compiler error: expected fullfillment errors
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:461:23

error: internal compiler error: Missing value for constant, but no error reported?
   --> src/inlinable_ptr.rs:127:10
    |
127 |     ptr: [NonNull<T>; const { T::PTRS_LEN }],
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

error: internal compiler error: Missing value for constant, but no error reported?
   --> src/inlinable_ptr.rs:128:10
    |
128 |     val: [ManuallyDrop<Unaligned<T>>; const { T::VALS_LEN }],
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

error: internal compiler error: `report_selection_error` did not emit an error
   --> src/inlinable_ptr.rs:127:10
    |
127 |     ptr: [NonNull<T>; const { T::PTRS_LEN }],
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:592:22

error: internal compiler error: `ErrorGuaranteed` without an error
   --> src/inlinable_ptr.rs:127:10
    |
127 |     ptr: [NonNull<T>; const { T::PTRS_LEN }],
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1372:31

error: internal compiler error: `report_selection_error` did not emit an error
   --> src/inlinable_ptr.rs:128:10
    |
128 |     val: [ManuallyDrop<Unaligned<T>>; const { T::VALS_LEN }],
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:592:22

error: internal compiler error: `ErrorGuaranteed` without an error
   --> src/inlinable_ptr.rs:128:10
    |
128 |     val: [ManuallyDrop<Unaligned<T>>; const { T::VALS_LEN }],
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1372:31

error: internal compiler error: Missing value for constant, but no error reported?
  --> src/inlinable_ptr.rs:34:31
   |
34 |                 ptr: unsafe { transmute([create(val)]) },
   |                               ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

error: internal compiler error: `report_selection_error` did not emit an error
  --> src/inlinable_ptr.rs:34:31
   |
34 |                 ptr: unsafe { transmute([create(val)]) },
   |                               ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:592:22

error: internal compiler error: `ErrorGuaranteed` without an error
  --> src/inlinable_ptr.rs:34:31
   |
34 |                 ptr: unsafe { transmute([create(val)]) },
   |                               ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1372:31

error: internal compiler error: Missing value for constant, but no error reported?
  --> src/inlinable_ptr.rs:35:31
   |
35 |                 val: unsafe { transmute([]) },
   |                               ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

error: internal compiler error: `report_selection_error` did not emit an error
  --> src/inlinable_ptr.rs:35:31
   |
35 |                 val: unsafe { transmute([]) },
   |                               ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:592:22

error: internal compiler error: `ErrorGuaranteed` without an error
  --> src/inlinable_ptr.rs:35:31
   |
35 |                 val: unsafe { transmute([]) },
   |                               ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1372:31

error: internal compiler error: Missing value for constant, but no error reported?
  --> src/inlinable_ptr.rs:39:31
   |
39 |                 ptr: unsafe { transmute([]) },
   |                               ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

error: internal compiler error: `report_selection_error` did not emit an error
  --> src/inlinable_ptr.rs:39:31
   |
39 |                 ptr: unsafe { transmute([]) },
   |                               ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:592:22

error: internal compiler error: `ErrorGuaranteed` without an error
  --> src/inlinable_ptr.rs:39:31
   |
39 |                 ptr: unsafe { transmute([]) },
   |                               ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1372:31

error: internal compiler error: Missing value for constant, but no error reported?
  --> src/inlinable_ptr.rs:40:31
   |
40 |                 val: unsafe { transmute([ManuallyDrop::new(Unaligned(val))]) },
   |                               ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

error: internal compiler error: `report_selection_error` did not emit an error
  --> src/inlinable_ptr.rs:40:31
   |
40 |                 val: unsafe { transmute([ManuallyDrop::new(Unaligned(val))]) },
   |                               ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:592:22

error: internal compiler error: `ErrorGuaranteed` without an error
  --> src/inlinable_ptr.rs:40:31
   |
40 |                 val: unsafe { transmute([ManuallyDrop::new(Unaligned(val))]) },
   |                               ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1372:31

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/compiler/rustc_middle/src/ty/relate.rs:417:59

error: internal compiler error: Missing value for constant, but no error reported?
   --> src/inlinable_ptr.rs:137:31
    |
137 |                 ptr: unsafe { transmute([create(val)]) },
    |                               ^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

error: internal compiler error: `report_selection_error` did not emit an error
   --> src/inlinable_ptr.rs:137:31
    |
137 |                 ptr: unsafe { transmute([create(val)]) },
    |                               ^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:592:22

error: internal compiler error: `ErrorGuaranteed` without an error
   --> src/inlinable_ptr.rs:137:31
    |
137 |                 ptr: unsafe { transmute([create(val)]) },
    |                               ^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1372:31

error: internal compiler error: Missing value for constant, but no error reported?
   --> src/inlinable_ptr.rs:138:31
    |
138 |                 val: unsafe { transmute([]) },
    |                               ^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

error: internal compiler error: `report_selection_error` did not emit an error
   --> src/inlinable_ptr.rs:138:31
    |
138 |                 val: unsafe { transmute([]) },
    |                               ^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:592:22

error: internal compiler error: `ErrorGuaranteed` without an error
   --> src/inlinable_ptr.rs:138:31
    |
138 |                 val: unsafe { transmute([]) },
    |                               ^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1372:31

error: internal compiler error: Missing value for constant, but no error reported?
   --> src/inlinable_ptr.rs:142:31
    |
142 |                 ptr: unsafe { transmute([]) },
    |                               ^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

error: internal compiler error: `report_selection_error` did not emit an error
   --> src/inlinable_ptr.rs:142:31
    |
142 |                 ptr: unsafe { transmute([]) },
    |                               ^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:592:22

error: internal compiler error: `ErrorGuaranteed` without an error
   --> src/inlinable_ptr.rs:142:31
    |
142 |                 ptr: unsafe { transmute([]) },
    |                               ^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1372:31

error: internal compiler error: Missing value for constant, but no error reported?
   --> src/inlinable_ptr.rs:143:31
    |
143 |                 val: unsafe { transmute([ManuallyDrop::new(Unaligned(val))]) },
    |                               ^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

error: internal compiler error: `report_selection_error` did not emit an error
   --> src/inlinable_ptr.rs:143:31
    |
143 |                 val: unsafe { transmute([ManuallyDrop::new(Unaligned(val))]) },
    |                               ^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:592:22

error: internal compiler error: `ErrorGuaranteed` without an error
   --> src/inlinable_ptr.rs:143:31
    |
143 |                 val: unsafe { transmute([ManuallyDrop::new(Unaligned(val))]) },
    |                               ^^^^^^^^^
    |
    = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1372:31

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_mir_build/src/build/mod.rs:638:18

error: internal compiler error: broken MIR in DefId(0:912 ~ AssemblyTest[7d02]::inlinable_ptr::{impl#0}::new_with) ("return type"): bad type [type error]
  --> src/inlinable_ptr.rs:31:5
   |
31 |     pub fn new_with(val: T, create: impl FnMut(T) -> NonNull<T>) -> Self {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:768:20

error: internal compiler error: broken MIR in DefId(0:912 ~ AssemblyTest[7d02]::inlinable_ptr::{impl#0}::new_with) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: src/inlinable_ptr.rs:31:5: 31:73 (#0), scope: scope[0] } }): bad type [type error]
  --> src/inlinable_ptr.rs:31:5
   |
31 |     pub fn new_with(val: T, create: impl FnMut(T) -> NonNull<T>) -> Self {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

error: internal compiler error: broken MIR in DefId(0:940 ~ AssemblyTest[7d02]::inlinable_ptr::{impl#5}::new_with) ("return type"): bad type [type error]
   --> src/inlinable_ptr.rs:134:5
    |
134 |     pub fn new_with(val: T, create: impl FnMut(T) -> NonNull<T>) -> Self {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

error: internal compiler error: broken MIR in DefId(0:940 ~ AssemblyTest[7d02]::inlinable_ptr::{impl#5}::new_with) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: src/inlinable_ptr.rs:134:5: 134:73 (#0), scope: scope[0] } }): bad type [type error]
   --> src/inlinable_ptr.rs:134:5
    |
134 |     pub fn new_with(val: T, create: impl FnMut(T) -> NonNull<T>) -> Self {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1610:13
stack backtrace:
   0:     0x7f15bca3bd5a - std::backtrace_rs::backtrace::libunwind::trace::hf3e23dba944728e7
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f15bca3bd5a - std::backtrace_rs::backtrace::trace_unsynchronized::ha7a661dbe14f9bec
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f15bca3bd5a - std::sys_common::backtrace::_print_fmt::h8bb3e793399a1d31
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f15bca3bd5a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8f001b4156af7ff0
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f15b89c836e - core::fmt::write::h98c67bacb0ad9cb8
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f15bca2fe35 - std::io::Write::write_fmt::h21d43ee83b8bf3da
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/io/mod.rs:1682:15
   6:     0x7f15bca3bb25 - std::sys_common::backtrace::_print::hed3e659c4722fff2
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f15bca3bb25 - std::sys_common::backtrace::print::hf3af686623d05885
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f15bca3deaf - std::panicking::default_hook::{{closure}}::hfbc532e2813a4fd8
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/panicking.rs:267:22
   9:     0x7f15bca3dbeb - std::panicking::default_hook::hf22d9a6bedeb8cbb
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/panicking.rs:286:9
  10:     0x7f15bbc67351 - rustc_driver[8203396c4671b89c]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f15bca3e6ad - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h839d8563a5defb2f
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/alloc/src/boxed.rs:2032:9
  12:     0x7f15bca3e6ad - std::panicking::rust_panic_with_hook::h2e7c62506c5adf89
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/panicking.rs:692:13
  13:     0x7f15bbca04d1 - std[fecc2c98d64c5e20]::panicking::begin_panic::<rustc_errors[6c86e693eff69e36]::ExplicitBug>::{closure#0}
  14:     0x7f15bbc9eda6 - std[fecc2c98d64c5e20]::sys_common::backtrace::__rust_end_short_backtrace::<std[fecc2c98d64c5e20]::panicking::begin_panic<rustc_errors[6c86e693eff69e36]::ExplicitBug>::{closure#0}, !>
  15:     0x7f15bbc7dd66 - std[fecc2c98d64c5e20]::panicking::begin_panic::<rustc_errors[6c86e693eff69e36]::ExplicitBug>
  16:     0x7f15bbc9c806 - std[fecc2c98d64c5e20]::panic::panic_any::<rustc_errors[6c86e693eff69e36]::ExplicitBug>
  17:     0x7f15bb155906 - <rustc_errors[6c86e693eff69e36]::HandlerInner>::flush_delayed::<alloc[4e38580f0181725e]::vec::Vec<rustc_errors[6c86e693eff69e36]::diagnostic::Diagnostic>, &str>
  18:     0x7f15baeee0ac - <rustc_interface[3feed755d27e3616]::passes::QueryContext>::enter::<<rustc_interface[3feed755d27e3616]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[4c48bf2e04a135c7]::result::Result<alloc[4e38580f0181725e]::boxed::Box<dyn core[4c48bf2e04a135c7]::any::Any>, rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>
  19:     0x7f15baeeb586 - <rustc_interface[3feed755d27e3616]::queries::Queries>::ongoing_codegen
  20:     0x7f15baeeaaa7 - <rustc_interface[3feed755d27e3616]::interface::Compiler>::enter::<rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}::{closure#2}, core[4c48bf2e04a135c7]::result::Result<core[4c48bf2e04a135c7]::option::Option<rustc_interface[3feed755d27e3616]::queries::Linker>, rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>
  21:     0x7f15baee5a88 - rustc_span[b683b297262634fe]::with_source_map::<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_interface[3feed755d27e3616]::interface::run_compiler<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  22:     0x7f15baee5575 - <scoped_tls[b4ee55afb72dd1f]::ScopedKey<rustc_span[b683b297262634fe]::SessionGlobals>>::set::<rustc_interface[3feed755d27e3616]::interface::run_compiler<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}>::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>
  23:     0x7f15baee4b62 - std[fecc2c98d64c5e20]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3feed755d27e3616]::util::run_in_thread_pool_with_globals<rustc_interface[3feed755d27e3616]::interface::run_compiler<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}>::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>
  24:     0x7f15bb5251fe - <<std[fecc2c98d64c5e20]::thread::Builder>::spawn_unchecked_<rustc_interface[3feed755d27e3616]::util::run_in_thread_pool_with_globals<rustc_interface[3feed755d27e3616]::interface::run_compiler<core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>, rustc_driver[8203396c4671b89c]::run_compiler::{closure#1}>::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4c48bf2e04a135c7]::result::Result<(), rustc_errors[6c86e693eff69e36]::ErrorGuaranteed>>::{closure#1} as core[4c48bf2e04a135c7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f15bca45923 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha40757527af5f65d
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/alloc/src/boxed.rs:2000:9
  26:     0x7f15bca45923 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf5bd55cd4ab92745
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/alloc/src/boxed.rs:2000:9
  27:     0x7f15bca45923 - std::sys::unix::thread::Thread::new::thread_start::h087de3b4a94ba02b
                               at /rustc/9c07efe84f28a44f3044237696acc295aa407ee5/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f15b871414d - start_thread
  29:     0x7f15b8795a00 - __GI___clone3
  30:                0x0 - <unknown>

note: 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.68.0-nightly (9c07efe84 2022-12-16) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C opt-level=3 -C embed-bitcode=no

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

query stack during panic:
end of query stack
warning: `AssemblyTest` (bin "AssemblyTest") generated 158 warnings (run `cargo fix --bin "AssemblyTest"` to apply 59 suggestions)
error: could not compile `AssemblyTest`; 158 warnings emitted

@jruderman
Copy link
Contributor

Shorter variant that avoids unsafe and hits the same ICE:

#![allow(incomplete_features)]
#![feature(adt_const_params, const_ptr_read, generic_const_exprs)]
#![allow(dead_code)]

const fn catone<const M: usize>(_a: &[u8; M]) -> [u8; M + 1]
where
    [(); M + 1]:,
{
    unimplemented!()
}

struct Catter<const A: &'static [u8]>;
impl<const A: &'static [u8]> Catter<A>
where
    [(); A.len() + 1]:,
{
    const ZEROS: &'static [u8; A.len()] = &[0_u8; A.len()];
    const R: &'static [u8] = &catone(Self::ZEROS);
}

fn main() {}

Regression in nightly-2021-12-06. In earlier versions, the compiler reported "error: overly complex generic constant".

Commits in range
  commit[0] 2021-12-04UTC: Auto merge of #91517 - matthiaskrgr:rollup-3fmp4go, r=matthiaskrgr
  commit[1] 2021-12-05UTC: Auto merge of #91539 - matthiaskrgr:rollup-rnl10yb, r=matthiaskrgr
  commit[2] 2021-12-05UTC: Auto merge of #91475 - ecstatic-morse:mir-pass-manager3, r=oli-obk
  commit[3] 2021-12-05UTC: Auto merge of #91229 - Aaron1011:dist-lld, r=Mark-Simulacrum
  commit[4] 2021-12-05UTC: Auto merge of #91510 - camelid:two-cleanups, r=GuillaumeGomez
  commit[5] 2021-12-05UTC: Auto merge of #88611 - m-ou-se:array-into-iter-new-deprecate, r=joshtriplett
  commit[6] 2021-12-05UTC: Auto merge of #91555 - matthiaskrgr:rollup-pq0iaq7, r=matthiaskrgr
  commit[7] 2021-12-05UTC: Auto merge of #91356 - GuillaumeGomez:improve-rustdoc-layout, r=jsha

@AuroransSolis
Copy link
Author

Just to clarify, the issue is almost certainly just in adt_const_params. I have functioning (compiling, at least) code that does array concatenation, extension, etc. using the same pattern as in the first post for array concatenation when the arrays are function arguments instead of const generic parameters.

@AuroransSolis
Copy link
Author

Update: the issue is somewhere in the use of unsafe. I rewrote it without using any unsafe and this actually compiles and works:

#![allow(incomplete_features)]
#![feature(adt_const_params, generic_const_exprs)]

const fn str_to_arr<const FOO: &'static str>() -> [u8; FOO.len()] {
    let mut out = [0; FOO.len()];
    let bytes = FOO.as_bytes();
    let mut i = 0;
    while i < bytes.len() {
        out[i] = bytes[i];
        i += 1;
    }
    out
}

const fn concat_strs<const A: &'static str, const B: &'static str>() -> &'static str
where
    [(); A.len()]:,
    [(); B.len()]:,
    [(); A.len() + B.len()]:,
{
    struct Inner<const A: &'static str, const B: &'static str>;
    impl<const A: &'static str, const B: &'static str> Inner<A, B>
    where
        [(); A.len()]:,
        [(); B.len()]:,
        [(); A.len() + B.len()]:,
    {
        const ARRA: [u8; A.len()] = str_to_arr::<A>();
        const ARRB: [u8; B.len()] = str_to_arr::<B>();
        const ARRJOIN: [u8; A.len() + B.len()] = {
            let mut out = [0; A.len() + B.len()];
            let mut i = 0;
            while i < A.len() {
                out[i] = Self::ARRA[i];
                i += 1;
            }
            while i - A.len() < B.len() {
                out[i] = Self::ARRB[i - A.len()];
                i += 1;
            }
            out
        };
        const STRJOIN: &str = unsafe { std::str::from_utf8_unchecked(&Self::ARRJOIN) };
    }
    
    Inner::<A, B>::STRJOIN
}

const TESTL: &str = "Hello, ";
const TESTR: &str = "world!";
const TESTJOIN: &str = concat_strs::<TESTL, TESTR>();

fn main() {
    println!("'{TESTL}'");
    println!("'{TESTR}'");
    println!("'{TESTJOIN}'");
}

This was as part of trying to confirm the issue was not in const_ptr_read. However, as soon as I put the union method of joining arrays back in, e.g.

#[repr(C)]
struct ConcatJoin<const M: usize, const N: usize> {
    left: [u8; M],
    right: [u8; N],
}

#[repr(C)]
union ConcatJoiner<const M: usize, const N: usize>
where
    [(); M + N]:,
{
    whole: ManuallyDrop<[u8; M + N]>,
    split: ManuallyDrop<ConcatJoin<M, N>>,
}

const fn concat_arrs<const M: usize, const N: usize>(a: [u8; M], b: [u8; N]) -> [u8; M + N]
where
    [(); M + N]:,
{
    unsafe {
        let joiner = ConcatJoiner {
            split: ManuallyDrop::new(ConcatJoin { left: a, right: b }),
        };
        let join = joiner.whole;
        ManuallyDrop::into_inner(join)
    }
}

and then

        const ARRA: [u8; A.len()] = str_to_arr::<A>();
        const ARRB: [u8; B.len()] = str_to_arr::<B>();
        const ARRJOIN: [u8; A.len() + B.len()] = concat_arrs(Self::ARRA, Self::ARRB);
        const STRJOIN: &str = unsafe { std::str::from_utf8_unchecked(&Self::ARRJOIN) };

I get the exact same issue as in what was initially reported.

@Alexendoo
Copy link
Member

No longer ICEs since #107434

@Alexendoo Alexendoo added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Feb 8, 2023
JohnTitor added a commit to JohnTitor/rust that referenced this issue Mar 1, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 1, 2023
Rollup of 7 pull requests

Successful merges:

 - rust-lang#108143 (rustdoc: search by macro when query ends with `!`)
 - rust-lang#108394 (Make `x doc --open` work on every book)
 - rust-lang#108427 (Recover from for-else and while-else)
 - rust-lang#108462 (Fix `VecDeque::append` capacity overflow for ZSTs)
 - rust-lang#108568 (Make associated_item_def_ids for traits use an unstable option to also return associated types for RPITITs)
 - rust-lang#108604 (Add regression test for rust-lang#107280)
 - rust-lang#108605 (Add regression test for rust-lang#105821)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 02e4eef Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-adt_const_params `#![feature(adt_const_params)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` glacier ICE tracked in rust-lang/glacier. 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.

6 participants