Skip to content

Commit 90d8b2e

Browse files
committed
Document that cloning a SecondaryMap's default value should not allocate
1 parent 7051ab3 commit 90d8b2e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

crates/environ/src/collections/secondary_map.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ where
2828
V: Clone,
2929
{
3030
/// Same as [`cranelift_entity::SecondaryMap::new`].
31+
///
32+
/// XXX: `Clone::clone(&<V as Default>::default())` should never allocate.
3133
pub fn new() -> Self
3234
where
3335
V: Default,
@@ -38,6 +40,8 @@ where
3840
}
3941

4042
/// Same as [`cranelift_entity::SecondaryMap::try_with_capacity`].
43+
///
44+
/// XXX: `Clone::clone(&<V as Default>::default())` should never allocate.
4145
pub fn with_capacity(capacity: usize) -> Result<Self, OutOfMemory>
4246
where
4347
V: Default,
@@ -48,6 +52,8 @@ where
4852
}
4953

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

0 commit comments

Comments
 (0)