Repository: rust
Issue: ICE: `sig.c_variadic || extra_args.is_empty()`
Labels: I-ICE,T-compiler,C-bug

<!--
[31mICE[0m: Rustc ./a.rs '' 'thread 'rustc' panicked at compiler/rustc_ty_utils/src/abi.rs:608:9: 'assertion failed: sig.c_variadic || extra_args.is_empty()'', 'thread 'rustc' panicked at compiler/rustc_ty_utils/src/abi.rs:608:9: 'assertion failed: sig.c_variadic || extra_args.is_empty()''
File: /tmp/im/a.rs
-->

auto-reduced (treereduce-rust):
````rust
const fn gcd(value: *const X) -> u32 {}

macro_rules! const_assert {
    ($expr:expr) => {
        const _: () = assert!($expr);
        assert!($expr);
    };
}

fn main() {
    const_assert!(gcd(18, 48) == 6);
}


````

<details><summary><strong>original code</strong></summary>
<p>

original:
````rust
// Test basic functionality of control flow in a const context.

// run-pass

const X: u32 = 4;
const Y: u32 = 5;

const ABS_DIFF: u32 = if X < Y {
    Y - X
} else {
    X - Y
};

const fn abs_diff(a: u32, b: u32) -> u32 {
    match (a, b) {
        (big, little) if big > little => big - little,
        (little, big) => big - little,
    }
}

const fn gcd(value: *const X) -> u32 {
    if b == 0 {
        return a;
    }

    gcd(b, a % b)
}

const fn fib(n: u64) -> u64 {
    if n == 0 {
        return 0;
    }

    let mut fib = (0, 1);
    let mut i = 1;
    while i < n {
        fib = (fib.1, fib.0 + fib.1);
        i += 1;
    }

    fib.1
}

const fn is_prime(n: u64) -> bool {
    if n % 2 == 0 {
        return false;
    }

    let mut div = 3;
    loop {
        if n % div == 0 {
            return false;
        }

        if div * div > n {
            return true;
        }

        div += 2;
    }
}

macro_rules! const_assert {
    ($expr:expr) => {
        const _: () = assert!($expr);
        assert!($expr);
    }
}

fn main() {
    const_assert!(abs_diff(4, 5) == abs_diff(5, 4));
    const_assert!(ABS_DIFF == abs_diff(5, 4));

    const_assert!(gcd(48, 18) == 6);
    const_assert!(gcd(18, 48) == 6);

    const_assert!(fib(2) == 1);
    const_assert!(fib(8) == 21);

    const_assert!(is_prime(113));
    const_assert!(!is_prime(117));
}

````
</p>
</details>

Version information
````
rustc 1.81.0-nightly (28cc0b643 2024-07-06)
binary: rustc
commit-hash: 28cc0b643d6c07e2e0ba24a85f397963961b4c0d
commit-date: 2024-07-06
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

````

Command:
`/home/matthias/.rustup/toolchains/master/bin/rustc `

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Program output</strong></summary>
<p>

```
error[E0412]: cannot find type `X` in this scope
 --> /tmp/icemaker_global_tempdir.V32jcTFKcCMr/rustc_testrunner_tmpdir_reporting.PBqojMhMhlYe/mvce.rs:1:28
  |
1 | const fn gcd(value: *const X) -> u32 {}
  |                            ^ not found in this scope
  |
help: you might be missing a type parameter
  |
1 | const fn gcd<X>(value: *const X) -> u32 {}
  |             +++

thread 'rustc' panicked at compiler/rustc_ty_utils/src/abi.rs:608:9:
assertion failed: sig.c_variadic || extra_args.is_empty()
stack backtrace:
   0:     0x752546aeb645 - std::backtrace_rs::backtrace::libunwind::trace::hdb8bb88eb3e00556
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x752546aeb645 - std::backtrace_rs::backtrace::trace_unsynchronized::h99f31752ead39aa8
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x752546aeb645 - std::sys::backtrace::_print_fmt::h25b48d5217cd960f
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/std/src/sys/backtrace.rs:68:5
   3:     0x752546aeb645 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h02ff5d579e038944
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/std/src/sys/backtrace.rs:44:22
   4:     0x752546b3ad4b - core::fmt::rt::Argument::fmt::h1c57a82558aacf3d
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/core/src/fmt/rt.rs:173:76
   5:     0x752546b3ad4b - core::fmt::write::h5d5b1acab555c46e
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/core/src/fmt/mod.rs:1182:21
   6:     0x752546adff7f - std::io::Write::write_fmt::h229f7fd7d121a425
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/std/src/io/mod.rs:1835:15
   7:     0x752546aeb41e - std::sys::backtrace::_print::h838b84c553692cd9
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/std/src/sys/backtrace.rs:47:5
   8:     0x752546aeb41e - std::sys::backtrace::print::h612e4cf966ab6bf3
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/std/src/sys/backtrace.rs:34:9
   9:     0x752546aedd69 - std::panicking::default_hook::{{closure}}::h38448a4b4905bd04
  10:     0x752546aedb0c - std::panicking::default_hook::h8c30ce5562c3250e
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/std/src/panicking.rs:292:9
  11:     0x752543000239 - std[4c828775a4c98e34]::panicking::update_hook::<alloc[7c6a9df3eb911b33]::boxed::Box<rustc_driver_impl[f002cc27bf416152]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x752546aee68f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h600df9638cbd5bb9
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/alloc/src/boxed.rs:2078:9
  13:     0x752546aee68f - std::panicking::rust_panic_with_hook::h41f578911dd9994e
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/std/src/panicking.rs:804:13
  14:     0x752546aee283 - std::panicking::begin_panic_handler::{{closure}}::h23c4749cd7da3939
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/std/src/panicking.rs:663:13
  15:     0x752546aebb09 - std::sys::backtrace::__rust_end_short_backtrace::h969ec5a9caa0f725
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/std/src/sys/backtrace.rs:171:18
  16:     0x752546aedf44 - rust_begin_unwind
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/std/src/panicking.rs:661:5
  17:     0x752546b37303 - core::panicking::panic_fmt::h4e9caca7d04a1e50
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/core/src/panicking.rs:74:14
  18:     0x752546b3738c - core::panicking::panic::hbe66ef8a950765ad
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/core/src/panicking.rs:148:5
  19:     0x752544ecc611 - rustc_ty_utils[88640df7fb79cc5d]::abi::fn_abi_new_uncached
  20:     0x752544ec5acc - rustc_ty_utils[88640df7fb79cc5d]::abi::fn_abi_of_instance
  21:     0x752544ec43c9 - rustc_query_impl[fdf858c4482af3a0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fdf858c4482af3a0]::query_impl::fn_abi_of_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a7962af26fd609fb]::query::erase::Erased<[u8; 16usize]>>
  22:     0x752544ec2018 - rustc_query_system[6aeb11a3d3f46031]::query::plumbing::try_execute_query::<rustc_query_impl[fdf858c4482af3a0]::DynamicConfig<rustc_query_system[6aeb11a3d3f46031]::query::caches::DefaultCache<rustc_middle[a7962af26fd609fb]::ty::ParamEnvAnd<(rustc_middle[a7962af26fd609fb]::ty::instance::Instance, &rustc_middle[a7962af26fd609fb]::ty::list::RawList<(), rustc_middle[a7962af26fd609fb]::ty::Ty>)>, rustc_middle[a7962af26fd609fb]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[fdf858c4482af3a0]::plumbing::QueryCtxt, false>
  23:     0x752544ec1c6f - rustc_query_impl[fdf858c4482af3a0]::query_impl::fn_abi_of_instance::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7525451f7511 - <rustc_const_eval[d3bb8ec8a957a846]::interpret::eval_context::InterpCx<rustc_const_eval[d3bb8ec8a957a846]::const_eval::machine::CompileTimeMachine> as rustc_middle[a7962af26fd609fb]::ty::layout::FnAbiOf>::fn_abi_of_instance
  25:     0x7525451f382c - rustc_const_eval[d3bb8ec8a957a846]::const_eval::eval_queries::eval_to_allocation_raw_provider
  26:     0x7525451f14b6 - rustc_query_impl[fdf858c4482af3a0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fdf858c4482af3a0]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a7962af26fd609fb]::query::erase::Erased<[u8; 24usize]>>
  27:     0x7525451eb291 - rustc_query_system[6aeb11a3d3f46031]::query::plumbing::try_execute_query::<rustc_query_impl[fdf858c4482af3a0]::DynamicConfig<rustc_query_system[6aeb11a3d3f46031]::query::caches::DefaultCache<rustc_middle[a7962af26fd609fb]::ty::ParamEnvAnd<rustc_middle[a7962af26fd609fb]::mir::interpret::GlobalId>, rustc_middle[a7962af26fd609fb]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[fdf858c4482af3a0]::plumbing::QueryCtxt, false>
  28:     0x7525451eae70 - rustc_query_impl[fdf858c4482af3a0]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7525451ed0de - rustc_const_eval[d3bb8ec8a957a846]::const_eval::eval_queries::eval_to_const_value_raw_provider
  30:     0x7525451ecef6 - rustc_query_impl[fdf858c4482af3a0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fdf858c4482af3a0]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a7962af26fd609fb]::query::erase::Erased<[u8; 24usize]>>
  31:     0x7525451eb254 - rustc_query_system[6aeb11a3d3f46031]::query::plumbing::try_execute_query::<rustc_query_impl[fdf858c4482af3a0]::DynamicConfig<rustc_query_system[6aeb11a3d3f46031]::query::caches::DefaultCache<rustc_middle[a7962af26fd609fb]::ty::ParamEnvAnd<rustc_middle[a7962af26fd609fb]::mir::interpret::GlobalId>, rustc_middle[a7962af26fd609fb]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[fdf858c4482af3a0]::plumbing::QueryCtxt, false>
  32:     0x7525451ead70 - rustc_query_impl[fdf858c4482af3a0]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
  33:     0x75254480cbb6 - <rustc_middle[a7962af26fd609fb]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[60a48159061277cf]::check_crate::{closure#3}>::{closure#0}
  34:     0x75254480a358 - rustc_hir_analysis[60a48159061277cf]::check_crate
  35:     0x752544fcab55 - rustc_interface[1f6122faf9455c3d]::passes::analysis
  36:     0x752544fca715 - rustc_query_impl[fdf858c4482af3a0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fdf858c4482af3a0]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a7962af26fd609fb]::query::erase::Erased<[u8; 1usize]>>
  37:     0x7525454db425 - rustc_query_system[6aeb11a3d3f46031]::query::plumbing::try_execute_query::<rustc_query_impl[fdf858c4482af3a0]::DynamicConfig<rustc_query_system[6aeb11a3d3f46031]::query::caches::SingleCache<rustc_middle[a7962af26fd609fb]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[fdf858c4482af3a0]::plumbing::QueryCtxt, false>
  38:     0x7525454db18f - rustc_query_impl[fdf858c4482af3a0]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7525453de8c5 - rustc_interface[1f6122faf9455c3d]::interface::run_compiler::<core[268056f9cad16491]::result::Result<(), rustc_span[eecf7d11a5f5c5c1]::ErrorGuaranteed>, rustc_driver_impl[f002cc27bf416152]::run_compiler::{closure#0}>::{closure#1}
  40:     0x7525453b1dc9 - std[4c828775a4c98e34]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1f6122faf9455c3d]::util::run_in_thread_with_globals<rustc_interface[1f6122faf9455c3d]::util::run_in_thread_pool_with_globals<rustc_interface[1f6122faf9455c3d]::interface::run_compiler<core[268056f9cad16491]::result::Result<(), rustc_span[eecf7d11a5f5c5c1]::ErrorGuaranteed>, rustc_driver_impl[f002cc27bf416152]::run_compiler::{closure#0}>::{closure#1}, core[268056f9cad16491]::result::Result<(), rustc_span[eecf7d11a5f5c5c1]::ErrorGuaranteed>>::{closure#0}, core[268056f9cad16491]::result::Result<(), rustc_span[eecf7d11a5f5c5c1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[268056f9cad16491]::result::Result<(), rustc_span[eecf7d11a5f5c5c1]::ErrorGuaranteed>>
  41:     0x7525453b1b7a - <<std[4c828775a4c98e34]::thread::Builder>::spawn_unchecked_<rustc_interface[1f6122faf9455c3d]::util::run_in_thread_with_globals<rustc_interface[1f6122faf9455c3d]::util::run_in_thread_pool_with_globals<rustc_interface[1f6122faf9455c3d]::interface::run_compiler<core[268056f9cad16491]::result::Result<(), rustc_span[eecf7d11a5f5c5c1]::ErrorGuaranteed>, rustc_driver_impl[f002cc27bf416152]::run_compiler::{closure#0}>::{closure#1}, core[268056f9cad16491]::result::Result<(), rustc_span[eecf7d11a5f5c5c1]::ErrorGuaranteed>>::{closure#0}, core[268056f9cad16491]::result::Result<(), rustc_span[eecf7d11a5f5c5c1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[268056f9cad16491]::result::Result<(), rustc_span[eecf7d11a5f5c5c1]::ErrorGuaranteed>>::{closure#2} as core[268056f9cad16491]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x752546af84eb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h042ab5e01e096055
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/alloc/src/boxed.rs:2064:9
  43:     0x752546af84eb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc02f3d7c1202afa6
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/alloc/src/boxed.rs:2064:9
  44:     0x752546af84eb - std::sys::pal::unix::thread::Thread::new::thread_start::h805838ff7ef2ecb5
                               at /rustc/28cc0b643d6c07e2e0ba24a85f397963961b4c0d/library/std/src/sys/pal/unix/thread.rs:108:17
  45:     0x75253faa6ded - <unknown>
  46:     0x75253fb2a0dc - <unknown>
  47:                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: please make sure that you have updated to the latest nightly

note: rustc 1.81.0-nightly (28cc0b643 2024-07-06) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [fn_abi_of_instance] computing call ABI of `gcd`  |  = note: this failure-note originates in the macro `const_assert` (in Nightly builds, run with -Z macro-backtrace for more info)

#1 [eval_to_allocation_raw] const-evaluating + checking `main::_`
end of query stack
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0412`.

```

</p>
</details>

<!--
query stack:
#0 [fn_abi_of_instance] computing call ABI of `gcd`  |  = note: this failure-note originates in the macro `const_assert` (in Nightly builds, run with -Z macro-backtrace for more info)
#1 [eval_to_allocation_raw] const-evaluating + checking `main::_`

-->