Skip to content

[ICE]: "DefId::expect_local: … isn't local" in phantom-lifetime heavy traits #153375

@chrysn

Description

@chrysn

Code

A lot, and possibly depending on out-of-crate traits. Right now it's in https://github.com/chrysn-pull-requests/ariel-os/blob/client-lifetime-ice/src/lib/coapcore/src/client_standalone.rs; to reproduce, check it out, go to src/lib/coapcore and run cargo check there.

Note that the 'ws lifetimes in there don't necessarily make sense – I'm fighting the b^W^W^W doing pair programming with the compiler, and think I'm falling in the "just one more lifetime will fix everything" trap (it usually doesn't fix anything). But AIU, ICE is a bug no matter how stupid my code is.

It's 01:20 in the morning and I can't minify this today; I'll try to get it small tom... today.

I have a small bit of hope that just from the error output – not expecting anyone would look at unminified code – someone manages to already find that this is a duplicate of something else, so I don't have to minify, but unless that happens, minification it is. I've looked at open issues and found #143498, but that appears to be about unstable features, whereas my crash is reproducible on beta (couldn't try stable yet b/c the workspace has a few quirks).

Meta

rustc --version --verbose:

rustc 1.96.0-nightly (ec818fda3 2026-03-02)
binary: rustc
commit-hash: ec818fda361ca216eb186f5cf45131bd9c776bb4
commit-date: 2026-03-02
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0

but also on beta (but all other outputs are from nightly):

rustc 1.94.0-beta.6 (ec6e98837 2026-02-26)
binary: rustc
commit-hash: ec6e9883776ff64b7c97a33931f85cc02c31d05f
commit-date: 2026-02-26
host: x86_64-unknown-linux-gnu
release: 1.94.0-beta.6
LLVM version: 21.1.8

Error output

thread 'rustc' (4168347) panicked at /rustc-dev/ec818fda361ca216eb186f5cf45131bd9c776bb4/compiler/rustc_trait_selection/src/errors/note_and_explain.rs:26:22:
DefId::expect_local: `DefId(44:11 ~ coap_request[448f]::Request::build_request)` isn't local
Backtrace

(I didn't need to turn up backtraces; seems ICEs give full backtraces by default now).

    Checking coapcore v0.1.1 (/home/chrysn/git/crates/ariel-os-worktrees/client-lifetime-ice/src/lib/coapcore)

thread 'rustc' (4167884) panicked at /rustc-dev/ec818fda361ca216eb186f5cf45131bd9c776bb4/compiler/rustc_trait_selection/src/errors/note_and_explain.rs:26:22:
DefId::expect_local: `DefId(44:11 ~ coap_request[448f]::Request::build_request)` isn't local
stack backtrace:
   0:     0x7fd2b09532bb - <<std[eb110dcb1455ebbb]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[89784ade3600f19b]::fmt::Display>::fmt
   1:     0x7fd2b10202c8 - core[89784ade3600f19b]::fmt::write
   2:     0x7fd2b096a2c6 - <std[eb110dcb1455ebbb]::sys::stdio::unix::Stderr as std[eb110dcb1455ebbb]::io::Write>::write_fmt
   3:     0x7fd2b0929398 - std[eb110dcb1455ebbb]::panicking::default_hook::{closure#0}
   4:     0x7fd2b0946723 - std[eb110dcb1455ebbb]::panicking::default_hook
   5:     0x7fd2af93125c - std[eb110dcb1455ebbb]::panicking::update_hook::<alloc[29fb76bce34b892e]::boxed::Box<rustc_driver_impl[fb3bb71bcb51a2dc]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fd2b0946a02 - std[eb110dcb1455ebbb]::panicking::panic_with_hook
   7:     0x7fd2b0929458 - std[eb110dcb1455ebbb]::panicking::panic_handler::{closure#0}
   8:     0x7fd2b0920189 - std[eb110dcb1455ebbb]::sys::backtrace::__rust_end_short_backtrace::<std[eb110dcb1455ebbb]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fd2b092aebd - __rustc[b5c62ea7d35cbfc4]::rust_begin_unwind
  10:     0x7fd2ad4ce2fc - core[89784ade3600f19b]::panicking::panic_fmt
  11:     0x7fd2b074fa1a - <rustc_trait_selection[bf9027be1a6a20ec]::errors::note_and_explain::RegionExplanation>::new
  12:     0x7fd2b071eb95 - <rustc_trait_selection[bf9027be1a6a20ec]::error_reporting::TypeErrCtxt>::report_concrete_failure
  13:     0x7fd2b071d068 - <rustc_trait_selection[bf9027be1a6a20ec]::error_reporting::TypeErrCtxt>::report_region_errors
  14:     0x7fd2b193e00c - <rustc_trait_selection[bf9027be1a6a20ec]::traits::engine::ObligationCtxt<rustc_trait_selection[bf9027be1a6a20ec]::traits::FulfillmentError>>::resolve_regions_and_report_errors::<indexmap[777de5bf500a086]::set::IndexSet<rustc_middle[35e622c0033dd948]::ty::Ty, rustc_hash[5d99512a11e6cdb]::FxBuildHasher>>
  15:     0x7fd2b195e0b8 - rustc_hir_analysis[eb8396faa04d2a8f]::check::compare_impl_item::check_type_bounds
  16:     0x7fd2b1951efa - rustc_hir_analysis[eb8396faa04d2a8f]::check::compare_impl_item::compare_impl_item
  17:     0x7fd2b194f3e9 - rustc_query_impl[52bc1cae8cb1f0f9]::query_impl::compare_impl_item::invoke_provider_fn::__rust_begin_short_backtrace
  18:     0x7fd2b1906119 - rustc_query_impl[52bc1cae8cb1f0f9]::execution::try_execute_query::<rustc_data_structures[d0096a8ffe6a0514]::vec_cache::VecCache<rustc_span[566afffa9b4ced27]::def_id::LocalDefId, rustc_middle[35e622c0033dd948]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[35e622c0033dd948]::dep_graph::graph::DepNodeIndex>, false>
  19:     0x7fd2b1905c0e - rustc_query_impl[52bc1cae8cb1f0f9]::query_impl::compare_impl_item::execute_query_non_incr::__rust_end_short_backtrace
  20:     0x7fd2b19090b2 - rustc_hir_analysis[eb8396faa04d2a8f]::check::check::check_item_type
  21:     0x7fd2b1906ba6 - rustc_hir_analysis[eb8396faa04d2a8f]::check::wfcheck::check_well_formed
  22:     0x7fd2b1906b87 - rustc_query_impl[52bc1cae8cb1f0f9]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  23:     0x7fd2b1906119 - rustc_query_impl[52bc1cae8cb1f0f9]::execution::try_execute_query::<rustc_data_structures[d0096a8ffe6a0514]::vec_cache::VecCache<rustc_span[566afffa9b4ced27]::def_id::LocalDefId, rustc_middle[35e622c0033dd948]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[35e622c0033dd948]::dep_graph::graph::DepNodeIndex>, false>
  24:     0x7fd2b1905e7b - rustc_query_impl[52bc1cae8cb1f0f9]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  25:     0x7fd2b1902d7d - rustc_hir_analysis[eb8396faa04d2a8f]::check::wfcheck::check_type_wf
  26:     0x7fd2b1902c87 - rustc_query_impl[52bc1cae8cb1f0f9]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  27:     0x7fd2b221d097 - rustc_query_impl[52bc1cae8cb1f0f9]::execution::try_execute_query::<rustc_middle[35e622c0033dd948]::query::caches::SingleCache<rustc_middle[35e622c0033dd948]::query::erase::ErasedData<[u8; 1usize]>>, false>
  28:     0x7fd2b221cd69 - rustc_query_impl[52bc1cae8cb1f0f9]::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7fd2b1a08455 - rustc_hir_analysis[eb8396faa04d2a8f]::check_crate
  30:     0x7fd2b1174f93 - rustc_interface[e910a3c7e0b41bdb]::passes::analysis
  31:     0x7fd2b221ecda - rustc_query_impl[52bc1cae8cb1f0f9]::execution::try_execute_query::<rustc_middle[35e622c0033dd948]::query::caches::SingleCache<rustc_middle[35e622c0033dd948]::query::erase::ErasedData<[u8; 0usize]>>, false>
  32:     0x7fd2b221eaab - rustc_query_impl[52bc1cae8cb1f0f9]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  33:     0x7fd2b21de26d - rustc_interface[e910a3c7e0b41bdb]::interface::run_compiler::<(), rustc_driver_impl[fb3bb71bcb51a2dc]::run_compiler::{closure#0}>::{closure#1}
  34:     0x7fd2b220d4be - std[eb110dcb1455ebbb]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e910a3c7e0b41bdb]::util::run_in_thread_with_globals<rustc_interface[e910a3c7e0b41bdb]::util::run_in_thread_pool_with_globals<rustc_interface[e910a3c7e0b41bdb]::interface::run_compiler<(), rustc_driver_impl[fb3bb71bcb51a2dc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  35:     0x7fd2b220db20 - <std[eb110dcb1455ebbb]::thread::lifecycle::spawn_unchecked<rustc_interface[e910a3c7e0b41bdb]::util::run_in_thread_with_globals<rustc_interface[e910a3c7e0b41bdb]::util::run_in_thread_pool_with_globals<rustc_interface[e910a3c7e0b41bdb]::interface::run_compiler<(), rustc_driver_impl[fb3bb71bcb51a2dc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[89784ade3600f19b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7fd2b220e9ac - <std[eb110dcb1455ebbb]::sys::thread::unix::Thread>::new::thread_start
  37:     0x7fd2abc9cb7b - start_thread
                               at ./nptl/pthread_create.c:448:8
  38:     0x7fd2abd1a7b8 - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
  39:                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 `/home/chrysn/git/crates/ariel-os-worktrees/client-lifetime-ice/rustc-ice-2026-03-04T00_22_23-4167882.txt` to your bug report

note: rustc 1.96.0-nightly (ec818fda3 2026-03-02) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C opt-level=s -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 -C debug-assertions=on

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

query stack during panic:
#0 [compare_impl_item] checking assoc item `client_standalone::<impl at src/lib/coapcore/src/client_standalone.rs:104:1: 107:15>::build_request::{anon_assoc#0}` is compatible with trait definition
#1 [check_well_formed] checking that `client_standalone::<impl at src/lib/coapcore/src/client_standalone.rs:104:1: 107:15>` is well-formed
... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: could not compile `coapcore` (lib)

Caused by:
  process didn't exit successfully: `/home/chrysn/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name coapcore --edition=2024 src/lib/coapcore/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=419 --crate-type lib --emit=dep-info,metadata -C opt-level=s -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --warn=rust_2018_idioms '--warn=clippy::pedantic' '--warn=clippy::unused_trait_names' '--deny=clippy::unused_result_ok' --deny=unused_must_use --deny=unsafe_op_in_unsafe_fn --deny=unsafe_code --allow=unexpected_cfgs '--warn=clippy::undocumented_unsafe_blocks' '--allow=clippy::too_many_lines' '--warn=clippy::too_long_first_doc_paragraph' --deny=private_interfaces --deny=private_bounds '--warn=clippy::missing_safety_doc' '--deny=clippy::indexing_slicing' '--warn=clippy::doc_paragraphs_missing_punctuation' '--warn=rustdoc::broken_intra_doc_links' -C debug-assertions=on --cfg 'feature="default"' --cfg 'feature="liboscore-defaults"' --cfg 'feature="liboscore-provide-abort"' --cfg 'feature="liboscore-provide-assert"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("_nightly_docs", "_test", "default", "defmt", "liboscore-defaults", "liboscore-provide-abort", "liboscore-provide-assert", "log"))' -C metadata=8add47b4ef55fe8e -C extra-filename=-99c774bea8fe35b1 --out-dir /home/chrysn-cache/dot-cache/cargo-target/debug/deps -L dependency=/home/chrysn-cache/dot-cache/cargo-target/debug/deps --extern aes=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libaes-5bb9b23fbec4baa9.rmeta --extern arrayvec=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libarrayvec-a96e5f78150f7a0f.rmeta --extern ccm=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libccm-b10ac976b898d0b3.rmeta --extern coap_handler=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libcoap_handler-bc57d5491cddc9bc.rmeta --extern coap_message=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libcoap_message-e63988729416cfbb.rmeta --extern coap_message_implementations=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libcoap_message_implementations-396d4207cca59a52.rmeta --extern coap_message_utils=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libcoap_message_utils-5682998dc694705b.rmeta --extern coap_numbers=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libcoap_numbers-319a138ce99b34df.rmeta --extern coap_request=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libcoap_request-1e433c13c4af4691.rmeta --extern defmt_or_log=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libdefmt_or_log-ee06f1955b7e8f87.rmeta --extern document_features=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libdocument_features-52bac9d899dfb4ab.so --extern heapless=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libheapless-9fd7ae1cf814d250.rmeta --extern lakers=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/liblakers-6e8c9cf37ba6cec6.rmeta --extern lakers_crypto_rustcrypto=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/liblakers_crypto_rustcrypto-878c3a188a5f6f2b.rmeta --extern liboscore=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libliboscore-8f6a448b5896f77f.rmeta --extern minicbor=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libminicbor-bacc655ff0892c6b.rmeta --extern minicbor_adapters=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libminicbor_adapters-b0f99c0a8cb0afb9.rmeta --extern p256=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/libp256-81e9ddfc504871f3.rmeta --extern rand_core=/home/chrysn-cache/dot-cache/cargo-target/debug/deps/librand_core-93f2d37683537f78.rmeta -L native=/home/chrysn-cache/dot-cache/cargo-target/debug/build/liboscore-57651a036eee9ac4/out` (exit status: 101)

rustc-ice-2026-03-04T00_22_23-4167882.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions