Skip to content

[ICE]: OpaqueTypeStorage #156345

@matthiaskrgr

Description

@matthiaskrgr

snippet:

//@compile-flags: -Znext-solver=globally
#![feature(type_alias_impl_trait)]
struct Foo {
    field: String,
}
type Tait = impl Sized;
#[define_opaque(Tait)]
extern "C" fn ice_cold(beverage: Tait) {
    let Foo { field } = beverage;
}
fn main() {}

Version information

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

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally

Program output


warning: unused variable: `field`
 --> /tmp/icemaker_global_tempdir.OBCq4S7FTBay/rustc_testrunner_tmpdir_reporting.FP5ZZTww4WTO/mvce.rs:8:15
  |
8 |     let Foo { field } = beverage;
  |               ^^^^^ help: try ignoring the field: `field: _`
  |
  = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

warning: struct `Foo` is never constructed
 --> /tmp/icemaker_global_tempdir.OBCq4S7FTBay/rustc_testrunner_tmpdir_reporting.FP5ZZTww4WTO/mvce.rs:2:8
  |
2 | struct Foo {
  |        ^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: type alias `Tait` is never used
 --> /tmp/icemaker_global_tempdir.OBCq4S7FTBay/rustc_testrunner_tmpdir_reporting.FP5ZZTww4WTO/mvce.rs:5:6
  |
5 | type Tait = impl Sized;
  |      ^^^^

warning: function `ice_cold` is never used
 --> /tmp/icemaker_global_tempdir.OBCq4S7FTBay/rustc_testrunner_tmpdir_reporting.FP5ZZTww4WTO/mvce.rs:7:15
  |
7 | extern "C" fn ice_cold(beverage: Tait) {
  |               ^^^^^^^^

warning: `extern` fn uses type `Foo`, which is not FFI-safe
 --> /tmp/icemaker_global_tempdir.OBCq4S7FTBay/rustc_testrunner_tmpdir_reporting.FP5ZZTww4WTO/mvce.rs:7:34
  |
7 | extern "C" fn ice_cold(beverage: Tait) {
  |                                  ^^^^ not FFI-safe
  |
  = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
  = note: this struct has unspecified layout
note: the type is defined here
 --> /tmp/icemaker_global_tempdir.OBCq4S7FTBay/rustc_testrunner_tmpdir_reporting.FP5ZZTww4WTO/mvce.rs:2:1
  |
2 | struct Foo {
  | ^^^^^^^^^^
  = note: `#[warn(improper_ctypes_definitions)]` on by default

warning: 6 warnings emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: OpaqueTypeStorage { opaque_types: {OpaqueTypeKey { def_id: DefId(0:6 ~ mvce[78d7]::Tait::{opaque#0}), args: [] }: ProvisionalHiddenType { span: no-location (#0), ty: Foo }}, duplicate_entries: [] }
  |
  = note: delayed at /rustc-dev/fb0a5a5a9c892b351f34263d6d84da9dde72871a/compiler/rustc_infer/src/infer/mod.rs:347:43
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
             2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
             3: <rustc_errors::DiagCtxtHandle>::delayed_bug::<alloc::string::String>
             4: <rustc_traits::normalize_erasing_regions::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::PseudoCanonicalInput<rustc_middle::ty::generic_args::GenericArg>)>>::call_once
             5: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::ty::generic_args::GenericArg>, rustc_middle::query::erase::ErasedData<[u8; 8]>>, false>
             6: rustc_query_impl::query_impl::try_normalize_generic_arg_after_erasing_regions::execute_query_non_incr::__rust_end_short_backtrace
             7: <rustc_middle::ty::normalize_erasing_regions::TryNormalizeAfterErasingRegionsFolder as rustc_type_ir::fold::FallibleTypeFolder<rustc_middle::ty::context::TyCtxt>>::try_fold_ty
             8: <rustc_lint::types::improper_ctypes::ImproperCTypesLint>::check_foreign_fn
             9: <rustc_lint::BuiltinCombinedModuleLateLintPass as rustc_lint::passes::LateLintPass>::check_fn
            10: <rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_item
            11: rustc_lint::lint_mod
            12: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
            13: rustc_query_impl::query_impl::lint_mod::execute_query_non_incr::__rust_end_short_backtrace
            14: rustc_lint::late::check_crate::{closure#1}
            15: rustc_lint::late::check_crate
            16: rustc_interface::passes::analysis::{closure#0}::{closure#0}::{closure#2}
            17: rustc_data_structures::sync::parallel::par_fns
            18: rustc_interface::passes::analysis::{closure#0}::{closure#0}
            19: rustc_data_structures::sync::parallel::par_fns
            20: rustc_interface::passes::analysis
            21: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
            22: rustc_query_impl::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
            23: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
            24: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
            25: <std::thread::lifecycle::spawn_unchecked<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            26: <std::sys::thread::unix::Thread>::new::thread_start
            27: <unknown>
            28: <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: rustc 1.97.0-nightly (fb0a5a5a9 2026-05-08) running on x86_64-unknown-linux-gnu

note: compiler flags:  -Z next-solver=globally

query stack during panic:
end of query stack

@rustbot label +F-type_alias_impl_trait +WG-trait-system-refactor

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`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)needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    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