Skip to content

Commit 02bec40

Browse files
TB: protector end semantics never causes immediate UB
1 parent 0a86e79 commit 02bec40

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ impl fmt::Display for AccessCause {
2828
Self::Explicit(kind) => write!(f, "{kind}"),
2929
Self::Reborrow => write!(f, "reborrow"),
3030
Self::Dealloc => write!(f, "deallocation"),
31-
Self::FnExit(AccessKind::Read) => write!(f, "protector release read"),
32-
Self::FnExit(AccessKind::Write) => write!(f, "protector release write"),
31+
// This is dead code, since the protector release access itself can never
32+
// cause UB (while the protector is active, if some other access invalidates
33+
// further use of the protected tag, that is immediate UB).
34+
// Describing the cause of UB is the only time this function is called.
35+
Self::FnExit(_) => unreachable!("protector accesses can never be the source of UB"),
3336
}
3437
}
3538
}

0 commit comments

Comments
 (0)