-
Notifications
You must be signed in to change notification settings - Fork 390
Use the better FnEntry spans in protector errors #2519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
}).or_else(|| { | ||
// If we didn't find a retag that created this tag, it might be the base tag of | ||
// this allocation. | ||
if self.history.base.0.tag() == tag { | ||
Some(( | ||
format!("{:?} was created here, as a base tag for {:?}", tag, self.history.id), | ||
self.history.base.1.data() | ||
)) | ||
} else { | ||
None | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While developing this, I tried the reproducer for the current VecDeque issue:
use std::collections::VecDeque;
fn main() {
let mut tester: VecDeque<usize> = VecDeque::with_capacity(3);
for i in 0..3 {
tester.push_back(i);
}
let _: VecDeque<_> = tester.drain(1..2).collect();
}
Which before this PR reports no additional helps, because it fails to find the creation of the tag being used in the error. Because the tag being used is the base tag, which we never store anywhere.
// this allocation. | ||
if self.history.base.0.tag() == tag { | ||
Some(( | ||
format!("{:?} was created here, as a base tag for {:?}", tag, self.history.id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the tests emit this message, is it reachable at all?
☀️ Test successful - checks-actions |
Will do. |
Add a protector test that demonstrates the base tag diagnostic Per #2519 (comment), this demonstrates this case for protector diagnostics: ``` help: <3131> was created here, as a base tag for alloc1623 --> tests/fail/stacked_borrows/invalidate_against_protector3.rs:10:19 | 10 | let ptr = std::alloc::alloc(std::alloc::Layout::for_value(&0i32)) as *mut i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` This diagnostic is inspired by what Miri used to do with rust-lang/rust#60076 (comment)
Example error, from
tests/fail/stacked_borrows/invalidate_against_protector1.rs
:Benchmarks report no change, within noise.