Skip to content

add track_caller attribute to map_err and ok_or/_else #142093

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 1 commit into
base: master
Choose a base branch
from

Conversation

yaahc
Copy link
Member

@yaahc yaahc commented Jun 5, 2025

Motivation unicode-org/icu4x#4048

This PR resolves a common edge case where users attempting to manually track std::panic::Locations of their callers in their Error types end up with irrelevant locations inside of std.

The main concern with this approach that I'm aware of is that #[track_caller] increases the stack sizes of the functions it is applied to, though I think this is a non-issue since we already have #[track_caller] on Result's FromResidual impl which is used far more frequently than any of these APIs when converting errors between different types. This change brings these functions in line with that impl.

example demonstrating the issue: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=8205bcd02b380d9fd02b1f1153ac9c4e

@rustbot
Copy link
Collaborator

rustbot commented Jun 5, 2025

r? @thomcc

rustbot has assigned @thomcc.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 5, 2025
@yaahc
Copy link
Member Author

yaahc commented Jun 5, 2025

Relevant previous discussion: #91752

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants