[ICE]: `discr subgoal`
Open
Nobody has claimed this yet.
C-bug
F-unsafe_binders
I-ICE
needs-triage
T-compiler
WG-trait-system-refactor
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
Code
// compiler-flags: -Znext-solver=globally
#![feature(unsafe_binders)]
fn foo<T: std::marker::Copy>(x: unsafe<> T) {
std::mem::discriminant(&x);
}
fn main() {}
Meta
rustc --version --verbose:
rustc 1.99.0-nightly (3659db0d3 2026-07-05)
binary: rustc
commit-hash: 3659db0d3e2cd634c766fcda79ed118eca31a9fd
commit-date: 2026-07-05
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8
Error output
<output>
Backtrace
warning: the feature `unsafe_binders` is incomplete and may not be safe to use and/or cause compiler crashes
--> k.rs:1:12
|
1 | #![feature(unsafe_binders)]
| ^^^^^^^^^^^^^^
|
= note: see issue #130516 <https://github.com/rust-lang/rust/issues/130516> for more information
= note: `#[warn(incomplete_features)]` on by default
thread 'rustc' (3853805) panicked at /rustc-dev/3659db0d3e2cd634c766fcda79ed118eca31a9fd/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs:1008:17:
not yet implemented: discr subgoal...
stack backtrace:
0: 0x7f483ecd3846 - <<std[f3ff1fb6d3edc9aa]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[a41e0ab587117a37]::fmt::Display>::fmt
1: 0x7f483f40ec9e - core[a41e0ab587117a37]::fmt::write
2: 0x7f483ece8c2c - <std[f3ff1fb6d3edc9aa]::sys::stdio::unix::Stderr as std[f3ff1fb6d3edc9aa]::io::Write>::write_fmt
3: 0x7f483eca7caa - std[f3ff1fb6d3edc9aa]::panicking::default_hook::{closure#0}
4: 0x7f483ecc5f93 - std[f3ff1fb6d3edc9aa]::panicking::default_hook
5: 0x7f483dcb51d8 - std[f3ff1fb6d3edc9aa]::panicking::update_hook::<alloc[63993826f7b5d124]::boxed::Box<rustc_driver_impl[1d9b408d7a24224d]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f483ecc6432 - std[f3ff1fb6d3edc9aa]::panicking::panic_with_hook
7: 0x7f483eca7d94 - std[f3ff1fb6d3edc9aa]::panicking::panic_handler::{closure#0}
8: 0x7f483ec9ea29 - std[f3ff1fb6d3edc9aa]::sys::backtrace::__rust_end_short_backtrace::<std[f3ff1fb6d3edc9aa]::panicking::panic_handler::{closure#0}, !>
9: 0x7f483eca96cd - __rustc[1b6846d77d192586]::rust_begin_unwind
10: 0x7f483bd1e9ac - core[a41e0ab587117a37]::panicking::panic_fmt
11: 0x7f4840a6da18 - <rustc_type_ir[be49fdf947711b1b]::predicate::NormalizesTo<rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt> as rustc_next_trait_solver[29a5c63578321cec]::solve::assembly::GoalKind<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::consider_builtin_discriminant_kind_candidate
12: 0x7f48400f3a0a - <rustc_next_trait_solver[29a5c63578321cec]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::assemble_and_evaluate_candidates::<rustc_type_ir[be49fdf947711b1b]::predicate::NormalizesTo<rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>
13: 0x7f484062e5ec - <rustc_next_trait_solver[29a5c63578321cec]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate> as rustc_type_ir[be49fdf947711b1b]::search_graph::Delegate>::compute_goal::{closure#0}
14: 0x7f483c6e0843 - <rustc_type_ir[be49fdf947711b1b]::search_graph::SearchGraph<rustc_next_trait_solver[29a5c63578321cec]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate>, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::evaluate_goal::{closure#0}
15: 0x7f484017431b - <rustc_next_trait_solver[29a5c63578321cec]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::evaluate_goal_cold
16: 0x7f484062e178 - <rustc_next_trait_solver[29a5c63578321cec]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate> as rustc_type_ir[be49fdf947711b1b]::search_graph::Delegate>::compute_goal::{closure#0}
17: 0x7f483c6e0843 - <rustc_type_ir[be49fdf947711b1b]::search_graph::SearchGraph<rustc_next_trait_solver[29a5c63578321cec]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate>, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::evaluate_goal::{closure#0}
18: 0x7f484017431b - <rustc_next_trait_solver[29a5c63578321cec]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::evaluate_goal_cold
19: 0x7f48401719f8 - <rustc_next_trait_solver[29a5c63578321cec]::normalize::NormalizationFolder<rustc_infer[83676dc9fff0c021]::infer::InferCtxt, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt, <rustc_next_trait_solver[29a5c63578321cec]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::normalize<rustc_middle[67dc40c5dc90d8fe]::ty::predicate::Predicate>::{closure#0}> as rustc_type_ir[be49fdf947711b1b]::fold::FallibleTypeFolder<rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::try_fold_ty::{closure#0}
20: 0x7f4840170ad8 - <&rustc_middle[67dc40c5dc90d8fe]::ty::list::RawList<(), rustc_middle[67dc40c5dc90d8fe]::ty::generic_args::GenericArg> as rustc_type_ir[be49fdf947711b1b]::fold::TypeFoldable<rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::try_fold_with::<rustc_next_trait_solver[29a5c63578321cec]::normalize::NormalizationFolder<rustc_infer[83676dc9fff0c021]::infer::InferCtxt, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt, <rustc_next_trait_solver[29a5c63578321cec]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::normalize<rustc_middle[67dc40c5dc90d8fe]::ty::predicate::Predicate>::{closure#0}>>
21: 0x7f48400fe454 - <rustc_next_trait_solver[29a5c63578321cec]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::add_goal
22: 0x7f48400fbba7 - <rustc_next_trait_solver[29a5c63578321cec]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::probe_and_evaluate_goal_for_constituent_tys::<<rustc_type_ir[be49fdf947711b1b]::predicate::TraitPredicate<rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt> as rustc_next_trait_solver[29a5c63578321cec]::solve::assembly::GoalKind<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::consider_builtin_sizedness_candidates::{closure#0}>
23: 0x7f4840a5c12e - <rustc_next_trait_solver[29a5c63578321cec]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::compute_trait_goal
24: 0x7f484062d8d3 - <rustc_next_trait_solver[29a5c63578321cec]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate> as rustc_type_ir[be49fdf947711b1b]::search_graph::Delegate>::compute_goal::{closure#0}
25: 0x7f483c6e0843 - <rustc_type_ir[be49fdf947711b1b]::search_graph::SearchGraph<rustc_next_trait_solver[29a5c63578321cec]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate>, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::evaluate_goal::{closure#0}
26: 0x7f484017431b - <rustc_next_trait_solver[29a5c63578321cec]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[2948f6a729fb144b]::solve::delegate::SolverDelegate, rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>>::evaluate_goal_cold
27: 0x7f4840181799 - <rustc_trait_selection[2948f6a729fb144b]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[2948f6a729fb144b]::traits::FulfillmentError> as rustc_infer[83676dc9fff0c021]::traits::engine::TraitEngine<rustc_trait_selection[2948f6a729fb144b]::traits::FulfillmentError>>::try_evaluate_obligations
28: 0x7f48401b371d - rustc_hir_typeck[86bf61ef5573921e]::typeck_with_inspect::{closure#0}
29: 0x7f48401ade00 - rustc_query_impl[44f1d94f3682cc0a]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
30: 0x7f483f7f2be9 - rustc_query_impl[44f1d94f3682cc0a]::execution::try_execute_query::<rustc_data_structures[d344ec675b6e4243]::vec_cache::VecCache<rustc_span[e9819c9ffbcf2457]::def_id::LocalDefId, rustc_middle[67dc40c5dc90d8fe]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[67dc40c5dc90d8fe]::dep_graph::graph::DepNodeIndex>, false>
31: 0x7f483f7f2643 - rustc_query_impl[44f1d94f3682cc0a]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
32: 0x7f483f7efba3 - <rustc_middle[67dc40c5dc90d8fe]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[3a159b81db3b0a1f]::check_crate::{closure#1}>::{closure#0}
33: 0x7f483f7ef4e1 - rustc_hir_analysis[3a159b81db3b0a1f]::check_crate
34: 0x7f483f7f38fa - rustc_interface[96ef288c905db9b6]::passes::analysis
35: 0x7f484059e247 - rustc_query_impl[44f1d94f3682cc0a]::execution::try_execute_query::<rustc_middle[67dc40c5dc90d8fe]::query::caches::SingleCache<rustc_middle[67dc40c5dc90d8fe]::query::erase::ErasedData<[u8; 0usize]>>, false>
36: 0x7f484059dea9 - rustc_query_impl[44f1d94f3682cc0a]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
37: 0x7f48405d6140 - rustc_interface[96ef288c905db9b6]::interface::run_compiler::<(), rustc_driver_impl[1d9b408d7a24224d]::run_compiler::{closure#0}>::{closure#1}
38: 0x7f48405ad6fa - std[f3ff1fb6d3edc9aa]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[96ef288c905db9b6]::util::run_in_thread_with_globals<rustc_interface[96ef288c905db9b6]::util::run_in_thread_pool_with_globals<rustc_interface[96ef288c905db9b6]::interface::run_compiler<(), rustc_driver_impl[1d9b408d7a24224d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
39: 0x7f48405ad4ad - <std[f3ff1fb6d3edc9aa]::thread::lifecycle::spawn_unchecked<rustc_interface[96ef288c905db9b6]::util::run_in_thread_with_globals<rustc_interface[96ef288c905db9b6]::util::run_in_thread_pool_with_globals<rustc_interface[96ef288c905db9b6]::interface::run_compiler<(), rustc_driver_impl[1d9b408d7a24224d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a41e0ab587117a37]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
40: 0x7f48405b18d0 - <std[f3ff1fb6d3edc9aa]::sys::thread::unix::Thread>::new::thread_start
41: 0x7f4839e981b9 - <unknown>
42: 0x7f4839f1d21c - <unknown>
43: 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: please attach the file at `/tmp/im/j/rustc-ice-2026-07-06T04_54_21-3853795.txt` to your bug report
note: rustc 1.99.0-nightly (3659db0d3 2026-07-05) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z next-solver=globally
query stack during panic:
#0 [typeck_root] type-checking `foo`
#1 [analysis] running analysis passes on crate `k`
end of query stack
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
Run the supplied Rust reproducer with -Znext-solver=globally and the unsafe_binders feature to confirm the ICE. Start at compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs around consider_builtin_discriminant_kind_candidate, reported near line 1008. Done means the example no longer panics and has regression coverage for this case.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100