Repository: 3Hren/msgpack-rust
Pull request #215 (2019-09-02 00:43:19)

Edition 2018

kornelski: If you get conflicts from this, run in your branch:

```
cargo +nightly fix --edition --allow-dirty --allow-staged
cargo +nightly fix --edition-idioms --allow-dirty --allow-staged
```



Patch:
diff --git a/rmp-serde/Cargo.toml b/rmp-serde/Cargo.toml
index c691281..9f93008 100644
--- a/rmp-serde/Cargo.toml
+++ b/rmp-serde/Cargo.toml
@@ -9,6 +9,7 @@ documentation = "https://docs.rs/rmp-serde"
 readme = "../README.md"
 keywords = ["msgpack", "MessagePack", "serde", "serialization"]
 categories = ["encoding"]
+edition = "2018"
 
 [dependencies]
 byteorder = "1.3.2"
diff --git a/rmp-serde/benches/buf.rs b/rmp-serde/benches/buf.rs
index 4a31499..b6e0282 100644
--- a/rmp-serde/benches/buf.rs
+++ b/rmp-serde/benches/buf.rs
@@ -2,8 +2,8 @@
 
 extern crate test;
 
-extern crate serde;
-extern crate rmp_serde;
+
+use rmp_serde;
 
 use serde::{Serialize, Deserialize};
 
diff --git a/rmp-serde/src/config.rs b/rmp-serde/src/config.rs
index aafe83d..aea707a 100644
--- a/rmp-serde/src/config.rs
+++ b/rmp-serde/src/config.rs
@@ -2,7 +2,7 @@
 use rmp::encode;
 use serde::{Serialize, Serializer};
 
-use encode::{Error, UnderlyingWrite};
+use crate::encode::{Error, UnderlyingWrite};
 
 /// Represents configuration that dicatates what the serializer does.
 ///
@@ -15,7 +15,7 @@ impl<T: sealed::SerializerConfig> SerializerConfig for T {}
 mod sealed {
     use serde::{Serialize, Serializer};
 
-    use encode::{Error, UnderlyingWrite};
+    use crate::encode::{Error, UnderlyingWrite};
 
     /// This is the inner trait - the real SerializerConfig.
     ///
diff --git a/rmp-serde/src/decode.rs b/rmp-serde/src/decode.rs
index 671a452..41c41c4 100644
--- a/rmp-serde/src/decode.rs
+++ b/rmp-serde/src/decode.rs
@@ -46,7 +46,7 @@ impl error::Error for Error {
         "error while decoding value"
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         match *self {
             Error::TypeMismatch(..) => None,
             Error::InvalidMarkerRead(ref err) => Some(err),
@@ -68,7 +68,7 @@ impl de::Error for Error {
 }
 
 impl Display for Error {
-    fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), fmt::Error> {
         match *self {
             Error::InvalidMarkerRead(ref err) => write!(fmt, "IO error while reading marker: {}", err),
             Error::InvalidDataRead(ref err) => write!(fmt, "IO error while reading data: {}", err),
@@ -125,7 +125,7 @@ impl From<NumValueReadError> for Error {
 }
 
 impl<'a> From<DecodeStringError<'a>> for Error {
-    fn from(err: DecodeStringError) -> Error {
+    fn from(err: DecodeStringError<'_>) -> Error {
         match err {
             DecodeStringError::InvalidMarkerRead(err) => Error::InvalidMarkerRead(err),
             DecodeStringError::InvalidDataRead(err) => Error::InvalidDataRead(err),
@@ -474,7 +474,7 @@ impl<'de, 'a, R: ReadSlice<'de>> serde::Deserializer<'de> for &'a mut Deserializ
     }
 }
 
-struct SeqAccess<'a, R: 'a> {
+struct SeqAccess<'a, R> {
     de: &'a mut Deserializer<R>,
     left: usize,
 }
@@ -507,7 +507,7 @@ impl<'de, 'a, R: ReadSlice<'de> + 'a> de::SeqAccess<'de> for SeqAccess<'a, R> {
     }
 }
 
-struct MapAccess<'a, R: 'a> {
+struct MapAccess<'a, R> {
     de: &'a mut Deserializer<R>,
     left: usize,
 }
@@ -546,7 +546,7 @@ impl<'de, 'a, R: ReadSlice<'de> + 'a> de::MapAccess<'de> for MapAccess<'a, R> {
     }
 }
 
-struct VariantAccess<'a, R: 'a> {
+struct VariantAccess<'a, R> {
     de: &'a mut Deserializer<R>,
 }
 
@@ -653,7 +653,7 @@ impl<R: Read> Read for ReadReader<R> {
 
 /// Borrowed reader wrapper.
 #[derive(Debug)]
-pub struct ReadRefReader<'a, R: ?Sized + 'a> {
+pub struct ReadRefReader<'a, R: ?Sized> {
     rd: &'a R,
     buf: &'a [u8],
 }
diff --git a/rmp-serde/src/encode.rs b/rmp-serde/src/encode.rs
index 2c4e9a0..444ffc2 100644
--- a/rmp-serde/src/encode.rs
+++ b/rmp-serde/src/encode.rs
@@ -12,7 +12,7 @@ use serde::ser::{SerializeMap, SerializeSeq, SerializeStruct, SerializeStructVar
 use rmp::encode;
 use rmp::encode::ValueWriteError;
 
-use config::{
+use crate::config::{
     DefaultConfig, SerializerConfig, StructMapConfig, StructTupleConfig, VariantIntegerConfig,
     VariantStringConfig,
 };
@@ -43,7 +43,7 @@ impl error::Error for Error {
         }
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         match *self {
             Error::InvalidValueWrite(ref err) => Some(err),
             Error::UnknownLength => None,
@@ -54,7 +54,7 @@ impl error::Error for Error {
 }
 
 impl Display for Error {
-    fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
         match *self {
             Error::InvalidValueWrite(ref err) => write!(f, "invalid value write: {}", err),
             Error::UnknownLength => {
diff --git a/rmp-serde/src/lib.rs b/rmp-serde/src/lib.rs
index 215337f..cea7eac 100644
--- a/rmp-serde/src/lib.rs
+++ b/rmp-serde/src/lib.rs
@@ -62,8 +62,6 @@
 
 #![warn(missing_debug_implementations, missing_docs)]
 
-extern crate rmp;
-extern crate byteorder;
 #[macro_use]
 extern crate serde;
 
@@ -74,12 +72,12 @@ use std::str::{self, Utf8Error};
 use serde::{Deserialize, Serialize};
 use serde::de;
 
-pub use decode::{Deserializer, from_read, from_read_ref, from_slice};
-pub use encode::{Serializer, to_vec, to_vec_named};
+pub use crate::decode::{Deserializer, from_read, from_read_ref, from_slice};
+pub use crate::encode::{Serializer, to_vec, to_vec_named};
 
+pub mod config;
 pub mod decode;
 pub mod encode;
-pub mod config;
 
 /// Helper that allows both to encode and decode strings no matter whether they contain valid or
 /// invalid UTF-8.
@@ -177,7 +175,7 @@ struct RawVisitor;
 impl<'de> de::Visitor<'de> for RawVisitor {
     type Value = Raw;
 
-    fn expecting(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
+    fn expecting(&self, fmt: &mut Formatter<'_>) -> Result<(), fmt::Error> {
         "string or bytes".fmt(fmt)
     }
 
@@ -312,7 +310,7 @@ struct RawRefVisitor;
 impl<'de> de::Visitor<'de> for RawRefVisitor {
     type Value = RawRef<'de>;
 
-    fn expecting(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
+    fn expecting(&self, fmt: &mut Formatter<'_>) -> Result<(), fmt::Error> {
         "string or bytes".fmt(fmt)
     }
 
diff --git a/rmp/Cargo.toml b/rmp/Cargo.toml
index fe2aa51..52ad493 100644
--- a/rmp/Cargo.toml
+++ b/rmp/Cargo.toml
@@ -9,6 +9,7 @@ documentation = "https://docs.rs/rmp"
 readme = "README.md"
 keywords = ["msgpack", "MessagePack"]
 categories = ["encoding"]
+edition = "2018"
 
 [dependencies]
 byteorder = "1.3.2"
diff --git a/rmp/benches/bench.rs b/rmp/benches/bench.rs
index d9fbaf3..dc08b3c 100644
--- a/rmp/benches/bench.rs
+++ b/rmp/benches/bench.rs
@@ -1,6 +1,5 @@
 #![feature(test)]
 
-extern crate rmp;
 extern crate test;
 
 use test::Bencher;
diff --git a/rmp/src/decode/dec.rs b/rmp/src/decode/dec.rs
index a66c246..0f59ab6 100644
--- a/rmp/src/decode/dec.rs
+++ b/rmp/src/decode/dec.rs
@@ -1,6 +1,6 @@
 use std::io::Read;
 
-use Marker;
+use crate::Marker;
 use super::{read_marker, read_data_f32, read_data_f64, ValueReadError};
 
 /// Attempts to read exactly 5 bytes from the given reader and to decode them as `f32` value.
@@ -20,8 +20,8 @@ use super::{read_marker, read_data_f32, read_data_f64, ValueReadError};
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_f32<R: Read>(rd: &mut R) -> Result<f32, ValueReadError> {
-    match try!(read_marker(rd)) {
-        Marker::F32 => Ok(try!(read_data_f32(rd))),
+    match read_marker(rd)? {
+        Marker::F32 => Ok(read_data_f32(rd)?),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
 }
@@ -43,8 +43,8 @@ pub fn read_f32<R: Read>(rd: &mut R) -> Result<f32, ValueReadError> {
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_f64<R: Read>(rd: &mut R) -> Result<f64, ValueReadError> {
-    match try!(read_marker(rd)) {
-        Marker::F64 => Ok(try!(read_data_f64(rd))),
+    match read_marker(rd)? {
+        Marker::F64 => Ok(read_data_f64(rd)?),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
 }
diff --git a/rmp/src/decode/ext.rs b/rmp/src/decode/ext.rs
index fef35db..472aa57 100644
--- a/rmp/src/decode/ext.rs
+++ b/rmp/src/decode/ext.rs
@@ -1,6 +1,6 @@
 use std::io::Read;
 
-use Marker;
+use crate::Marker;
 use super::{read_marker, read_data_i8, read_data_u8, read_data_u16, read_data_u32, ValueReadError};
 
 /// Attempts to read exactly 3 bytes from the given reader and interpret them as a fixext1 type
@@ -21,10 +21,10 @@ use super::{read_marker, read_data_i8, read_data_u8, read_data_u16, read_data_u3
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_fixext1<R: Read>(rd: &mut R) -> Result<(i8, u8), ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::FixExt1 => {
-            let ty = try!(read_data_i8(rd));
-            let data = try!(read_data_u8(rd));
+            let ty = read_data_i8(rd)?;
+            let data = read_data_u8(rd)?;
             Ok((ty, data))
         }
         marker => Err(ValueReadError::TypeMismatch(marker)),
@@ -45,7 +45,7 @@ pub fn read_fixext1<R: Read>(rd: &mut R) -> Result<(i8, u8), ValueReadError> {
 /// This function will return `ValueReadError` on any I/O error while reading either the marker or
 /// the data.
 pub fn read_fixext2<R: Read>(rd: &mut R) -> Result<(i8, [u8; 2]), ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::FixExt2 => {
             let mut buf = [0; 2];
             read_fixext_data(rd, &mut buf).map(|ty| (ty, buf))
@@ -68,7 +68,7 @@ pub fn read_fixext2<R: Read>(rd: &mut R) -> Result<(i8, [u8; 2]), ValueReadError
 /// This function will return `ValueReadError` on any I/O error while reading either the marker or
 /// the data.
 pub fn read_fixext4<R: Read>(rd: &mut R) -> Result<(i8, [u8; 4]), ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::FixExt4 => {
             let mut buf = [0; 4];
             read_fixext_data(rd, &mut buf).map(|ty| (ty, buf))
@@ -91,7 +91,7 @@ pub fn read_fixext4<R: Read>(rd: &mut R) -> Result<(i8, [u8; 4]), ValueReadError
 /// This function will return `ValueReadError` on any I/O error while reading either the marker or
 /// the data.
 pub fn read_fixext8<R: Read>(rd: &mut R) -> Result<(i8, [u8; 8]), ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::FixExt8 => {
             let mut buf = [0; 8];
             read_fixext_data(rd, &mut buf).map(|ty| (ty, buf))
@@ -114,7 +114,7 @@ pub fn read_fixext8<R: Read>(rd: &mut R) -> Result<(i8, [u8; 8]), ValueReadError
 /// This function will return `ValueReadError` on any I/O error while reading either the marker or
 /// the data.
 pub fn read_fixext16<R: Read>(rd: &mut R) -> Result<(i8, [u8; 16]), ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::FixExt16 => {
             let mut buf = [0; 16];
             read_fixext_data(rd, &mut buf).map(|ty| (ty, buf))
@@ -124,7 +124,7 @@ pub fn read_fixext16<R: Read>(rd: &mut R) -> Result<(i8, [u8; 16]), ValueReadErr
 }
 
 fn read_fixext_data<R: Read>(rd: &mut R, buf: &mut [u8]) -> Result<i8, ValueReadError> {
-    let id = try!(read_data_i8(rd));
+    let id = read_data_i8(rd)?;
     match rd.read_exact(buf) {
         Ok(()) => Ok(id),
         Err(err) => Err(ValueReadError::InvalidDataRead(From::from(err))),
@@ -157,9 +157,9 @@ pub fn read_ext_meta<R: Read>(rd: &mut R) -> Result<ExtMeta, ValueReadError> {
         Marker::FixExt4 => 4,
         Marker::FixExt8 => 8,
         Marker::FixExt16 => 16,
-        Marker::Ext8 => try!(read_data_u8(rd)) as u32,
-        Marker::Ext16 => try!(read_data_u16(rd)) as u32,
-        Marker::Ext32 => try!(read_data_u32(rd)),
+        Marker::Ext8 => read_data_u8(rd)? as u32,
+        Marker::Ext16 => read_data_u16(rd)? as u32,
+        Marker::Ext32 => read_data_u32(rd)?,
         marker => return Err(ValueReadError::TypeMismatch(marker)),
     };
 
diff --git a/rmp/src/decode/mod.rs b/rmp/src/decode/mod.rs
index 419ccbc..2d3dff2 100644
--- a/rmp/src/decode/mod.rs
+++ b/rmp/src/decode/mod.rs
@@ -9,18 +9,17 @@
 //! non-blocking socket and it returns EWOULDBLOCK) be sure that you buffer the data externally
 //! to avoid data loss (using `BufRead` readers with manual consuming or some other way).
 
-mod sint;
-mod uint;
 mod dec;
-mod str;
 mod ext;
+mod sint;
+mod str;
+mod uint;
 
 pub use self::sint::{read_nfix, read_i8, read_i16, read_i32, read_i64};
 pub use self::uint::{read_pfix, read_u8, read_u16, read_u32, read_u64};
 pub use self::dec::{read_f32, read_f64};
 pub use self::str::{read_str_len, read_str, read_str_from_slice, read_str_ref, DecodeStringError};
-pub use self::ext::{read_fixext1, read_fixext2, read_fixext4, read_fixext8, read_fixext16,
-                    read_ext_meta, ExtMeta};
+pub use self::ext::{read_fixext1, read_fixext2, read_fixext4, read_fixext8, read_fixext16, read_ext_meta, ExtMeta};
 
 use std::error;
 use std::fmt::{self, Display, Formatter};
@@ -30,7 +29,7 @@ use byteorder::{self, ReadBytesExt};
 
 use num_traits::cast::FromPrimitive;
 
-use Marker;
+use crate::Marker;
 
 /// An error that can occur when attempting to read bytes from the reader.
 pub type Error = ::std::io::Error;
@@ -61,7 +60,7 @@ impl error::Error for ValueReadError {
         }
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         match *self {
             ValueReadError::InvalidMarkerRead(ref err) |
             ValueReadError::InvalidDataRead(ref err) => Some(err),
@@ -71,7 +70,7 @@ impl error::Error for ValueReadError {
 }
 
 impl Display for ValueReadError {
-    fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
         error::Error::description(self).fmt(f)
     }
 }
@@ -92,7 +91,7 @@ impl From<Error> for MarkerReadError {
 
 /// Attempts to read a single byte from the given reader and to decode it as a MessagePack marker.
 pub fn read_marker<R: Read>(rd: &mut R) -> Result<Marker, MarkerReadError> {
-    Ok(Marker::from_u8(try!(rd.read_u8())))
+    Ok(Marker::from_u8(rd.read_u8()?))
 }
 
 /// Attempts to read a single byte from the given reader and to decode it as a nil value.
@@ -112,7 +111,7 @@ pub fn read_marker<R: Read>(rd: &mut R) -> Result<Marker, MarkerReadError> {
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_nil<R: Read>(rd: &mut R) -> Result<(), ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::Null => Ok(()),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
@@ -136,7 +135,7 @@ pub fn read_nil<R: Read>(rd: &mut R) -> Result<(), ValueReadError> {
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_bool<R: Read>(rd: &mut R) -> Result<bool, ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::True => Ok(true),
         Marker::False => Ok(false),
         marker => Err(ValueReadError::TypeMismatch(marker)),
@@ -168,7 +167,7 @@ impl error::Error for NumValueReadError {
         }
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         match *self {
             NumValueReadError::InvalidMarkerRead(ref err) |
             NumValueReadError::InvalidDataRead(ref err) => Some(err),
@@ -179,7 +178,7 @@ impl error::Error for NumValueReadError {
 }
 
 impl Display for NumValueReadError {
-    fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
         error::Error::description(self).fmt(f)
     }
 }
@@ -285,17 +284,17 @@ pub fn read_data_f64<R: Read>(rd: &mut R) -> Result<f64, ValueReadError> {
 /// assert_eq!(300isize, rmp::decode::read_int(&mut &buf[..]).unwrap());
 /// ```
 pub fn read_int<T: FromPrimitive, R: Read>(rd: &mut R) -> Result<T, NumValueReadError> {
-    let val = match try!(read_marker(rd)) {
+    let val = match read_marker(rd)? {
         Marker::FixPos(val) => T::from_u8(val),
         Marker::FixNeg(val) => T::from_i8(val),
-        Marker::U8 => T::from_u8(try!(read_data_u8(rd))),
-        Marker::U16 => T::from_u16(try!(read_data_u16(rd))),
-        Marker::U32 => T::from_u32(try!(read_data_u32(rd))),
-        Marker::U64 => T::from_u64(try!(read_data_u64(rd))),
-        Marker::I8 => T::from_i8(try!(read_data_i8(rd))),
-        Marker::I16 => T::from_i16(try!(read_data_i16(rd))),
-        Marker::I32 => T::from_i32(try!(read_data_i32(rd))),
-        Marker::I64 => T::from_i64(try!(read_data_i64(rd))),
+        Marker::U8 => T::from_u8(read_data_u8(rd)?),
+        Marker::U16 => T::from_u16(read_data_u16(rd)?),
+        Marker::U32 => T::from_u32(read_data_u32(rd)?),
+        Marker::U64 => T::from_u64(read_data_u64(rd)?),
+        Marker::I8 => T::from_i8(read_data_i8(rd)?),
+        Marker::I16 => T::from_i16(read_data_i16(rd)?),
+        Marker::I32 => T::from_i32(read_data_i32(rd)?),
+        Marker::I64 => T::from_i64(read_data_i64(rd)?),
         marker => return Err(NumValueReadError::TypeMismatch(marker)),
     };
 
@@ -315,12 +314,13 @@ pub fn read_int<T: FromPrimitive, R: Read>(rd: &mut R) -> Result<T, NumValueRead
 // TODO: Docs.
 // NOTE: EINTR is managed internally.
 pub fn read_array_len<R>(rd: &mut R) -> Result<u32, ValueReadError>
-    where R: Read
+where
+    R: Read,
 {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::FixArray(size) => Ok(size as u32),
-        Marker::Array16 => Ok(try!(read_data_u16(rd)) as u32),
-        Marker::Array32 => Ok(try!(read_data_u32(rd))),
+        Marker::Array16 => Ok(read_data_u16(rd)? as u32),
+        Marker::Array32 => Ok(read_data_u32(rd)?),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
 }
@@ -344,8 +344,8 @@ pub fn read_map_len<R: Read>(rd: &mut R) -> Result<u32, ValueReadError> {
 pub fn marker_to_len<R: Read>(rd: &mut R, marker: Marker) -> Result<u32, ValueReadError> {
     match marker {
         Marker::FixMap(size) => Ok(size as u32),
-        Marker::Map16 => Ok(try!(read_data_u16(rd)) as u32),
-        Marker::Map32 => Ok(try!(read_data_u32(rd))),
+        Marker::Map16 => Ok(read_data_u16(rd)? as u32),
+        Marker::Map32 => Ok(read_data_u32(rd)?),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
 }
@@ -358,10 +358,10 @@ pub fn marker_to_len<R: Read>(rd: &mut R, marker: Marker) -> Result<u32, ValueRe
 /// successful read.
 // TODO: Docs.
 pub fn read_bin_len<R: Read>(rd: &mut R) -> Result<u32, ValueReadError> {
-    match try!(read_marker(rd)) {
-        Marker::Bin8 => Ok(try!(read_data_u8(rd)) as u32),
-        Marker::Bin16 => Ok(try!(read_data_u16(rd)) as u32),
-        Marker::Bin32 => Ok(try!(read_data_u32(rd))),
+    match read_marker(rd)? {
+        Marker::Bin8 => Ok(read_data_u8(rd)? as u32),
+        Marker::Bin16 => Ok(read_data_u16(rd)? as u32),
+        Marker::Bin32 => Ok(read_data_u32(rd)?),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
 }
diff --git a/rmp/src/decode/sint.rs b/rmp/src/decode/sint.rs
index d4b9e26..af46039 100644
--- a/rmp/src/decode/sint.rs
+++ b/rmp/src/decode/sint.rs
@@ -1,6 +1,6 @@
 use std::io::Read;
 
-use Marker;
+use crate::Marker;
 use super::{read_marker, read_data_i8, read_data_i16, read_data_i32, read_data_i64, ValueReadError};
 
 /// Attempts to read a single byte from the given reader and to decode it as a negative fixnum
@@ -22,7 +22,7 @@ use super::{read_marker, read_data_i8, read_data_i16, read_data_i32, read_data_i
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_nfix<R: Read>(rd: &mut R) -> Result<i8, ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::FixNeg(val) => Ok(val),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
@@ -45,7 +45,7 @@ pub fn read_nfix<R: Read>(rd: &mut R) -> Result<i8, ValueReadError> {
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_i8<R: Read>(rd: &mut R) -> Result<i8, ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::I8 => read_data_i8(rd),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
@@ -68,7 +68,7 @@ pub fn read_i8<R: Read>(rd: &mut R) -> Result<i8, ValueReadError> {
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_i16<R: Read>(rd: &mut R) -> Result<i16, ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::I16 => read_data_i16(rd),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
@@ -91,7 +91,7 @@ pub fn read_i16<R: Read>(rd: &mut R) -> Result<i16, ValueReadError> {
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_i32<R: Read>(rd: &mut R) -> Result<i32, ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::I32 => read_data_i32(rd),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
@@ -114,7 +114,7 @@ pub fn read_i32<R: Read>(rd: &mut R) -> Result<i32, ValueReadError> {
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_i64<R: Read>(rd: &mut R) -> Result<i64, ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::I64 => read_data_i64(rd),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
diff --git a/rmp/src/decode/str.rs b/rmp/src/decode/str.rs
index 4041f1c..df8aadf 100644
--- a/rmp/src/decode/str.rs
+++ b/rmp/src/decode/str.rs
@@ -3,7 +3,7 @@ use std::io::{self, Read};
 use std::fmt::{self, Display, Formatter};
 use std::str::{Utf8Error, from_utf8};
 
-use Marker;
+use crate::Marker;
 use super::{read_marker, read_data_u8, read_data_u16, read_data_u32, Error, ValueReadError};
 
 #[derive(Debug)]
@@ -21,7 +21,7 @@ impl<'a> error::Error for DecodeStringError<'a> {
         "error while decoding string"
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         match *self {
             DecodeStringError::InvalidMarkerRead(ref err) |
             DecodeStringError::InvalidDataRead(ref err) => Some(err),
@@ -33,7 +33,7 @@ impl<'a> error::Error for DecodeStringError<'a> {
 }
 
 impl<'a> Display for DecodeStringError<'a> {
-    fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
         error::Error::description(self).fmt(f)
     }
 }
@@ -108,9 +108,10 @@ fn read_str_len_with_nread<R>(rd: &mut R) -> Result<(u32, usize), ValueReadError
 /// This function is **unstable**, because it needs review.
 // TODO: Stabilize. Mark error values for each error case (in docs).
 pub fn read_str<'r, R>(rd: &mut R, buf: &'r mut [u8]) -> Result<&'r str, DecodeStringError<'r>>
-    where R: Read
+where
+    R: Read,
 {
-    let len = try!(read_str_len(rd));
+    let len = read_str_len(rd)?;
     let ulen = len as usize;
 
     if buf.len() < ulen {
@@ -144,9 +145,9 @@ pub fn read_str_data<'r, R>(rd: &mut R,
 ///
 // TODO: Also it's possible to implement all borrowing functions for all `BufRead` implementors.
 #[deprecated(since = "0.8.6", note = "useless, use `read_str_from_slice` instead")]
-pub fn read_str_ref(rd: &[u8]) -> Result<&[u8], DecodeStringError> {
+pub fn read_str_ref(rd: &[u8]) -> Result<&[u8], DecodeStringError<'_>> {
     let mut cur = io::Cursor::new(rd);
-    let len = try!(read_str_len(&mut cur));
+    let len = read_str_len(&mut cur)?;
     let start = cur.position() as usize;
     Ok(&rd[start..start + len as usize])
 }
@@ -174,7 +175,7 @@ pub fn read_str_ref(rd: &[u8]) -> Result<&[u8], DecodeStringError> {
 /// assert_eq!(vec!["Unpacking", "multiple", "strings"], chunks);
 /// ```
 pub fn read_str_from_slice<T: ?Sized + AsRef<[u8]>>(buf: &T) ->
-    Result<(&str, &[u8]), DecodeStringError>
+    Result<(&str, &[u8]), DecodeStringError<'_>>
 {
     let buf = buf.as_ref();
     let (len, nread) = read_str_len_with_nread(&mut &buf[..])?;
diff --git a/rmp/src/decode/uint.rs b/rmp/src/decode/uint.rs
index a18f1c9..941f709 100644
--- a/rmp/src/decode/uint.rs
+++ b/rmp/src/decode/uint.rs
@@ -1,6 +1,6 @@
 use std::io::Read;
 
-use Marker;
+use crate::Marker;
 use super::{read_marker, read_data_u8, read_data_u16, read_data_u32, read_data_u64, ValueReadError};
 
 /// Attempts to read a single byte from the given reader and to decode it as a positive fixnum
@@ -22,7 +22,7 @@ use super::{read_marker, read_data_u8, read_data_u16, read_data_u32, read_data_u
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_pfix<R: Read>(rd: &mut R) -> Result<u8, ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::FixPos(val) => Ok(val),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
@@ -40,7 +40,7 @@ pub fn read_pfix<R: Read>(rd: &mut R) -> Result<u8, ValueReadError> {
 /// It also returns `ValueReadError::TypeMismatch` if the actual type is not equal with the
 /// expected one, indicating you with the actual type.
 pub fn read_u8<R: Read>(rd: &mut R) -> Result<u8, ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::U8 => read_data_u8(rd),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
@@ -63,7 +63,7 @@ pub fn read_u8<R: Read>(rd: &mut R) -> Result<u8, ValueReadError> {
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_u16<R: Read>(rd: &mut R) -> Result<u16, ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::U16 => read_data_u16(rd),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
@@ -86,7 +86,7 @@ pub fn read_u16<R: Read>(rd: &mut R) -> Result<u16, ValueReadError> {
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_u32<R: Read>(rd: &mut R) -> Result<u32, ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::U32 => read_data_u32(rd),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
@@ -109,7 +109,7 @@ pub fn read_u32<R: Read>(rd: &mut R) -> Result<u32, ValueReadError> {
 /// This function will silently retry on every EINTR received from the underlying `Read` until
 /// successful read.
 pub fn read_u64<R: Read>(rd: &mut R) -> Result<u64, ValueReadError> {
-    match try!(read_marker(rd)) {
+    match read_marker(rd)? {
         Marker::U64 => read_data_u64(rd),
         marker => Err(ValueReadError::TypeMismatch(marker)),
     }
diff --git a/rmp/src/encode/bin.rs b/rmp/src/encode/bin.rs
index ace69a9..8f82f08 100644
--- a/rmp/src/encode/bin.rs
+++ b/rmp/src/encode/bin.rs
@@ -1,7 +1,7 @@
 use std::io::Write;
 
-use Marker;
-use encode::{write_marker, ValueWriteError};
+use crate::Marker;
+use crate::encode::{write_marker, ValueWriteError};
 use super::{write_data_u8, write_data_u16, write_data_u32};
 
 /// Encodes and attempts to write the most efficient binary array length implementation to the given
@@ -16,16 +16,16 @@ use super::{write_data_u8, write_data_u16, write_data_u32};
 /// marker or the data.
 pub fn write_bin_len<W: Write>(wr: &mut W, len: u32) -> Result<Marker, ValueWriteError> {
     if len < 256 {
-        try!(write_marker(wr, Marker::Bin8));
-        try!(write_data_u8(wr, len as u8));
+        write_marker(wr, Marker::Bin8)?;
+        write_data_u8(wr, len as u8)?;
         Ok(Marker::Bin8)
     } else if len < 65536 {
-        try!(write_marker(wr, Marker::Bin16));
-        try!(write_data_u16(wr, len as u16));
+        write_marker(wr, Marker::Bin16)?;
+        write_data_u16(wr, len as u16)?;
         Ok(Marker::Bin16)
     } else {
-        try!(write_marker(wr, Marker::Bin32));
-        try!(write_data_u32(wr, len));
+        write_marker(wr, Marker::Bin32)?;
+        write_data_u32(wr, len)?;
         Ok(Marker::Bin32)
     }
 }
@@ -38,6 +38,6 @@ pub fn write_bin_len<W: Write>(wr: &mut W, len: u32) -> Result<Marker, ValueWrit
 /// marker or the data.
 // TODO: Docs, range check, example, visibility.
 pub fn write_bin<W: Write>(wr: &mut W, data: &[u8]) -> Result<(), ValueWriteError> {
-    try!(write_bin_len(wr, data.len() as u32));
+    write_bin_len(wr, data.len() as u32)?;
     wr.write_all(data).map_err(ValueWriteError::InvalidDataWrite)
 }
diff --git a/rmp/src/encode/dec.rs b/rmp/src/encode/dec.rs
index 82a71fc..28dc816 100644
--- a/rmp/src/encode/dec.rs
+++ b/rmp/src/encode/dec.rs
@@ -1,7 +1,7 @@
 use std::io::Write;
 
-use Marker;
-use encode::ValueWriteError;
+use crate::Marker;
+use crate::encode::ValueWriteError;
 use super::{write_marker, write_data_f32, write_data_f64};
 
 /// Encodes and attempts to write an `f32` value as a 5-byte sequence into the given write.
@@ -13,8 +13,8 @@ use super::{write_marker, write_data_f32, write_data_f64};
 /// This function will return `ValueWriteError` on any I/O error occurred while writing either the
 /// marker or the data.
 pub fn write_f32<W: Write>(wr: &mut W, val: f32) -> Result<(), ValueWriteError> {
-    try!(write_marker(wr, Marker::F32));
-    try!(write_data_f32(wr, val));
+    write_marker(wr, Marker::F32)?;
+    write_data_f32(wr, val)?;
     Ok(())
 }
 
@@ -27,7 +27,7 @@ pub fn write_f32<W: Write>(wr: &mut W, val: f32) -> Result<(), ValueWriteError>
 /// This function will return `ValueWriteError` on any I/O error occurred while writing either the
 /// marker or the data.
 pub fn write_f64<W: Write>(wr: &mut W, val: f64) -> Result<(), ValueWriteError> {
-    try!(write_marker(wr, Marker::F64));
-    try!(write_data_f64(wr, val));
+    write_marker(wr, Marker::F64)?;
+    write_data_f64(wr, val)?;
     Ok(())
 }
diff --git a/rmp/src/encode/mod.rs b/rmp/src/encode/mod.rs
index 42b9942..b3676c7 100644
--- a/rmp/src/encode/mod.rs
+++ b/rmp/src/encode/mod.rs
@@ -1,13 +1,13 @@
 //! Provides various functions and structs for MessagePack encoding.
 
-mod sint;
-mod uint;
+mod bin;
 mod dec;
+mod ext;
+mod map;
+mod sint;
 mod str;
-mod bin;
+mod uint;
 mod vec;
-mod map;
-mod ext;
 
 pub use self::sint::{write_nfix, write_i8, write_i16, write_i32, write_i64, write_sint};
 pub use self::uint::{write_pfix, write_u8, write_u16, write_u32, write_u64, write_uint};
@@ -21,7 +21,7 @@ use std::io::Write;
 
 use byteorder::{self, WriteBytesExt};
 
-use Marker;
+use crate::Marker;
 
 /// The error type for I/O operations of the `Write` and associated traits.
 pub type Error = ::std::io::Error;
@@ -182,7 +182,7 @@ impl error::Error for ValueWriteError {
         "error while writing multi-byte MessagePack value"
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         match *self {
             ValueWriteError::InvalidMarkerWrite(ref err) |
             ValueWriteError::InvalidDataWrite(ref err) => Some(err),
@@ -191,7 +191,7 @@ impl error::Error for ValueWriteError {
 }
 
 impl Display for ValueWriteError {
-    fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
         error::Error::description(self).fmt(f)
     }
 }
@@ -205,15 +205,15 @@ impl Display for ValueWriteError {
 /// marker or the data.
 pub fn write_array_len<W: Write>(wr: &mut W, len: u32) -> Result<Marker, ValueWriteError> {
     let marker = if len < 16 {
-        try!(write_marker(wr, Marker::FixArray(len as u8)));
+        r#try!(write_marker(wr, Marker::FixArray(len as u8)));
         Marker::FixArray(len as u8)
     } else if len < 65536 {
-        try!(write_marker(wr, Marker::Array16));
-        try!(write_data_u16(wr, len as u16));
+        write_marker(wr, Marker::Array16)?;
+        write_data_u16(wr, len as u16)?;
         Marker::Array16
     } else {
-        try!(write_marker(wr, Marker::Array32));
-        try!(write_data_u32(wr, len));
+        write_marker(wr, Marker::Array32)?;
+        write_data_u32(wr, len)?;
         Marker::Array32
     };
 
@@ -229,15 +229,15 @@ pub fn write_array_len<W: Write>(wr: &mut W, len: u32) -> Result<Marker, ValueWr
 /// marker or the data.
 pub fn write_map_len<W: Write>(wr: &mut W, len: u32) -> Result<Marker, ValueWriteError> {
     let marker = if len < 16 {
-        try!(write_marker(wr, Marker::FixMap(len as u8)));
+        r#try!(write_marker(wr, Marker::FixMap(len as u8)));
         Marker::FixMap(len as u8)
     } else if len < 65536 {
-        try!(write_marker(wr, Marker::Map16));
-        try!(write_data_u16(wr, len as u16));
+        write_marker(wr, Marker::Map16)?;
+        write_data_u16(wr, len as u16)?;
         Marker::Map16
     } else {
-        try!(write_marker(wr, Marker::Map32));
-        try!(write_data_u32(wr, len));
+        write_marker(wr, Marker::Map32)?;
+        write_data_u32(wr, len)?;
         Marker::Map32
     };
 
@@ -261,43 +261,43 @@ pub fn write_ext_meta<W: Write>(wr: &mut W, len: u32, ty: i8) -> Result<Marker,
 
     let marker = match len {
         1 => {
-            try!(write_marker(wr, Marker::FixExt1));
+            write_marker(wr, Marker::FixExt1)?;
             Marker::FixExt1
         }
         2 => {
-            try!(write_marker(wr, Marker::FixExt2));
+            write_marker(wr, Marker::FixExt2)?;
             Marker::FixExt2
         }
         4 => {
-            try!(write_marker(wr, Marker::FixExt4));
+            write_marker(wr, Marker::FixExt4)?;
             Marker::FixExt4
         }
         8 => {
-            try!(write_marker(wr, Marker::FixExt8));
+            write_marker(wr, Marker::FixExt8)?;
             Marker::FixExt8
         }
         16 => {
-            try!(write_marker(wr, Marker::FixExt16));
+            write_marker(wr, Marker::FixExt16)?;
             Marker::FixExt16
         }
         len if len < 256 => {
-            try!(write_marker(wr, Marker::Ext8));
-            try!(write_data_u8(wr, len as u8));
+            write_marker(wr, Marker::Ext8)?;
+            write_data_u8(wr, len as u8)?;
             Marker::Ext8
         }
         len if len < 65536 => {
-            try!(write_marker(wr, Marker::Ext16));
-            try!(write_data_u16(wr, len as u16));
+            write_marker(wr, Marker::Ext16)?;
+            write_data_u16(wr, len as u16)?;
             Marker::Ext16
         }
         len => {
-            try!(write_marker(wr, Marker::Ext32));
-            try!(write_data_u32(wr, len));
+            write_marker(wr, Marker::Ext32)?;
+            write_data_u32(wr, len)?;
             Marker::Ext32
         }
     };
 
-    try!(write_data_i8(wr, ty));
+    write_data_i8(wr, ty)?;
 
     Ok(marker)
 }
diff --git a/rmp/src/encode/sint.rs b/rmp/src/encode/sint.rs
index 338cce2..41fb22e 100644
--- a/rmp/src/encode/sint.rs
+++ b/rmp/src/encode/sint.rs
@@ -1,7 +1,7 @@
 use std::io::Write;
 
-use Marker;
-use encode::{write_pfix, write_u8, write_u16, write_u32, write_u64, Error, ValueWriteError};
+use crate::Marker;
+use crate::encode::{write_pfix, write_u8, write_u16, write_u32, write_u64, Error, ValueWriteError};
 use super::{write_data_i8, write_data_i16, write_data_i32, write_data_i64, write_marker};
 
 /// Encodes and attempts to write a negative small integer value as a negative fixnum into the
@@ -26,7 +26,7 @@ use super::{write_data_i8, write_data_i16, write_data_i32, write_data_i64, write
 /// Panics if `val` does not fit in `[-32; 0)` range.
 pub fn write_nfix<W: Write>(wr: &mut W, val: i8) -> Result<(), Error> {
     assert!(-32 <= val && val < 0);
-    try!(write_marker(wr, Marker::FixNeg(val)));
+    r#try!(write_marker(wr, Marker::FixNeg(val)));
     Ok(())
 }
 
@@ -59,8 +59,8 @@ pub fn write_nfix<W: Write>(wr: &mut W, val: i8) -> Result<(), Error> {
 /// assert_eq!([0xd0, 0xee], buf);
 /// ```
 pub fn write_i8<W: Write>(wr: &mut W, val: i8) -> Result<(), ValueWriteError> {
-    try!(write_marker(wr, Marker::I8));
-    try!(write_data_i8(wr, val));
+    write_marker(wr, Marker::I8)?;
+    write_data_i8(wr, val)?;
     Ok(())
 }
 
@@ -80,8 +80,8 @@ pub fn write_i8<W: Write>(wr: &mut W, val: i8) -> Result<(), ValueWriteError> {
 /// This function will return `ValueWriteError` on any I/O error occurred while writing either the
 /// marker or the data.
 pub fn write_i16<W: Write>(wr: &mut W, val: i16) -> Result<(), ValueWriteError> {
-    try!(write_marker(wr, Marker::I16));
-    try!(write_data_i16(wr, val));
+    write_marker(wr, Marker::I16)?;
+    write_data_i16(wr, val)?;
     Ok(())
 }
 
@@ -101,8 +101,8 @@ pub fn write_i16<W: Write>(wr: &mut W, val: i16) -> Result<(), ValueWriteError>
 /// This function will return `ValueWriteError` on any I/O error occurred while writing either the
 /// marker or the data.
 pub fn write_i32<W: Write>(wr: &mut W, val: i32) -> Result<(), ValueWriteError> {
-    try!(write_marker(wr, Marker::I32));
-    try!(write_data_i32(wr, val));
+    write_marker(wr, Marker::I32)?;
+    write_data_i32(wr, val)?;
     Ok(())
 }
 
@@ -122,8 +122,8 @@ pub fn write_i32<W: Write>(wr: &mut W, val: i32) -> Result<(), ValueWriteError>
 /// This function will return `ValueWriteError` on any I/O error occurred while writing either the
 /// marker or the data.
 pub fn write_i64<W: Write>(wr: &mut W, val: i64) -> Result<(), ValueWriteError> {
-    try!(write_marker(wr, Marker::I64));
-    try!(write_data_i64(wr, val));
+    write_marker(wr, Marker::I64)?;
+    write_data_i64(wr, val)?;
     Ok(())
 }
 
diff --git a/rmp/src/encode/str.rs b/rmp/src/encode/str.rs
index b7a6857..110c3a7 100644
--- a/rmp/src/encode/str.rs
+++ b/rmp/src/encode/str.rs
@@ -1,7 +1,7 @@
 use std::io::Write;
 
-use Marker;
-use encode::ValueWriteError;
+use crate::Marker;
+use crate::encode::ValueWriteError;
 use super::{write_marker, write_data_u8, write_data_u16, write_data_u32};
 
 /// Encodes and attempts to write the most efficient string length implementation to the given
@@ -13,19 +13,19 @@ use super::{write_marker, write_data_u8, write_data_u16, write_data_u32};
 /// marker or the data.
 pub fn write_str_len<W: Write>(wr: &mut W, len: u32) -> Result<Marker, ValueWriteError> {
     if len < 32 {
-        try!(write_marker(wr, Marker::FixStr(len as u8)));
+        r#try!(write_marker(wr, Marker::FixStr(len as u8)));
         Ok(Marker::FixStr(len as u8))
     } else if len < 256 {
-        try!(write_marker(wr, Marker::Str8));
-        try!(write_data_u8(wr, len as u8));
+        write_marker(wr, Marker::Str8)?;
+        write_data_u8(wr, len as u8)?;
         Ok(Marker::Str8)
     } else if len < 65536 {
-        try!(write_marker(wr, Marker::Str16));
-        try!(write_data_u16(wr, len as u16));
+        write_marker(wr, Marker::Str16)?;
+        write_data_u16(wr, len as u16)?;
         Ok(Marker::Str16)
     } else {
-        try!(write_marker(wr, Marker::Str32));
-        try!(write_data_u32(wr, len));
+        write_marker(wr, Marker::Str32)?;
+        write_data_u32(wr, len)?;
         Ok(Marker::Str32)
     }
 }
@@ -39,6 +39,6 @@ pub fn write_str_len<W: Write>(wr: &mut W, len: u32) -> Result<Marker, ValueWrit
 /// marker or the data.
 // TODO: Docs, range check, example, visibility.
 pub fn write_str<W: Write>(wr: &mut W, data: &str) -> Result<(), ValueWriteError> {
-    try!(write_str_len(wr, data.len() as u32));
+    r#try!(write_str_len(wr, data.len() as u32));
     wr.write_all(data.as_bytes()).map_err(ValueWriteError::InvalidDataWrite)
 }
diff --git a/rmp/src/encode/uint.rs b/rmp/src/encode/uint.rs
index a16167d..f3e6488 100644
--- a/rmp/src/encode/uint.rs
+++ b/rmp/src/encode/uint.rs
@@ -1,7 +1,7 @@
 use std::io::Write;
 
-use Marker;
-use encode::{Error, ValueWriteError};
+use crate::Marker;
+use crate::encode::{Error, ValueWriteError};
 use super::{write_data_u8, write_data_u16, write_data_u32, write_data_u64, write_marker};
 
 /// Encodes and attempts to write an unsigned small integer value as a positive fixint into the
@@ -26,7 +26,7 @@ use super::{write_data_u8, write_data_u16, write_data_u32, write_data_u64, write
 /// Panics if `val` is greater than 127.
 pub fn write_pfix<W: Write>(wr: &mut W, val: u8) -> Result<(), Error> {
     assert!(val < 128);
-    try!(write_marker(wr, Marker::FixPos(val)));
+    r#try!(write_marker(wr, Marker::FixPos(val)));
     Ok(())
 }
 
@@ -57,8 +57,8 @@ pub fn write_pfix<W: Write>(wr: &mut W, val: u8) -> Result<(), Error> {
 /// assert_eq!([0xcc, 0x2a], buf);
 /// ```
 pub fn write_u8<W: Write>(wr: &mut W, val: u8) -> Result<(), ValueWriteError> {
-    try!(write_marker(wr, Marker::U8));
-    try!(write_data_u8(wr, val));
+    write_marker(wr, Marker::U8)?;
+    write_data_u8(wr, val)?;
     Ok(())
 }
 
@@ -77,8 +77,8 @@ pub fn write_u8<W: Write>(wr: &mut W, val: u8) -> Result<(), ValueWriteError> {
 /// This function will return `ValueWriteError` on any I/O error occurred while writing either the
 /// marker or the data.
 pub fn write_u16<W: Write>(wr: &mut W, val: u16) -> Result<(), ValueWriteError> {
-    try!(write_marker(wr, Marker::U16));
-    try!(write_data_u16(wr, val));
+    write_marker(wr, Marker::U16)?;
+    write_data_u16(wr, val)?;
     Ok(())
 }
 
@@ -97,8 +97,8 @@ pub fn write_u16<W: Write>(wr: &mut W, val: u16) -> Result<(), ValueWriteError>
 /// This function will return `ValueWriteError` on any I/O error occurred while writing either the
 /// marker or the data.
 pub fn write_u32<W: Write>(wr: &mut W, val: u32) -> Result<(), ValueWriteError> {
-    try!(write_marker(wr, Marker::U32));
-    try!(write_data_u32(wr, val));
+    write_marker(wr, Marker::U32)?;
+    write_data_u32(wr, val)?;
     Ok(())
 }
 
@@ -117,8 +117,8 @@ pub fn write_u32<W: Write>(wr: &mut W, val: u32) -> Result<(), ValueWriteError>
 /// This function will return `ValueWriteError` on any I/O error occurred while writing either the
 /// marker or the data.
 pub fn write_u64<W: Write>(wr: &mut W, val: u64) -> Result<(), ValueWriteError> {
-    try!(write_marker(wr, Marker::U64));
-    try!(write_data_u64(wr, val));
+    write_marker(wr, Marker::U64)?;
+    write_data_u64(wr, val)?;
     Ok(())
 }
 
diff --git a/rmp/src/lib.rs b/rmp/src/lib.rs
index 86ab6df..b4d572b 100644
--- a/rmp/src/lib.rs
+++ b/rmp/src/lib.rs
@@ -148,14 +148,11 @@
 //!
 //! [read_int]: decode/fn.read_int.html
 
-extern crate byteorder;
-extern crate num_traits;
-
-mod marker;
-pub mod encode;
 pub mod decode;
+pub mod encode;
+mod marker;
 
-pub use marker::Marker;
+pub use crate::marker::Marker;
 
 /// Version of the MessagePack [spec](http://github.com/msgpack/msgpack/blob/master/spec.md).
 pub const MSGPACK_VERSION: u32 = 5;
diff --git a/rmp/src/marker.rs b/rmp/src/marker.rs
index a1e5f85..fb393c8 100644
--- a/rmp/src/marker.rs
+++ b/rmp/src/marker.rs
@@ -48,11 +48,11 @@ impl Marker {
     /// Construct a msgpack marker from a single byte.
     pub fn from_u8(n: u8) -> Marker {
         match n {
-            0x00 ... 0x7f => Marker::FixPos(n),
-            0xe0 ... 0xff => Marker::FixNeg(n as i8),
-            0x80 ... 0x8f => Marker::FixMap(n & FIXMAP_SIZE),
-            0x90 ... 0x9f => Marker::FixArray(n & FIXARRAY_SIZE),
-            0xa0 ... 0xbf => Marker::FixStr(n & FIXSTR_SIZE),
+            0x00 ..= 0x7f => Marker::FixPos(n),
+            0xe0 ..= 0xff => Marker::FixNeg(n as i8),
+            0x80 ..= 0x8f => Marker::FixMap(n & FIXMAP_SIZE),
+            0x90 ..= 0x9f => Marker::FixArray(n & FIXARRAY_SIZE),
+            0xa0 ..= 0xbf => Marker::FixStr(n & FIXSTR_SIZE),
             0xc0 => Marker::Null,
             // Marked in MessagePack spec as never used.
             0xc1 => Marker::Reserved,
diff --git a/rmpv/Cargo.toml b/rmpv/Cargo.toml
index 8627e24..20c3c1e 100644
--- a/rmpv/Cargo.toml
+++ b/rmpv/Cargo.toml
@@ -9,13 +9,14 @@ documentation = "https://docs.rs/rmpv"
 readme = "../README.md"
 keywords = ["msgpack", "MessagePack", "serialization"]
 categories = ["encoding"]
+edition = "2018"
 
 [features]
 with-serde = ["serde", "serde_bytes"]
 
 [dependencies]
 serde_bytes = { version = "0.11.2", optional = true }
-rmp = "0.8.7"
+rmp = { version = "0.8.8", path = "../rmp" }
 num-traits = "0.2.8"
 serde = { version = "1.0.99", optional = true }
 
diff --git a/rmpv/src/decode/mod.rs b/rmpv/src/decode/mod.rs
index bb7dd0f..c0d2c3e 100644
--- a/rmpv/src/decode/mod.rs
+++ b/rmpv/src/decode/mod.rs
@@ -36,7 +36,7 @@ impl error::Error for Error {
         }
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         match *self {
             Error::InvalidMarkerRead(ref err) => Some(err),
             Error::InvalidDataRead(ref err) => Some(err),
@@ -45,7 +45,7 @@ impl error::Error for Error {
 }
 
 impl Display for Error {
-    fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), fmt::Error> {
         match *self {
             Error::InvalidMarkerRead(ref err) => {
                 write!(fmt, "I/O error while reading marker byte: {}", err)
diff --git a/rmpv/src/decode/value.rs b/rmpv/src/decode/value.rs
index 0153426..5c5c125 100644
--- a/rmpv/src/decode/value.rs
+++ b/rmpv/src/decode/value.rs
@@ -5,7 +5,7 @@ use rmp::decode::{read_marker, read_data_u8, read_data_u16, read_data_u32, read_
                   read_data_i8, read_data_i16, read_data_i32, read_data_i64, read_data_f32,
                   read_data_f64};
 
-use {Utf8String, Value};
+use crate::{Utf8String, Value};
 use super::Error;
 
 fn read_array_data<R: Read>(rd: &mut R, mut len: usize) -> Result<Vec<Value>, Error> {
diff --git a/rmpv/src/decode/value_ref.rs b/rmpv/src/decode/value_ref.rs
index b6fe6ea..383ab9a 100644
--- a/rmpv/src/decode/value_ref.rs
+++ b/rmpv/src/decode/value_ref.rs
@@ -7,7 +7,7 @@ use rmp::decode::{read_marker, read_data_u8, read_data_u16, read_data_u32, read_
                   read_data_i8, read_data_i16, read_data_i32, read_data_i64, read_data_f32,
                   read_data_f64};
 
-use {Utf8StringRef, ValueRef};
+use crate::{Utf8StringRef, ValueRef};
 use super::Error;
 
 fn read_str_data<'a, R>(rd: &mut R, len: usize) -> Result<Utf8StringRef<'a>, Error>
@@ -153,7 +153,6 @@ impl<'a> BorrowRead<'a> for Cursor<&'a [u8]> {
 pub fn read_value_ref<'a, R>(rd: &mut R) -> Result<ValueRef<'a>, Error>
     where R: BorrowRead<'a>
 {
-    let mut rd = rd;
 
     // Reading the marker involves either 1 byte read or nothing. On success consumes strictly
     // 1 byte from the `rd`.
diff --git a/rmpv/src/encode/value.rs b/rmpv/src/encode/value.rs
index 45f1787..8f5e531 100644
--- a/rmpv/src/encode/value.rs
+++ b/rmpv/src/encode/value.rs
@@ -3,7 +3,7 @@ use std::io::Write;
 use rmp::encode::{write_nil, write_bool, write_uint, write_sint, write_f32, write_f64, write_str,
                   write_bin, write_array_len, write_map_len, write_ext_meta};
 
-use {Integer, IntPriv, Utf8String, Value};
+use crate::{Integer, IntPriv, Utf8String, Value};
 use super::Error;
 
 /// Encodes and attempts to write the most efficient representation of the given Value.
diff --git a/rmpv/src/encode/value_ref.rs b/rmpv/src/encode/value_ref.rs
index 6a6f61a..667dfd2 100644
--- a/rmpv/src/encode/value_ref.rs
+++ b/rmpv/src/encode/value_ref.rs
@@ -3,7 +3,7 @@ use std::io::Write;
 use rmp::encode::{write_bool, write_nil, write_sint, write_uint, write_f32, write_f64, write_str,
                   write_bin, write_array_len, write_map_len, write_ext_meta};
 
-use {Integer, IntPriv, Utf8StringRef, ValueRef};
+use crate::{Integer, IntPriv, Utf8StringRef, ValueRef};
 use super::Error;
 
 /// Encodes and attempts to write the given non-owning ValueRef into the Write.
@@ -24,7 +24,7 @@ use super::Error;
 /// write_value_ref(&mut buf, &val).unwrap();
 /// assert_eq!(vec![0xaa, 0x6c, 0x65, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65], buf);
 /// ```
-pub fn write_value_ref<W>(wr: &mut W, val: &ValueRef) -> Result<(), Error>
+pub fn write_value_ref<W>(wr: &mut W, val: &ValueRef<'_>) -> Result<(), Error>
     where W: Write
 {
     match *val {
diff --git a/rmpv/src/ext/de.rs b/rmpv/src/ext/de.rs
index 8ef95a2..8fcb1a1 100644
--- a/rmpv/src/ext/de.rs
+++ b/rmpv/src/ext/de.rs
@@ -6,7 +6,7 @@ use std::vec::IntoIter;
 use serde::{self, Deserialize, Deserializer};
 use serde::de::{self, DeserializeSeed, IntoDeserializer, SeqAccess, Unexpected, Visitor};
 
-use {Integer, IntPriv, Utf8String, Utf8StringRef, Value, ValueRef};
+use crate::{Integer, IntPriv, Utf8String, Utf8StringRef, Value, ValueRef};
 
 use super::{Error, ValueExt};
 
@@ -39,7 +39,7 @@ impl<'de> Deserialize<'de> for Value {
         impl<'de> serde::de::Visitor<'de> for ValueVisitor {
             type Value = Value;
 
-            fn expecting(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
+            fn expecting(&self, fmt: &mut Formatter<'_>) -> Result<(), fmt::Error> {
                 "any valid MessagePack value".fmt(fmt)
             }
 
@@ -148,7 +148,7 @@ impl<'de> Deserialize<'de> for ValueRef<'de> {
         impl<'de> de::Visitor<'de> for ValueVisitor {
             type Value = ValueRef<'de>;
 
-            fn expecting(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
+            fn expecting(&self, fmt: &mut Formatter<'_>) -> Result<(), fmt::Error> {
                 "any valid MessagePack value".fmt(fmt)
             }
 
diff --git a/rmpv/src/ext/mod.rs b/rmpv/src/ext/mod.rs
index e20ad6d..c4f3066 100644
--- a/rmpv/src/ext/mod.rs
+++ b/rmpv/src/ext/mod.rs
@@ -3,7 +3,7 @@ use std::fmt::{self, Display, Formatter};
 
 use serde::de::Unexpected;
 
-use {Integer, IntPriv, Value, ValueRef};
+use crate::{Integer, IntPriv, Value, ValueRef};
 
 pub use self::de::{deserialize_from, from_value, EnumRefDeserializer};
 pub use self::se::to_value;
@@ -17,7 +17,7 @@ pub enum Error {
 }
 
 impl Display for Error {
-    fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), fmt::Error> {
         match *self {
             Error::Syntax(ref err) => write!(fmt, "{}: {}", error::Error::description(self), err)
         }
@@ -29,7 +29,7 @@ impl error::Error for Error {
         "error while decoding value"
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         match *self {
             Error::Syntax(..) => None,
         }
@@ -37,11 +37,11 @@ impl error::Error for Error {
 }
 
 trait ValueExt {
-    fn unexpected(&self) -> Unexpected;
+    fn unexpected(&self) -> Unexpected<'_>;
 }
 
 impl ValueExt for Value {
-    fn unexpected(&self) -> Unexpected {
+    fn unexpected(&self) -> Unexpected<'_> {
         match *self {
             Value::Nil => Unexpected::Unit,
             Value::Boolean(v) => Unexpected::Bool(v),
@@ -68,7 +68,7 @@ impl ValueExt for Value {
 }
 
 impl<'a> ValueExt for ValueRef<'a> {
-    fn unexpected(&self) -> Unexpected {
+    fn unexpected(&self) -> Unexpected<'_> {
         match *self {
             ValueRef::Nil => Unexpected::Unit,
             ValueRef::Boolean(v) => Unexpected::Bool(v),
diff --git a/rmpv/src/ext/se.rs b/rmpv/src/ext/se.rs
index 3b3035c..86a0892 100644
--- a/rmpv/src/ext/se.rs
+++ b/rmpv/src/ext/se.rs
@@ -4,7 +4,7 @@ use serde::Serialize;
 use serde::ser::{self, SerializeSeq, SerializeTuple, SerializeTupleStruct, SerializeMap, SerializeStruct};
 use serde_bytes::Bytes;
 
-use {Integer, IntPriv, Value};
+use crate::{Integer, IntPriv, Value};
 
 use super::Error;
 
diff --git a/rmpv/src/lib.rs b/rmpv/src/lib.rs
index 4ab999e..09caeba 100644
--- a/rmpv/src/lib.rs
+++ b/rmpv/src/lib.rs
@@ -8,10 +8,6 @@
 #[cfg(feature = "with-serde")]
 #[macro_use]
 extern crate serde;
-#[cfg(feature = "with-serde")]
-extern crate serde_bytes;
-extern crate rmp;
-extern crate num_traits;
 
 use std::borrow::Cow;
 use std::fmt::{self, Debug, Display};
@@ -90,13 +86,13 @@ impl Integer {
 }
 
 impl Debug for Integer {
-    fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
         Debug::fmt(&self.n, fmt)
     }
 }
 
 impl Display for Integer {
-    fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
         match self.n {
             IntPriv::PosInt(v) => Display::fmt(&v, fmt),
             IntPriv::NegInt(v) => Display::fmt(&v, fmt),
@@ -250,7 +246,7 @@ impl Utf8String {
         }
     }
 
-    pub fn as_ref(&self) -> Utf8StringRef {
+    pub fn as_ref(&self) -> Utf8StringRef<'_> {
         match self.s {
             Ok(ref s) => Utf8StringRef { s: Ok(s.as_str()) },
             Err((ref buf, err)) => Utf8StringRef { s: Err((&buf[..], err)) },
@@ -259,7 +255,7 @@ impl Utf8String {
 }
 
 impl Display for Utf8String {
-    fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
         match self.s {
             Ok(ref s) => write!(fmt, "\"{}\"", s),
             Err(ref err) => Debug::fmt(&err.0, fmt),
@@ -348,7 +344,7 @@ impl<'a> Utf8StringRef<'a> {
 }
 
 impl<'a> Display for Utf8StringRef<'a> {
-    fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
         match self.s {
             Ok(ref s) => write!(fmt, "\"{}\"", s),
             Err(ref err) => Debug::fmt(&err.0, fmt),
@@ -445,7 +441,7 @@ impl Value {
     ///
     /// assert_eq!(expected, val.as_ref());
     /// ```
-    pub fn as_ref(&self) -> ValueRef {
+    pub fn as_ref(&self) -> ValueRef<'_> {
         match self {
             &Value::Nil => ValueRef::Nil,
             &Value::Boolean(val) => ValueRef::Boolean(val),
@@ -963,7 +959,7 @@ impl From<Vec<(Value, Value)>> for Value {
 }
 
 impl Display for Value {
-    fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
         match *self {
             Value::Nil => Display::fmt("nil", f),
             Value::Boolean(val) => write!(f, "{}", val),
@@ -983,19 +979,19 @@ impl Display for Value {
                 write!(f, "[{}]", res)
             }
             Value::Map(ref vec) => {
-                try!(write!(f, "{{"));
+                write!(f, "{{")?;
 
                 match vec.iter().take(1).next() {
                     Some(&(ref k, ref v)) => {
-                        try!(write!(f, "{}: {}", k, v));
+                        write!(f, "{}: {}", k, v)?;
                     }
                     None => {
-                        try!(write!(f, ""));
+                        write!(f, "")?;
                     }
                 }
 
                 for &(ref k, ref v) in vec.iter().skip(1) {
-                    try!(write!(f, ", {}: {}", k, v));
+                    write!(f, ", {}: {}", k, v)?;
                 }
 
                 write!(f, "}}")
@@ -1084,7 +1080,7 @@ impl<'a> ValueRef<'a> {
         }
     }
 
-    pub fn index(&self, index: usize) -> &ValueRef {
+    pub fn index(&self, index: usize) -> &ValueRef<'_> {
         self.as_array().and_then(|v| v.get(index)).unwrap_or(&NIL_REF)
     }
 
@@ -1118,7 +1114,7 @@ impl<'a> ValueRef<'a> {
     /// assert_eq!(Some(&vec![ValueRef::Nil, ValueRef::Boolean(true)]), val.as_array());
     /// assert_eq!(None, ValueRef::Nil.as_array());
     /// ```
-    pub fn as_array(&self) -> Option<&Vec<ValueRef>> {
+    pub fn as_array(&self) -> Option<&Vec<ValueRef<'_>>> {
         if let ValueRef::Array(ref array) = *self {
             Some(&*array)
         } else {
@@ -1232,7 +1228,7 @@ impl<'a> From<Vec<(ValueRef<'a>, ValueRef<'a>)>> for ValueRef<'a> {
 }
 
 impl<'a> Display for ValueRef<'a> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
         match *self {
             ValueRef::Nil => write!(f, "nil"),
             ValueRef::Boolean(val) => write!(f, "{}", val),
@@ -1250,19 +1246,19 @@ impl<'a> Display for ValueRef<'a> {
                 write!(f, "[{}]", res)
             }
             ValueRef::Map(ref vec) => {
-                try!(write!(f, "{{"));
+                write!(f, "{{")?;
 
                 match vec.iter().take(1).next() {
                     Some(&(ref k, ref v)) => {
-                        try!(write!(f, "{}: {}", k, v));
+                        write!(f, "{}: {}", k, v)?;
                     }
                     None => {
-                        try!(write!(f, ""));
+                        write!(f, "")?;
                     }
                 }
 
                 for &(ref k, ref v) in vec.iter().skip(1) {
-                    try!(write!(f, ", {}: {}", k, v));
+                    write!(f, ", {}: {}", k, v)?;
                 }
 
                 write!(f, "}}")


Test patch:
diff --git a/rmp-serde/tests/decode.rs b/rmp-serde/tests/decode.rs
index 93b9ad6..d35e66b 100644
--- a/rmp-serde/tests/decode.rs
+++ b/rmp-serde/tests/decode.rs
@@ -1,6 +1,3 @@
-extern crate serde;
-extern crate serde_bytes;
-extern crate rmp;
 extern crate rmp_serde as rmps;
 
 use std::io::Cursor;
@@ -10,8 +7,8 @@ use serde::de;
 use serde::Deserialize;
 
 use rmp::Marker;
-use rmps::{Deserializer, Raw, RawRef};
-use rmps::decode::{self, Error};
+use crate::rmps::{Deserializer, Raw, RawRef};
+use crate::rmps::decode::{self, Error};
 
 #[test]
 fn pass_nil() {
@@ -393,7 +390,7 @@ fn test_deserialize_numeric() {
             impl<'de> de::Visitor<'de> for FloatOrIntegerVisitor {
                 type Value = FloatOrInteger;
 
-                fn expecting(&self, fmt: &mut Formatter) ->  Result<(), fmt::Error> {
+                fn expecting(&self, fmt: &mut Formatter<'_>) ->  Result<(), fmt::Error> {
                     write!(fmt, "either a float or an integer")
                 }
 
@@ -495,7 +492,7 @@ fn pass_raw_invalid_utf8() {
 #[test]
 fn pass_raw_ref_valid_utf8() {
     let buf = vec![0xa3, 0x6b, 0x65, 0x79];
-    let raw: RawRef = rmps::from_slice(&buf[..]).unwrap();
+    let raw: RawRef<'_> = rmps::from_slice(&buf[..]).unwrap();
 
     assert!(raw.is_str());
     assert_eq!("key", raw.as_str().unwrap());
@@ -507,7 +504,7 @@ fn pass_raw_ref_invalid_utf8() {
     // >>> msgpack.dumps(msgpack.dumps([200, []]))
     // '\xa4\x92\xcc\xc8\x90'
     let buf = vec![0xa4, 0x92, 0xcc, 0xc8, 0x90];
-    let raw: RawRef = rmps::from_slice(&buf[..]).unwrap();
+    let raw: RawRef<'_> = rmps::from_slice(&buf[..]).unwrap();
 
     assert!(raw.is_err());
     assert_eq!(0, raw.as_err().unwrap().valid_up_to());
diff --git a/rmp-serde/tests/decode_derive.rs b/rmp-serde/tests/decode_derive.rs
index e243235..3b8919f 100644
--- a/rmp-serde/tests/decode_derive.rs
+++ b/rmp-serde/tests/decode_derive.rs
@@ -1,15 +1,14 @@
-extern crate serde;
 #[macro_use]
 extern crate serde_derive;
-extern crate rmp;
+
 extern crate rmp_serde as rmps;
 
 use std::io::Cursor;
 
 use serde::Deserialize;
 
-use rmps::Deserializer;
-use rmps::decode::Error;
+use crate::rmps::Deserializer;
+use crate::rmps::decode::Error;
 
 #[test]
 fn pass_newtype() {
diff --git a/rmp-serde/tests/encode.rs b/rmp-serde/tests/encode.rs
index c1c4d6e..21337c9 100644
--- a/rmp-serde/tests/encode.rs
+++ b/rmp-serde/tests/encode.rs
@@ -1,14 +1,11 @@
-extern crate serde;
-extern crate serde_bytes;
-extern crate rmp;
 extern crate rmp_serde as rmps;
 
 use std::io::Cursor;
 
 use serde::Serialize;
 
-use rmps::{Raw, RawRef, Serializer};
-use rmps::encode::{self, Error};
+use crate::rmps::{Raw, RawRef, Serializer};
+use crate::rmps::encode::{self, Error};
 
 #[test]
 fn pass_null() {
diff --git a/rmp-serde/tests/encode_derive.rs b/rmp-serde/tests/encode_derive.rs
index 9e988f7..9dd4de9 100644
--- a/rmp-serde/tests/encode_derive.rs
+++ b/rmp-serde/tests/encode_derive.rs
@@ -1,12 +1,10 @@
-extern crate serde;
 #[macro_use]
 extern crate serde_derive;
-extern crate rmp;
+
 extern crate rmp_serde as rmps;
 
 use serde::Serialize;
-use rmps::Serializer;
-use rmps::encode::UnderlyingWrite;
+use crate::rmps::Serializer;
 
 #[test]
 fn pass_unit_struct() {
diff --git a/rmp-serde/tests/round.rs b/rmp-serde/tests/round.rs
index 0449df8..b41740d 100644
--- a/rmp-serde/tests/round.rs
+++ b/rmp-serde/tests/round.rs
@@ -1,14 +1,13 @@
-extern crate serde;
 #[macro_use]
 extern crate serde_derive;
-extern crate rmp;
+
 extern crate rmp_serde as rmps;
 
 use std::borrow::Cow;
 use std::io::Cursor;
 
 use serde::{Deserialize, Serialize};
-use rmps::{Deserializer, Serializer};
+use crate::rmps::{Deserializer, Serializer};
 
 #[test]
 fn round_trip_option() {
@@ -199,8 +198,8 @@ fn round_trip_untagged_enum_with_enum_associated_data() {
 // Checks whether deserialization and serialization can both work with structs as maps
 #[test]
 fn round_struct_as_map() {
-    use rmps::to_vec_named;
-    use rmps::decode::from_slice;
+    use crate::rmps::to_vec_named;
+    use crate::rmps::decode::from_slice;
 
     #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
     struct Dog1 {
@@ -232,8 +231,8 @@ fn round_struct_as_map() {
 #[test]
 fn round_struct_as_map_in_vec() {
     // See: issue #205
-    use rmps::decode::from_slice;
-    use rmps::to_vec_named;
+    use crate::rmps::decode::from_slice;
+    use crate::rmps::to_vec_named;
 
     #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
     struct Dog1 {
@@ -336,7 +335,7 @@ fn round_trip_unit_struct_untagged_enum() {
 // Checks whether deserialization and serialization can both work with enum variants as strings
 #[test]
 fn round_variant_string() {
-    use rmps::decode::from_slice;
+    use crate::rmps::decode::from_slice;
 
     #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
     enum Animal1 {
diff --git a/rmp/tests/func/decode/array.rs b/rmp/tests/func/decode/array.rs
index 1174642..579c05a 100644
--- a/rmp/tests/func/decode/array.rs
+++ b/rmp/tests/func/decode/array.rs
@@ -1,7 +1,7 @@
 use std::io::Cursor;
 
-use msgpack::Marker;
-use msgpack::decode::*;
+use crate::msgpack::Marker;
+use crate::msgpack::decode::*;
 
 #[test]
 fn from_empty_array_read_size() {
diff --git a/rmp/tests/func/decode/bin.rs b/rmp/tests/func/decode/bin.rs
index 8d0892e..20db903 100644
--- a/rmp/tests/func/decode/bin.rs
+++ b/rmp/tests/func/decode/bin.rs
@@ -1,7 +1,7 @@
 use std::io::Cursor;
 
-use msgpack::Marker;
-use msgpack::decode::*;
+use crate::msgpack::Marker;
+use crate::msgpack::decode::*;
 
 #[test]
 fn from_bin8_min_read_len() {
diff --git a/rmp/tests/func/decode/bool.rs b/rmp/tests/func/decode/bool.rs
index c23d2f3..cb11d55 100644
--- a/rmp/tests/func/decode/bool.rs
+++ b/rmp/tests/func/decode/bool.rs
@@ -1,6 +1,6 @@
 use std::io::Cursor;
 
-use msgpack::decode::*;
+use crate::msgpack::decode::*;
 
 #[test]
 fn from_bool_false() {
diff --git a/rmp/tests/func/decode/ext.rs b/rmp/tests/func/decode/ext.rs
index 70ee4c8..b417e98 100644
--- a/rmp/tests/func/decode/ext.rs
+++ b/rmp/tests/func/decode/ext.rs
@@ -1,6 +1,6 @@
 use std::io::Cursor;
 
-use msgpack::decode::*;
+use crate::msgpack::decode::*;
 
 #[test]
 fn from_fixext1_read_fixext1() {
diff --git a/rmp/tests/func/decode/float.rs b/rmp/tests/func/decode/float.rs
index 3f716b4..9c60a8a 100644
--- a/rmp/tests/func/decode/float.rs
+++ b/rmp/tests/func/decode/float.rs
@@ -1,7 +1,7 @@
 use std::io::Cursor;
 
-use msgpack::Marker;
-use msgpack::decode::*;
+use crate::msgpack::Marker;
+use crate::msgpack::decode::*;
 
 #[test]
 fn from_f32_zero_plus() {
diff --git a/rmp/tests/func/decode/map.rs b/rmp/tests/func/decode/map.rs
index bf58120..df19219 100644
--- a/rmp/tests/func/decode/map.rs
+++ b/rmp/tests/func/decode/map.rs
@@ -1,7 +1,7 @@
 use std::io::Cursor;
 
-use msgpack::Marker;
-use msgpack::decode::*;
+use crate::msgpack::Marker;
+use crate::msgpack::decode::*;
 
 #[test]
 fn from_fixmap_min_read_size() {
diff --git a/rmp/tests/func/decode/mod.rs b/rmp/tests/func/decode/mod.rs
index ef07c38..8c89eb1 100644
--- a/rmp/tests/func/decode/mod.rs
+++ b/rmp/tests/func/decode/mod.rs
@@ -1,10 +1,10 @@
-mod null;
+mod array;
+mod bin;
 mod bool;
-mod sint;
-mod uint;
+mod ext;
 mod float;
-mod string;
-mod bin;
-mod array;
 mod map;
-mod ext;
+mod null;
+mod sint;
+mod string;
+mod uint;
diff --git a/rmp/tests/func/decode/null.rs b/rmp/tests/func/decode/null.rs
index 6808df4..255bf2a 100644
--- a/rmp/tests/func/decode/null.rs
+++ b/rmp/tests/func/decode/null.rs
@@ -1,6 +1,6 @@
 use std::io::Cursor;
 
-use msgpack::decode::*;
+use crate::msgpack::decode::*;
 
 #[test]
 fn pass() {
diff --git a/rmp/tests/func/decode/sint.rs b/rmp/tests/func/decode/sint.rs
index ddf46ce..9e8982f 100644
--- a/rmp/tests/func/decode/sint.rs
+++ b/rmp/tests/func/decode/sint.rs
@@ -1,7 +1,7 @@
 use std::io::Cursor;
 
-use msgpack::Marker;
-use msgpack::decode::*;
+use crate::msgpack::Marker;
+use crate::msgpack::decode::*;
 
 #[test]
 fn from_nfix_min() {
diff --git a/rmp/tests/func/decode/string.rs b/rmp/tests/func/decode/string.rs
index 6f6dd83..35cb997 100644
--- a/rmp/tests/func/decode/string.rs
+++ b/rmp/tests/func/decode/string.rs
@@ -1,7 +1,7 @@
 use std::io::Cursor;
 
-use msgpack::Marker;
-use msgpack::decode::*;
+use crate::msgpack::Marker;
+use crate::msgpack::decode::*;
 
 #[test]
 fn from_fixstr_min_read_str_len() {
diff --git a/rmp/tests/func/decode/uint.rs b/rmp/tests/func/decode/uint.rs
index a35e516..d056965 100644
--- a/rmp/tests/func/decode/uint.rs
+++ b/rmp/tests/func/decode/uint.rs
@@ -1,7 +1,7 @@
 use std::io::Cursor;
 
-use msgpack::Marker;
-use msgpack::decode::*;
+use crate::msgpack::Marker;
+use crate::msgpack::decode::*;
 
 #[test]
 fn from_positive_fixnum() {
diff --git a/rmp/tests/func/encode/array.rs b/rmp/tests/func/encode/array.rs
index 7f77403..1feb7f1 100644
--- a/rmp/tests/func/encode/array.rs
+++ b/rmp/tests/func/encode/array.rs
@@ -1,5 +1,5 @@
-use msgpack::Marker;
-use msgpack::encode::*;
+use crate::msgpack::Marker;
+use crate::msgpack::encode::*;
 
 #[test]
 fn pass_pack_len_fix() {
diff --git a/rmp/tests/func/encode/bin.rs b/rmp/tests/func/encode/bin.rs
index 718bed4..dc577fc 100644
--- a/rmp/tests/func/encode/bin.rs
+++ b/rmp/tests/func/encode/bin.rs
@@ -1,5 +1,5 @@
-use msgpack::Marker;
-use msgpack::encode::*;
+use crate::msgpack::Marker;
+use crate::msgpack::encode::*;
 
 #[test]
 fn pass_pack_len_u8() {
diff --git a/rmp/tests/func/encode/bool.rs b/rmp/tests/func/encode/bool.rs
index fb79984..c8d1eaf 100644
--- a/rmp/tests/func/encode/bool.rs
+++ b/rmp/tests/func/encode/bool.rs
@@ -1,4 +1,4 @@
-use msgpack::encode::*;
+use crate::msgpack::encode::*;
 
 #[test]
 fn pass_pack_true() {
diff --git a/rmp/tests/func/encode/ext.rs b/rmp/tests/func/encode/ext.rs
index 954a4ad..363cb47 100644
--- a/rmp/tests/func/encode/ext.rs
+++ b/rmp/tests/func/encode/ext.rs
@@ -1,5 +1,5 @@
-use msgpack::Marker;
-use msgpack::encode::*;
+use crate::msgpack::Marker;
+use crate::msgpack::encode::*;
 
 #[test]
 fn pass_pack_meta_fix1() {
@@ -37,7 +37,6 @@ fn pass_pack_meta_fix8() {
     assert_eq!([0xd7, 0x10], buf);
 }
 
-
 #[test]
 fn pass_pack_meta_fix16() {
     let mut buf = [0x00, 0x00];
diff --git a/rmp/tests/func/encode/float.rs b/rmp/tests/func/encode/float.rs
index 283940a..5464c60 100644
--- a/rmp/tests/func/encode/float.rs
+++ b/rmp/tests/func/encode/float.rs
@@ -1,4 +1,4 @@
-use msgpack::encode::*;
+use crate::msgpack::encode::*;
 
 #[test]
 fn pass_pack_f32() {
diff --git a/rmp/tests/func/encode/int.rs b/rmp/tests/func/encode/int.rs
index 9dc8771..0316d9e 100644
--- a/rmp/tests/func/encode/int.rs
+++ b/rmp/tests/func/encode/int.rs
@@ -1,5 +1,5 @@
-use msgpack::Marker;
-use msgpack::encode::*;
+use crate::msgpack::Marker;
+use crate::msgpack::encode::*;
 
 #[test]
 fn pass_pack_pfix() {
diff --git a/rmp/tests/func/encode/map.rs b/rmp/tests/func/encode/map.rs
index 790bbf2..bf0fe16 100644
--- a/rmp/tests/func/encode/map.rs
+++ b/rmp/tests/func/encode/map.rs
@@ -1,5 +1,5 @@
-use msgpack::Marker;
-use msgpack::encode::*;
+use crate::msgpack::Marker;
+use crate::msgpack::encode::*;
 
 #[test]
 fn pass_pack_len_fix() {
diff --git a/rmp/tests/func/encode/null.rs b/rmp/tests/func/encode/null.rs
index e0440c3..cb75062 100644
--- a/rmp/tests/func/encode/null.rs
+++ b/rmp/tests/func/encode/null.rs
@@ -1,4 +1,4 @@
-use msgpack::encode::*;
+use crate::msgpack::encode::*;
 
 #[test]
 fn pass_pack() {
diff --git a/rmp/tests/func/encode/string.rs b/rmp/tests/func/encode/string.rs
index 9c862f0..4fa1090 100644
--- a/rmp/tests/func/encode/string.rs
+++ b/rmp/tests/func/encode/string.rs
@@ -1,5 +1,5 @@
-use msgpack::Marker;
-use msgpack::encode::*;
+use crate::msgpack::Marker;
+use crate::msgpack::encode::*;
 
 #[test]
 fn pass_pack_len_fix() {
diff --git a/rmp/tests/func/mirror.rs b/rmp/tests/func/mirror.rs
index bb346e4..e789393 100644
--- a/rmp/tests/func/mirror.rs
+++ b/rmp/tests/func/mirror.rs
@@ -1,4 +1,4 @@
-use msgpack::{decode, encode};
+use crate::msgpack::{decode, encode};
 
 quickcheck! {
     fn mirror_uint(xs: u64) -> bool {
diff --git a/rmp/tests/func/mod.rs b/rmp/tests/func/mod.rs
index dc101b8..5d450e6 100644
--- a/rmp/tests/func/mod.rs
+++ b/rmp/tests/func/mod.rs
@@ -1,3 +1,3 @@
-mod encode;
 mod decode;
+mod encode;
 mod mirror;
diff --git a/rmpv-tests/Cargo.toml b/rmpv-tests/Cargo.toml
index 5fac6a0..5b314e8 100644
--- a/rmpv-tests/Cargo.toml
+++ b/rmpv-tests/Cargo.toml
@@ -3,6 +3,7 @@ name = "rmpv-tests"
 version = "0.0.0"
 authors = ["Evgeny Safronov <division494@gmail.com>"]
 publish = false
+edition = "2018"
 
 [dependencies]
 serde = "1"
diff --git a/rmpv-tests/benches/value.rs b/rmpv-tests/benches/value.rs
index 757469e..984c84b 100644
--- a/rmpv-tests/benches/value.rs
+++ b/rmpv-tests/benches/value.rs
@@ -1,7 +1,7 @@
 #![feature(test)]
 
 extern crate rmp_serde as rmps;
-extern crate rmpv;
+use rmpv;
 extern crate test;
 
 use test::Bencher;
@@ -42,7 +42,7 @@ fn from_complex_read_value_ref(b: &mut Bencher) {
 #[bench]
 fn from_complex_zero_copy_decode(b: &mut Bencher) {
     b.iter(|| {
-        let res: ValueRef = rmps::from_slice(&COMPLEX[..]).unwrap();
+        let res: ValueRef<'_> = rmps::from_slice(&COMPLEX[..]).unwrap();
         test::black_box(res);
     });
     b.bytes = COMPLEX.len() as u64;
diff --git a/rmpv-tests/tests/de_ref.rs b/rmpv-tests/tests/de_ref.rs
index 3a45a58..fd07a9d 100644
--- a/rmpv-tests/tests/de_ref.rs
+++ b/rmpv-tests/tests/de_ref.rs
@@ -1,9 +1,6 @@
-extern crate serde;
-extern crate serde_bytes;
 #[macro_use]
 extern crate serde_derive;
 extern crate rmp_serde as rmps;
-extern crate rmpv;
 
 use std::collections::BTreeMap;
 
@@ -15,11 +12,11 @@ use rmpv::ext::deserialize_from;
 
 /// Tests that a `ValueRef` is properly decoded from bytes using two different mechanisms: direct
 /// deserialization using `rmp::decode::read_value_ref` and using `serde`.
-fn test_decode(buf: &[u8], v: ValueRef) {
-    let val0: ValueRef = decode::read_value_ref(&mut &buf[..]).unwrap();
+fn test_decode(buf: &[u8], v: ValueRef<'_>) {
+    let val0: ValueRef<'_> = decode::read_value_ref(&mut &buf[..]).unwrap();
     assert_eq!(v, val0);
 
-    let val1: ValueRef = rmps::from_slice(buf).unwrap();
+    let val1: ValueRef<'_> = rmps::from_slice(buf).unwrap();
     assert_eq!(v, val1);
 }
 
diff --git a/rmpv-tests/tests/decode.rs b/rmpv-tests/tests/decode.rs
index 3d9b47a..9f6f981 100644
--- a/rmpv-tests/tests/decode.rs
+++ b/rmpv-tests/tests/decode.rs
@@ -1,9 +1,6 @@
-extern crate serde;
-extern crate serde_bytes;
 #[macro_use]
 extern crate serde_derive;
 extern crate rmp_serde as rmps;
-extern crate rmpv;
 
 use std::collections::BTreeMap;
 
diff --git a/rmpv-tests/tests/encode.rs b/rmpv-tests/tests/encode.rs
index 8a97a23..7967dba 100644
--- a/rmpv-tests/tests/encode.rs
+++ b/rmpv-tests/tests/encode.rs
@@ -1,9 +1,6 @@
-extern crate serde;
-extern crate serde_bytes;
 #[macro_use]
 extern crate serde_derive;
 extern crate rmp_serde as rmps;
-extern crate rmpv;
 
 use std::borrow::Cow;
 use std::collections::BTreeMap;
@@ -11,7 +8,7 @@ use std::collections::BTreeMap;
 use serde::Serialize;
 use serde_bytes::{Bytes, ByteBuf};
 
-use rmps::Serializer;
+use crate::rmps::Serializer;
 use rmpv::Value;
 use rmpv::encode;
 use rmpv::ext::to_value;
diff --git a/rmpv-tests/tests/round.rs b/rmpv-tests/tests/round.rs
index 27741ab..0f3ce25 100644
--- a/rmpv-tests/tests/round.rs
+++ b/rmpv-tests/tests/round.rs
@@ -1,9 +1,6 @@
-extern crate serde;
-extern crate serde_bytes;
 #[macro_use]
 extern crate serde_derive;
 extern crate rmp_serde as rmps;
-extern crate rmpv;
 
 use std::fmt::Debug;
 
diff --git a/rmpv/tests/decode.rs b/rmpv/tests/decode.rs
index f2dede2..8971e3c 100644
--- a/rmpv/tests/decode.rs
+++ b/rmpv/tests/decode.rs
@@ -1,5 +1,3 @@
-extern crate rmpv;
-
 use rmpv::Value;
 use rmpv::decode::{read_value, Error};
 
diff --git a/rmpv/tests/decode_ref.rs b/rmpv/tests/decode_ref.rs
index 0bd6f3d..70b4bf7 100644
--- a/rmpv/tests/decode_ref.rs
+++ b/rmpv/tests/decode_ref.rs
@@ -1,5 +1,3 @@
-extern crate rmpv;
-
 use rmpv::ValueRef;
 use rmpv::decode::{read_value_ref, Error};
 
diff --git a/rmpv/tests/encode_ref.rs b/rmpv/tests/encode_ref.rs
index f9bf9de..c618ffb 100644
--- a/rmpv/tests/encode_ref.rs
+++ b/rmpv/tests/encode_ref.rs
@@ -1,5 +1,3 @@
-extern crate rmpv;
-
 use rmpv::ValueRef;
 use rmpv::encode::write_value_ref;
 
@@ -59,7 +57,7 @@ fn pass_pack_i64() {
     assert_eq!([0xd3, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], buf);
 }
 
-fn check_packed_eq(expected: &Vec<u8>, actual: &ValueRef) {
+fn check_packed_eq(expected: &Vec<u8>, actual: &ValueRef<'_>) {
     let mut buf = Vec::new();
 
     write_value_ref(&mut buf, actual).unwrap();
diff --git a/rmpv/tests/mirror.rs b/rmpv/tests/mirror.rs
index 0ec35ca..32d36d3 100644
--- a/rmpv/tests/mirror.rs
+++ b/rmpv/tests/mirror.rs
@@ -1,4 +1,3 @@
-extern crate rmpv;
 #[macro_use]
 extern crate quickcheck;
 
diff --git a/rmpv/tests/value.rs b/rmpv/tests/value.rs
index 9abecc5..10df32f 100644
--- a/rmpv/tests/value.rs
+++ b/rmpv/tests/value.rs
@@ -1,5 +1,3 @@
-extern crate rmpv;
-
 use rmpv::Value;
 
 #[test]