Introduce CoerceShared lang item and trait

This commit is contained in:
Aapo Alasuutari
2025-08-29 23:29:46 +03:00
parent f3fd3efe4f
commit c8663eec6a
3 changed files with 11 additions and 0 deletions

View File

@@ -441,6 +441,7 @@ language_item_table! {
// Reborrowing related lang-items // Reborrowing related lang-items
Reborrow, sym::reborrow, reborrow, Target::Trait, GenericRequirement::Exact(0); Reborrow, sym::reborrow, reborrow, Target::Trait, GenericRequirement::Exact(0);
CoerceShared, sym::coerce_shared, coerce_shared, Target::Trait, GenericRequirement::Exact(0);
} }
/// The requirement imposed on the generics of a lang item /// The requirement imposed on the generics of a lang item

View File

@@ -679,6 +679,7 @@ symbols! {
cmpxchg16b_target_feature, cmpxchg16b_target_feature,
cmse_nonsecure_entry, cmse_nonsecure_entry,
coerce_pointee_validated, coerce_pointee_validated,
coerce_shared,
coerce_unsized, coerce_unsized,
cold, cold,
cold_path, cold_path,

View File

@@ -1372,3 +1372,12 @@ pub trait CoercePointeeValidated {
pub trait Reborrow { pub trait Reborrow {
// Empty. // Empty.
} }
/// Allows reborrowable value to be reborrowed as shared, creating a copy of
/// that disables the source for writes for the lifetime of the copy.
#[lang = "coerce_shared"]
#[unstable(feature = "reborrow", issue = "145612")]
pub trait CoerceShared: Reborrow {
/// The type of this value when reborrowed as shared.
type Target: Copy;
}