Skip to content

Commit d099786

Browse files
committed
Introduce CoerceShared lang item and trait
1 parent db3fd47 commit d099786

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
@@ -440,6 +440,7 @@ language_item_table! {
440440

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

445446
/// 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
@@ -1373,3 +1373,12 @@ pub trait CoercePointeeValidated {
13731373
pub trait Reborrow {
13741374
// Empty.
13751375
}
1376+
1377+
/// Allows reborrowable value to be reborrowed as shared, creating a copy of
1378+
/// that disables the source for writes for the lifetime of the copy.
1379+
#[lang = "coerce_shared"]
1380+
#[unstable(feature = "reborrow", issue = "145612")]
1381+
pub trait CoerceShared: Reborrow {
1382+
/// The type of this value when reborrowed as shared.
1383+
type Target: Copy;
1384+
}

0 commit comments

Comments
 (0)