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

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

Closed
matthiaskrgr opened this issue Apr 13, 2024 · 5 comments · Fixed by #126830
Closed

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

matthiaskrgr opened this issue Apr 13, 2024 · 5 comments · Fixed by #126830
Labels
C-bug Category: This is a bug. F-extern_types `#![feature(extern_types)]` F-unsized_fn_params `#![feature(unsized_fn_params)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Apr 13, 2024

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

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Apr 13, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 13, 2024
@matthiaskrgr
Copy link
Member Author

Regression in nightly-2020-10-29
fetching (via remote github) commits from max(07e968b, 2020-10-26) to 31ee872
ending github query because we found starting sha: 07e968b
get_commits_between returning commits, len: 7
commit[0] 2020-10-27: Auto merge of #76269 - ayrtonm:function-reference-lint, r=oli-obk
commit[1] 2020-10-27: Auto merge of #75671 - nathanwhit:cstring-temp-lint, r=oli-obk
commit[2] 2020-10-28: Auto merge of #78458 - Dylan-DPC:rollup-tan044s, r=Dylan-DPC
commit[3] 2020-10-28: Auto merge of #78323 - est31:smaller_list_overlap, r=varkor
commit[4] 2020-10-28: Auto merge of #78409 - pietroalbini:build-manifest-checksum-cache, r=Mark-Simulacrum
commit[5] 2020-10-28: Auto merge of #78414 - nox:function-sections, r=nagisa,bjorn3
commit[6] 2020-10-28: Auto merge of #78415 - tgnottingham:expn_id_tag_hash, r=Aaron1011

I guess #78152

@eggyal
Copy link
Contributor

eggyal commented Apr 13, 2024

@rustbot claim

@eggyal
Copy link
Contributor

eggyal commented Apr 14, 2024

Looks like this is WONTFIX while the features remain experimental (see #123894 (comment)).

@rustbot release-assignment

@jieyouxu jieyouxu added F-extern_types `#![feature(extern_types)]` F-unsized_fn_params `#![feature(unsized_fn_params)]` S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 15, 2024
@RalfJung
Copy link
Member

Yeah, this is a deliberate ICE since a better error requires too much refactoring, and the fundamental issue is that this entire feature was never properly designed and poorly interacts with many other parts of the language.

The fix is to mark unsized_fn_params as an internal feature, to warn people about the ICEs lurking here.

@RalfJung
Copy link
Member

RalfJung commented Jun 22, 2024 via email

compiler-errors added a commit to compiler-errors/rust that referenced this issue Jun 23, 2024
…iler-errors

make unsized_fn_params an internal feature

As suggested [here](rust-lang#123894 (comment)).
r? `@compiler-errors`

Fixes rust-lang#123887 (kind of -- ICEs on internal features are considered acceptable so this issue is not-a-bug once this PR lands)
compiler-errors added a commit to compiler-errors/rust that referenced this issue Jun 23, 2024
…iler-errors

make unsized_fn_params an internal feature

As suggested [here](rust-lang#123894 (comment)).
r? ``@compiler-errors``

Fixes rust-lang#123887 (kind of -- ICEs on internal features are considered acceptable so this issue is not-a-bug once this PR lands)
@bors bors closed this as completed in 0a7adaf Jun 23, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 23, 2024
Rollup merge of rust-lang#126830 - RalfJung:unsized-fn-params, r=compiler-errors

make unsized_fn_params an internal feature

As suggested [here](rust-lang#123894 (comment)).
r? `@compiler-errors`

Fixes rust-lang#123887 (kind of -- ICEs on internal features are considered acceptable so this issue is not-a-bug once this PR lands)
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Jun 24, 2024
make unsized_fn_params an internal feature

As suggested [here](rust-lang/rust#123894 (comment)).
r? `@compiler-errors`

Fixes rust-lang/rust#123887 (kind of -- ICEs on internal features are considered acceptable so this issue is not-a-bug once this PR lands)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-extern_types `#![feature(extern_types)]` F-unsized_fn_params `#![feature(unsized_fn_params)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
5 participants