Skip to content

Commit c8663ee

Browse files
committed
Introduce CoerceShared lang item and trait
1 parent f3fd3ef commit c8663ee

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

compiler/rustc_hir/src/lang_items.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ language_item_table! {
441441

442442
// Reborrowing related lang-items
443443
Reborrow, sym::reborrow, reborrow, Target::Trait, GenericRequirement::Exact(0);
444+
CoerceShared, sym::coerce_shared, coerce_shared, Target::Trait, GenericRequirement::Exact(0);
444445
}
445446

446447
/// The requirement imposed on the generics of a lang item

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ symbols! {
679679
cmpxchg16b_target_feature,
680680
cmse_nonsecure_entry,
681681
coerce_pointee_validated,
682+
coerce_shared,
682683
coerce_unsized,
683684
cold,
684685
cold_path,

library/core/src/marker.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,3 +1372,12 @@ pub trait CoercePointeeValidated {
13721372
pub trait Reborrow {
13731373
// Empty.
13741374
}
1375+
1376+
/// Allows reborrowable value to be reborrowed as shared, creating a copy of
1377+
/// that disables the source for writes for the lifetime of the copy.
1378+
#[lang = "coerce_shared"]
1379+
#[unstable(feature = "reborrow", issue = "145612")]
1380+
pub trait CoerceShared: Reborrow {
1381+
/// The type of this value when reborrowed as shared.
1382+
type Target: Copy;
1383+
}

0 commit comments

Comments
 (0)