Skip to content

[ICE]: compiler/rustc_borrowck/src/diagnostics/mod.rs:542:21: End-user description not implemented for field access on T/#0 #155344

@bjorn3

Description

@bjorn3

Code

#![no_std]
#![feature(lang_items)]

unsafe extern "C" {
    fn free(_: *mut ());
}

// Workaround for #155330
#[repr(transparent)]
pub struct NonNull<T: ?Sized>(pub *const T);

#[lang = "owned_box"] // Works fine without this
pub struct Box<T: ?Sized, A = ()>(NonNull<T>, A);

impl<T: ?Sized, A> Drop for Box<T, A> {
    fn drop(&mut self) {
        // inner value is dropped by compiler
        unsafe {
            free(core::mem::transmute::<NonNull<T>, *mut _>(self.0));
        }
    }
}

Meta

rustc --version --verbose:

rustc 1.97.0-nightly (17584a181 2026-04-13)

Error output

error: internal compiler error: /rustc-dev/17584a181979f04f2aaad867332c22db1caa511a/compiler/rustc_borrowck/src/diagnostics/mod.rs:542:21: End-user description not implemented for field access on `T/#0`
Backtrace

error: internal compiler error: /rustc-dev/17584a181979f04f2aaad867332c22db1caa511a/compiler/rustc_borrowck/src/diagnostics/mod.rs:542:21: End-user description not implemented for field access on `T/#0`


thread 'rustc' (424) panicked at /rustc-dev/17584a181979f04f2aaad867332c22db1caa511a/compiler/rustc_borrowck/src/diagnostics/mod.rs:542:21:
Box<dyn Any>
stack backtrace:
   0:     0x7794b3a129bb - <<std[82445d07c273dcb0]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[e6c15338c37dc114]::fmt::Display>::fmt
   1:     0x7794b4021748 - core[e6c15338c37dc114]::fmt::write
   2:     0x7794b3a29c86 - <std[82445d07c273dcb0]::sys::stdio::unix::Stderr as std[82445d07c273dcb0]::io::Write>::write_fmt
   3:     0x7794b39e8cb8 - std[82445d07c273dcb0]::panicking::default_hook::{closure#0}
   4:     0x7794b3a06023 - std[82445d07c273dcb0]::panicking::default_hook
   5:     0x7794b29e16ec - std[82445d07c273dcb0]::panicking::update_hook::<alloc[8aa01d6867f017eb]::boxed::Box<rustc_driver_impl[b53ec1d8796d19d7]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7794b3a06302 - std[82445d07c273dcb0]::panicking::panic_with_hook
   7:     0x7794b2a10f31 - std[82445d07c273dcb0]::panicking::begin_panic::<rustc_errors[b0ae1706c7483024]::ExplicitBug>::{closure#0}
   8:     0x7794b2a09aa6 - std[82445d07c273dcb0]::sys::backtrace::__rust_end_short_backtrace::<std[82445d07c273dcb0]::panicking::begin_panic<rustc_errors[b0ae1706c7483024]::ExplicitBug>::{closure#0}, !>
   9:     0x7794b2a078a8 - std[82445d07c273dcb0]::panicking::begin_panic::<rustc_errors[b0ae1706c7483024]::ExplicitBug>
  10:     0x7794b2a1c481 - <rustc_errors[b0ae1706c7483024]::diagnostic::BugAbort as rustc_errors[b0ae1706c7483024]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7794b3015229 - rustc_middle[f0f16db128b18e3d]::util::bug::opt_span_bug_fmt::<rustc_span[34530b50b0c8ebdf]::span_encoding::Span>::{closure#0}
  12:     0x7794b30153b2 - rustc_middle[f0f16db128b18e3d]::ty::context::tls::with_opt::<rustc_middle[f0f16db128b18e3d]::util::bug::opt_span_bug_fmt<rustc_span[34530b50b0c8ebdf]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7794b300605b - rustc_middle[f0f16db128b18e3d]::ty::context::tls::with_context_opt::<rustc_middle[f0f16db128b18e3d]::ty::context::tls::with_opt<rustc_middle[f0f16db128b18e3d]::util::bug::opt_span_bug_fmt<rustc_span[34530b50b0c8ebdf]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7794b012dd14 - rustc_middle[f0f16db128b18e3d]::util::bug::bug_fmt
  15:     0x7794b2697981 - <rustc_borrowck[4ef2d2a4e4480fad]::MirBorrowckCtxt>::describe_field_from_ty
  16:     0x7794b2698498 - <rustc_borrowck[4ef2d2a4e4480fad]::MirBorrowckCtxt>::describe_place_with_options
  17:     0x7794b26ba15d - <rustc_borrowck[4ef2d2a4e4480fad]::MirBorrowckCtxt>::report
  18:     0x7794b09118a6 - rustc_borrowck[4ef2d2a4e4480fad]::borrowck_check_region_constraints
  19:     0x7794b5148f58 - <rustc_borrowck[4ef2d2a4e4480fad]::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
  20:     0x7794b514386f - rustc_borrowck[4ef2d2a4e4480fad]::mir_borrowck
  21:     0x7794b51436a5 - rustc_query_impl[9f92680ed44839a1]::query_impl::mir_borrowck::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7794b415f1a6 - rustc_query_impl[9f92680ed44839a1]::execution::try_execute_query::<rustc_data_structures[89e4a6a540cc2895]::vec_cache::VecCache<rustc_span[34530b50b0c8ebdf]::def_id::LocalDefId, rustc_middle[f0f16db128b18e3d]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[f0f16db128b18e3d]::dep_graph::graph::DepNodeIndex>, false>
  23:     0x7794b415e843 - rustc_query_impl[9f92680ed44839a1]::query_impl::mir_borrowck::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7794b4f2c426 - <rustc_middle[f0f16db128b18e3d]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[36da19b6867c2d6b]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  25:     0x7794b4f2b882 - rustc_interface[36da19b6867c2d6b]::passes::analysis
  26:     0x7794b51c4949 - rustc_query_impl[9f92680ed44839a1]::execution::try_execute_query::<rustc_middle[f0f16db128b18e3d]::query::caches::SingleCache<rustc_middle[f0f16db128b18e3d]::query::erase::ErasedData<[u8; 0usize]>>, false>
  27:     0x7794b51c45a9 - rustc_query_impl[9f92680ed44839a1]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  28:     0x7794b518a650 - rustc_interface[36da19b6867c2d6b]::interface::run_compiler::<(), rustc_driver_impl[b53ec1d8796d19d7]::run_compiler::{closure#0}>::{closure#1}
  29:     0x7794b51aa2be - std[82445d07c273dcb0]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[36da19b6867c2d6b]::util::run_in_thread_with_globals<rustc_interface[36da19b6867c2d6b]::util::run_in_thread_pool_with_globals<rustc_interface[36da19b6867c2d6b]::interface::run_compiler<(), rustc_driver_impl[b53ec1d8796d19d7]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  30:     0x7794b51aab60 - <std[82445d07c273dcb0]::thread::lifecycle::spawn_unchecked<rustc_interface[36da19b6867c2d6b]::util::run_in_thread_with_globals<rustc_interface[36da19b6867c2d6b]::util::run_in_thread_pool_with_globals<rustc_interface[36da19b6867c2d6b]::interface::run_compiler<(), rustc_driver_impl[b53ec1d8796d19d7]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[e6c15338c37dc114]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  31:     0x7794b51ab9ec - <std[82445d07c273dcb0]::sys::thread::unix::Thread>::new::thread_start
  32:     0x7794aec8aaa4 - <unknown>
  33:     0x7794aed17a64 - clone
  34:                0x0 - <unknown>

note: using internal features is not supported and expected to cause internal compiler errors when used incorrectly

note: please attach the file at `/playground/rustc-ice-2026-04-15T15_02_43-422.txt` to your bug report

note: rustc 1.97.0-nightly (17584a181 2026-04-13) 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_borrowck] borrow-checking `<impl at src/lib.rs:10:1: 10:38>::drop`
#1 [analysis] running analysis passes on crate `playground`
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-borrow-checkerArea: The borrow checkerA-boxArea: Our favorite opsem complicationC-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.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions