Skip to content

Commit 5af3591

Browse files
committed
Introduce Reborrow lang item and trait
1 parent 719880d commit 5af3591

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

compiler/rustc_feature/src/unstable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ declare_features! (
614614
(unstable, proc_macro_hygiene, "1.30.0", Some(54727)),
615615
/// Allows the use of raw-dylibs on ELF platforms
616616
(incomplete, raw_dylib_elf, "1.87.0", Some(135694)),
617-
(unstable, reborrow, "CURRENT_RUSTC_VERSION", None),
617+
(unstable, reborrow, "CURRENT_RUSTC_VERSION", Some(145612)),
618618
/// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024.
619619
(incomplete, ref_pat_eat_one_layer_2024, "1.79.0", Some(123076)),
620620
/// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024—structural variant

compiler/rustc_hir/src/lang_items.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ language_item_table! {
437437
DefaultTrait1, sym::default_trait1, default_trait1_trait, Target::Trait, GenericRequirement::None;
438438

439439
ContractCheckEnsures, sym::contract_check_ensures, contract_check_ensures_fn, Target::Fn, GenericRequirement::None;
440+
441+
// Reborrowing related lang-items
442+
Reborrow, sym::reborrow, reborrow, Target::Trait, GenericRequirement::Exact(0);
440443
}
441444

442445
/// 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
@@ -1754,6 +1754,7 @@ symbols! {
17541754
readonly,
17551755
realloc,
17561756
reason,
1757+
reborrow,
17571758
receiver,
17581759
receiver_target,
17591760
recursion_limit,

library/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
#![feature(no_core)]
173173
#![feature(optimize_attribute)]
174174
#![feature(prelude_import)]
175+
#![feature(reborrow)]
175176
#![feature(repr_simd)]
176177
#![feature(rustc_allow_const_fn_unstable)]
177178
#![feature(rustc_attrs)]

library/core/src/marker.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,3 +1365,11 @@ pub macro CoercePointee($item:item) {
13651365
pub trait CoercePointeeValidated {
13661366
/* compiler built-in */
13671367
}
1368+
1369+
/// Allows value to be reborrowed as exclusive, creating a copy of the value
1370+
/// that disables the source for reads and writes for the lifetime of the copy.
1371+
#[lang = "reborrow"]
1372+
#[unstable(feature = "reborrow", issue = "145612")]
1373+
pub trait Reborrow {
1374+
// Empty.
1375+
}

0 commit comments

Comments
 (0)