Skip to content

[ICE]: next-solver regression: unexpected type in foreign function: Coroutine #156352

@matthiaskrgr

Description

@matthiaskrgr

Code

This compiles in the old solver but ICEs the new solver --edition=2021 --crate-type lib -Znext-solver=globally

async extern "system" fn check_valid_subset(h: usize) {}

Meta

rustc --version --verbose:

rustc 1.97.0-nightly (fb0a5a5a9 2026-05-08)
binary: rustc
commit-hash: fb0a5a5a9c892b351f34263d6d84da9dde72871a
commit-date: 2026-05-08
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.4

Error output

warning: unused variable: `h`
 --> 106279801431849655477005251870741752883.rs:1:45
  |
1 | async extern "system" fn check_valid_subset(h: usize) {}
  |                                             ^ help: if this is intentional, prefix it with an underscore: `_h`
  |
  = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

warning: function `check_valid_subset` is never used
 --> 106279801431849655477005251870741752883.rs:1:26
  |
1 | async extern "system" fn check_valid_subset(h: usize) {}
  |                          ^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

error: internal compiler error: /rustc-dev/fb0a5a5a9c892b351f34263d6d84da9dde72871a/compiler/rustc_lint/src/types/improper_ctypes.rs:915:32: unexpected type in foreign function: Coroutine(DefId(0:5 ~ 106279801431849655477005251870741752883[9bff]::check_valid_subset::{closure#0}), [(), std::future::ResumeTy, (), (), (usize,)])


thread 'rustc' (4030522) panicked at /rustc-dev/fb0a5a5a9c892b351f34263d6d84da9dde72871a/compiler/rustc_lint/src/types/improper_ctypes.rs:915:32:
Box<dyn Any>
stack backtrace:
   0:     0x7fd163a921c9 - <<std[5dec58442217e086]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[25f2680f0c79e2cd]::fmt::Display>::fmt
   1:     0x7fd16421b2c8 - core[25f2680f0c79e2cd]::fmt::write
   2:     0x7fd163aa8bf6 - <std[5dec58442217e086]::sys::stdio::unix::Stderr as std[5dec58442217e086]::io::Write>::write_fmt
   3:     0x7fd163a6826e - std[5dec58442217e086]::panicking::default_hook::{closure#0}
   4:     0x7fd163a85883 - std[5dec58442217e086]::panicking::default_hook
   5:     0x7fd162965df1 - std[5dec58442217e086]::panicking::update_hook::<alloc[9c6f66c92dcb7933]::boxed::Box<rustc_driver_impl[95354f5e54878bbe]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fd163a85b62 - std[5dec58442217e086]::panicking::panic_with_hook
   7:     0x7fd162993851 - std[5dec58442217e086]::panicking::begin_panic::<rustc_errors[67dc93df25960d24]::ExplicitBug>::{closure#0}
   8:     0x7fd16298c5c6 - std[5dec58442217e086]::sys::backtrace::__rust_end_short_backtrace::<std[5dec58442217e086]::panicking::begin_panic<rustc_errors[67dc93df25960d24]::ExplicitBug>::{closure#0}, !>
   9:     0x7fd16298c5ab - std[5dec58442217e086]::panicking::begin_panic::<rustc_errors[67dc93df25960d24]::ExplicitBug>
  10:     0x7fd16299ed31 - <rustc_errors[67dc93df25960d24]::diagnostic::BugAbort as rustc_errors[67dc93df25960d24]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fd162fb33d9 - rustc_middle[de9db29f5f8f3285]::util::bug::opt_span_bug_fmt::<rustc_span[863f3d4d1612f1a0]::span_encoding::Span>::{closure#0}
  12:     0x7fd162fb3542 - rustc_middle[de9db29f5f8f3285]::ty::context::tls::with_opt::<rustc_middle[de9db29f5f8f3285]::util::bug::opt_span_bug_fmt<rustc_span[863f3d4d1612f1a0]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7fd162fa21ab - rustc_middle[de9db29f5f8f3285]::ty::context::tls::with_context_opt::<rustc_middle[de9db29f5f8f3285]::ty::context::tls::with_opt<rustc_middle[de9db29f5f8f3285]::util::bug::opt_span_bug_fmt<rustc_span[863f3d4d1612f1a0]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7fd1609b79f4 - rustc_middle[de9db29f5f8f3285]::util::bug::bug_fmt
  15:     0x7fd165c99aa4 - <rustc_lint[74c4110a4846f7a1]::types::improper_ctypes::ImproperCTypesVisitor>::visit_type.cold
  16:     0x7fd16479fe04 - <rustc_lint[74c4110a4846f7a1]::types::improper_ctypes::ImproperCTypesVisitor>::check_type
  17:     0x7fd16479f94f - <rustc_lint[74c4110a4846f7a1]::types::improper_ctypes::ImproperCTypesLint>::check_foreign_fn
  18:     0x7fd164bae96e - <rustc_lint[74c4110a4846f7a1]::BuiltinCombinedModuleLateLintPass as rustc_lint[74c4110a4846f7a1]::passes::LateLintPass>::check_fn
  19:     0x7fd164ba5646 - <rustc_lint[74c4110a4846f7a1]::late::LateContextAndPass<rustc_lint[74c4110a4846f7a1]::BuiltinCombinedModuleLateLintPass> as rustc_hir[2c5149180598054c]::intravisit::Visitor>::visit_nested_item
  20:     0x7fd164ba6c57 - rustc_lint[74c4110a4846f7a1]::lint_mod
  21:     0x7fd1650ee6b2 - rustc_query_impl[3d3558aac3f8f781]::execution::try_execute_query::<rustc_middle[de9db29f5f8f3285]::query::caches::DefaultCache<rustc_span[863f3d4d1612f1a0]::def_id::LocalModDefId, rustc_middle[de9db29f5f8f3285]::query::erase::ErasedData<[u8; 0usize]>>, false>
  22:     0x7fd1650ec794 - rustc_query_impl[3d3558aac3f8f781]::query_impl::lint_mod::execute_query_non_incr::__rust_end_short_backtrace
  23:     0x7fd1650ec295 - rustc_lint[74c4110a4846f7a1]::late::check_crate::{closure#1}
  24:     0x7fd1650ebeba - rustc_lint[74c4110a4846f7a1]::late::check_crate
  25:     0x7fd1650eb630 - rustc_interface[2aa37de45ba6cff9]::passes::analysis::{closure#0}::{closure#0}::{closure#2}
  26:     0x7fd1650eb41a - rustc_data_structures[11157f3c65e52add]::sync::parallel::par_fns
  27:     0x7fd1650eb3a6 - rustc_interface[2aa37de45ba6cff9]::passes::analysis::{closure#0}::{closure#0}
  28:     0x7fd1650eb41a - rustc_data_structures[11157f3c65e52add]::sync::parallel::par_fns
  29:     0x7fd1645189a0 - rustc_interface[2aa37de45ba6cff9]::passes::analysis
  30:     0x7fd16535b389 - rustc_query_impl[3d3558aac3f8f781]::execution::try_execute_query::<rustc_middle[de9db29f5f8f3285]::query::caches::SingleCache<rustc_middle[de9db29f5f8f3285]::query::erase::ErasedData<[u8; 0usize]>>, false>
  31:     0x7fd16535aff3 - rustc_query_impl[3d3558aac3f8f781]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  32:     0x7fd16537729b - rustc_interface[2aa37de45ba6cff9]::interface::run_compiler::<(), rustc_driver_impl[95354f5e54878bbe]::run_compiler::{closure#0}>::{closure#1}
  33:     0x7fd1653437fa - std[5dec58442217e086]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[2aa37de45ba6cff9]::util::run_in_thread_with_globals<rustc_interface[2aa37de45ba6cff9]::util::run_in_thread_pool_with_globals<rustc_interface[2aa37de45ba6cff9]::interface::run_compiler<(), rustc_driver_impl[95354f5e54878bbe]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  34:     0x7fd165343eed - <std[5dec58442217e086]::thread::lifecycle::spawn_unchecked<rustc_interface[2aa37de45ba6cff9]::util::run_in_thread_with_globals<rustc_interface[2aa37de45ba6cff9]::util::run_in_thread_pool_with_globals<rustc_interface[2aa37de45ba6cff9]::interface::run_compiler<(), rustc_driver_impl[95354f5e54878bbe]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[25f2680f0c79e2cd]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7fd165344cec - <std[5dec58442217e086]::sys::thread::unix::Thread>::new::thread_start
  36:     0x7fd15eca597a - <unknown>
  37:     0x7fd15ed292bc - <unknown>
  38:                0x0 - <unknown>

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: please attach the file at `/tmp/im/rustc-ice-2026-05-09T06_28_11-4030512.txt` to your bug report

note: rustc 1.97.0-nightly (fb0a5a5a9 2026-05-08) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z next-solver=globally

query stack during panic:
#0 [lint_mod] linting top-level module
#1 [analysis] running analysis passes on crate `106279801431849655477005251870741752883`
end of query stack
error: aborting due to 1 previous error; 2 warnings emitted
Backtrace

<backtrace>

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️L-improper_ctypesLint: improper_ctypesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions