From 3a1e114120d3570b2b1b4dd4b0b1d31ce0382861 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 17 Jun 2022 16:23:51 -0700 Subject: [PATCH] comments explaining why we have and don't have ManuallyDrop --- library/alloc/src/collections/btree/map.rs | 3 +++ library/alloc/src/collections/btree/map/entry.rs | 2 ++ library/alloc/src/collections/btree/set.rs | 1 + 3 files changed, 6 insertions(+) diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index cc445e89267..e1124a68750 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -175,6 +175,7 @@ pub struct BTreeMap< > { root: Option>, length: usize, + /// `ManuallyDrop` to control drop order (needs to be dropped after all the nodes). pub(super) alloc: ManuallyDrop, } @@ -384,6 +385,7 @@ pub struct IntoIter< > { range: LazyLeafRange, length: usize, + /// The BTreeMap will outlive this IntoIter so we don't care about drop order for `alloc`. alloc: A, } @@ -1800,6 +1802,7 @@ pub struct DrainFilter< { pred: F, inner: DrainFilterInner<'a, K, V>, + /// The BTreeMap will outlive this IntoIter so we don't care about drop order for `alloc`. alloc: A, } /// Most of the implementation of DrainFilter are generic over the type diff --git a/library/alloc/src/collections/btree/map/entry.rs b/library/alloc/src/collections/btree/map/entry.rs index ffaf7daad48..b6eecf9b0e9 100644 --- a/library/alloc/src/collections/btree/map/entry.rs +++ b/library/alloc/src/collections/btree/map/entry.rs @@ -56,6 +56,7 @@ pub struct VacantEntry< pub(super) handle: Option, K, V, marker::Leaf>, marker::Edge>>, pub(super) dormant_map: DormantMutRef<'a, BTreeMap>, + /// The BTreeMap will outlive this IntoIter so we don't care about drop order for `alloc`. pub(super) alloc: A, // Be invariant in `K` and `V` @@ -81,6 +82,7 @@ pub struct OccupiedEntry< pub(super) handle: Handle, K, V, marker::LeafOrInternal>, marker::KV>, pub(super) dormant_map: DormantMutRef<'a, BTreeMap>, + /// The BTreeMap will outlive this IntoIter so we don't care about drop order for `alloc`. pub(super) alloc: A, // Be invariant in `K` and `V` diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index 91b4838f370..bec3b967525 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -1285,6 +1285,7 @@ pub struct DrainFilter< { pred: F, inner: super::map::DrainFilterInner<'a, T, ()>, + /// The BTreeMap will outlive this IntoIter so we don't care about drop order for `alloc`. alloc: A, }