[ICE]: `None` in `self_ty.normalized.ty_adt_def()`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
snippet:
//@compile-flags: -Znext-solver=globally
#![feature(lazy_type_alias)]
struct Inv;
enum Foo<F: Fn()> {
Bar,
Var(F),
}
type Supertype = Foo<dyn Fn()>;
fn main() {
let x: Inv = todo!();
match x {
Foo::Var(Supertype::Bar) => {}
_ => {}
}
}
Version information
rustc 1.95.0-nightly (1500f0f47 2026-02-22)
binary: rustc
commit-hash: 1500f0f47f5fe8ddcd6528f6c6c031b210b4eac5
commit-date: 2026-02-22
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0
Possibly related line of code:
https://github.com/rust-lang/rust/blob/1500f0f47f5fe8ddcd6528f6c6c031b210b4eac5/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs#L976-L988
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally
Program output
warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.XjHPTBIuznYH/rustc_testrunner_tmpdir_reporting.WcK5sUzG23U6/mvce.rs:1:12
|
1 | #![feature(lazy_type_alias)]
| ^^^^^^^^^^^^^^^
|
= note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
= note: `#[warn(incomplete_features)]` on by default
error[E0277]: the size for values of type `(dyn Fn() + 'static)` cannot be known at compilation time
--> /tmp/icemaker_global_tempdir.XjHPTBIuznYH/rustc_testrunner_tmpdir_reporting.WcK5sUzG23U6/mvce.rs:7:1
|
7 | type Supertype = Foo<dyn Fn()>;
| ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn Fn() + 'static)`
note: required by an implicit `Sized` bound in `Foo`
--> /tmp/icemaker_global_tempdir.XjHPTBIuznYH/rustc_testrunner_tmpdir_reporting.WcK5sUzG23U6/mvce.rs:3:10
|
3 | enum Foo<F: Fn()> {
| ^ required by the implicit `Sized` requirement on this type parameter in `Foo`
help: you could relax the implicit `Sized` bound on `F` if it were used through indirection like `&F` or `Box<F>`
--> /tmp/icemaker_global_tempdir.XjHPTBIuznYH/rustc_testrunner_tmpdir_reporting.WcK5sUzG23U6/mvce.rs:3:10
|
3 | enum Foo<F: Fn()> {
| ^ this could be changed to `F: ?Sized`...
4 | Bar,
5 | Var(F),
| - ...if indirection were used here: `Box<F>`
warning: unreachable expression
--> /tmp/icemaker_global_tempdir.XjHPTBIuznYH/rustc_testrunner_tmpdir_reporting.WcK5sUzG23U6/mvce.rs:11:5
|
10 | let x: Inv = todo!();
| ------- any code following this expression is unreachable
11 | / match x {
12 | | Foo::Var(Supertype::Bar) => {}
13 | | _ => {}
14 | | }
| |_____^ unreachable expression
|
= note: `#[warn(unreachable_code)]` (part of `#[warn(unused)]`) on by default
error[E0308]: mismatched types
--> /tmp/icemaker_global_tempdir.XjHPTBIuznYH/rustc_testrunner_tmpdir_reporting.WcK5sUzG23U6/mvce.rs:12:9
|
11 | match x {
| - this expression has type `Inv`
12 | Foo::Var(Supertype::Bar) => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `Inv`, found `Foo<_>`
|
= note: expected struct `Inv`
found enum `Foo<_>`
error[E0277]: the size for values of type `(dyn Fn() + 'static)` cannot be known at compilation time
--> /tmp/icemaker_global_tempdir.XjHPTBIuznYH/rustc_testrunner_tmpdir_reporting.WcK5sUzG23U6/mvce.rs:12:18
|
12 | Foo::Var(Supertype::Bar) => {}
| ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn Fn() + 'static)`
note: required by a bound in `Foo::Bar`
--> /tmp/icemaker_global_tempdir.XjHPTBIuznYH/rustc_testrunner_tmpdir_reporting.WcK5sUzG23U6/mvce.rs:3:10
|
3 | enum Foo<F: Fn()> {
| ^ required by this bound in `Foo::Bar`
4 | Bar,
| --- required by a bound in this unit variant
error[E0277]: expected a `Fn()` closure, found `Foo<dyn Fn()>`
--> /tmp/icemaker_global_tempdir.XjHPTBIuznYH/rustc_testrunner_tmpdir_reporting.WcK5sUzG23U6/mvce.rs:12:9
|
12 | Foo::Var(Supertype::Bar) => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected an `Fn()` closure, found `Foo<dyn Fn()>`
|
help: the trait `Fn()` is not implemented for `Foo<dyn Fn()>`
--> /tmp/icemaker_global_tempdir.XjHPTBIuznYH/rustc_testrunner_tmpdir_reporting.WcK5sUzG23U6/mvce.rs:3:1
|
3 | enum Foo<F: Fn()> {
| ^^^^^^^^^^^^^^^^^
= note: wrap the `Foo<dyn Fn()>` in a closure with no arguments: `|| { /* code */ }`
note: required by a bound in `Foo::Var`
--> /tmp/icemaker_global_tempdir.XjHPTBIuznYH/rustc_testrunner_tmpdir_reporting.WcK5sUzG23U6/mvce.rs:3:13
|
3 | enum Foo<F: Fn()> {
| ^^^^ required by this bound in `Foo::Var`
4 | Bar,
5 | Var(F),
| --- required by a bound in this tuple variant
thread 'rustc' (163240) panicked at /rustc-dev/1500f0f47f5fe8ddcd6528f6c6c031b210b4eac5/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:982:63:
called `Option::unwrap()` on a `None` value
stack backtrace:
0: 0x7fd377fb80eb - <<std[8fa6c4d7877d9fa6]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[8d2c922a005dfed9]::fmt::Display>::fmt
1: 0x7fd378621648 - core[8d2c922a005dfed9]::fmt::write
2: 0x7fd377fcf0f6 - <std[8fa6c4d7877d9fa6]::sys::stdio::unix::Stderr as std[8fa6c4d7877d9fa6]::io::Write>::write_fmt
3: 0x7fd377f8e1d8 - std[8fa6c4d7877d9fa6]::panicking::default_hook::{closure#0}
4: 0x7fd377fab553 - std[8fa6c4d7877d9fa6]::panicking::default_hook
5: 0x7fd376f84080 - std[8fa6c4d7877d9fa6]::panicking::update_hook::<alloc[e536beed0316d181]::boxed::Box<rustc_driver_impl[f1389595c05d78d8]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7fd377fab832 - std[8fa6c4d7877d9fa6]::panicking::panic_with_hook
7: 0x7fd377f8e2ca - std[8fa6c4d7877d9fa6]::panicking::panic_handler::{closure#0}
8: 0x7fd377f84fe9 - std[8fa6c4d7877d9fa6]::sys::backtrace::__rust_end_short_backtrace::<std[8fa6c4d7877d9fa6]::panicking::panic_handler::{closure#0}, !>
9: 0x7fd377f8fcfd - __rustc[d7af78fd024a5d6e]::rust_begin_unwind
10: 0x7fd3753ed78c - core[8d2c922a005dfed9]::panicking::panic_fmt
11: 0x7fd374642312 - core[8d2c922a005dfed9]::panicking::panic
12: 0x7fd374f373c9 - core[8d2c922a005dfed9]::option::unwrap_failed
13: 0x7fd3792d7163 - <rustc_hir_typeck[aadce8c622caaa3b]::fn_ctxt::FnCtxt>::instantiate_value_path
14: 0x7fd378a37216 - <rustc_hir_typeck[aadce8c622caaa3b]::fn_ctxt::FnCtxt>::check_pat
15: 0x7fd378a3aefa - <rustc_hir_typeck[aadce8c622caaa3b]::fn_ctxt::FnCtxt>::check_pat_inner
16: 0x7fd378a36b13 - <rustc_hir_typeck[aadce8c622caaa3b]::fn_ctxt::FnCtxt>::check_pat
17: 0x7fd378a32f6a - <rustc_hir_typeck[aadce8c622caaa3b]::fn_ctxt::FnCtxt>::check_expr_match
18: 0x7fd378a5ac7b - <rustc_hir_typeck[aadce8c622caaa3b]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
19: 0x7fd378a53a70 - <rustc_hir_typeck[aadce8c622caaa3b]::fn_ctxt::FnCtxt>::check_expr_block
20: 0x7fd378a59817 - <rustc_hir_typeck[aadce8c622caaa3b]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
21: 0x7fd378a28610 - rustc_hir_typeck[aadce8c622caaa3b]::check::check_fn
22: 0x7fd3793f1332 - rustc_hir_typeck[aadce8c622caaa3b]::typeck_with_inspect::{closure#0}
23: 0x7fd3793efd72 - rustc_query_impl[cec139e1f3385ac4]::query_impl::typeck::invoke_provider_fn::__rust_begin_short_backtrace
24: 0x7fd378db853e - rustc_query_impl[cec139e1f3385ac4]::execution::try_execute_query::<rustc_data_structures[1a0237db0a3cda6a]::vec_cache::VecCache<rustc_span[8a11d63785993c5a]::def_id::LocalDefId, rustc_middle[60c2cf3af82b0a08]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[60c2cf3af82b0a08]::dep_graph::graph::DepNodeIndex>, {rustc_query_impl[cec139e1f3385ac4]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
25: 0x7fd378db8109 - rustc_query_impl[cec139e1f3385ac4]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
26: 0x7fd378db1b4e - <rustc_middle[60c2cf3af82b0a08]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[a8016fad3afadedb]::check_crate::{closure#2}>::{closure#0}
27: 0x7fd378db156e - rustc_hir_analysis[a8016fad3afadedb]::check_crate
28: 0x7fd378db50ac - rustc_interface[b6ce98af9df5606d]::passes::analysis
29: 0x7fd3797e1499 - rustc_query_impl[cec139e1f3385ac4]::execution::try_execute_query::<rustc_middle[60c2cf3af82b0a08]::query::caches::SingleCache<rustc_middle[60c2cf3af82b0a08]::query::erase::ErasedData<[u8; 0usize]>>, {rustc_query_impl[cec139e1f3385ac4]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
30: 0x7fd3797e10c8 - rustc_query_impl[cec139e1f3385ac4]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
31: 0x7fd37982088b - rustc_interface[b6ce98af9df5606d]::interface::run_compiler::<(), rustc_driver_impl[f1389595c05d78d8]::run_compiler::{closure#0}>::{closure#1}
32: 0x7fd3797d09fe - std[8fa6c4d7877d9fa6]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[b6ce98af9df5606d]::util::run_in_thread_with_globals<rustc_interface[b6ce98af9df5606d]::util::run_in_thread_pool_with_globals<rustc_interface[b6ce98af9df5606d]::interface::run_compiler<(), rustc_driver_impl[f1389595c05d78d8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
33: 0x7fd3797d10e0 - <std[8fa6c4d7877d9fa6]::thread::lifecycle::spawn_unchecked<rustc_interface[b6ce98af9df5606d]::util::run_in_thread_with_globals<rustc_interface[b6ce98af9df5606d]::util::run_in_thread_pool_with_globals<rustc_interface[b6ce98af9df5606d]::interface::run_compiler<(), rustc_driver_impl[f1389595c05d78d8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[8d2c922a005dfed9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
34: 0x7fd3797d1f6c - <std[8fa6c4d7877d9fa6]::sys::thread::unix::Thread>::new::thread_start
35: 0x7fd3732a598b - <unknown>
36: 0x7fd373329a0c - <unknown>
37: 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.95.0-nightly (1500f0f47 2026-02-22) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z next-solver=globally -Z dump-mir-dir=dir
query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors; 2 warnings emitted
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
@rustbot label +F-lazy_type_alias +WG-trait-system-refactor
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the ICE with the supplied a.rs snippet and -Znext-solver=globally. Start at compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:976-988, especially FnCtxt::instantiate_value_path, and trace the failing pattern type-checking path shown in the stack trace. Done means the example reports its existing type errors without rustc panicking.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100