Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion parity-util-mem/src/malloc_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,16 @@ macro_rules! malloc_size_of_is_0(
}
}
)+
);
(any: $($ty:ident<$($gen:ident),+>),+) => (
Comment thread
NikVolf marked this conversation as resolved.
$(
impl<$($gen),+> $crate::MallocSizeOf for $ty<$($gen),+> {
#[inline(always)]
fn size_of(&self, _: &mut $crate::MallocSizeOfOps) -> usize {
0
}
}
)+
);
($($ty:ident<$($gen:ident),+>),+) => (
$(
Expand All @@ -585,7 +595,7 @@ macro_rules! malloc_size_of_is_0(
}
}
)+
);
);
Comment thread
NikVolf marked this conversation as resolved.
);

malloc_size_of_is_0!(bool, char, str);
Expand Down Expand Up @@ -763,4 +773,16 @@ mod tests {
// ~36 per value
assert!(crate::malloc_size(&set) > 3000);
}

#[test]
fn special_malloc_size_of_0() {
struct Data<P> {
phantom: std::marker::PhantomData<P>,
}

malloc_size_of_is_0!(any: Data<P>);

// MallocSizeOf is not implemented for [u8; 333]
assert_eq!(crate::malloc_size(&Data::<[u8; 333]> { phantom: std::marker::PhantomData }), 0);
}
}