rust-lang / rust-lang/rust

"evaluating trait selection obligation `alloc::vec::Vec<OwnedThisEnum>: core::marker::Unpin`"

Open
#145,482 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-incr-comp C-bug fixed-by-next-solver I-ICE T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

this error occurs when using the borrowme crate's attribute macro for a struct that specifically has a collection of both str and any enum which has a lifetime, and when you use borrowme::ToOwned::to_owned on the struct, but only after making any change and recompiling with cargo build etc

Code (minimal as possible)
use borrowme::borrowme;

fn main() {
	let this = ThisStruct {
		enums: vec![ThisEnum::ThisVariant("test")],
		strs: vec!["test"],
	};

	let owned = borrowme::ToOwned::to_owned(&this);
}

#[borrowme]
pub struct ThisStruct<'a> {
	pub enums: Vec<ThisEnum<'a>>,
	pub strs: Vec<&'a str>,
}

#[borrowme]
pub enum ThisEnum<'a> {
	ThisVariant(&'a str),
}
Expanded

#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2024::*;
#[macro_use]
extern crate std;
use borrowme::borrowme;
fn main() {
    let this = ThisStruct {
        enums: <[_]>::into_vec(::alloc::boxed::box_new([ThisEnum::ThisVariant("test")])),
        strs: <[_]>::into_vec(::alloc::boxed::box_new(["test"])),
    };
    let owned = borrowme::ToOwned::to_owned(&this);
}
pub struct ThisStruct<'a> {
    pub enums: Vec<ThisEnum<'a>>,
    pub strs: Vec<&'a str>,
}
pub struct OwnedThisStruct {
    pub enums: <Vec<ThisEnum<'static>> as ::borrowme::ToOwned>::Owned,
    pub strs: <Vec<&'static str> as ::borrowme::ToOwned>::Owned,
}
#[automatically_derived]
impl<'a> ::borrowme::ToOwned for ThisStruct<'a> {
    type Owned = OwnedThisStruct;
    #[inline]
    fn to_owned(&self) -> Self::Owned {
        OwnedThisStruct {
            enums: ::borrowme::ToOwned::to_owned(&self.enums),
            strs: ::borrowme::ToOwned::to_owned(&self.strs),
        }
    }
}
#[automatically_derived]
impl ::borrowme::Borrow for OwnedThisStruct {
    type Target<'this> = ThisStruct<'this>;
    #[inline]
    fn borrow(&self) -> Self::Target<'_> {
        ThisStruct {
            enums: ::borrowme::Borrow::borrow(&self.enums),
            strs: ::borrowme::Borrow::borrow(&self.strs),
        }
    }
}
pub enum ThisEnum<'a> {
    ThisVariant(&'a str),
}
pub enum OwnedThisEnum {
    ThisVariant(<&'static str as ::borrowme::ToOwned>::Owned),
}
#[automatically_derived]
impl<'a> ::borrowme::ToOwned for ThisEnum<'a> {
    type Owned = OwnedThisEnum;
    #[inline]
    fn to_owned(&self) -> Self::Owned {
        match self {
            ThisEnum::ThisVariant { 0: f0 } => {
                OwnedThisEnum::ThisVariant {
                    0: ::borrowme::ToOwned::to_owned(f0),
                }
            }
        }
    }
}
#[automatically_derived]
impl ::borrowme::Borrow for OwnedThisEnum {
    type Target<'this> = ThisEnum<'this>;
    #[inline]
    fn borrow(&self) -> Self::Target<'_> {
        match self {
            OwnedThisEnum::ThisVariant { 0: f0 } => {
                ThisEnum::ThisVariant {
                    0: ::borrowme::Borrow::borrow(f0),
                }
            }
        }
    }
}

Meta

rustc --version --verbose:

rustc 1.88.0 (6b00bc388 2025-06-23)
binary: rustc
commit-hash: 6b00bc3880198600130e1cf62b8f8a93494488cc
commit-date: 2025-06-23
host: x86_64-pc-windows-msvc
release: 1.88.0
LLVM version: 20.1.5

Note: this same exact bug occurs in 1.84.0 (rust 2021) and all of the above

Error output
error: internal compiler error: encountered incremental compilation error with evaluate_obligation(88453a1bd78827f5-d56a0ff94d36afa6)
  |
  = help: This is a known issue with the compiler. Run `cargo clean -p borrowme` or `cargo clean` to allow your project to compile
  = note: Please follow the instructions below to create a bug report with the provided information
  = note: See <https://github.com/rust-lang/rust/issues/84970> for more information


thread 'rustc' panicked at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc\compiler\rustc_query_system\src\query\plumbing.rs:739:9:
Found unstable fingerprints for evaluate_obligation(88453a1bd78827f5-d56a0ff94d36afa6): Ok(EvaluatedToOk)
Backtrace

stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library\std\src\panicking.rs:697
   1: core::panicking::panic_fmt
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library\core\src\panicking.rs:75
   2: rustc_query_system::query::plumbing::incremental_verify_ich_failed::<rustc_middle::ty::context::TyCtxt>
   3: RINvNtNtCs7IFNuxsOQZH_18rustc_query_system5query8plumbing17try_execute_queryINtCsiSfPmaTe9VX_16rustc_query_impl13DynamicConfigINtNtCsco0OWYSRcIH_21rustc_data_structures9vec_cache8VecCacheNtNtCshkOTHbTNELB_9rustc_hir6hir_id7OwnerIdINtNtNtCs5BYDmTWcnKQ_12rus
   4: RINvNtNtCs7IFNuxsOQZH_18rustc_query_system5query8plumbing17try_execute_queryINtCsiSfPmaTe9VX_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCshnIBNndEbiu_13rustc_type_ir9canonical19CanonicalQueryInputNtNtNtCs5BYDmTWcnKQ_12rustc_middle2t
   5: rustc_query_impl::plumbing::query_key_hash_verify_all
   6: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
   7: rustc_trait_selection::traits::type_known_to_meet_bound_modulo_regions
   8: rustc_ty_utils::common_traits::is_sized_raw
   9: RINvNtNtCs7IFNuxsOQZH_18rustc_query_system5query8plumbing17try_execute_queryINtCsiSfPmaTe9VX_16rustc_query_impl13DynamicConfigINtNtCsco0OWYSRcIH_21rustc_data_structures9vec_cache8VecCacheNtNtCs5K2xb0UU2Jw_10rustc_span6def_id8CrateNumINtNtNtCs5BYDmTWcnKQ_12
  10: RINvNtNtCs7IFNuxsOQZH_18rustc_query_system5query8plumbing17try_execute_queryINtCsiSfPmaTe9VX_16rustc_query_impl13DynamicConfigINtNtCsco0OWYSRcIH_21rustc_data_structures9vec_cache8VecCacheNtNtCs5K2xb0UU2Jw_10rustc_span6def_id8CrateNumINtNtNtCs5BYDmTWcnKQ_12
  11: RINvNtNtCs7IFNuxsOQZH_18rustc_query_system5query8plumbing17try_execute_queryINtCsiSfPmaTe9VX_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCs5BYDmTWcnKQ_12rustc_middle2ty20PseudoCanonicalInputNtB2w_2TyEINtNtNtB2y_5query5erase6ErasedAhj
  12: rustc_query_impl::query_system
  13: <rustc_middle::ty::Ty>::is_unpin
  14: RINvNtNtNtNtCs5cb5cxfFw7H_4core5slice4sort6stable9quicksort9quicksortmNCINvMNtCs2ocB3yIIgEv_5alloc5sliceSm11sort_by_keyRINtNtBa_6option6OptionNtNtCs5K2xb0UU2Jw_10rustc_span6symbol6SymbolENCINvXs3_NtNtCsco0OWYSRcIH_21rustc_data_structures10sorted_map9index_
  15: rustc_ty_utils::ty::impl_self_is_guaranteed_unsized
  16: rustc_ty_utils::abi::fn_abi_of_instance
  17: rustc_query_impl::plumbing::query_key_hash_verify_all
  18: RINvNtNtCs7IFNuxsOQZH_18rustc_query_system5query8plumbing17try_execute_queryINtCsiSfPmaTe9VX_16rustc_query_impl13DynamicConfigINtNtCsco0OWYSRcIH_21rustc_data_structures9vec_cache8VecCacheNtNtCs5K2xb0UU2Jw_10rustc_span6def_id8CrateNumINtNtNtCs5BYDmTWcnKQ_12
  19: RINvNtNtCs7IFNuxsOQZH_18rustc_query_system5query8plumbing17try_execute_queryINtCsiSfPmaTe9VX_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCs5BYDmTWcnKQ_12rustc_middle2ty20PseudoCanonicalInputTNtNtB2w_8instance8InstanceRINtNtB2w_4list7
  20: rustc_query_impl::plumbing::query_key_hash_verify_all
  21: <alloc::raw_vec::RawVec<rustc_codegen_ssa::mir::debuginfo::PerLocalVarDebugInfo<&rustc_codegen_llvm::llvm::ffi::Metadata>>>::grow_one
  22: <rustc_codegen_llvm::builder::GenericBuilder<rustc_codegen_llvm::context::FullCx> as rustc_codegen_ssa::traits::builder::BuilderMethods>::call
  23: <hashbrown::raw::RawTable<((&rustc_codegen_llvm::llvm::ffi::Metadata, usize), &rustc_codegen_llvm::llvm::ffi::Metadata)>>::reserve_rehash::<hashbrown::map::make_hasher<(&rustc_codegen_llvm::llvm::ffi::Metadata, usize), &rustc_codegen_llvm::llvm::ffi::Metadata, rustc_hash::FxBuildHasher>::{closure#0}>
  24: <rustc_target::callconv::FnAbi<rustc_middle::ty::Ty> as rustc_codegen_llvm::abi::FnAbiLlvmExt>::apply_attrs_callsite
  25: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  26: std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::_Construct_n<std::basic_string<char,std::char_traits<char>,std::allocator<char> > * __
  27: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  28: <rustc_interface::queries::Linker>::codegen_and_build_linker
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


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: rustc 1.88.0 (6b00bc388 2025-06-23) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `alloc::vec::Vec<OwnedThisEnum>: core::marker::Unpin`
#1 [is_unpin_raw] computing whether `alloc::vec::Vec<OwnedThisEnum>` is `Unpin`
#2 [fn_abi_of_instance] computing call ABI of `core::ptr::drop_in_place::<alloc::vec::Vec<OwnedThisEnum>> - shim(Some(alloc::vec::Vec<OwnedThisEnum>))`
end of query stack

temporary fix

adding this to Cargo.toml disables incremental building and prevents the error, but of course as drawbacks and isnt sustainable:

[profile.dev]
incremental = false

[profile.release]
incremental = false

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

Reproduce the minimal borrowme example with cargo build, including a source change followed by an incremental rebuild. Start at rustc_query_system/src/query/plumbing.rs:739 and follow the reported evaluate_obligation, is_unpin_raw, and fn_abi_of_instance query entries. Done means the example no longer triggers the incremental-compilation ICE while retaining the reported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.