Skip to content

ICE: Unexpected type for constructor Variant(0): Alias(Opaque, AliasTy .. #139817

Closed
@matthiaskrgr

Description

@matthiaskrgr
Member

auto-reduced (treereduce-rust):

fn enum_upvar() {
    type T = impl Copy;
    let foo: T = Some((42, std::marker::PhantomData::<T>));
    let x = move || match foo {
        None => (),
    };
}

original:

//@ check-pass

#![feature(type_alias_impl_trait)]

fn enum_upvar() {
    type T = impl Copy;
    let foo: T = Some((42, std::marker::PhantomData::<T>));
    let x = move || match foo {
        None => (),
        Some((a, b)) => (),
    };
}

fn main(){
    type Tait = impl Sized + 'static;
    spawn::<Tait, _>(move || sender)
}

Version information

rustc 1.88.0-nightly (c580c498a 2025-04-14)
binary: rustc
commit-hash: c580c498a1fe144d7c5b2dfc7faab1a229aa288b
commit-date: 2025-04-14
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Possibly related line of code:

let skip = is_uninhabited && (!is_visible || is_unstable);
(ty, PrivateUninhabitedField(skip))
});
cx.dropless_arena.alloc_from_iter(tys)
}
}
_ => bug!("Unexpected type for constructor `{ctor:?}`: {ty:?}"),
},
Ref => match ty.kind() {
ty::Ref(_, rty, _) => reveal_and_alloc(cx, once(*rty)),
_ => bug!("Unexpected type for `Ref` constructor: {ty:?}"),
},
Slice(slice) => match *ty.kind() {

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0658]: `impl Trait` in type aliases is unstable
 --> /tmp/icemaker_global_tempdir.hHKPo6bbeRMr/rustc_testrunner_tmpdir_reporting.A6splXMwSkpr/mvce.rs:2:14
  |
2 |     type T = impl Copy;
  |              ^^^^^^^^^
  |
  = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
  = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
  = note: this compiler was built on 2025-04-14; consider upgrading it if it is out of date

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.hHKPo6bbeRMr/rustc_testrunner_tmpdir_reporting.A6splXMwSkpr/mvce.rs:7:2
  |
7 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.hHKPo6bbeRMr/rustc_testrunner_tmpdir_reporting.A6splXMwSkpr/mvce.rs`

warning: unused variable: `x`
 --> /tmp/icemaker_global_tempdir.hHKPo6bbeRMr/rustc_testrunner_tmpdir_reporting.A6splXMwSkpr/mvce.rs:4:9
  |
4 |     let x = move || match foo {
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

error: internal compiler error: compiler/rustc_pattern_analysis/src/rustc.rs:259:22: Unexpected type for constructor `Variant(0)`: Alias(Opaque, AliasTy { args: [], def_id: DefId(0:5 ~ mvce[28ab]::enum_upvar::T::{opaque#0}), .. })


thread 'rustc' panicked at compiler/rustc_pattern_analysis/src/rustc.rs:259:22:
Box<dyn Any>
stack backtrace:
   0:     0x723021cf5803 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::he137faf1a18df1db
   1:     0x723022406051 - core::fmt::write::h91755fbfaddf7ffb
   2:     0x7230238ae011 - std::io::Write::write_fmt::hc96efb08aa08a02e
   3:     0x723021cf5662 - std::sys::backtrace::BacktraceLock::print::ha70abd97698330ed
   4:     0x723021cf914a - std::panicking::default_hook::{{closure}}::h8caf203b8fc4b95a
   5:     0x723021cf8ccf - std::panicking::default_hook::h18654ff1fe4ed24b
   6:     0x723020d63603 - std[8cc451807e0e7beb]::panicking::update_hook::<alloc[73f72a203e12369d]::boxed::Box<rustc_driver_impl[c4ad34755bb049a3]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x723021cf99c3 - std::panicking::rust_panic_with_hook::h76d5e98d413ceeff
   8:     0x723020da2161 - std[8cc451807e0e7beb]::panicking::begin_panic::<rustc_errors[440c2428a84582d1]::ExplicitBug>::{closure#0}
   9:     0x723020d96196 - std[8cc451807e0e7beb]::sys::backtrace::__rust_end_short_backtrace::<std[8cc451807e0e7beb]::panicking::begin_panic<rustc_errors[440c2428a84582d1]::ExplicitBug>::{closure#0}, !>
  10:     0x723020d92a7b - std[8cc451807e0e7beb]::panicking::begin_panic::<rustc_errors[440c2428a84582d1]::ExplicitBug>
  11:     0x723020dac531 - <rustc_errors[440c2428a84582d1]::diagnostic::BugAbort as rustc_errors[440c2428a84582d1]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7230213f61ba - rustc_middle[cdeaf14df3177256]::util::bug::opt_span_bug_fmt::<rustc_span[d423fa63ad2163fb]::span_encoding::Span>::{closure#0}
  13:     0x7230213d100a - rustc_middle[cdeaf14df3177256]::ty::context::tls::with_opt::<rustc_middle[cdeaf14df3177256]::util::bug::opt_span_bug_fmt<rustc_span[d423fa63ad2163fb]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7230213d0e7b - rustc_middle[cdeaf14df3177256]::ty::context::tls::with_context_opt::<rustc_middle[cdeaf14df3177256]::ty::context::tls::with_opt<rustc_middle[cdeaf14df3177256]::util::bug::opt_span_bug_fmt<rustc_span[d423fa63ad2163fb]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x72301e68b760 - rustc_middle[cdeaf14df3177256]::util::bug::bug_fmt
  16:     0x723022d30eb7 - rustc_pattern_analysis[386c649c64cad14]::usefulness::compute_exhaustiveness_and_usefulness::<rustc_pattern_analysis[386c649c64cad14]::rustc::RustcPatCtxt>::{closure#0}
  17:     0x723022d16a93 - rustc_pattern_analysis[386c649c64cad14]::rustc::analyze_match
  18:     0x7230227ce9a7 - <rustc_mir_build[c533163d3a765291]::thir::pattern::check_match::MatchVisitor as rustc_middle[cdeaf14df3177256]::thir::visit::Visitor>::visit_expr
  19:     0x7230227ce587 - <rustc_mir_build[c533163d3a765291]::thir::pattern::check_match::MatchVisitor as rustc_middle[cdeaf14df3177256]::thir::visit::Visitor>::visit_expr
  20:     0x7230227d44b0 - rustc_mir_build[c533163d3a765291]::thir::pattern::check_match::check_match
  21:     0x7230227d40eb - rustc_query_impl[994d8d0f232e6f76]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[994d8d0f232e6f76]::query_impl::check_match::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 1usize]>>
  22:     0x723022c8c608 - rustc_query_system[fdd22cd2b18f3d20]::query::plumbing::try_execute_query::<rustc_query_impl[994d8d0f232e6f76]::DynamicConfig<rustc_data_structures[bb20cc737854270d]::vec_cache::VecCache<rustc_span[d423fa63ad2163fb]::def_id::LocalDefId, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[fdd22cd2b18f3d20]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[994d8d0f232e6f76]::plumbing::QueryCtxt, false>
  23:     0x723022c8c23e - rustc_query_impl[994d8d0f232e6f76]::query_impl::check_match::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7230227d9461 - rustc_mir_build[c533163d3a765291]::builder::build_mir
  25:     0x72302240a0c5 - rustc_mir_transform[a20fd6afc3bb3ae5]::mir_built
  26:     0x72302240a097 - rustc_query_impl[994d8d0f232e6f76]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[994d8d0f232e6f76]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 8usize]>>
  27:     0x72302265c22c - rustc_query_system[fdd22cd2b18f3d20]::query::plumbing::try_execute_query::<rustc_query_impl[994d8d0f232e6f76]::DynamicConfig<rustc_data_structures[bb20cc737854270d]::vec_cache::VecCache<rustc_span[d423fa63ad2163fb]::def_id::LocalDefId, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[fdd22cd2b18f3d20]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[994d8d0f232e6f76]::plumbing::QueryCtxt, false>
  28:     0x72302265bd4b - rustc_query_impl[994d8d0f232e6f76]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  29:     0x723022436baf - rustc_mir_transform[a20fd6afc3bb3ae5]::ffi_unwind_calls::has_ffi_unwind_calls
  30:     0x723022436759 - rustc_query_impl[994d8d0f232e6f76]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[994d8d0f232e6f76]::query_impl::has_ffi_unwind_calls::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 1usize]>>
  31:     0x723022c8c608 - rustc_query_system[fdd22cd2b18f3d20]::query::plumbing::try_execute_query::<rustc_query_impl[994d8d0f232e6f76]::DynamicConfig<rustc_data_structures[bb20cc737854270d]::vec_cache::VecCache<rustc_span[d423fa63ad2163fb]::def_id::LocalDefId, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[fdd22cd2b18f3d20]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[994d8d0f232e6f76]::plumbing::QueryCtxt, false>
  32:     0x723022c8c2d2 - rustc_query_impl[994d8d0f232e6f76]::query_impl::has_ffi_unwind_calls::get_query_non_incr::__rust_end_short_backtrace
  33:     0x72301fa06aa5 - rustc_mir_transform[a20fd6afc3bb3ae5]::mir_promoted
  34:     0x7230227d1212 - rustc_query_impl[994d8d0f232e6f76]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[994d8d0f232e6f76]::query_impl::mir_promoted::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 16usize]>>
  35:     0x7230227d14aa - rustc_query_system[fdd22cd2b18f3d20]::query::plumbing::try_execute_query::<rustc_query_impl[994d8d0f232e6f76]::DynamicConfig<rustc_data_structures[bb20cc737854270d]::vec_cache::VecCache<rustc_span[d423fa63ad2163fb]::def_id::LocalDefId, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 16usize]>, rustc_query_system[fdd22cd2b18f3d20]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[994d8d0f232e6f76]::plumbing::QueryCtxt, false>
  36:     0x7230227d105f - rustc_query_impl[994d8d0f232e6f76]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7230236a2eff - rustc_borrowck[2b49f7f4951f3059]::do_mir_borrowck
  38:     0x723022de9e53 - <rustc_borrowck[2b49f7f4951f3059]::root_cx::BorrowCheckRootCtxt>::get_or_insert_nested
  39:     0x723022dea115 - <rustc_borrowck[2b49f7f4951f3059]::type_check::TypeChecker>::prove_closure_bounds
  40:     0x72301f61dbe2 - <rustc_borrowck[2b49f7f4951f3059]::type_check::TypeChecker as rustc_middle[cdeaf14df3177256]::mir::visit::Visitor>::visit_rvalue
  41:     0x7230234191f8 - <rustc_borrowck[2b49f7f4951f3059]::type_check::TypeChecker as rustc_middle[cdeaf14df3177256]::mir::visit::Visitor>::visit_body
  42:     0x7230236b2d29 - rustc_borrowck[2b49f7f4951f3059]::do_mir_borrowck
  43:     0x72302369f911 - rustc_borrowck[2b49f7f4951f3059]::mir_borrowck
  44:     0x72302369f799 - rustc_query_impl[994d8d0f232e6f76]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[994d8d0f232e6f76]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 8usize]>>
  45:     0x72302265c22c - rustc_query_system[fdd22cd2b18f3d20]::query::plumbing::try_execute_query::<rustc_query_impl[994d8d0f232e6f76]::DynamicConfig<rustc_data_structures[bb20cc737854270d]::vec_cache::VecCache<rustc_span[d423fa63ad2163fb]::def_id::LocalDefId, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[fdd22cd2b18f3d20]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[994d8d0f232e6f76]::plumbing::QueryCtxt, false>
  46:     0x72302265bbcb - rustc_query_impl[994d8d0f232e6f76]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  47:     0x723020f72569 - <rustc_hir_analysis[9c3c5f969fccaefd]::collect::type_of::opaque::TaitConstraintLocator>::check
  48:     0x723020e59327 - rustc_hir[14d79ec8c47a11c9]::intravisit::walk_mod::<rustc_hir_analysis[9c3c5f969fccaefd]::collect::type_of::opaque::TaitConstraintLocator>
  49:     0x723020f7203d - rustc_hir_analysis[9c3c5f969fccaefd]::collect::type_of::opaque::find_opaque_ty_constraints_for_tait
  50:     0x7230241b6047 - rustc_hir_analysis[9c3c5f969fccaefd]::collect::type_of::type_of_opaque.cold
  51:     0x72302371a1ed - rustc_query_impl[994d8d0f232e6f76]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[994d8d0f232e6f76]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 8usize]>>
  52:     0x72302273fe6f - rustc_query_system[fdd22cd2b18f3d20]::query::plumbing::try_execute_query::<rustc_query_impl[994d8d0f232e6f76]::DynamicConfig<rustc_query_system[fdd22cd2b18f3d20]::query::caches::DefIdCache<rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[994d8d0f232e6f76]::plumbing::QueryCtxt, false>
  53:     0x72302379d71d - rustc_query_impl[994d8d0f232e6f76]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
  54:     0x7230227474da - rustc_hir_analysis[9c3c5f969fccaefd]::collect::type_of::type_of
  55:     0x723022745bb8 - rustc_query_impl[994d8d0f232e6f76]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[994d8d0f232e6f76]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 8usize]>>
  56:     0x72302273fe6f - rustc_query_system[fdd22cd2b18f3d20]::query::plumbing::try_execute_query::<rustc_query_impl[994d8d0f232e6f76]::DynamicConfig<rustc_query_system[fdd22cd2b18f3d20]::query::caches::DefIdCache<rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[994d8d0f232e6f76]::plumbing::QueryCtxt, false>
  57:     0x72302273fa1f - rustc_query_impl[994d8d0f232e6f76]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  58:     0x72302371aadd - rustc_hir_analysis[9c3c5f969fccaefd]::check::check::check_opaque
  59:     0x723022a702f7 - rustc_hir_analysis[9c3c5f969fccaefd]::check::check::check_item_type
  60:     0x723022c8fb5d - rustc_hir_analysis[9c3c5f969fccaefd]::check::wfcheck::check_well_formed
  61:     0x723022c8cfeb - rustc_query_impl[994d8d0f232e6f76]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[994d8d0f232e6f76]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 1usize]>>
  62:     0x723022c8c894 - rustc_query_system[fdd22cd2b18f3d20]::query::plumbing::try_execute_query::<rustc_query_impl[994d8d0f232e6f76]::DynamicConfig<rustc_data_structures[bb20cc737854270d]::vec_cache::VecCache<rustc_span[d423fa63ad2163fb]::def_id::LocalDefId, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[fdd22cd2b18f3d20]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[994d8d0f232e6f76]::plumbing::QueryCtxt, false>
  63:     0x723022c8c383 - rustc_query_impl[994d8d0f232e6f76]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  64:     0x723022c88ba8 - rustc_hir_analysis[9c3c5f969fccaefd]::check::wfcheck::check_mod_type_wf
  65:     0x723022c885dd - rustc_query_impl[994d8d0f232e6f76]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[994d8d0f232e6f76]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 1usize]>>
  66:     0x72302350cd99 - rustc_query_system[fdd22cd2b18f3d20]::query::plumbing::try_execute_query::<rustc_query_impl[994d8d0f232e6f76]::DynamicConfig<rustc_query_system[fdd22cd2b18f3d20]::query::caches::DefaultCache<rustc_span[d423fa63ad2163fb]::def_id::LocalModDefId, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[994d8d0f232e6f76]::plumbing::QueryCtxt, false>
  67:     0x72302350cb0a - rustc_query_impl[994d8d0f232e6f76]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  68:     0x723022659f66 - rustc_hir_analysis[9c3c5f969fccaefd]::check_crate
  69:     0x723022d709f4 - rustc_interface[89d8dc017f235532]::passes::run_required_analyses
  70:     0x723023346d1e - rustc_interface[89d8dc017f235532]::passes::analysis
  71:     0x723023346ced - rustc_query_impl[994d8d0f232e6f76]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[994d8d0f232e6f76]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 0usize]>>
  72:     0x72302334c7bd - rustc_query_system[fdd22cd2b18f3d20]::query::plumbing::try_execute_query::<rustc_query_impl[994d8d0f232e6f76]::DynamicConfig<rustc_query_system[fdd22cd2b18f3d20]::query::caches::SingleCache<rustc_middle[cdeaf14df3177256]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[994d8d0f232e6f76]::plumbing::QueryCtxt, false>
  73:     0x72302334c4b8 - rustc_query_impl[994d8d0f232e6f76]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  74:     0x72302373ccbe - rustc_interface[89d8dc017f235532]::passes::create_and_enter_global_ctxt::<core[9797c9d635bbf607]::option::Option<rustc_interface[89d8dc017f235532]::queries::Linker>, rustc_driver_impl[c4ad34755bb049a3]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  75:     0x72302353ddc4 - rustc_interface[89d8dc017f235532]::interface::run_compiler::<(), rustc_driver_impl[c4ad34755bb049a3]::run_compiler::{closure#0}>::{closure#1}
  76:     0x7230235633b2 - std[8cc451807e0e7beb]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[89d8dc017f235532]::util::run_in_thread_with_globals<rustc_interface[89d8dc017f235532]::util::run_in_thread_pool_with_globals<rustc_interface[89d8dc017f235532]::interface::run_compiler<(), rustc_driver_impl[c4ad34755bb049a3]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  77:     0x723023563cab - <<std[8cc451807e0e7beb]::thread::Builder>::spawn_unchecked_<rustc_interface[89d8dc017f235532]::util::run_in_thread_with_globals<rustc_interface[89d8dc017f235532]::util::run_in_thread_pool_with_globals<rustc_interface[89d8dc017f235532]::interface::run_compiler<(), rustc_driver_impl[c4ad34755bb049a3]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9797c9d635bbf607]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  78:     0x7230235650ab - std::sys::pal::unix::thread::Thread::new::thread_start::heb5f87066979571c
  79:     0x72301d2a370a - <unknown>
  80:     0x72301d327aac - <unknown>
  81:                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: rustc 1.88.0-nightly (c580c498a 2025-04-14) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_match] match-checking `enum_upvar::{closure#0}`
#1 [mir_built] building MIR for `enum_upvar::{closure#0}`
#2 [has_ffi_unwind_calls] checking if `enum_upvar::{closure#0}` contains FFI-unwind calls
#3 [mir_promoted] promoting constants in MIR for `enum_upvar::{closure#0}`
#4 [mir_borrowck] borrow-checking `enum_upvar`
#5 [type_of_opaque] computing type of opaque `enum_upvar::T::{opaque#0}`
#6 [type_of] computing type of `enum_upvar::T::{opaque#0}`
#7 [check_well_formed] checking that `enum_upvar::T::{opaque#0}` is well-formed
#8 [check_mod_type_wf] checking that types are well-formed in top-level module
#9 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.

@rustbot label +F-type_alias_impl_trait

Activity

added
C-bugCategory: This is a bug.
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Apr 14, 2025
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Apr 14, 2025
matthiaskrgr

matthiaskrgr commented on Apr 14, 2025

@matthiaskrgr
MemberAuthor

bisects to #139501

theemathas

theemathas commented on Apr 27, 2025

@theemathas
Contributor

Variant that also ICEs in stable rust 1.86.0:

fn enum_upvar() -> impl Copy {
    let mut foo = enum_upvar();
    foo = Some(enum_upvar());
    let x = || match foo {
        Some(_) => (),
        _ => {}
    };
    foo
}
Error output
warning: value assigned to `foo` is never read
 --> src/lib.rs:2:13
  |
2 |     let mut foo = enum_upvar();
  |             ^^^
  |
  = help: maybe it is overwritten before being read?
  = note: `#[warn(unused_assignments)]` on by default

warning: unused variable: `x`
 --> src/lib.rs:4:9
  |
4 |     let x = || match foo {
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: function cannot return without recursing
 --> src/lib.rs:1:1
  |
1 | fn enum_upvar() -> impl Copy {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
2 |     let mut foo = enum_upvar();
  |                   ------------ recursive call site
  |
  = help: a `loop` may express intention better if this is on purpose
  = note: `#[warn(unconditional_recursion)]` on by default


thread 'rustc' panicked at compiler/rustc_mir_build/src/builder/matches/mod.rs:2099:44:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: <rustc_mir_build::builder::Builder>::test_candidates
   5: <rustc_mir_build::builder::Builder>::match_candidates
   6: <rustc_mir_build::builder::Builder>::lower_match_tree
   7: <rustc_mir_build::builder::Builder>::expr_into_dest
   8: <rustc_mir_build::builder::Builder>::expr_into_dest
   9: rustc_mir_build::builder::build_mir
  10: rustc_mir_transform::mir_built
      [... omitted 1 frame ...]
  11: rustc_mir_transform::ffi_unwind_calls::has_ffi_unwind_calls
      [... omitted 1 frame ...]
  12: rustc_mir_transform::mir_promoted
      [... omitted 2 frames ...]
  13: rustc_middle::query::plumbing::query_get_at::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>>
  14: <rustc_borrowck::type_check::TypeChecker>::prove_closure_bounds
  15: <rustc_borrowck::type_check::TypeChecker>::typeck_mir
  16: rustc_borrowck::type_check::type_check
  17: rustc_borrowck::nll::compute_regions
  18: rustc_borrowck::do_mir_borrowck
      [... omitted 1 frame ...]
  19: rustc_middle::query::plumbing::query_get_at::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>>
  20: rustc_hir_analysis::collect::type_of::type_of_opaque
      [... omitted 1 frame ...]
  21: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
  22: rustc_hir_analysis::collect::type_of::type_of
      [... omitted 1 frame ...]
  23: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
  24: rustc_hir_analysis::check::check::check_item_type
  25: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 1 frame ...]
  26: rustc_middle::query::plumbing::query_ensure_error_guaranteed::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, ()>
  27: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
      [... omitted 1 frame ...]
  28: rustc_hir_analysis::check_crate
  29: rustc_interface::passes::run_required_analyses
  30: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  31: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  32: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.86.0 (05f9846f8 2025-03-31) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_built] building MIR for `enum_upvar::{closure#0}`
#1 [has_ffi_unwind_calls] checking if `enum_upvar::{closure#0}` contains FFI-unwind calls
#2 [mir_promoted] promoting constants in MIR for `enum_upvar::{closure#0}`
#3 [mir_borrowck] borrow-checking `enum_upvar::{closure#0}`
#4 [mir_borrowck] borrow-checking `enum_upvar`
#5 [type_of_opaque] computing type of opaque `enum_upvar::{opaque#0}`
#6 [type_of] computing type of `enum_upvar::{opaque#0}`
#7 [check_well_formed] checking that `enum_upvar::{opaque#0}` is well-formed
#8 [check_mod_type_wf] checking that types are well-formed in top-level module
#9 [analysis] running analysis passes on this crate
end of query stack
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: {OpaqueTypeKey { def_id: DefId(0:4 ~ playground[8a9a]::enum_upvar::{opaque#0}), args: [] }: OpaqueHiddenType { span: src/lib.rs:3:5: 3:29 (#0), ty: std::option::Option<Alias(Opaque, AliasTy { args: [], def_id: DefId(0:4 ~ playground[8a9a]::enum_upvar::{opaque#0}), .. })> }}
  |
  = note: delayed at compiler/rustc_infer/src/infer/opaque_types/table.rs:48: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: core::ptr::drop_in_place::<rustc_infer::infer::InferCtxt>
             5: core::ptr::drop_in_place::<rustc_borrowck::BorrowckInferCtxt>
             6: rustc_borrowck::do_mir_borrowck
             7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
             8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
             9: rustc_query_impl::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
            10: rustc_middle::query::plumbing::query_get_at::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>>
            11: rustc_hir_analysis::collect::type_of::type_of_opaque
            12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
            13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            14: rustc_query_impl::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
            15: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
            16: rustc_hir_analysis::collect::type_of::type_of
            17: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
            18: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            19: rustc_query_impl::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
            20: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
            21: rustc_hir_analysis::check::check::check_item_type
            22: rustc_hir_analysis::check::wfcheck::check_well_formed
            23: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            24: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            25: rustc_query_impl::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
            26: rustc_middle::query::plumbing::query_ensure_error_guaranteed::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, ()>
            27: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
            28: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            29: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            30: rustc_query_impl::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
            31: rustc_hir_analysis::check_crate
            32: rustc_interface::passes::run_required_analyses
            33: rustc_interface::passes::analysis
            34: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
            35: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            36: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
            37: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
            38: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
            39: 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}, ()>
            40: <<std::thread::Builder>::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}
            41: std::sys::pal::unix::thread::Thread::new::thread_start
            42: <unknown>
            43: clone
          

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: rustc 1.86.0 (05f9846f8 2025-03-31) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
warning: `playground` (lib) generated 3 warnings
matthiaskrgr

matthiaskrgr commented on Apr 27, 2025

@matthiaskrgr
MemberAuthor

yes, see #119786

added
S-has-bisectionStatus: A bisection has been found for this issue
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on May 1, 2025
added
S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.
on May 2, 2025
matthiaskrgr

matthiaskrgr commented on May 21, 2025

@matthiaskrgr
MemberAuthor

Fixed in #139419

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.S-has-bisectionStatus: A bisection 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

        Participants

        @matthiaskrgr@theemathas@jieyouxu@rustbot

        Issue actions

          ICE: Unexpected type for constructor `Variant(0)`: Alias(Opaque, AliasTy .. · Issue #139817 · rust-lang/rust