Remove unecessary unreachable! calls (#8)

This commit is contained in:
Adam Wright
2017-01-08 21:36:28 -07:00
committed by Tim
parent 626254e836
commit 48452c04a6
2 changed files with 7 additions and 12 deletions

View File

@@ -59,7 +59,7 @@
//! ```
//!
#![deny(missing_docs)]
#![feature(plugin, conservative_impl_trait, never_type, proc_macro, unboxed_closures, fn_traits, specialization)]
#![feature(plugin, conservative_impl_trait, never_type, unboxed_closures, fn_traits, specialization)]
#![plugin(tarpc_plugins)]
extern crate byteorder;

View File

@@ -15,14 +15,17 @@ use tokio_core::reactor;
/// A bottom type that impls `Error`, `Serialize`, and `Deserialize`. It is impossible to
/// instantiate this type.
#[allow(unreachable_code)]
#[derive(Debug)]
pub struct Never(!);
impl fmt::Debug for Never {
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
unreachable!("Never cannot be instantiated");
}
}
impl Error for Never {
fn description(&self) -> &str {
match self.0 {
// TODO(tikue): remove when https://github.com/rust-lang/rust/issues/12609 lands
_ => unreachable!(),
}
}
}
@@ -30,8 +33,6 @@ impl Error for Never {
impl fmt::Display for Never {
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
match self.0 {
// TODO(tikue): remove when https://github.com/rust-lang/rust/issues/12609 lands
_ => unreachable!(),
}
}
}
@@ -42,8 +43,6 @@ impl Future for Never {
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
match self.0 {
// TODO(tikue): remove when https://github.com/rust-lang/rust/issues/12609 lands
_ => unreachable!(),
}
}
}
@@ -54,8 +53,6 @@ impl Stream for Never {
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
match self.0 {
// TODO(tikue): remove when https://github.com/rust-lang/rust/issues/12609 lands
_ => unreachable!(),
}
}
}
@@ -65,8 +62,6 @@ impl Serialize for Never {
where S: Serializer
{
match self.0 {
// TODO(tikue): remove when https://github.com/rust-lang/rust/issues/12609 lands
_ => unreachable!(),
}
}
}