From 5f498cab13800da77be7f6450a8d5264d31b0d1f Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Thu, 22 Sep 2022 10:44:03 -0400 Subject: [PATCH] Only add 'inside this call' for Invalidation diagnostics --- .../miri/src/stacked_borrows/diagnostics.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/tools/miri/src/stacked_borrows/diagnostics.rs b/src/tools/miri/src/stacked_borrows/diagnostics.rs index 8deb8cda2e17..2cc7a88704ea 100644 --- a/src/tools/miri/src/stacked_borrows/diagnostics.rs +++ b/src/tools/miri/src/stacked_borrows/diagnostics.rs @@ -66,13 +66,20 @@ enum InvalidationCause { impl Invalidation { fn generate_diagnostic(&self) -> (String, SpanData) { - ( + let message = if let InvalidationCause::Retag(_, RetagCause::FnEntry) = self.cause { + // For a FnEntry retag, our Span points at the caller. + // See `DiagnosticCx::log_invalidation`. + format!( + "{:?} was later invalidated at offsets {:?} by a {} inside this call", + self.tag, self.range, self.cause + ) + } else { format!( "{:?} was later invalidated at offsets {:?} by a {}", self.tag, self.range, self.cause - ), - self.span.data(), - ) + ) + }; + (message, self.span.data()) } } @@ -82,7 +89,7 @@ impl fmt::Display for InvalidationCause { InvalidationCause::Access(kind) => write!(f, "{}", kind), InvalidationCause::Retag(perm, kind) => if *kind == RetagCause::FnEntry { - write!(f, "{:?} FnEntry retag inside this call", perm) + write!(f, "{:?} FnEntry retag", perm) } else { write!(f, "{:?} retag", perm) },