Include the type of Err variant when there's a type error in a Result

A couple of weeks ago I was playing with rust and I ran into a type error where I had a mismatch between the Err type in a Result and the compiler wasn't being very forthcoming in what the expected type was. I mentioned this off-hand on Twitter while live-tweeting my experience writing my first non-trivial rust project (successful, 4/5 stars) and someone suggested that I file a feature request:

It seems like this is less of a bug and more of a known gap in what the rust compiler is capable of reporting on due to some specifics of how Results are implemented, so when I was on GitHub I clicked "Feature Request" instead of "Bug Report", but I don't actually know what would be more useful. Either way, I appreciated the idea that osmeone might actually look into this, and while I don't understand the issue well enough to explain it all that well I'm going to do my best to get it on paper and in a ticketing system anyway.

I don't really have the time or knowledge to engage with this further, but I hope this was helpful.

1 Like

Is it the one in here?

I think the error type you have there is egg_mode::error::Error? It shows in the From<...> part, though that's not necessarily obvious.

There's another issue in a related area recently: Confusing compiler error when returning a `Result<Result>` via `?`-operator · Issue #86547 · rust-lang/rust · GitHub

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.