Print location when using expect_throw()
#4049
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After going over it again I noticed that the
UnwrapThrow
implementation didn't really make sense. Because if you calledexpect_throw()
you wouldn't get any location information.So I just manually implemented both
unwrap_throw()
andexpect_throw()
forOption
andResult
and made it as close as possible to Std (apart from the location information).I also noticed that the implementation I've fixed in #4035 wasn't exactly right, e.g. calling
Result::unwrap_throw()
would panic instead of throwing withoutcfg(debug_assertions)
. Through the overhaul this was fixed as well.In hindsight, I believe that adding a default implementation on
UnwrapThrow
was a mistake.With this I will also close #2732, while leaving the discussion if the whole idea of
UnwrapThrow
is a good one or not to a different place and time.Fixes #2732.
Follow-up to #4035 and #4042.