Skip to content

Commit ccfd33b

Browse files
authored
Document that cloning a SecondaryMap's default value should not allocate (#12667)
1 parent c99bf94 commit ccfd33b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

crates/environ/src/collections/secondary_map.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ where
2727
V: Clone,
2828
{
2929
/// Same as [`cranelift_entity::SecondaryMap::new`].
30+
///
31+
/// XXX: `Clone::clone(&<V as Default>::default())` should never allocate.
3032
pub fn new() -> Self
3133
where
3234
V: Default,
@@ -37,6 +39,8 @@ where
3739
}
3840

3941
/// Same as [`cranelift_entity::SecondaryMap::try_with_capacity`].
42+
///
43+
/// XXX: `Clone::clone(&<V as Default>::default())` should never allocate.
4044
pub fn with_capacity(capacity: usize) -> Result<Self, OutOfMemory>
4145
where
4246
V: Default,
@@ -47,6 +51,8 @@ where
4751
}
4852

4953
/// Same as [`cranelift_entity::SecondaryMap::with_default`].
54+
///
55+
/// XXX: `Clone::clone(&default)` should never allocate.
5056
pub fn with_default(default: V) -> Self {
5157
Self {
5258
inner: Inner::with_default(default),

0 commit comments

Comments
 (0)