Rollup merge of #70281 - xfix:infallible-hash, r=dtolnay

Implement Hash for Infallible

https://www.reddit.com/r/rust/comments/fmllgx/never_crate_stable_alternative_to/ lists not implementing `Hash` as a reason for the `never` crate. I see no reason not to implement `Hash` for `Infallible`, so might as well do it.

No changes necessary for `!`, because `!` already implements `Hash` (see https://github.com/rust-lang/rust/pull/51404).
This commit is contained in:
Mazdak Farrokhzad 2020-04-02 14:27:52 +02:00 committed by GitHub
commit cb81b41c9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,6 +41,7 @@
#![stable(feature = "rust1", since = "1.0.0")]
use crate::fmt;
use crate::hash::{Hash, Hasher};
mod num;
@ -746,3 +747,10 @@ fn from(x: !) -> Self {
x
}
}
#[stable(feature = "convert_infallible_hash", since = "1.44.0")]
impl Hash for Infallible {
fn hash<H: Hasher>(&self, _: &mut H) {
match *self {}
}
}