Skip to content
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

Improve panic messages and add #[track_caller] attribute to functions that may panic #367

Merged
merged 2 commits into from
Jan 20, 2025

Conversation

savannstm
Copy link
Contributor

Currently, indexmap panic messages aren't really helpful, and this PR adds #[track_caller] attributes to functions that may panic, for better understanding where to actually look for the panic, and uses the same panic messages that standard collections do with more details.
Seems like #[track_caller] is compatible with no_std, and it shouldn't break anything.

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.

Seems like a good idea, thanks!

@@ -1325,7 +1346,7 @@ where
///
/// ***Panics*** if `key` is not present in the map.
fn index(&self, key: &Q) -> &V {
Copy link
Member

Choose a reason for hiding this comment

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

Just clarifying for future reference -- our Index and IndexMut implementations don't need #[track_caller] because the trait definition already applies it.

@cuviper cuviper added this pull request to the merge queue Jan 20, 2025
Merged via the queue into indexmap-rs:master with commit f0ec924 Jan 20, 2025
16 checks passed
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