Skip to content

Commit

Permalink
Unrolled build for rust-lang#123206
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#123206 - stepancheg:pointee-metadata-freeze, r=Amanieu

Require Pointee::Metadata to be Freeze

So pointee metadata can be used in anonymous statics.

This is prerequisite for implementing ThinBox without allocation for ZST.

See rust-lang#123184 (comment)

r? joboet
  • Loading branch information
rust-timer authored Apr 5, 2024
2 parents 9cbaa01 + 8f5a28e commit dab0be0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion library/core/src/ptr/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use crate::fmt;
use crate::hash::{Hash, Hasher};
use crate::marker::Freeze;

/// Provides the pointer metadata type of any pointed-to type.
///
Expand Down Expand Up @@ -57,7 +58,7 @@ pub trait Pointee {
// NOTE: Keep trait bounds in `static_assert_expected_bounds_for_metadata`
// in `library/core/src/ptr/metadata.rs`
// in sync with those here:
type Metadata: fmt::Debug + Copy + Send + Sync + Ord + Hash + Unpin;
type Metadata: fmt::Debug + Copy + Send + Sync + Ord + Hash + Unpin + Freeze;
}

/// Pointers to types implementing this trait alias are “thin”.
Expand Down
1 change: 1 addition & 0 deletions library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#![feature(duration_constructors)]
#![feature(exact_size_is_empty)]
#![feature(extern_types)]
#![feature(freeze)]
#![feature(flt2dec)]
#![feature(fmt_internals)]
#![feature(float_minimum_maximum)]
Expand Down
3 changes: 2 additions & 1 deletion library/core/tests/ptr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use core::cell::RefCell;
use core::marker::Freeze;
use core::mem::{self, MaybeUninit};
use core::num::NonZero;
use core::ptr;
Expand Down Expand Up @@ -841,7 +842,7 @@ fn ptr_metadata_bounds() {
fn static_assert_expected_bounds_for_metadata<Meta>()
where
// Keep this in sync with the associated type in `library/core/src/ptr/metadata.rs`
Meta: Debug + Copy + Send + Sync + Ord + std::hash::Hash + Unpin,
Meta: Debug + Copy + Send + Sync + Ord + std::hash::Hash + Unpin + Freeze,
{
}
}
Expand Down

0 comments on commit dab0be0

Please sign in to comment.