-
Notifications
You must be signed in to change notification settings - Fork 0
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
result_tracing
: error return tracing in core
#1
base: const-trait-specialize
Are you sure you want to change the base?
Conversation
Beep boop I am the CI, here are the UI test failures: Test output
|
} | ||
|
||
#[test] | ||
fn try_operator_calls_trace() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: add const equivalent of this test
// FIXME(bgr360): how to properly add this change that depends on compiler | ||
// functionality that's not yet in the beta? | ||
#[cfg(not(bootstrap))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you did it right. The release team has a whole process for how they remove cfg(bootstrap) directives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok dope
d912178
to
92cb72b
Compare
f380b39
to
fe53cac
Compare
What It Does
This PR enables users of
Result
to be notified of every invocation of the try operator (?
) by implementing a newTrace
trait on their error type. For anyResult::<T, E>::Err(e)
whereE: Trace
, invoking the try operator will callTrace::trace()
one
and pass in the code location of the?
invocation.So the following code example:
Would produce the following output:
How It Does
core::result::Trace
FromResidual for Result<T, E>
to behave differently whenE: Trace
.Why It Does
The primary motivation for this is to enable low-overhead error return tracing, to borrow the term from the Zig language.
A decent argument for why return tracing is desirable over backtraces or other approaches can be found here.
Additional Context
There is a lengthy thread introducing the idea and cataloging its evolution on Zulip: track_caller error crate.
Blockers
FromResidual for Result
is not valid until rustc can properly handle specialized const trait impls.min_specialization
.