Introduce CoerceShared lang item and trait
diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs
index 67d2f15..889b16a 100644
--- a/compiler/rustc_hir/src/lang_items.rs
+++ b/compiler/rustc_hir/src/lang_items.rs
@@ -441,6 +441,7 @@ pub fn extract(attrs: &[impl AttributeExt]) -> Option<(Symbol, Span)> {
// Reborrowing related lang-items
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
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index cdb0b5b..882abf7 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -679,6 +679,7 @@
cmpxchg16b_target_feature,
cmse_nonsecure_entry,
coerce_pointee_validated,
+ coerce_shared,
coerce_unsized,
cold,
cold_path,
diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs
index d03d7a4..8541a5b 100644
--- a/library/core/src/marker.rs
+++ b/library/core/src/marker.rs
@@ -1372,3 +1372,12 @@ pub trait CoercePointeeValidated {
pub trait Reborrow {
// 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;
+}