From 7dd1d7ca1de2504842aa1a755d59f9ac0ba245ae Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 22 Jul 2025 09:49:21 -0700 Subject: [PATCH 1/2] Ignore must_use warning --- tests/global.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/global.rs b/tests/global.rs index b5cfacd..04906a0 100644 --- a/tests/global.rs +++ b/tests/global.rs @@ -22,7 +22,7 @@ fn map() { #[test] fn strings() { - format!("foo, bar, {}", "baz"); + let _ = format!("foo, bar, {}", "baz"); } #[test] From 1ad1cffa74d91542d79e61a009c5c8f310d45d87 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 22 Jul 2025 09:50:01 -0700 Subject: [PATCH 2/2] Fix one instance of Miri-flagged UB `mark_smallbin` invalidates a previous borrow, so acquire the borrow after that function is called. --- src/dlmalloc.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/dlmalloc.rs b/src/dlmalloc.rs index a03d34e..f11a64b 100644 --- a/src/dlmalloc.rs +++ b/src/dlmalloc.rs @@ -1024,14 +1024,15 @@ impl Dlmalloc { unsafe fn insert_small_chunk(&mut self, chunk: *mut Chunk, size: usize) { let idx = self.small_index(size); - let head = self.smallbin_at(idx); - let mut f = head; debug_assert!(size >= self.min_chunk_size()); - if !self.smallmap_is_marked(idx) { + let (f, head) = if !self.smallmap_is_marked(idx) { self.mark_smallmap(idx); + let head = self.smallbin_at(idx); + (head, head) } else { - f = (*head).prev; - } + let head = self.smallbin_at(idx); + ((*head).prev, head) + }; (*head).prev = chunk; (*f).next = chunk;