-
Notifications
You must be signed in to change notification settings - Fork 168
Add #[track_caller]
to all functions that are marked with ***Panics***
and can potentially panic
#389
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
base: main
Are you sure you want to change the base?
Conversation
…s***` and can potentially panic
…tion in case of panic
@@ -1388,6 +1388,7 @@ where | |||
/// Returns a reference to the value corresponding to the supplied `key`. | |||
/// | |||
/// ***Panics*** if `key` is not present in the map. | |||
#[track_caller] |
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.
Last time, we decided this wasn't needed because the trait already has it:
#367 (comment)
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.
Oh, I didn't know that the trait already has it, thank you for the clarification
"index out of bounds: the len is {len} but the index is {index}", | ||
len = self.len() | ||
); | ||
} |
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.
I think you're right that this closure was in the way though, so this is a good change.
#[track_caller] | ||
fn insert_bulk_no_grow<K, V>(indices: &mut Indices, entries: &[Bucket<K, V>]) { |
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.
This is an internal function, and the pre-condition is entirely in our own control. If this ever fails, I think it would be confusing to the user to have their caller location reported, when they really should report a bug to us. So, I don't think we should add this one.
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.
Yeah, you're right, I just slapped #[track_caller]
all over the place without even checking whether the function was internal or not
No description provided.