Skip to content

ICE: unsized arguments must not be 'extern' types #123887

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(extern_types)]
#![feature(unsized_fn_params)]

extern "C" {
    pub type ExternType;
}

impl ExternType {
    pub fn f(self) {}
}

pub fn main() {}

original:

#![feature(extern_types)]

extern {
    pub type ExternType;
}

pub trait T {
    fn test(&self) {}
}

pub trait G<N> {
    fn g(&self, n: N) {}
}

impl ExternType {
    pub fn f(self) {}
}

impl T for ExternType {
    fn test(&self) {}
}

impl G<usize> for ExternType {
    fn g(&self, n: usize) {}
}

// @has 'extern_type/foreigntype.ExternType.html'
// @hasraw 'extern_type/fn.links_to_extern_type.html' \
// 'href="foreigntype.ExternType.html#method.f"'
// @hasraw 'extern_type/fn.links_to_extern_type.html' \
// 'href="foreigntype.ExternType.html#method.test"'
// @hasraw 'extern_type/fn.links_to_extern_type.html' \
// 'href="foreigntype.ExternType.html#method.g"'
/// See also [ExternType::f]
/// See also [ExternType::test]
/// See also [ExternType::g]
pub fn links_to_extern_type() {}

Version information

rustc 1.79.0-nightly (9782770a8 2024-04-12)
binary: rustc
commit-hash: 9782770a810a631db7f2cf3e132354352db92c3d
commit-date: 2024-04-12
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.3

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Clink-dead-code

Program output

thread 'rustc' panicked at compiler/rustc_ty_utils/src/abi.rs:556:21:
unsized arguments must not be `extern` types
stack backtrace:
   0:     0x7ea41a5d7c05 - std::backtrace_rs::backtrace::libunwind::trace::hc97629f27c9ca7dc
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7ea41a5d7c05 - std::backtrace_rs::backtrace::trace_unsynchronized::h3bd01f2fc2868707
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ea41a5d7c05 - std::sys_common::backtrace::_print_fmt::h1a7fed32d32a36ed
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7ea41a5d7c05 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h11de12f07fb5e872
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ea41a626f3b - core::fmt::rt::Argument::fmt::hff810badaa43d8a5
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/core/src/fmt/rt.rs:142:9
   5:     0x7ea41a626f3b - core::fmt::write::h695ad1763a41b6a2
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/core/src/fmt/mod.rs:1153:17
   6:     0x7ea41a5cc78f - std::io::Write::write_fmt::h996819ef859e0bd9
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/std/src/io/mod.rs:1832:15
   7:     0x7ea41a5d79de - std::sys_common::backtrace::_print::ha606d020009e521f
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7ea41a5d79de - std::sys_common::backtrace::print::h6acd0d8e3b3bbcb7
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7ea41a5da359 - std::panicking::default_hook::{{closure}}::h97560f501e6a6395
  10:     0x7ea41a5da09d - std::panicking::default_hook::h521e75bb7c199dc6
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/std/src/panicking.rs:291:9
  11:     0x7ea416e7377c - std[92b5fb492eab709]::panicking::update_hook::<alloc[3417867723560e92]::boxed::Box<rustc_driver_impl[3b860a6e1b6538]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7ea41a5daa5c - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h424cccf6aa9399e5
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/alloc/src/boxed.rs:2032:9
  13:     0x7ea41a5daa5c - std::panicking::rust_panic_with_hook::h87aa9a4a82f4b04e
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/std/src/panicking.rs:792:13
  14:     0x7ea41a5da7cd - std::panicking::begin_panic_handler::{{closure}}::ha058251271362722
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/std/src/panicking.rs:649:13
  15:     0x7ea41a5d80c9 - std::sys_common::backtrace::__rust_end_short_backtrace::hfc0529c9dcacaad1
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7ea41a5da537 - rust_begin_unwind
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/std/src/panicking.rs:645:5
  17:     0x7ea41a6233d6 - core::panicking::panic_fmt::hfac585198285458d
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/core/src/panicking.rs:72:14
  18:     0x7ea4186ef4cf - rustc_ty_utils[9972d1999dce6bd8]::abi::fn_abi_new_uncached
  19:     0x7ea41870905f - rustc_ty_utils[9972d1999dce6bd8]::abi::fn_abi_of_instance
  20:     0x7ea418707873 - rustc_query_impl[d881b72fd1ae356b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d881b72fd1ae356b]::query_impl::fn_abi_of_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b6fbeb4026dfaa3b]::query::erase::Erased<[u8; 16usize]>>
  21:     0x7ea41870677b - rustc_query_system[4cd1bdc9d04c27d4]::query::plumbing::try_execute_query::<rustc_query_impl[d881b72fd1ae356b]::DynamicConfig<rustc_query_system[4cd1bdc9d04c27d4]::query::caches::DefaultCache<rustc_middle[b6fbeb4026dfaa3b]::ty::ParamEnvAnd<(rustc_middle[b6fbeb4026dfaa3b]::ty::instance::Instance, &rustc_middle[b6fbeb4026dfaa3b]::ty::list::RawList<(), rustc_middle[b6fbeb4026dfaa3b]::ty::Ty>)>, rustc_middle[b6fbeb4026dfaa3b]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[d881b72fd1ae356b]::plumbing::QueryCtxt, false>
  22:     0x7ea4187063c1 - rustc_query_impl[d881b72fd1ae356b]::query_impl::fn_abi_of_instance::get_query_non_incr::__rust_end_short_backtrace
  23:     0x7ea4154b81f8 - <rustc_codegen_llvm[aa19ef11ae7b7390]::context::CodegenCx as rustc_codegen_ssa[b63fa8c1b80c9216]::traits::declare::PreDefineMethods>::predefine_fn
  24:     0x7ea418f5803b - rustc_codegen_llvm[aa19ef11ae7b7390]::base::compile_codegen_unit::module_codegen
  25:     0x7ea418f54356 - <rustc_codegen_llvm[aa19ef11ae7b7390]::LlvmCodegenBackend as rustc_codegen_ssa[b63fa8c1b80c9216]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  26:     0x7ea419200427 - rustc_codegen_ssa[b63fa8c1b80c9216]::base::codegen_crate::<rustc_codegen_llvm[aa19ef11ae7b7390]::LlvmCodegenBackend>
  27:     0x7ea4190e2c34 - <rustc_codegen_llvm[aa19ef11ae7b7390]::LlvmCodegenBackend as rustc_codegen_ssa[b63fa8c1b80c9216]::traits::backend::CodegenBackend>::codegen_crate
  28:     0x7ea4190e259d - rustc_interface[783e1e05bf79483b]::passes::start_codegen
  29:     0x7ea4190e1c18 - <rustc_interface[783e1e05bf79483b]::queries::Queries>::codegen_and_build_linker
  30:     0x7ea418ee5244 - rustc_interface[783e1e05bf79483b]::interface::run_compiler::<core[aa9f06c7e63ba1be]::result::Result<(), rustc_span[4445b5a2bf5580a8]::ErrorGuaranteed>, rustc_driver_impl[3b860a6e1b6538]::run_compiler::{closure#0}>::{closure#0}
  31:     0x7ea418fba67f - std[92b5fb492eab709]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[783e1e05bf79483b]::util::run_in_thread_with_globals<rustc_interface[783e1e05bf79483b]::util::run_in_thread_pool_with_globals<rustc_interface[783e1e05bf79483b]::interface::run_compiler<core[aa9f06c7e63ba1be]::result::Result<(), rustc_span[4445b5a2bf5580a8]::ErrorGuaranteed>, rustc_driver_impl[3b860a6e1b6538]::run_compiler::{closure#0}>::{closure#0}, core[aa9f06c7e63ba1be]::result::Result<(), rustc_span[4445b5a2bf5580a8]::ErrorGuaranteed>>::{closure#0}, core[aa9f06c7e63ba1be]::result::Result<(), rustc_span[4445b5a2bf5580a8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[aa9f06c7e63ba1be]::result::Result<(), rustc_span[4445b5a2bf5580a8]::ErrorGuaranteed>>
  32:     0x7ea418fba46e - <<std[92b5fb492eab709]::thread::Builder>::spawn_unchecked_<rustc_interface[783e1e05bf79483b]::util::run_in_thread_with_globals<rustc_interface[783e1e05bf79483b]::util::run_in_thread_pool_with_globals<rustc_interface[783e1e05bf79483b]::interface::run_compiler<core[aa9f06c7e63ba1be]::result::Result<(), rustc_span[4445b5a2bf5580a8]::ErrorGuaranteed>, rustc_driver_impl[3b860a6e1b6538]::run_compiler::{closure#0}>::{closure#0}, core[aa9f06c7e63ba1be]::result::Result<(), rustc_span[4445b5a2bf5580a8]::ErrorGuaranteed>>::{closure#0}, core[aa9f06c7e63ba1be]::result::Result<(), rustc_span[4445b5a2bf5580a8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[aa9f06c7e63ba1be]::result::Result<(), rustc_span[4445b5a2bf5580a8]::ErrorGuaranteed>>::{closure#2} as core[aa9f06c7e63ba1be]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7ea41a5e495b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc468b4f2d5e781d6
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/alloc/src/boxed.rs:2018:9
  34:     0x7ea41a5e495b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he27b2252ec3fce4a
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/alloc/src/boxed.rs:2018:9
  35:     0x7ea41a5e495b - std::sys::pal::unix::thread::Thread::new::thread_start::hbed2bb6c95e840c7
                               at /rustc/9782770a810a631db7f2cf3e132354352db92c3d/library/std/src/sys/pal/unix/thread.rs:108:17
  36:     0x7ea41a38255a - <unknown>
  37:     0x7ea41a3ffa3c - <unknown>
  38:                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.79.0-nightly (9782770a8 2024-04-12) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(unsized_fn_params) --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
#0 [fn_abi_of_instance] computing call ABI of `<impl at /tmp/icemaker_global_tempdir.tOsUA2SS2YoY/rustc_testrunner_tmpdir_reporting.9M68PvpWdUoO/mvce.rs:7:1: 7:16>::f`
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-extern_types`#![feature(extern_types)]`F-unsized_fn_params`#![feature(unsized_fn_params)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions