Skip to content

Commit 5f498ca

Browse files
committed
Only add 'inside this call' for Invalidation diagnostics
1 parent 45d7121 commit 5f498ca

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/tools/miri/src/stacked_borrows/diagnostics.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,20 @@ enum InvalidationCause {
6666

6767
impl Invalidation {
6868
fn generate_diagnostic(&self) -> (String, SpanData) {
69-
(
69+
let message = if let InvalidationCause::Retag(_, RetagCause::FnEntry) = self.cause {
70+
// For a FnEntry retag, our Span points at the caller.
71+
// See `DiagnosticCx::log_invalidation`.
72+
format!(
73+
"{:?} was later invalidated at offsets {:?} by a {} inside this call",
74+
self.tag, self.range, self.cause
75+
)
76+
} else {
7077
format!(
7178
"{:?} was later invalidated at offsets {:?} by a {}",
7279
self.tag, self.range, self.cause
73-
),
74-
self.span.data(),
75-
)
80+
)
81+
};
82+
(message, self.span.data())
7683
}
7784
}
7885

@@ -82,7 +89,7 @@ impl fmt::Display for InvalidationCause {
8289
InvalidationCause::Access(kind) => write!(f, "{}", kind),
8390
InvalidationCause::Retag(perm, kind) =>
8491
if *kind == RetagCause::FnEntry {
85-
write!(f, "{:?} FnEntry retag inside this call", perm)
92+
write!(f, "{:?} FnEntry retag", perm)
8693
} else {
8794
write!(f, "{:?} retag", perm)
8895
},

0 commit comments

Comments
 (0)