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
return inner error of std:io::Error as source/cause #124536
Conversation
Proposed solution to close rust-lang#124513 Not sure if this should be seen as a breaking change or not. See for more context rust-lang#124513.
rustbot has assigned @workingjubilee. Use |
cc @thomcc apparently you were the last to touch this. |
As you noted in #124513, this would break a lot code, so I don't think that this can be merged. Additionally, this makes an In your case, you probably need a wrapper (as you have shown works) or use The fact that you were confused by this may be sign that it be better documented, though. |
@a1phyr downcast is not a universal thing though. So based on your answer I seem to understand that But that also means that approaches such as the one taken by https://docs.rs/anyhow/latest/anyhow/struct.Error.html#method.chain (not something I use, but it's close enough), are flawed? As these rely upon source. And once you start to skip errors (persistent or at random) things get confusing very quickly. Downcast sounds great, but it's not part of the |
For custom errors, |
In practice, |
If you wish, you can open an issue against the anyhow library here: https://github.com/dtolnay/anyhow/issues I have not really been presented with an argument for why this should change beyond "but anyhow uses it, and anyhow is supposedly more infallible than std, because ???" |
Fair enough. I trust you all in this. Much respect. Most important for me here is that I understand the intended behaviour behind ::source() as a concept. I understand that no one is making random io errors and I get that there are no guarantees that people use the trait contract correctly. Most important for me is just to know what source exactly is supposed to do. Are you always supposed to call inner.source? Should you never do it. Is it undefined and is there no real meaning to source? That's the thing I'm still confused about. |
It is more than "do people use the trait contract correctly", the issue is that https://doc.rust-lang.org/1.77.2/src/core/error.rs.html#83-86 |
That's indeed the danger of provided trait methods. So ok, that is indeed a concern. And i get it is a reason why a chain iterator might anyway fail at any point. Still. My question remains. Assuming the person did not forget to implement the trait method. What is the intended contract behaviour that person should take into account? Asking to aid my understanding and to know if perhaps there's room for additional documentation for that source method. |
When an implementation overrides |
Ok that is super clear. Thanks a lot. Going to close this then. Thank you so much. Learned a lot from this ❤️🦀 |
Proposed solution to close #124513
Not sure if this should be seen as a breaking change or not.
See for more context #124513.