From 8573b9ac7dfe080684da487edae774dbaf789447 Mon Sep 17 00:00:00 2001 From: dylni <46035563+dylni@users.noreply.github.com> Date: Mon, 15 Mar 2021 00:26:41 -0400 Subject: [PATCH 1/2] Clarify BTree range searching comments --- collections/btree/search.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/collections/btree/search.rs b/collections/btree/search.rs index f376b3c..e599800 100644 --- a/collections/btree/search.rs +++ b/collections/btree/search.rs @@ -94,7 +94,7 @@ impl NodeRef, R: RangeBounds, { - // WARNING: Inlining these variables would be unsound (#81138) + // It might be unsound to inline these variables if this logic changes (#81138). // We assume the bounds reported by `range` remain the same, but // an adversarial implementation could change between calls let (start, end) = (range.start_bound(), range.end_bound()); @@ -114,6 +114,8 @@ impl NodeRef upper_edge_idx { panic!("Ord is ill-defined in BTreeMap range") } From cecf43d2a8f32d879f5278b4ce040fa466400eb3 Mon Sep 17 00:00:00 2001 From: dylni <46035563+dylni@users.noreply.github.com> Date: Tue, 16 Mar 2021 22:17:49 -0400 Subject: [PATCH 2/2] Fix comments based on review --- collections/btree/search.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/collections/btree/search.rs b/collections/btree/search.rs index e599800..5dc62d4 100644 --- a/collections/btree/search.rs +++ b/collections/btree/search.rs @@ -94,9 +94,8 @@ impl NodeRef, R: RangeBounds, { - // It might be unsound to inline these variables if this logic changes (#81138). - // We assume the bounds reported by `range` remain the same, but - // an adversarial implementation could change between calls + // Inlining these variables should be avoided. We assume the bounds reported by `range` + // remain the same, but an adversarial implementation could change between calls (#81138). let (start, end) = (range.start_bound(), range.end_bound()); match (start, end) { (Bound::Excluded(s), Bound::Excluded(e)) if s == e => { @@ -114,8 +113,6 @@ impl NodeRef upper_edge_idx { panic!("Ord is ill-defined in BTreeMap range") }