Skip to content

Regression ICE with const generics when updating from 7c3872e6b 2021-06-24 to 7a16cfcff 2021-07-11 #87076

Description

@Buzzec

Compiled fine on 7c3872e6b 2021-06-24, updated to 7a16cfcff 2021-07-11 and got ICE.
Using const generic features.

Code

Github link

Meta

rustc --version --verbose:

rustc 1.53.0 (53cb7b09b 2021-06-17)
binary: rustc
commit-hash: 53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b
commit-date: 2021-06-17
host: x86_64-unknown-linux-gnu
release: 1.53.0
LLVM version: 12.0.1

Error output

/home/buzzec/.cargo/bin/cargo +nightly test --color=always --message-format=json-diagnostic-rendered-ansi --no-run
   Compiling space_rpg v0.1.0 (/home/buzzec/CLionProjects/space_rpg)
error: internal compiler error: /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/compiler/rustc_middle/src/ty/consts.rs:195:32: expected bits of units::unit_dims::UnitDims, got Const {
    ty: units::unit_dims::UnitDims,
    val: Value(
        ByRef {
            alloc: Allocation {
                bytes: [
                    1,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    2,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    3,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    4,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    5,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    6,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    7,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                ],
                relocations: Relocations(
                    SortedMap {
                        data: [],
                    },
                ),
                init_mask: InitMask {
                    blocks: [
                        72057594037927935,
                    ],
                    len: Size {
                        raw: 56,
                    },
                },
                align: Align {
                    pow2: 3,
                },
                mutability: Not,
                extra: (),
            },
            offset: Size {
                raw: 0,
            },
        },
    ),
}

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1035:9
stack backtrace:
   0:     0x7fea34ac8f20 - std::backtrace_rs::backtrace::libunwind::trace::h706b838f5bbd876b
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7fea34ac8f20 - std::backtrace_rs::backtrace::trace_unsynchronized::hc15f29ae7822b7b8
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fea34ac8f20 - std::sys_common::backtrace::_print_fmt::h7c580c971f91926c
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fea34ac8f20 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2a772198c4032452
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fea34b36d0c - core::fmt::write::h9a6d9c74526a6c1b
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/core/src/fmt/mod.rs:1115:17
   5:     0x7fea34aba665 - std::io::Write::write_fmt::h00f38d9eb2c32e02
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/io/mod.rs:1663:15
   6:     0x7fea34accc3b - std::sys_common::backtrace::_print::h5b3c171e6f864ae4
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fea34accc3b - std::sys_common::backtrace::print::h93b9e9ed2a98e611
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fea34accc3b - std::panicking::default_hook::{{closure}}::hd8da92bb68d520c5
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/panicking.rs:208:50
   9:     0x7fea34acc711 - std::panicking::default_hook::hdbc8b2951c5afbab
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/panicking.rs:225:9
  10:     0x7fea352a2ee1 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h9115897f26ef0e94
  11:     0x7fea34acd469 - std::panicking::rust_panic_with_hook::h8a4c841655926f4e
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/panicking.rs:626:17
  12:     0x7fea3627c3fb - std::panicking::begin_panic::{{closure}}::hac8dad9bdcca0cfd
  13:     0x7fea3627c396 - std::sys_common::backtrace::__rust_end_short_backtrace::h99db2744a599084f
  14:     0x7fea3627d67f - std::panicking::begin_panic::h41e6b8bec3069875
  15:     0x7fea362929ad - std::panic::panic_any::h0c9457317d749814
  16:     0x7fea3629580a - rustc_errors::HandlerInner::bug::h1af6e8cc9c30e551
  17:     0x7fea362952c0 - rustc_errors::Handler::bug::h92bd20b9466c2cbf
  18:     0x7fea361051ec - rustc_middle::ty::context::tls::with_opt::h1c4490ff766d8628
  19:     0x7fea36105a80 - rustc_middle::util::bug::opt_span_bug_fmt::ha8d3313fb245704f
  20:     0x7fea361059f6 - rustc_middle::util::bug::bug_fmt::h7d94326a7f647af1
  21:     0x7fea369c4ade - rustc_codegen_ssa::debuginfo::type_names::push_generic_params_internal::h023c4e6ede752e45
  22:     0x7fea369be17e - rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_type_name::h554f60ebcc2b3436
  23:     0x7fea363c8f40 - rustc_codegen_llvm::debuginfo::metadata::type_metadata::h20e77a5a61e1260c
  24:     0x7fea363db88f - rustc_codegen_llvm::debuginfo::<impl rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods for rustc_codegen_llvm::context::CodegenCx>::create_dbg_var::hfc309198a701ce07
  25:     0x7fea363f7814 - rustc_codegen_ssa::mir::codegen_mir::hba46b235138f9c53
  26:     0x7fea363e0ae6 - rustc_codegen_ssa::base::codegen_instance::h5ce3a13b251f2241
  27:     0x7fea363e4d46 - <rustc_middle::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define::h3096383390f22ff0
  28:     0x7fea363ee18d - rustc_codegen_llvm::base::compile_codegen_unit::module_codegen::h2d90d12cab20a933
  29:     0x7fea36e26d9a - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h45893157b175f074
  30:     0x7fea36e3e347 - rustc_codegen_llvm::base::compile_codegen_unit::h1ce3124a5e9e6cea
  31:     0x7fea36e2b406 - <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::h64257afe5c81b421
  32:     0x7fea36dade4c - rustc_interface::passes::QueryContext::enter::hd468a0e11b4f6832
  33:     0x7fea36da5a16 - rustc_interface::queries::Queries::ongoing_codegen::h469a87d34d18ff55
  34:     0x7fea36d8480f - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h322d262b9c0938c4
  35:     0x7fea36d7389c - rustc_span::with_source_map::hef536b13581cfdf1
  36:     0x7fea36d8597a - rustc_interface::interface::create_compiler_and_run::h268d650d50fb09f1
  37:     0x7fea36d78ac9 - scoped_tls::ScopedKey<T>::set::h01e1202900a6e691
  38:     0x7fea36d759aa - std::sys_common::backtrace::__rust_begin_short_backtrace::h32f903e490a897c1
  39:     0x7fea36d74235 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h3ecb73c3653fe1a0
  40:     0x7fea34ad9a17 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha8b1d5a0092467fc
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/alloc/src/boxed.rs:1572:9
  41:     0x7fea34ad9a17 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4b9f24ec4e8a879e
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/alloc/src/boxed.rs:1572:9
  42:     0x7fea34ad9a17 - std::sys::unix::thread::Thread::new::thread_start::h2a0e98fbc4ab4c32
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/sys/unix/thread.rs:74:17
  43:     0x7fea349fe609 - start_thread
  44:     0x7fea34912293 - clone
  45:                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.55.0-nightly (7a16cfcff 2021-07-11) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: aborting due to previous error

error: could not compile `space_rpg`
To learn more, run the command again with --verbose.
Process finished with exit code 101
Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1035:9
stack backtrace:
   0:     0x7fea34ac8f20 - std::backtrace_rs::backtrace::libunwind::trace::h706b838f5bbd876b
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7fea34ac8f20 - std::backtrace_rs::backtrace::trace_unsynchronized::hc15f29ae7822b7b8
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fea34ac8f20 - std::sys_common::backtrace::_print_fmt::h7c580c971f91926c
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fea34ac8f20 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2a772198c4032452
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fea34b36d0c - core::fmt::write::h9a6d9c74526a6c1b
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/core/src/fmt/mod.rs:1115:17
   5:     0x7fea34aba665 - std::io::Write::write_fmt::h00f38d9eb2c32e02
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/io/mod.rs:1663:15
   6:     0x7fea34accc3b - std::sys_common::backtrace::_print::h5b3c171e6f864ae4
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fea34accc3b - std::sys_common::backtrace::print::h93b9e9ed2a98e611
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fea34accc3b - std::panicking::default_hook::{{closure}}::hd8da92bb68d520c5
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/panicking.rs:208:50
   9:     0x7fea34acc711 - std::panicking::default_hook::hdbc8b2951c5afbab
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/panicking.rs:225:9
  10:     0x7fea352a2ee1 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h9115897f26ef0e94
  11:     0x7fea34acd469 - std::panicking::rust_panic_with_hook::h8a4c841655926f4e
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/panicking.rs:626:17
  12:     0x7fea3627c3fb - std::panicking::begin_panic::{{closure}}::hac8dad9bdcca0cfd
  13:     0x7fea3627c396 - std::sys_common::backtrace::__rust_end_short_backtrace::h99db2744a599084f
  14:     0x7fea3627d67f - std::panicking::begin_panic::h41e6b8bec3069875
  15:     0x7fea362929ad - std::panic::panic_any::h0c9457317d749814
  16:     0x7fea3629580a - rustc_errors::HandlerInner::bug::h1af6e8cc9c30e551
  17:     0x7fea362952c0 - rustc_errors::Handler::bug::h92bd20b9466c2cbf
  18:     0x7fea361051ec - rustc_middle::ty::context::tls::with_opt::h1c4490ff766d8628
  19:     0x7fea36105a80 - rustc_middle::util::bug::opt_span_bug_fmt::ha8d3313fb245704f
  20:     0x7fea361059f6 - rustc_middle::util::bug::bug_fmt::h7d94326a7f647af1
  21:     0x7fea369c4ade - rustc_codegen_ssa::debuginfo::type_names::push_generic_params_internal::h023c4e6ede752e45
  22:     0x7fea369be17e - rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_type_name::h554f60ebcc2b3436
  23:     0x7fea363c8f40 - rustc_codegen_llvm::debuginfo::metadata::type_metadata::h20e77a5a61e1260c
  24:     0x7fea363db88f - rustc_codegen_llvm::debuginfo::<impl rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods for rustc_codegen_llvm::context::CodegenCx>::create_dbg_var::hfc309198a701ce07
  25:     0x7fea363f7814 - rustc_codegen_ssa::mir::codegen_mir::hba46b235138f9c53
  26:     0x7fea363e0ae6 - rustc_codegen_ssa::base::codegen_instance::h5ce3a13b251f2241
  27:     0x7fea363e4d46 - <rustc_middle::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define::h3096383390f22ff0
  28:     0x7fea363ee18d - rustc_codegen_llvm::base::compile_codegen_unit::module_codegen::h2d90d12cab20a933
  29:     0x7fea36e26d9a - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h45893157b175f074
  30:     0x7fea36e3e347 - rustc_codegen_llvm::base::compile_codegen_unit::h1ce3124a5e9e6cea
  31:     0x7fea36e2b406 - <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::h64257afe5c81b421
  32:     0x7fea36dade4c - rustc_interface::passes::QueryContext::enter::hd468a0e11b4f6832
  33:     0x7fea36da5a16 - rustc_interface::queries::Queries::ongoing_codegen::h469a87d34d18ff55
  34:     0x7fea36d8480f - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h322d262b9c0938c4
  35:     0x7fea36d7389c - rustc_span::with_source_map::hef536b13581cfdf1
  36:     0x7fea36d8597a - rustc_interface::interface::create_compiler_and_run::h268d650d50fb09f1
  37:     0x7fea36d78ac9 - scoped_tls::ScopedKey<T>::set::h01e1202900a6e691
  38:     0x7fea36d759aa - std::sys_common::backtrace::__rust_begin_short_backtrace::h32f903e490a897c1
  39:     0x7fea36d74235 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h3ecb73c3653fe1a0
  40:     0x7fea34ad9a17 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha8b1d5a0092467fc
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/alloc/src/boxed.rs:1572:9
  41:     0x7fea34ad9a17 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4b9f24ec4e8a879e
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/alloc/src/boxed.rs:1572:9
  42:     0x7fea34ad9a17 - std::sys::unix::thread::Thread::new::thread_start::h2a0e98fbc4ab4c32
                               at /rustc/7a16cfcffc58cd6994984a2c014b0cc27ed8f66b/library/std/src/sys/unix/thread.rs:74:17
  43:     0x7fea349fe609 - start_thread
  44:     0x7fea34912293 - clone
  45:                0x0 - <unknown>

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 12, 2021
  2. Buzzec commented on Jul 12, 2021

    @Buzzec
    Author

    Does not occur on 7100b311d 2021-07-01:

    rustc 1.55.0-nightly (7100b311d 2021-07-01)
    binary: rustc
    commit-hash: 7100b311df0367c4d9067687573d1396b22411df
    commit-date: 2021-07-01
    host: x86_64-unknown-linux-gnu
    release: 1.55.0-nightly
    LLVM version: 12.0.1
    

    Does occur on 798baebde 2021-07-02

    rustc 1.55.0-nightly (798baebde 2021-07-02)
    binary: rustc
    commit-hash: 798baebde1fe77e5a660490ec64e727a5d79970d
    commit-date: 2021-07-02
    host: x86_64-unknown-linux-gnu
    release: 1.55.0-nightly
    LLVM version: 12.0.1
    
  3. Buzzec commented on Jul 12, 2021

    @Buzzec
    Author

    I'm not the most familiar with the compiler but I think the issue lies here commit.

  4. Buzzec commented on Jul 12, 2021

    @Buzzec
    Author

    Also similar to #86961

  5. changed the title [-]New ICE with const generics when updating from `7c3872e6b 2021-06-24` to `7a16cfcff 2021-07-11`[/-] [+]Regression ICE with const generics when updating from `7c3872e6b 2021-06-24` to `7a16cfcff 2021-07-11`[/+] on Jul 12, 2021
  6. hellow554 commented on Jul 12, 2021

    @hellow554
    Contributor

    One thing to mention:

    you are asked to provide your rust version and you provided the stable version, but in your command you are using cargo +nightly test, therefore you should provide the nightly version you're using, e.g. rustc +nightly --version --verbose

  7. hellow554 commented on Jul 12, 2021

    @hellow554
    Contributor

    MCVE:

    cargo build (test is not sufficient)

    #![feature(const_generics)]
    
    #[derive(PartialEq, Eq)]
    pub struct UnitDims {
        pub time: u8,
        pub length: u8,
    }
    
    pub struct UnitValue<const DIMS: UnitDims>;
    
    impl<const DIMS: UnitDims> UnitValue<DIMS> {
        fn crash() {}
    }
    
    fn main() {
        UnitValue::<{ UnitDims { time: 1, length: 2 } }>::crash();
    }

    @rustbot modify labels: requires-nightly A-const-generics

  8. rustbot commented on Jul 12, 2021

    @rustbot
    Collaborator

    Error: Label needs-nightly can only be set by Rust team members

    Please let @rust-lang/release know if you're having trouble with this bot.

  9. added
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    A-const-genericsArea: const generics (parameters and arguments)
    on Jul 12, 2021
  10. hellow554 commented on Jul 12, 2021

    @hellow554
    Contributor

    searched nightlies: from nightly-2021-06-26 to nightly-2021-07-11
    regressed nightly: nightly-2021-07-03
    searched commits: from 7100b31 to 798baeb
    regressed commit: 2545459

    bisected with cargo-bisect-rustc v0.6.0

    Host triple: x86_64-unknown-linux-gnu
    Reproduce with:

    cargo bisect-rustc --access=github --regress=ice --without-cargo -- build

    cc #85269 @dpaoliello

  11. Buzzec commented on Jul 18, 2021

    @Buzzec
    Author

    Fixed as of

    rustc 1.55.0-nightly (74ef0c3e4 2021-07-16)
    binary: rustc
    commit-hash: 74ef0c3e404cc72c08b2d1e14506f90d9e877269
    commit-date: 2021-07-16
    host: x86_64-unknown-linux-gnu
    release: 1.55.0-nightly
    LLVM version: 12.0.1
    
  12. hellow554 commented on Jul 19, 2021

    @hellow554
    Contributor

    Fixed by #87082

    @Buzzec please reopen this issue, there should be a testcase for this.

    @rustbot modify labels: E-needs-test

  13. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Jul 19, 2021
  14. reopened this on Jul 19, 2021
  15. added 2 commits that reference this issue on Jul 23, 2021
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

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been 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.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions