Skip to content

[ICE]: called Result::unwrap() on an Err value: NoSolution #156309

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024


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

struct CustomMarker<'a>(PhantomData<&'a ()>);


struct CustomMarkerRef<'a>(PhantomData<(Debug, Clone, Copy)>);
impl<'a> CoerceShared<CustomMarkerRef<'a>> for CustomMarker<'a> {}


fn method<'a>(_a: CustomMarkerRef<'a>) -> 'a () {
    &()
}

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

original:

//@ run-pass

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

struct CustomMarker<'a>(PhantomData<&'a ()>);
impl<'a> Reborrow for CustomMarker<'CoerceShared> {}
#[derive(Debug, Clone, Copy)]
struct CustomMarkerRef<'a>(PhantomData<(Debug, Clone, Copy)>);
impl<'a> CoerceShared<CustomMarkerRef<'a>> for CustomMarker<'a> {}


fn method<'a>(_a: CustomMarkerRef<'a>) -> 'a () {
    &()
}

fn main() {
    let a = CustomMarker(PhantomData);
    let b = method(a);
    let c = method(a);
    let _ = (b, c);
}

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:

borrowed_ty,
ty::Variance::Covariant,
dest_ty,
location.to_locations(),
category,
)
.unwrap();
}
}
} else {
// Exclusive reborrow
self.relate_types(
borrowed_ty,

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024

Program output

error: expected type, found lifetime
  --> /tmp/icemaker_global_tempdir.mCrvX9yCDWyy/rustc_testrunner_tmpdir_reporting.fUKak9Z01wCD/mvce.rs:13:43
   |
13 | fn method<'a>(_a: CustomMarkerRef<'a>) -> 'a () {
   |                                           ^^ expected type
   |
help: you might have meant to write a reference type here
   |
13 | fn method<'a>(_a: CustomMarkerRef<'a>) -> &'a () {
   |                                           +

error[E0573]: expected type, found derive macro `Debug`
 --> /tmp/icemaker_global_tempdir.mCrvX9yCDWyy/rustc_testrunner_tmpdir_reporting.fUKak9Z01wCD/mvce.rs:9:41
  |
9 | struct CustomMarkerRef<'a>(PhantomData<(Debug, Clone, Copy)>);
  |                                         ^^^^^ not a type
  |
help: consider importing this trait instead
  |
4 + use std::fmt::Debug;
  |

warning: unused import: `Reborrow`
 --> /tmp/icemaker_global_tempdir.mCrvX9yCDWyy/rustc_testrunner_tmpdir_reporting.fUKak9Z01wCD/mvce.rs:4:46
  |
4 | use std::marker::{CoerceShared, PhantomData, Reborrow};
  |                                              ^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default

error[E0782]: expected a type, found a trait
 --> /tmp/icemaker_global_tempdir.mCrvX9yCDWyy/rustc_testrunner_tmpdir_reporting.fUKak9Z01wCD/mvce.rs:9:48
  |
9 | struct CustomMarkerRef<'a>(PhantomData<(Debug, Clone, Copy)>);
  |                                                ^^^^^
  |
help: you can add the `dyn` keyword if you want a trait object
  |
9 | struct CustomMarkerRef<'a>(PhantomData<(Debug, dyn Clone, Copy)>);
  |                                                +++

error[E0782]: expected a type, found a trait
 --> /tmp/icemaker_global_tempdir.mCrvX9yCDWyy/rustc_testrunner_tmpdir_reporting.fUKak9Z01wCD/mvce.rs:9:55
  |
9 | struct CustomMarkerRef<'a>(PhantomData<(Debug, Clone, Copy)>);
  |                                                       ^^^^
  |
help: you can add the `dyn` keyword if you want a trait object
  |
9 | struct CustomMarkerRef<'a>(PhantomData<(Debug, Clone, dyn Copy)>);
  |                                                       +++

error[E0277]: the trait bound `CustomMarkerRef<'a>: Copy` is not satisfied
    --> /tmp/icemaker_global_tempdir.mCrvX9yCDWyy/rustc_testrunner_tmpdir_reporting.fUKak9Z01wCD/mvce.rs:10:10
     |
  10 | impl<'a> CoerceShared<CustomMarkerRef<'a>> for CustomMarker<'a> {}
     |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `CustomMarkerRef<'a>`
     |
note: required by a bound in `CoerceShared`
    --> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/marker.rs:1363:32
     |
1363 | pub trait CoerceShared<Target: Copy>: Reborrow {
     |                                ^^^^ required by this bound in `CoerceShared`
help: consider annotating `CustomMarkerRef<'a>` with `#[derive(Copy)]`
     |
   9 + #[derive(Copy)]
  10 | struct CustomMarkerRef<'a>(PhantomData<(Debug, Clone, Copy)>);
     |

error[E0277]: the trait bound `CustomMarker<'a>: Reborrow` is not satisfied
    --> /tmp/icemaker_global_tempdir.mCrvX9yCDWyy/rustc_testrunner_tmpdir_reporting.fUKak9Z01wCD/mvce.rs:10:48
     |
  10 | impl<'a> CoerceShared<CustomMarkerRef<'a>> for CustomMarker<'a> {}
     |                                                ^^^^^^^^^^^^^^^^ unsatisfied trait bound
     |
help: the nightly-only, unstable trait `Reborrow` is not implemented for `CustomMarker<'a>`
    --> /tmp/icemaker_global_tempdir.mCrvX9yCDWyy/rustc_testrunner_tmpdir_reporting.fUKak9Z01wCD/mvce.rs:6:1
     |
   6 | struct CustomMarker<'a>(PhantomData<&'a ()>);
     | ^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `CoerceShared`
    --> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/marker.rs:1363:39
     |
1363 | pub trait CoerceShared<Target: Copy>: Reborrow {
     |                                       ^^^^^^^^ required by this bound in `CoerceShared`


thread 'rustc' (4098030) panicked at /rustc-dev/3e353d7353b0cd6fa4eefd5c882457cc2708184c/compiler/rustc_borrowck/src/type_check/mod.rs:2529:22:
called `Result::unwrap()` on an `Err` value: NoSolution
stack backtrace:
   0:     0x7fcc4f074239 - <<std[db65628f2330fd11]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[b3c617e8375f9bd0]::fmt::Display>::fmt
   1:     0x7fcc4f61b788 - core[b3c617e8375f9bd0]::fmt::write
   2:     0x7fcc4f08ac66 - <std[db65628f2330fd11]::sys::stdio::unix::Stderr as std[db65628f2330fd11]::io::Write>::write_fmt
   3:     0x7fcc4f04a2de - std[db65628f2330fd11]::panicking::default_hook::{closure#0}
   4:     0x7fcc4f0678f3 - std[db65628f2330fd11]::panicking::default_hook
   5:     0x7fcc4df544d1 - std[db65628f2330fd11]::panicking::update_hook::<alloc[b10a1c065189447]::boxed::Box<rustc_driver_impl[1f444ccaa450aabc]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fcc4f067bd2 - std[db65628f2330fd11]::panicking::panic_with_hook
   7:     0x7fcc4f04a3a2 - std[db65628f2330fd11]::panicking::panic_handler::{closure#0}
   8:     0x7fcc4f0410b9 - std[db65628f2330fd11]::sys::backtrace::__rust_end_short_backtrace::<std[db65628f2330fd11]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fcc4f04be0d - __rustc[87b1f669d989e0ab]::rust_begin_unwind
  10:     0x7fcc4c12c50c - core[b3c617e8375f9bd0]::panicking::panic_fmt
  11:     0x7fcc4b799682 - core[b3c617e8375f9bd0]::result::unwrap_failed
  12:     0x7fcc504c23c7 - <rustc_borrowck[543291a75b63dc2a]::type_check::TypeChecker as rustc_middle[4a2cff3451d2bad5]::mir::visit::Visitor>::visit_body
  13:     0x7fcc5047286c - rustc_borrowck[543291a75b63dc2a]::type_check::type_check
  14:     0x7fcc500d7176 - <rustc_borrowck[543291a75b63dc2a]::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
  15:     0x7fcc500d2b1b - rustc_borrowck[543291a75b63dc2a]::mir_borrowck
  16:     0x7fcc500d28e9 - rustc_query_impl[3b9ecabc2cca1a8f]::query_impl::mir_borrowck::invoke_provider_fn::__rust_begin_short_backtrace
  17:     0x7fcc4f76d6a6 - 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>
  18:     0x7fcc4f76fdc3 - rustc_query_impl[3b9ecabc2cca1a8f]::query_impl::mir_borrowck::execute_query_non_incr::__rust_end_short_backtrace
  19:     0x7fcc4f76ff94 - <rustc_middle[4a2cff3451d2bad5]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[232b63f46aa35c0e]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  20:     0x7fcc4f76f276 - rustc_interface[232b63f46aa35c0e]::passes::analysis
  21:     0x7fcc507822c9 - rustc_query_impl[3b9ecabc2cca1a8f]::execution::try_execute_query::<rustc_middle[4a2cff3451d2bad5]::query::caches::SingleCache<rustc_middle[4a2cff3451d2bad5]::query::erase::ErasedData<[u8; 0usize]>>, false>
  22:     0x7fcc50781f33 - rustc_query_impl[3b9ecabc2cca1a8f]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  23:     0x7fcc507c765b - rustc_interface[232b63f46aa35c0e]::interface::run_compiler::<(), rustc_driver_impl[1f444ccaa450aabc]::run_compiler::{closure#0}>::{closure#1}
  24:     0x7fcc50775c3e - 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}, ()>
  25:     0x7fcc5077632d - <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}
  26:     0x7fcc5077712c - <std[db65628f2330fd11]::sys::thread::unix::Thread>::new::thread_start
  27:     0x7fcc4a2a597a - <unknown>
  28:     0x7fcc4a3292bc - <unknown>
  29:                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: rustc 1.97.0-nightly (3e353d735 2026-05-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

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 6 previous errors; 1 warning emitted

Some errors have detailed explanations: E0277, E0573, E0782.
For more information about an error, try `rustc --explain E0277`.

@rustbot label +F-reborrow

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-reborrow`#![feature(reborrow)]`; see #145612I-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