From 02bec40930d7256d290c6a61b60df8284e460dda Mon Sep 17 00:00:00 2001 From: Johannes Hostert Date: Thu, 4 Jul 2024 12:01:49 +0200 Subject: [PATCH] TB: protector end semantics never causes immediate UB --- .../miri/src/borrow_tracker/tree_borrows/diagnostics.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs index 498b7dc3e420..a753de28a041 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs @@ -28,8 +28,11 @@ impl fmt::Display for AccessCause { Self::Explicit(kind) => write!(f, "{kind}"), Self::Reborrow => write!(f, "reborrow"), Self::Dealloc => write!(f, "deallocation"), - Self::FnExit(AccessKind::Read) => write!(f, "protector release read"), - Self::FnExit(AccessKind::Write) => write!(f, "protector release write"), + // This is dead code, since the protector release access itself can never + // cause UB (while the protector is active, if some other access invalidates + // further use of the protected tag, that is immediate UB). + // Describing the cause of UB is the only time this function is called. + Self::FnExit(_) => unreachable!("protector accesses can never be the source of UB"), } } }