Auto merge of #123181 - stepancheg:pointee-metadata-debug, r=the8472,Amanieu
Require Debug for Pointee::Metadata Useful for debugging.
This commit is contained in:
commit
1aedc9640c
@ -57,7 +57,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: Copy + Send + Sync + Ord + Hash + Unpin;
|
||||
type Metadata: fmt::Debug + Copy + Send + Sync + Ord + Hash + Unpin;
|
||||
}
|
||||
|
||||
/// Pointers to types implementing this trait alias are “thin”.
|
||||
|
@ -841,11 +841,19 @@ 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: Copy + Send + Sync + Ord + std::hash::Hash + Unpin,
|
||||
Meta: Debug + Copy + Send + Sync + Ord + std::hash::Hash + Unpin,
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pointee_metadata_debug() {
|
||||
assert_eq!("()", format!("{:?}", metadata::<u32>(&17)));
|
||||
assert_eq!("2", format!("{:?}", metadata::<[u32]>(&[19, 23])));
|
||||
let for_dyn = format!("{:?}", metadata::<dyn Debug>(&29));
|
||||
assert!(for_dyn.starts_with("DynMetadata(0x"), "{:?}", for_dyn);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dyn_metadata() {
|
||||
#[derive(Debug)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user