rust-lang / rust-lang/rust

[ICE]: reborrow `region constraints already solved` missing lifetime

Open
#160,650 0 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

if we take coerce-shared-field-region-obligation.rs and remove a lifetime, we crash

Code
#![feature(reborrow)]

use std::marker::{CoerceShared, Reborrow};

struct FieldMut<'a, T> {
    value: &'a mut T,
}

impl<'a, T> Reborrow for FieldMut<'a, T> {}

#[derive(Clone, Copy)]
struct FieldRef< /*'a, */ T> { // boom 
    value: &'a T,
}

impl<'a, T> CoerceShared<FieldRef<'a, T>> for FieldMut<'a, T> {}

struct Source<'a> {
    field: FieldMut<'a, &'a ()>,
}

impl Reborrow for Source<'_> {}

#[derive(Clone, Copy)]
struct Target<'a> {
    field: FieldRef<'a, &'static ()>,
}

impl<'a> CoerceShared<Target<'a>> for Source<'a> {}
//~^ ERROR mismatched types

fn main() {}

Meta

rustc --version --verbose:

rustc 1.99.0-nightly (84b36a78a 2026-08-06)
binary: rustc
commit-hash: 84b36a78a28a63f134171c670be1932ffa2485f8
commit-date: 2026-08-06
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 23.1.0
Error output
<output>
Backtrace

error: implementing `CoerceShared` requires that a single lifetime parameter is passed between source and target
 --> code.rs:5:1
  |
5 | impl CoerceShared for FieldMut {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


thread 'rustc' (2628218) panicked at /rustc-dev/84b36a78a28a63f134171c670be1932ffa2485f8/compiler/rustc_infer/src/infer/outlives/mod.rs:60:52:
regions already resolved
stack backtrace:
   0:     0x7f41ff8f2956 - <<std[6cb999a3dbb652d9]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[cdb7ffe4be53d62]::fmt::Display>::fmt
   1:     0x7f420001118f - core[cdb7ffe4be53d62]::fmt::write
   2:     0x7f41ff90787c - <std[6cb999a3dbb652d9]::sys::stdio::unix::Stderr as core[cdb7ffe4be53d62]::io::write::Write>::write_fmt
   3:     0x7f41ff8c573a - std[6cb999a3dbb652d9]::panicking::default_hook::{closure#0}
   4:     0x7f41ff8e64d3 - std[6cb999a3dbb652d9]::panicking::default_hook
   5:     0x7f41fe841caa - std[6cb999a3dbb652d9]::panicking::update_hook::<alloc[1d52d4102791da9a]::boxed::Box<rustc_driver_impl[3bc4d727b6aa2dc4]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f41ff8e6972 - std[6cb999a3dbb652d9]::panicking::panic_with_hook
   7:     0x7f41ff8c57f2 - std[6cb999a3dbb652d9]::panicking::panic_handler::{closure#0}
   8:     0x7f41ff8bd469 - std[6cb999a3dbb652d9]::sys::backtrace::__rust_end_short_backtrace::<std[6cb999a3dbb652d9]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f41ff8c71cd - __rustc[8f1b7a2c2a45eb1c]::rust_begin_unwind
  10:     0x7f41fc54c44c - core[cdb7ffe4be53d62]::panicking::panic_fmt
  11:     0x7f41fc790484 - core[cdb7ffe4be53d62]::option::expect_failed
  12:     0x7f41fd3f039c - <rustc_infer[6d122beaa720e606]::infer::InferCtxt>::resolve_regions_with_outlives_env
  13:     0x7f420142759d - <rustc_infer[6d122beaa720e606]::infer::InferCtxt as rustc_trait_selection[5318fcdf8a4fcd26]::regions::InferCtxtRegionExt>::resolve_regions::<[rustc_middle[72de90f4b57d7b8b]::ty::Ty; 0usize]>
  14:     0x7f4201427128 - <rustc_trait_selection[5318fcdf8a4fcd26]::traits::engine::ObligationCtxt<rustc_trait_selection[5318fcdf8a4fcd26]::traits::FulfillmentError>>::resolve_regions_and_report_errors::<[rustc_middle[72de90f4b57d7b8b]::ty::Ty; 0usize]>
  15:     0x7f41fea1bb60 - rustc_hir_analysis[18be3156a7e28758]::coherence::builtin::coerce_shared::validate_field_tys_satisfy_coerce_shared_relation
  16:     0x7f41fea1ab7f - rustc_hir_analysis[18be3156a7e28758]::coherence::builtin::coerce_shared::validate_coerce_shared_fields
  17:     0x7f420099cf44 - rustc_hir_analysis[18be3156a7e28758]::coherence::builtin::check_trait
  18:     0x7f4200c12ef0 - rustc_hir_analysis[18be3156a7e28758]::coherence::coherent_trait
  19:     0x7f4200c119b3 - rustc_query_impl[528f4f3081ff05f8]::query_impl::coherent_trait::invoke_provider_fn::__rust_begin_short_backtrace
  20:     0x7f42005351c5 - rustc_query_impl[528f4f3081ff05f8]::execution::try_execute_query::<rustc_middle[72de90f4b57d7b8b]::query::caches::DefIdCache<rustc_middle[72de90f4b57d7b8b]::query::erase::ErasedData<[u8; 1usize]>>, false>
  21:     0x7f42005340ce - rustc_query_impl[528f4f3081ff05f8]::query_impl::coherent_trait::execute_query_non_incr::__rust_end_short_backtrace
  22:     0x7f4200d61811 - rustc_hir_analysis[18be3156a7e28758]::check::check::check_item_type
  23:     0x7f4200d5926e - rustc_hir_analysis[18be3156a7e28758]::check::wfcheck::check_well_formed
  24:     0x7f4200d5924f - rustc_query_impl[528f4f3081ff05f8]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  25:     0x7f4200d588bd - rustc_query_impl[528f4f3081ff05f8]::execution::try_execute_query::<rustc_data_structures[1c35ab8e0d4fbb02]::vec_cache::VecCache<rustc_span[78ea2eb5514a41c4]::def_id::LocalDefId, rustc_middle[72de90f4b57d7b8b]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[72de90f4b57d7b8b]::dep_graph::graph::DepNodeIndex>, false>
  26:     0x7f4200d58647 - rustc_query_impl[528f4f3081ff05f8]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7f4200d5585c - rustc_hir_analysis[18be3156a7e28758]::check::wfcheck::check_type_wf
  28:     0x7f4200d55757 - rustc_query_impl[528f4f3081ff05f8]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  29:     0x7f42012481c9 - rustc_query_impl[528f4f3081ff05f8]::execution::try_execute_query::<rustc_middle[72de90f4b57d7b8b]::query::caches::SingleCache<rustc_middle[72de90f4b57d7b8b]::query::erase::ErasedData<[u8; 1usize]>>, false>
  30:     0x7f4201247fa9 - rustc_query_impl[528f4f3081ff05f8]::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  31:     0x7f420085e0e4 - rustc_hir_analysis[18be3156a7e28758]::check_crate
  32:     0x7f42005883ba - rustc_interface[1b7d442e2e02cb08]::passes::analysis
  33:     0x7f420124668a - rustc_query_impl[528f4f3081ff05f8]::execution::try_execute_query::<rustc_middle[72de90f4b57d7b8b]::query::caches::SingleCache<rustc_middle[72de90f4b57d7b8b]::query::erase::ErasedData<[u8; 0usize]>>, false>
  34:     0x7f42012462e9 - rustc_query_impl[528f4f3081ff05f8]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  35:     0x7f42012f4777 - rustc_interface[1b7d442e2e02cb08]::interface::run_compiler::<(), rustc_driver_impl[3bc4d727b6aa2dc4]::run_compiler::{closure#0}>::{closure#2}
  36:     0x7f420131b424 - std[6cb999a3dbb652d9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1b7d442e2e02cb08]::util::run_in_thread_with_globals<rustc_interface[1b7d442e2e02cb08]::util::run_in_thread_pool_with_globals<rustc_interface[1b7d442e2e02cb08]::interface::run_compiler<(), rustc_driver_impl[3bc4d727b6aa2dc4]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  37:     0x7f420131b1ed - <std[6cb999a3dbb652d9]::thread::lifecycle::spawn_unchecked<rustc_interface[1b7d442e2e02cb08]::util::run_in_thread_with_globals<rustc_interface[1b7d442e2e02cb08]::util::run_in_thread_pool_with_globals<rustc_interface[1b7d442e2e02cb08]::interface::run_compiler<(), rustc_driver_impl[3bc4d727b6aa2dc4]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[cdb7ffe4be53d62]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7f42013237c0 - <std[6cb999a3dbb652d9]::sys::thread::unix::Thread>::new::thread_start
  39:     0x7f41fa697739 - <unknown>
  40:     0x7f41fa71bedc - <unknown>
  41:                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/matthias/vcs/github/CRED/rustc-ice-2026-08-06T17_42_16-2628216.txt` to your bug report

note: rustc 1.99.0-nightly (84b36a78a 2026-08-06) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [coherent_trait] coherence checking all impls of trait `core::marker::CoerceShared`
#1 [check_well_formed] checking that `<impl at code.rs:5:1: 5:31>` is well-formed
#2 [check_type_wf] checking that types are well-formed
#3 [analysis] running analysis passes on crate `code`
end of query stack
error: aborting due to 8 previous errors

Some errors have detailed explanations: E0107, E0392, E0601.
For more information about an error, try `rustc --explain E0107`.

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 minimal code.rs reproducer with the reported nightly toolchain. Read rustc_hir_analysis coherence/builtin/coerce_shared.rs and rustc_infer/src/infer/outlives/mod.rs around resolve_regions_with_outlives_env, then trace the CoerceShared validation path. Done means the missing lifetime produces diagnostics without an internal compiler panic.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.