Skip to content

Commit

Permalink
Rollup merge of rust-lang#70281 - xfix:infallible-hash, r=dtolnay
Browse files Browse the repository at this point in the history
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 rust-lang#51404).
  • Loading branch information
Centril authored Apr 2, 2020
2 parents 0f72ce1 + 4582c14 commit cb81b41
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libcore/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#![stable(feature = "rust1", since = "1.0.0")]

use crate::fmt;
use crate::hash::{Hash, Hasher};

mod num;

Expand Down Expand Up @@ -746,3 +747,10 @@ impl From<!> for Infallible {
x
}
}

#[stable(feature = "convert_infallible_hash", since = "1.44.0")]
impl Hash for Infallible {
fn hash<H: Hasher>(&self, _: &mut H) {
match *self {}
}
}

0 comments on commit cb81b41

Please sign in to comment.