Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rakivo
Copy link

@rakivo rakivo commented Apr 30, 2025

No description provided.

src/map.rs Outdated
@@ -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]
Copy link
Member

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)

Copy link
Author

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

src/map/core.rs Outdated
Comment on lines 83 to 84
#[track_caller]
fn insert_bulk_no_grow<K, V>(indices: &mut Indices, entries: &[Bucket<K, V>]) {
Copy link
Member

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.

Copy link
Author

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

Copy link
Member

@cuviper cuviper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do remove those on Index and IndexMut traits, and on the internal function.

@rakivo
Copy link
Author

rakivo commented May 14, 2025

Ok, here you go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants