Skip to content

Retire VortexExpect#6554

Closed
AdamGS wants to merge 4 commits intodevelopfrom
adamg/remove-vortex-expect
Closed

Retire VortexExpect#6554
AdamGS wants to merge 4 commits intodevelopfrom
adamg/remove-vortex-expect

Conversation

@AdamGS
Copy link
Contributor

@AdamGS AdamGS commented Feb 17, 2026

Summary

This PR builds on top of #6410.

This PR removes the VortexExpect trait, the way its used right now isn't very useful and adds visual noise in multiple places:

  1. Because it ends up in a panic, we print out two backtraces, making it harder to parse where the issue is. The backtraces also end up with multiple layers of Vortex-specific content that just tracks the error's path through vortex-error.
  2. vortex_expect (or create-specific expect functions) is just more verbose and not a common pattern in the ecosystem
  3. It requires multiple variants of VortexError which are rarely used (and I would argue should never be used), some codepaths get around that by calling .ok() on the original error, which brings us back to the first point here.

API Changes

Removes the VortexExpect trait and a few VortexError variants (like TryFromInt).

Testing

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 17, 2026

Merging this PR will not alter performance

✅ 383 untouched benchmarks
⏩ 2020 skipped benchmarks1


Comparing adamg/remove-vortex-expect (6811eb5) with develop (74c0bcf)

Open in CodSpeed

Footnotes

  1. 2020 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@AdamGS AdamGS added the changelog/break A breaking API change label Feb 17, 2026
@connortsui20
Copy link
Contributor

is the windows test failure expected here?

@AdamGS
Copy link
Contributor Author

AdamGS commented Feb 17, 2026

@connortsui20 the windows failure is from #6410, I think its now fixed there

Base automatically changed from adamg/trim-backtraces to develop February 17, 2026 14:17
@AdamGS AdamGS force-pushed the adamg/remove-vortex-expect branch 2 times, most recently from d6dbda5 to bbd1974 Compare February 17, 2026 14:51
@AdamGS AdamGS force-pushed the adamg/remove-vortex-expect branch from 6811eb5 to 3d9d2a7 Compare February 17, 2026 14:59
Signed-off-by: Adam Gutglick <adam@spiraldb.com>

Expect everything

Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
@AdamGS AdamGS force-pushed the adamg/remove-vortex-expect branch from 3d9d2a7 to 21938ea Compare February 17, 2026 15:27
@connortsui20
Copy link
Contributor

This looks good to me. I was always wondering why we do this, but if @robert3005 has a reason then we can reconsider.

@a10y
Copy link
Contributor

a10y commented Feb 17, 2026

Yea, vortex_expect does not seem to do anything useful here. I thought the whole point was to force capturing a backtrace even if RUST_BACKTRACE isn't set, but it doesn't even seem to do that

image image

@AdamGS
Copy link
Contributor Author

AdamGS commented Feb 17, 2026

as far as I can tell, it never did that. There is an API to force a backtrace capture even RUST_BACKTRACE=0, but I don't think we ever used it.

@robert3005
Copy link
Contributor

robert3005 commented Feb 17, 2026

I spent whole day thinking about this. We can remove VortexExpect BUT we cannot allow expect. It's not about force capturing a backtrace is to make sure that you cannot unwrap/expect errors without backtraces. If you would to allow nightly you could implement VortexExpect so it doesn't double capture but without it I don't have a solution. I spent a while playing on rust playground and the thing that's bad is something like https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=560e73d67f42262bbec6fb609f39b517

tests_outside_test_module = "deny"
# todo = "deny"
# unimplemented = "deny"
unwrap_in_result = "deny"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't sneak by here, it's orthogonal to the pr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't allow calling expect in functions that return a result

equatable_if_let = "deny"
exit = "deny"
expect_fun_call = "deny"
expect_used = "deny"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per my other comment, this should stay

@AdamGS
Copy link
Contributor Author

AdamGS commented Feb 17, 2026

the playground link you shared isn't a permalink, so no idea what you're looking at 😅

@AdamGS
Copy link
Contributor Author

AdamGS commented Feb 17, 2026

also removing VortexExpect and not allowing expect doesn't achieve much. If anything, it makes things more verbose.

@robert3005
Copy link
Contributor

sorry I updated the link

@AdamGS
Copy link
Contributor Author

AdamGS commented Feb 17, 2026

Ok I see what you're saying, if that's a no go - this PR isn't relevant. I don't think there are many use cases of that, but if we don't trust people to use expect as assertions, the current design works IMO.

@AdamGS AdamGS closed this Feb 17, 2026
@robert3005
Copy link
Contributor

We have added this after a painful debugging session where the source of the error was obscured because of expect in bad place. FWIW you can implement this properly if you had error_generic_member_access nightly feature. But right now it's impossible to know if error has a backtrace or not

@a10y
Copy link
Contributor

a10y commented Feb 17, 2026

Sorry, just to be concrete: the problem is that we don't capture the backtrace at the site where the TryFromIntError originates, so when we expect() on it we get an incomplete Backtrace?

But VortexExpect enforces this b/c it only allows us to expect on errors that are VortexError-shaped

If that's the case, I think there's a bit of a hole, which is that we currently let you .vortex_expect() on anything that is Into<VortexError>. TryFromIntError is in fact Into<VortexError>, which means that if you'd .vortex_expect() on it you'd get the same backtrace as you do here i think?

I guess in practice, this is generally not a problem b/c our functions always return VortexResult which means the backtrace should be captured immediately, but if we're really concerned about this then we should probably remove the blanket impl of `VortexExpect

@a10y
Copy link
Contributor

a10y commented Feb 17, 2026

Could we remove it for Option unwrapping? There are 487 usages of that (mostly in tests) and I don't think it helps you at all

@AdamGS
Copy link
Contributor Author

AdamGS commented Feb 17, 2026

mappings those to an error just to unwrap it seems really weird to me, and would actually provide a worse backtrace

@robert3005
Copy link
Contributor

Basically I’m fine removing vortexexpect but also keeping deny for expect_used. Yes the problem is that you can use expect on an arbitrary error and that will not provide you with a backtrace.

@a10y
Copy link
Contributor

a10y commented Feb 17, 2026

It feels like what we actually want is to prevent propagating non-VortexError errors across function call boundaries? Like, if I do u32::try_from(x).vortex_expect("...") i get no valuable information than if i had just done .expect().

But if I return a Result<(), TryFromIntError> and then try and unwrap that 10 stack frames up, I lose a lot of useful information.

Can we accomplish this by adding std::result::Result as a disallowed type in clippy, forcing you to always return VortexResult ?

This would mean that you either propagate VortexError (which has backtrace), or you have some other error type and are immediately unwrapping it at its return site.

@robert3005
Copy link
Contributor

I think forbidding std::result::Result could be a good solution

@a10y
Copy link
Contributor

a10y commented Feb 18, 2026

spent 5 minutes trying to do this ^ on #6575, i hit a snag with serde derived impls but otherwise it's not too bad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/break A breaking API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments