#![stable(feature = "rust1", since = "1.0.0")]
+use crate::convert::Infallible;
use crate::fmt;
use crate::intrinsics;
use crate::mem;
/// Provides intentionally-wrapped arithmetic on `T`.
///
- /// Operations like `+` on `u32` values is intended to never overflow,
+ /// Operations like `+` on `u32` values are intended to never overflow,
/// and in some debug configurations overflow is detected and results
/// in a panic. While most arithmetic falls into this category, some
/// code explicitly expects and relies upon modular arithmetic (e.g.,
}
#[stable(feature = "try_from", since = "1.34.0")]
+impl From<Infallible> for TryFromIntError {
+ fn from(x: Infallible) -> TryFromIntError {
+ match x {}
+ }
+}
+
+#[unstable(feature = "never_type", issue = "35121")]
impl From<!> for TryFromIntError {
fn from(never: !) -> TryFromIntError {
+ // Match rather than coerce to make sure that code like
+ // `From<Infallible> for TryFromIntError` above will keep working
+ // when `Infallible` becomes an alias to `!`.
match never {}
}
}