ICE: `unexpected bound ty in binder: DefId(..::Foo::T)` (`dyn_compatibility_violations`)
Open
Nobody has claimed this yet.
C-bug
F-non_lifetime_binders
I-ICE
S-bug-has-test
S-has-bisection
S-has-mcve
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
snippet:
#![feature(non_lifetime_binders)]
trait Foo: for<T> Bar<T> {
type Item;
fn next(self) -> Self::Item;
}
trait Bar<T> {}
fn main() {}
Version information
rustc 1.94.0-nightly (2848c2ebe 2025-12-31)
binary: rustc
commit-hash: 2848c2ebe9a8a604cd63455263299d7258bc8252
commit-date: 2025-12-31
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8
Possibly related line of code:
https://github.com/rust-lang/rust/blob/2848c2ebe9a8a604cd63455263299d7258bc8252/compiler/rustc_middle/src/ty/fold.rs#L230-L242
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.Md7TpIkIwV0N/rustc_testrunner_tmpdir_reporting.gjJSpFN7Z6bY/mvce.rs:1:12
|
1 | #![feature(non_lifetime_binders)]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: trait `Foo` is never used
--> /tmp/icemaker_global_tempdir.Md7TpIkIwV0N/rustc_testrunner_tmpdir_reporting.gjJSpFN7Z6bY/mvce.rs:2:7
|
2 | trait Foo: for<T> Bar<T> {
| ^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
warning: trait `Bar` is never used
--> /tmp/icemaker_global_tempdir.Md7TpIkIwV0N/rustc_testrunner_tmpdir_reporting.gjJSpFN7Z6bY/mvce.rs:6:7
|
6 | trait Bar<T> {}
| ^^^
error: internal compiler error: /rustc-dev/2848c2ebe9a8a604cd63455263299d7258bc8252/compiler/rustc_middle/src/ty/fold.rs:236:33: unexpected bound ty in binder: DefId(0:4 ~ mvce[1a65]::Foo::T)
thread 'rustc' (126813) panicked at /rustc-dev/2848c2ebe9a8a604cd63455263299d7258bc8252/compiler/rustc_middle/src/ty/fold.rs:236:33:
Box<dyn Any>
stack backtrace:
0: 0x7f28f2a359f3 - <<std[1406f49530aa7bc7]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[c2fd9633a439008]::fmt::Display>::fmt
1: 0x7f28f300e348 - core[c2fd9633a439008]::fmt::write
2: 0x7f28f2a4c116 - <std[1406f49530aa7bc7]::sys::stdio::unix::Stderr as std[1406f49530aa7bc7]::io::Write>::write_fmt
3: 0x7f28f2a0c1e8 - std[1406f49530aa7bc7]::panicking::default_hook::{closure#0}
4: 0x7f28f2a29933 - std[1406f49530aa7bc7]::panicking::default_hook
5: 0x7f28f1a1059a - std[1406f49530aa7bc7]::panicking::update_hook::<alloc[a0bf8f2463c5d49b]::boxed::Box<rustc_driver_impl[f774c5f30e20a801]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f28f2a29c12 - std[1406f49530aa7bc7]::panicking::panic_with_hook
7: 0x7f28f1a4d581 - std[1406f49530aa7bc7]::panicking::begin_panic::<rustc_errors[959057a8a12e659b]::ExplicitBug>::{closure#0}
8: 0x7f28f1a3d836 - std[1406f49530aa7bc7]::sys::backtrace::__rust_end_short_backtrace::<std[1406f49530aa7bc7]::panicking::begin_panic<rustc_errors[959057a8a12e659b]::ExplicitBug>::{closure#0}, !>
9: 0x7f28f1a3d63f - std[1406f49530aa7bc7]::panicking::begin_panic::<rustc_errors[959057a8a12e659b]::ExplicitBug>
10: 0x7f28f1a6b461 - <rustc_errors[959057a8a12e659b]::diagnostic::BugAbort as rustc_errors[959057a8a12e659b]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x7f28f2019409 - rustc_middle[ae8a157094bc1f6]::util::bug::opt_span_bug_fmt::<rustc_span[1862988e702d2bbf]::span_encoding::Span>::{closure#0}
12: 0x7f28f2019592 - rustc_middle[ae8a157094bc1f6]::ty::context::tls::with_opt::<rustc_middle[ae8a157094bc1f6]::util::bug::opt_span_bug_fmt<rustc_span[1862988e702d2bbf]::span_encoding::Span>::{closure#0}, !>::{closure#0}
13: 0x7f28f200abbb - rustc_middle[ae8a157094bc1f6]::ty::context::tls::with_context_opt::<rustc_middle[ae8a157094bc1f6]::ty::context::tls::with_opt<rustc_middle[ae8a157094bc1f6]::util::bug::opt_span_bug_fmt<rustc_span[1862988e702d2bbf]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
14: 0x7f28efb47934 - rustc_middle[ae8a157094bc1f6]::util::bug::bug_fmt
15: 0x7f28f27c07be - <rustc_middle[ae8a157094bc1f6]::ty::context::TyCtxt>::instantiate_bound_regions_uncached::<rustc_type_ir[82846f740e557bef]::ty_kind::FnSig<rustc_middle[ae8a157094bc1f6]::ty::context::TyCtxt>, <rustc_middle[ae8a157094bc1f6]::ty::context::TyCtxt>::instantiate_bound_regions<rustc_type_ir[82846f740e557bef]::ty_kind::FnSig<rustc_middle[ae8a157094bc1f6]::ty::context::TyCtxt>, <rustc_middle[ae8a157094bc1f6]::ty::context::TyCtxt>::instantiate_bound_regions_with_erased<rustc_type_ir[82846f740e557bef]::ty_kind::FnSig<rustc_middle[ae8a157094bc1f6]::ty::context::TyCtxt>>::{closure#0}>::{closure#0}>::{closure#0}
16: 0x7f28f209ca46 - <rustc_middle[ae8a157094bc1f6]::ty::fold::FnMutDelegate as rustc_middle[ae8a157094bc1f6]::ty::fold::BoundVarReplacerDelegate>::replace_ty
17: 0x7f28f371605c - <rustc_middle[ae8a157094bc1f6]::ty::fold::BoundVarReplacer<rustc_middle[ae8a157094bc1f6]::ty::fold::FnMutDelegate> as rustc_type_ir[82846f740e557bef]::fold::TypeFolder<rustc_middle[ae8a157094bc1f6]::ty::context::TyCtxt>>::fold_ty
18: 0x7f28f3714bb4 - <&rustc_middle[ae8a157094bc1f6]::ty::list::RawList<(), rustc_middle[ae8a157094bc1f6]::ty::generic_args::GenericArg> as rustc_type_ir[82846f740e557bef]::fold::TypeFoldable<rustc_middle[ae8a157094bc1f6]::ty::context::TyCtxt>>::fold_with::<rustc_middle[ae8a157094bc1f6]::ty::fold::BoundVarReplacer<rustc_middle[ae8a157094bc1f6]::ty::fold::FnMutDelegate>>
19: 0x7f28f382a6f8 - <rustc_middle[ae8a157094bc1f6]::ty::context::TyCtxt>::instantiate_bound_regions_with_erased::<rustc_type_ir[82846f740e557bef]::predicate::TraitRef<rustc_middle[ae8a157094bc1f6]::ty::context::TyCtxt>>
20: 0x7f28f382a212 - <rustc_trait_selection[fbba24d623cd4096]::traits::dyn_compatibility::IllegalSelfTypeVisitor as rustc_type_ir[82846f740e557bef]::visit::TypeVisitor<rustc_middle[ae8a157094bc1f6]::ty::context::TyCtxt>>::visit_ty
21: 0x7f28f382b127 - rustc_trait_selection[fbba24d623cd4096]::traits::dyn_compatibility::virtual_call_violations_for_method
22: 0x7f28f420b096 - rustc_trait_selection[fbba24d623cd4096]::traits::dyn_compatibility::dyn_compatibility_violations_for_assoc_item
23: 0x7f28f420ad5a - <core[c2fd9633a439008]::iter::adapters::flatten::FlatMap<core[c2fd9633a439008]::iter::adapters::map::Map<core[c2fd9633a439008]::iter::adapters::map::Map<core[c2fd9633a439008]::slice::iter::Iter<(core[c2fd9633a439008]::option::Option<rustc_span[1862988e702d2bbf]::symbol::Symbol>, rustc_middle[ae8a157094bc1f6]::ty::assoc::AssocItem)>, <rustc_data_structures[bdeeb9af53330c65]::sorted_map::index_map::SortedIndexMultiMap<u32, core[c2fd9633a439008]::option::Option<rustc_span[1862988e702d2bbf]::symbol::Symbol>, rustc_middle[ae8a157094bc1f6]::ty::assoc::AssocItem>>::iter::{closure#0}>, <rustc_middle[ae8a157094bc1f6]::ty::assoc::AssocItems>::in_definition_order::{closure#0}>, alloc[a0bf8f2463c5d49b]::vec::Vec<rustc_middle[ae8a157094bc1f6]::traits::DynCompatibilityViolation>, rustc_trait_selection[fbba24d623cd4096]::traits::dyn_compatibility::dyn_compatibility_violations_for_trait::{closure#0}::{closure#0}> as core[c2fd9633a439008]::iter::traits::iterator::Iterator>::next
24: 0x7f28f4208ee5 - <core[c2fd9633a439008]::iter::adapters::GenericShunt<core[c2fd9633a439008]::iter::adapters::map::Map<core[c2fd9633a439008]::iter::adapters::flatten::FlatMap<core[c2fd9633a439008]::iter::sources::from_fn::FromFn<rustc_type_ir[82846f740e557bef]::elaborate::supertrait_def_ids<rustc_middle[ae8a157094bc1f6]::ty::context::TyCtxt>::{closure#0}>, alloc[a0bf8f2463c5d49b]::vec::Vec<rustc_middle[ae8a157094bc1f6]::traits::DynCompatibilityViolation>, rustc_trait_selection[fbba24d623cd4096]::traits::dyn_compatibility::dyn_compatibility_violations::{closure#0}>, core[c2fd9633a439008]::result::Result<rustc_middle[ae8a157094bc1f6]::traits::DynCompatibilityViolation, !>::Ok>, core[c2fd9633a439008]::result::Result<core[c2fd9633a439008]::convert::Infallible, !>> as core[c2fd9633a439008]::iter::traits::iterator::Iterator>::next
25: 0x7f28f420821b - rustc_trait_selection[fbba24d623cd4096]::traits::dyn_compatibility::dyn_compatibility_violations
26: 0x7f28f4208114 - rustc_query_impl[99b7d357338e6b4e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[99b7d357338e6b4e]::query_impl::dyn_compatibility_violations::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ae8a157094bc1f6]::query::erase::Erased<[u8; 16usize]>>
27: 0x7f28f42080e7 - <rustc_query_impl[99b7d357338e6b4e]::query_impl::dyn_compatibility_violations::dynamic_query::{closure#2} as core[c2fd9633a439008]::ops::function::FnOnce<(rustc_middle[ae8a157094bc1f6]::ty::context::TyCtxt, rustc_span[1862988e702d2bbf]::def_id::DefId)>>::call_once
28: 0x7f28f31c4e61 - rustc_query_system[471161554613612f]::query::plumbing::try_execute_query::<rustc_query_impl[99b7d357338e6b4e]::DynamicConfig<rustc_query_system[471161554613612f]::query::caches::DefIdCache<rustc_middle[ae8a157094bc1f6]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[99b7d357338e6b4e]::plumbing::QueryCtxt, false>
29: 0x7f28f3f871aa - rustc_query_impl[99b7d357338e6b4e]::query_impl::dyn_compatibility_violations::get_query_non_incr::__rust_end_short_backtrace
30: 0x7f28f3f87278 - rustc_trait_selection[fbba24d623cd4096]::traits::dyn_compatibility::is_dyn_compatible
31: 0x7f28f3f871df - rustc_query_impl[99b7d357338e6b4e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[99b7d357338e6b4e]::query_impl::is_dyn_compatible::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ae8a157094bc1f6]::query::erase::Erased<[u8; 1usize]>>
32: 0x7f28f3697c63 - rustc_query_system[471161554613612f]::query::plumbing::try_execute_query::<rustc_query_impl[99b7d357338e6b4e]::DynamicConfig<rustc_query_system[471161554613612f]::query::caches::DefIdCache<rustc_middle[ae8a157094bc1f6]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[99b7d357338e6b4e]::plumbing::QueryCtxt, false>
33: 0x7f28f353ea06 - rustc_query_impl[99b7d357338e6b4e]::query_impl::is_dyn_compatible::get_query_non_incr::__rust_end_short_backtrace
34: 0x7f28f3902aa2 - <rustc_lint[60ac789def8cef48]::BuiltinCombinedModuleLateLintPass as rustc_lint[60ac789def8cef48]::passes::LateLintPass>::check_item
35: 0x7f28f38f6eb9 - <rustc_lint[60ac789def8cef48]::late::LateContextAndPass<rustc_lint[60ac789def8cef48]::BuiltinCombinedModuleLateLintPass> as rustc_hir[4ba9d63f4a7b19eb]::intravisit::Visitor>::visit_nested_item
36: 0x7f28f38f57a2 - rustc_lint[60ac789def8cef48]::lint_mod
37: 0x7f28f38f5349 - rustc_query_impl[99b7d357338e6b4e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[99b7d357338e6b4e]::query_impl::lint_mod::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ae8a157094bc1f6]::query::erase::Erased<[u8; 0usize]>>
38: 0x7f28f3dfa295 - rustc_query_system[471161554613612f]::query::plumbing::try_execute_query::<rustc_query_impl[99b7d357338e6b4e]::DynamicConfig<rustc_query_system[471161554613612f]::query::caches::DefaultCache<rustc_span[1862988e702d2bbf]::def_id::LocalModDefId, rustc_middle[ae8a157094bc1f6]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[99b7d357338e6b4e]::plumbing::QueryCtxt, false>
39: 0x7f28f3dfa019 - rustc_query_impl[99b7d357338e6b4e]::query_impl::lint_mod::get_query_non_incr::__rust_end_short_backtrace
40: 0x7f28f3df8290 - rustc_lint[60ac789def8cef48]::late::check_crate::{closure#1}
41: 0x7f28f3df7e7a - rustc_lint[60ac789def8cef48]::late::check_crate
42: 0x7f28f3f17f8e - rustc_interface[e170b1ead6fc4b95]::passes::analysis
43: 0x7f28f3f176b5 - rustc_query_impl[99b7d357338e6b4e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[99b7d357338e6b4e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ae8a157094bc1f6]::query::erase::Erased<[u8; 0usize]>>
44: 0x7f28f4202326 - rustc_query_system[471161554613612f]::query::plumbing::try_execute_query::<rustc_query_impl[99b7d357338e6b4e]::DynamicConfig<rustc_query_system[471161554613612f]::query::caches::SingleCache<rustc_middle[ae8a157094bc1f6]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[99b7d357338e6b4e]::plumbing::QueryCtxt, false>
45: 0x7f28f4201ef6 - rustc_query_impl[99b7d357338e6b4e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
46: 0x7f28f43a8dd1 - <rustc_interface[e170b1ead6fc4b95]::passes::create_and_enter_global_ctxt<core[c2fd9633a439008]::option::Option<rustc_interface[e170b1ead6fc4b95]::queries::Linker>, rustc_driver_impl[f774c5f30e20a801]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[c2fd9633a439008]::ops::function::FnOnce<(&rustc_session[eeb817090c26c2ae]::session::Session, rustc_middle[ae8a157094bc1f6]::ty::context::CurrentGcx, alloc[a0bf8f2463c5d49b]::sync::Arc<rustc_data_structures[bdeeb9af53330c65]::jobserver::Proxy>, &std[1406f49530aa7bc7]::sync::once_lock::OnceLock<rustc_middle[ae8a157094bc1f6]::ty::context::GlobalCtxt>, &rustc_data_structures[bdeeb9af53330c65]::sync::worker_local::WorkerLocal<rustc_middle[ae8a157094bc1f6]::arena::Arena>, &rustc_data_structures[bdeeb9af53330c65]::sync::worker_local::WorkerLocal<rustc_hir[4ba9d63f4a7b19eb]::Arena>, rustc_driver_impl[f774c5f30e20a801]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
47: 0x7f28f4280d98 - rustc_interface[e170b1ead6fc4b95]::interface::run_compiler::<(), rustc_driver_impl[f774c5f30e20a801]::run_compiler::{closure#0}>::{closure#1}
48: 0x7f28f41185fa - std[1406f49530aa7bc7]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e170b1ead6fc4b95]::util::run_in_thread_with_globals<rustc_interface[e170b1ead6fc4b95]::util::run_in_thread_pool_with_globals<rustc_interface[e170b1ead6fc4b95]::interface::run_compiler<(), rustc_driver_impl[f774c5f30e20a801]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
49: 0x7f28f41183ac - <std[1406f49530aa7bc7]::thread::lifecycle::spawn_unchecked<rustc_interface[e170b1ead6fc4b95]::util::run_in_thread_with_globals<rustc_interface[e170b1ead6fc4b95]::util::run_in_thread_pool_with_globals<rustc_interface[e170b1ead6fc4b95]::interface::run_compiler<(), rustc_driver_impl[f774c5f30e20a801]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c2fd9633a439008]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
50: 0x7f28f41167f8 - <std[1406f49530aa7bc7]::sys::thread::unix::Thread>::new::thread_start
51: 0x7f28eda9698b - <unknown>
52: 0x7f28edb1a9cc - <unknown>
53: 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.94.0-nightly (2848c2ebe 2025-12-31) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [dyn_compatibility_violations] determining dyn-compatibility of trait `Foo`
#1 [is_dyn_compatible] checking if trait `Foo` is dyn-compatible
#2 [lint_mod] linting top-level module
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 1 previous error; 3 warnings emitted
@rustbot label +F-non_lifetime_binders
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 provided a.rs snippet and the listed rustc command. Inspect compiler/rustc_middle/src/ty/fold.rs around lines 230-242, then trace the dyn_compatibility path shown in the backtrace. Done means this input no longer causes an internal compiler error and instead produces a regular compiler result.
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
- Mostly clear
- Newbie friendliness
- 40/100