-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Replace all uses of the never type (!
) with the stable Infallible
#966
Conversation
Looking at the final diff, it looks like VS Code auto-formatted when saving. I can manually undo this if wanted. |
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.
Given the history of the never type, I think it's reasonable to switch to Infallible
, which will later become an alias for !
. Aside from this This should be fine to include in a major release.bail!()
thing,
This is a breaking API change, albeit unlikely to break much if any code in the wild.
NB: this needs a minimum rustc version bump, probably the same version as #967. |
@jebrosen This could technically be done without the version bump if necessary, as It would actually be pretty simple to switch over, since we'd just need to add |
The version bump should be covered by #967 (merged). I personally think a custom empty enum is the worst option - not in |
@SergioBenitez I can perform a rebase if a merge is desired; it shouldn't be too difficult. |
LGTM pending rebase. |
For the most part, this is simple substitution and nothing else. In one specific location (core/lib/src/config/mod.rs), the compiler threw an error, as the `Infallible` type is not a special case in the compiler. As such, we have to explicitly tell it that code after that point cannot be reached using `unreachable_unchecked()`.
@jebrosen Rebase is complete — should be able to merge after CI is complete. |
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.
LGTM. I had one point about consistency - some places write out type Error = std::convert::Infallible
and some use std::convert::Infallible
, even if there's only one use. Similarly, some places use Result<T, Infallible>
and some use Result<Self, Self::Error>
. That should be easy to do during merge, though.
wrt consistency, I actually intended on doing another PR to switch to Edit: A quick |
Wonderful! This was merged in 34a741a. |
I didn't see your early comment; I switched to using std::convert::Infallible everywhere to make switching back to |
Infallible
will be stabilized on Thursday.Most of the diff is simple substitution of types (along with the relevant
use
).There is one situation that required a compiler hint regarding the function not actually returning;Infallible
isn't a special case in the compiler, so it regards it the same as returning any otherenum
. I worked around this by creating a trivial macro (for readability) that addsunsafe { std::hint::unreachable_unchecked() }
after a call; this will allow the compiler to avoid related errors and perform the relevant optimizations.Related: Compile on stable Rust (#19).
Pinging @jebrosen for review.