Skip to content

Commit 38fc6be

Browse files
Rollup merge of #112662 - Vanille-N:symbol_unique, r=RalfJung
`#[lang_item]` for `core::ptr::Unique` Tree Borrows is about to introduce experimental special handling of `core::ptr::Unique` in Miri to give it a semantics. As of now there does not seem to be a clean way (i.e. other than `&format!("{adt:?}") == "std::ptr::Unique"`) to check if an `AdtDef` represents a `Unique`. r? `@RalfJung` Draft: making a lang item
2 parents 3eb8c2a + dc3e91c commit 38fc6be

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

compiler/rustc_hir/src/lang_items.rs

+2
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ language_item_table! {
260260
EhCatchTypeinfo, sym::eh_catch_typeinfo, eh_catch_typeinfo, Target::Static, GenericRequirement::None;
261261

262262
OwnedBox, sym::owned_box, owned_box, Target::Struct, GenericRequirement::Minimum(1);
263+
// Experimental language item for Miri
264+
PtrUnique, sym::ptr_unique, ptr_unique, Target::Struct, GenericRequirement::Exact(1);
263265

264266
PhantomData, sym::phantom_data, phantom_data, Target::Struct, GenericRequirement::Exact(1);
265267

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,7 @@ symbols! {
11561156
ptr_null_mut,
11571157
ptr_offset_from,
11581158
ptr_offset_from_unsigned,
1159+
ptr_unique,
11591160
pub_macro_rules,
11601161
pub_restricted,
11611162
public,

library/core/src/ptr/unique.rs

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ use crate::ptr::NonNull;
3232
)]
3333
#[doc(hidden)]
3434
#[repr(transparent)]
35+
// Lang item used experimentally by Miri to define the semantics of `Unique`.
36+
#[cfg_attr(not(bootstrap), lang = "ptr_unique")]
3537
pub struct Unique<T: ?Sized> {
3638
pointer: NonNull<T>,
3739
// NOTE: this marker has no consequences for variance, but is necessary

0 commit comments

Comments
 (0)