Commit b52d9f8
authored
Auto merge of #142093 - yaahc:track-map-error, r=<try>
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=8205bcd02b380d9fd02b1f1153ac9c4e2 files changed
+3
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1305 | 1305 | | |
1306 | 1306 | | |
1307 | 1307 | | |
| 1308 | + | |
1308 | 1309 | | |
1309 | 1310 | | |
1310 | 1311 | | |
| |||
1330 | 1331 | | |
1331 | 1332 | | |
1332 | 1333 | | |
| 1334 | + | |
1333 | 1335 | | |
1334 | 1336 | | |
1335 | 1337 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
907 | 907 | | |
908 | 908 | | |
909 | 909 | | |
| 910 | + | |
910 | 911 | | |
911 | 912 | | |
912 | 913 | | |
| |||
0 commit comments