-
Notifications
You must be signed in to change notification settings - Fork 13.4k
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
base: master
Are you sure you want to change the base?
Conversation
Relevant previous discussion: #91752 |
@bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
add track_caller attribute to map_err and ok_or/_else <!-- homu-ignore:start --> <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r? <reviewer name> --> <!-- homu-ignore:end --> Motivation unicode-org/icu4x#4048 This PR resolves a common edge case where users attempting to manually track `std::panic::Location`s 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
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (b52d9f8): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResults (primary 2.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.1%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 693.336s -> 692.254s (-0.16%) |
Motivation unicode-org/icu4x#4048
This PR resolves a common edge case where users attempting to manually track
std::panic::Location
s of their callers in theirError
types end up with irrelevant locations inside ofstd
.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]
onResult
'sFromResidual
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