rust-lang / rust-lang/rust

[ICE]: `hir-typeck passed but Reborrow does not have a lifetime argument`

Open
#156,308 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-reborrow I-ICE needs-triage T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

#![feature(reborrow)]
use std::marker::{PhantomData, Reborrow};

struct CustomMarker<'a>(PhantomData<&'a ()>);
impl<'a> Reborrow for PhantomData<'a> {}

fn main() {
    let mut a = CustomMarker(PhantomData);
}

original:

//@ run-pass

#![feature(reborrow)]
use std::marker::{Reborrow, PhantomData};

struct CustomMarker<'a>(PhantomData<&'a ()>);
impl<'a> Reborrow for PhantomData<'a> {}

impl<'a> std::ops::Deref for CustomMarker<'a> {
    type Target = CustomMarker<'a>;
    fn deref(&self) -> &Self::Target {
        self
    }
}

impl<'a> std::ops::DerefMut for CustomMarker<'a> {
    fn deref_mut(&mut self) -> &mut Self::Target {
        self
    }
}

fn main() {
    let mut a = CustomMarker(PhantomData);

    *a = CustomMarker(PhantomData);
}

Version information

rustc 1.97.0-nightly (3e353d735 2026-05-08)
binary: rustc
commit-hash: 3e353d7353b0cd6fa4eefd5c882457cc2708184c
commit-date: 2026-05-08
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.4

Possibly related line of code:
https://github.com/rust-lang/rust/blob/3e353d7353b0cd6fa4eefd5c882457cc2708184c/compiler/rustc_borrowck/src/borrow_set.rs#L307-L319

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied
   --> /tmp/icemaker_global_tempdir.HFhzK8XG8tRD/rustc_testrunner_tmpdir_reporting.ZH8KibTRlyKp/mvce.rs:5:23
    |
  5 | impl<'a> Reborrow for PhantomData<'a> {}
    |                       ^^^^^^^^^^^---- help: remove the unnecessary generics
    |                       |
    |                       expected 0 lifetime arguments
    |
note: struct defined here, with 0 lifetime parameters
   --> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/marker.rs:811:12
    |
811 | pub struct PhantomData<T: PointeeSized>;
    |            ^^^^^^^^^^^

error[E0107]: struct takes 1 generic argument but 0 generic arguments were supplied
   --> /tmp/icemaker_global_tempdir.HFhzK8XG8tRD/rustc_testrunner_tmpdir_reporting.ZH8KibTRlyKp/mvce.rs:5:23
    |
  5 | impl<'a> Reborrow for PhantomData<'a> {}
    |                       ^^^^^^^^^^^ expected 1 generic argument
    |
note: struct defined here, with 1 generic parameter: `T`
   --> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/marker.rs:811:12
    |
811 | pub struct PhantomData<T: PointeeSized>;
    |            ^^^^^^^^^^^ -
help: add missing generic argument
    |
  5 | impl<'a> Reborrow for PhantomData<'a, T> {}
    |                                     +++

error: implementing `Reborrow` does not allow multiple lifetimes or fields to be coerced
 --> /tmp/icemaker_global_tempdir.HFhzK8XG8tRD/rustc_testrunner_tmpdir_reporting.ZH8KibTRlyKp/mvce.rs:5:1
  |
5 | impl<'a> Reborrow for PhantomData<'a> {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: /rustc-dev/3e353d7353b0cd6fa4eefd5c882457cc2708184c/compiler/rustc_borrowck/src/borrow_set.rs:313:17: hir-typeck passed but Reborrow does not have a lifetime argument


thread 'rustc' (4044579) panicked at /rustc-dev/3e353d7353b0cd6fa4eefd5c882457cc2708184c/compiler/rustc_borrowck/src/borrow_set.rs:313:17:
Box<dyn Any>
stack backtrace:
   0:     0x7fba3d874239 - <<std[db65628f2330fd11]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[b3c617e8375f9bd0]::fmt::Display>::fmt
   1:     0x7fba3de1b788 - core[b3c617e8375f9bd0]::fmt::write
   2:     0x7fba3d88ac66 - <std[db65628f2330fd11]::sys::stdio::unix::Stderr as std[db65628f2330fd11]::io::Write>::write_fmt
   3:     0x7fba3d84a2de - std[db65628f2330fd11]::panicking::default_hook::{closure#0}
   4:     0x7fba3d8678f3 - std[db65628f2330fd11]::panicking::default_hook
   5:     0x7fba3c7544d1 - std[db65628f2330fd11]::panicking::update_hook::<alloc[b10a1c065189447]::boxed::Box<rustc_driver_impl[1f444ccaa450aabc]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fba3d867bd2 - std[db65628f2330fd11]::panicking::panic_with_hook
   7:     0x7fba3c781f51 - std[db65628f2330fd11]::panicking::begin_panic::<rustc_errors[4e25407aa9dfcb98]::ExplicitBug>::{closure#0}
   8:     0x7fba3c77af46 - std[db65628f2330fd11]::sys::backtrace::__rust_end_short_backtrace::<std[db65628f2330fd11]::panicking::begin_panic<rustc_errors[4e25407aa9dfcb98]::ExplicitBug>::{closure#0}, !>
   9:     0x7fba3c77acab - std[db65628f2330fd11]::panicking::begin_panic::<rustc_errors[4e25407aa9dfcb98]::ExplicitBug>
  10:     0x7fba3c78d431 - <rustc_errors[4e25407aa9dfcb98]::diagnostic::BugAbort as rustc_errors[4e25407aa9dfcb98]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fba3cd9cf69 - rustc_middle[4a2cff3451d2bad5]::util::bug::opt_span_bug_fmt::<rustc_span[749aae40fdac821d]::span_encoding::Span>::{closure#0}
  12:     0x7fba3cd9d0d2 - rustc_middle[4a2cff3451d2bad5]::ty::context::tls::with_opt::<rustc_middle[4a2cff3451d2bad5]::util::bug::opt_span_bug_fmt<rustc_span[749aae40fdac821d]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7fba3cd8b82b - rustc_middle[4a2cff3451d2bad5]::ty::context::tls::with_context_opt::<rustc_middle[4a2cff3451d2bad5]::ty::context::tls::with_opt<rustc_middle[4a2cff3451d2bad5]::util::bug::opt_span_bug_fmt<rustc_span[749aae40fdac821d]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7fba3a731134 - rustc_middle[4a2cff3451d2bad5]::util::bug::bug_fmt
  15:     0x7fba3b287486 - <rustc_borrowck[543291a75b63dc2a]::borrow_set::BorrowSet>::build
  16:     0x7fba3e8d6e5b - <rustc_borrowck[543291a75b63dc2a]::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
  17:     0x7fba3e8d2b1b - rustc_borrowck[543291a75b63dc2a]::mir_borrowck
  18:     0x7fba3e8d28e9 - rustc_query_impl[3b9ecabc2cca1a8f]::query_impl::mir_borrowck::invoke_provider_fn::__rust_begin_short_backtrace
  19:     0x7fba3df6d6a6 - rustc_query_impl[3b9ecabc2cca1a8f]::execution::try_execute_query::<rustc_data_structures[4a3bb46d707d6722]::vec_cache::VecCache<rustc_span[749aae40fdac821d]::def_id::LocalDefId, rustc_middle[4a2cff3451d2bad5]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[4a2cff3451d2bad5]::dep_graph::graph::DepNodeIndex>, false>
  20:     0x7fba3df6fdc3 - rustc_query_impl[3b9ecabc2cca1a8f]::query_impl::mir_borrowck::execute_query_non_incr::__rust_end_short_backtrace
  21:     0x7fba3df6ff94 - <rustc_middle[4a2cff3451d2bad5]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[232b63f46aa35c0e]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  22:     0x7fba3df6f276 - rustc_interface[232b63f46aa35c0e]::passes::analysis
  23:     0x7fba3ef822c9 - rustc_query_impl[3b9ecabc2cca1a8f]::execution::try_execute_query::<rustc_middle[4a2cff3451d2bad5]::query::caches::SingleCache<rustc_middle[4a2cff3451d2bad5]::query::erase::ErasedData<[u8; 0usize]>>, false>
  24:     0x7fba3ef81f33 - rustc_query_impl[3b9ecabc2cca1a8f]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  25:     0x7fba3efc765b - rustc_interface[232b63f46aa35c0e]::interface::run_compiler::<(), rustc_driver_impl[1f444ccaa450aabc]::run_compiler::{closure#0}>::{closure#1}
  26:     0x7fba3ef75c3e - std[db65628f2330fd11]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[232b63f46aa35c0e]::util::run_in_thread_with_globals<rustc_interface[232b63f46aa35c0e]::util::run_in_thread_pool_with_globals<rustc_interface[232b63f46aa35c0e]::interface::run_compiler<(), rustc_driver_impl[1f444ccaa450aabc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  27:     0x7fba3ef7632d - <std[db65628f2330fd11]::thread::lifecycle::spawn_unchecked<rustc_interface[232b63f46aa35c0e]::util::run_in_thread_with_globals<rustc_interface[232b63f46aa35c0e]::util::run_in_thread_pool_with_globals<rustc_interface[232b63f46aa35c0e]::interface::run_compiler<(), rustc_driver_impl[1f444ccaa450aabc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[b3c617e8375f9bd0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:     0x7fba3ef7712c - <std[db65628f2330fd11]::sys::thread::unix::Thread>::new::thread_start
  29:     0x7fba38aa597a - <unknown>
  30:     0x7fba38b292bc - <unknown>
  31:                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.97.0-nightly (3e353d735 2026-05-08) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_borrowck] borrow-checking `main`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0107`.

@rustbot label +F-reborrow

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the reduced reproducer in the issue with the reported nightly, then inspect compiler/rustc_borrowck/src/borrow_set.rs around lines 307-319 and the mir_borrowck query for main. Confirm the ICE is replaced by appropriate diagnostics and add a regression test based on the reduced program.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.