diff --git a/clippy.toml b/clippy.toml index ed59341c..f39fe20c 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,2 +1,2 @@ -doc-valid-idents = ["CLASSes", "IPv4", "IPv6", "OpCodes", "RRset"] +doc-valid-idents = ["CLASSes", "IPv4", "IPv6", "OpCodes", "RRset", "RRsets"] diff --git a/examples/dig.rs b/examples/dig.rs index 8ac9223b..439ef003 100644 --- a/examples/dig.rs +++ b/examples/dig.rs @@ -85,7 +85,7 @@ impl Options { fn qtype(&self) -> Result { if self.qtype.is_empty() { - Ok((if self.name.is_empty() { Rtype::Ns } else { Rtype::A })) + Ok(if self.name.is_empty() { Rtype::Ns } else { Rtype::A }) } else { Ok(try!(Rtype::from_str(&self.qtype))) @@ -93,7 +93,7 @@ impl Options { } fn qclass(&self) -> Result { - Ok((Class::In)) + Ok(Class::In) } fn conf(&self) -> &ResolvConf { &self.conf } diff --git a/src/bits/name/iter.rs b/src/bits/name/iter.rs index 720958df..5799d43f 100644 --- a/src/bits/name/iter.rs +++ b/src/bits/name/iter.rs @@ -74,7 +74,7 @@ impl<'a> NameLabels<'a> { Flavor::Parsed(ref name) => { name.unpack() } - Flavor::DoubleSlice{ref bytes, ..} => { + Flavor::DoubleSlice{bytes, ..} => { Cow::Borrowed(unsafe { DNameSlice::from_bytes_unsafe(bytes) }) } Flavor::DoubleParsed(ref labels) => { @@ -294,8 +294,8 @@ impl<'a> DoubleLabels<'a> { fn front(&self) -> Option<&LabelIter<'a>> { match *self { DoubleLabels::None | DoubleLabels::Back(..) => None, - DoubleLabels::Front(ref front) => Some(front), - DoubleLabels::Both(ref front, _) => Some(front), + DoubleLabels::Front(ref front) | DoubleLabels::Both(ref front, _) + => Some(front), DoubleLabels::Same(ref same) => Some(same) } } @@ -303,8 +303,8 @@ impl<'a> DoubleLabels<'a> { fn front_mut(&mut self) -> Option<&mut LabelIter<'a>> { match *self { DoubleLabels::None | DoubleLabels::Back(..) => None, - DoubleLabels::Front(ref mut front) => Some(front), - DoubleLabels::Both(ref mut front, _) => Some(front), + DoubleLabels::Front(ref mut front) + | DoubleLabels::Both(ref mut front, _) => Some(front), DoubleLabels::Same(ref mut same) => Some(same) } } @@ -312,8 +312,8 @@ impl<'a> DoubleLabels<'a> { fn back(&self) -> Option<&LabelIter<'a>> { match *self { DoubleLabels::None | DoubleLabels::Front(..) => None, - DoubleLabels::Back(ref back) => Some(back), - DoubleLabels::Both(_, ref back) => Some(back), + DoubleLabels::Back(ref back) + | DoubleLabels::Both(_, ref back) => Some(back), DoubleLabels::Same(ref same) => Some(same) } } @@ -321,8 +321,8 @@ impl<'a> DoubleLabels<'a> { fn back_mut(&mut self) -> Option<&mut LabelIter<'a>> { match *self { DoubleLabels::None | DoubleLabels::Front(..) => None, - DoubleLabels::Back(ref mut back) => Some(back), - DoubleLabels::Both(_, ref mut back) => Some(back), + DoubleLabels::Back(ref mut back) + | DoubleLabels::Both(_, ref mut back) => Some(back), DoubleLabels::Same(ref mut same) => Some(same) } } @@ -333,8 +333,8 @@ impl<'a> DoubleLabels<'a> { *self = match mem::replace(self, DoubleLabels::None) { DoubleLabels::None | DoubleLabels::Front(_) => DoubleLabels::Front(front), - DoubleLabels::Back(back) => DoubleLabels::Both(front, back), - DoubleLabels::Both(_, back) => DoubleLabels::Both(front, back), + DoubleLabels::Back(back) | DoubleLabels::Both(_, back) + => DoubleLabels::Both(front, back), DoubleLabels::Same(_) => unreachable!(), }; true @@ -356,8 +356,8 @@ impl<'a> DoubleLabels<'a> { *self = match mem::replace(self, DoubleLabels::None) { DoubleLabels::None | DoubleLabels::Back(_) => DoubleLabels::Back(back), - DoubleLabels::Front(front) => DoubleLabels::Both(front, back), - DoubleLabels::Both(front, _) => DoubleLabels::Both(front, back), + DoubleLabels::Front(front) | DoubleLabels::Both(front, _) + => DoubleLabels::Both(front, back), DoubleLabels::Same(_) => unreachable!() }; true diff --git a/src/bits/name/label.rs b/src/bits/name/label.rs index 6174eb6a..740a22ae 100644 --- a/src/bits/name/label.rs +++ b/src/bits/name/label.rs @@ -602,7 +602,7 @@ impl<'a> BinaryLabelIter<'a> { for (i, j) in (self.front .. self.back) .zip(0 .. (self.back - self.front)) { if let Labelette::Bit(true) = self.get_bit(i) { - bits[j >> 3] |= bits[j >> 3] | (0x80 >> (j & 7)); + bits[j >> 3] |= 0x80 >> (j & 7); } else { bits[j >> 3] &= !bits[j >> 3] | (0x80 >> (j & 7)); @@ -888,7 +888,7 @@ impl<'a> Labelette<'a> { /// Returns whether the labelette is the root label. pub fn is_root(&self) -> bool { if let Labelette::Normal(bytes) = *self { - bytes.len() == 0 + bytes.is_empty() } else { false diff --git a/src/bits/name/plain.rs b/src/bits/name/plain.rs index 0dfccc5f..4a38ed4c 100644 --- a/src/bits/name/plain.rs +++ b/src/bits/name/plain.rs @@ -693,7 +693,7 @@ impl DNameBuf { /// Appends the content of an iterator to the end of the name. pub fn append_iter<'a, T>(&mut self, iter: T) -> Result<(), PushError> where T: IntoIterator { - for item in iter.into_iter() { + for item in iter { self.push(item)? } Ok(()) diff --git a/src/iana/macros.rs b/src/iana/macros.rs index 82ff494f..c88a6a4d 100644 --- a/src/iana/macros.rs +++ b/src/iana/macros.rs @@ -2,8 +2,10 @@ /// Creates a standard IANA type wrapping an integer. /// -/// This adds impls for From, PartialEq, Eq, PartialOrd, Ord, and Hash. -/// For FromStr and Display, see one of the other macros in this module. +/// This adds impls for `From`, `PartialEq`, `Eq`, `PartialOrd`, `Ord`, and +/// `Hash`. +/// +/// For `FromStr` and `Display`, see one of the other macros in this module. macro_rules! int_enum { ( $(#[$attr:meta])* => $ianatype:ident, $inttype:path; @@ -149,12 +151,12 @@ macro_rules! int_enum { } } -/// Adds impls for FromStr and Display to the type given as first argument. +/// Adds impls for `FromStr` and `Display` to the type given as first argument. /// -/// The FromStr impl matches only well known mnemonics ignoring case, +/// The `FromStr` impl matches only well known mnemonics ignoring case, /// otherwise it returns an error of the second argument. /// -/// For Display, it will display a decimal number for values without +/// For `Display`, it will display a decimal number for values without /// mnemonic. macro_rules! int_enum_str_mnemonics_only { ($ianatype:ident, $error:expr) => { @@ -192,12 +194,12 @@ macro_rules! int_enum_str_mnemonics_only { } -/// Adds impls for FromStr and Display to the type given as first argument. +/// Adds impls for `FromStr` and `Display` to the type given as first argument. /// -/// For FromStr, recognizes all mnemonics case-insensitively as well as a +/// For `FromStr`, recognizes all mnemonics case-insensitively as well as a /// decimal number representing any value. /// -/// For Display, it will display a decimal number for values without +/// For `Display`, it will display a decimal number for values without /// mnemonic. macro_rules! int_enum_str_with_decimal { ($ianatype:ident, $inttype:ident, $error:expr) => { @@ -244,13 +246,13 @@ macro_rules! int_enum_str_with_decimal { } } -/// Adds impls for FromStr and Display to the type given as first argument. +/// Adds impls for `FromStr` and `Display` to the type given as first argument. /// -/// For FromStr recognizes all defined mnemonics ignoring case. Additionally +/// For `FromStr` recognizes all defined mnemonics ignoring case. Additionally /// recognizes a value starting with the prefix given in the second argument /// (again, ignoring case) directly followed by a decimal number. /// -/// For Display, values without mnemonic will be written starting with the +/// For `Display`, values without mnemonic will be written starting with the /// prefix directly followed by the decimal representation of the value. macro_rules! int_enum_str_with_prefix { ($ianatype:ident, $str_prefix:expr, $u8_prefix:expr, $inttype:ident, diff --git a/src/master/record.rs b/src/master/record.rs index e10a0558..16457da0 100644 --- a/src/master/record.rs +++ b/src/master/record.rs @@ -30,7 +30,7 @@ impl MasterRecord { origin: &Option>, default_ttl: Option) -> ScanResult { let owner = try!(MasterRecord::scan_owner(stream, last_owner, - &origin)); + origin)); let (ttl, class) = try!(MasterRecord::scan_ttl_class(stream, default_ttl, last_class)); diff --git a/src/rdata/rfc1035.rs b/src/rdata/rfc1035.rs index 95a4f11d..14ddde59 100644 --- a/src/rdata/rfc1035.rs +++ b/src/rdata/rfc1035.rs @@ -22,8 +22,8 @@ use ::utils::netdb::{ProtoEnt, ServEnt}; /// A macro for implementing a record data type with a single domain name. /// -/// Implements some basic methods plus the RecordData, FlatRecordData, and -/// Display traits. +/// Implements some basic methods plus the `RecordData`, `FlatRecordData`, +/// and `Display` traits. macro_rules! dname_type { ($target:ident, $rtype:ident, $field:ident) => { #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] @@ -703,7 +703,7 @@ impl> Txt { /// borrow else creates an owned vec by concatenating all the parts. pub fn text(&self) -> Cow<[u8]> { let text = self.text.as_ref(); - if text.len() == 0 { + if text.is_empty() { Cow::Borrowed(b"") } else if (text[0] as usize) == text.len() - 1 { diff --git a/src/resolv/public.rs b/src/resolv/public.rs index c32d797f..e3ffc55c 100644 --- a/src/resolv/public.rs +++ b/src/resolv/public.rs @@ -25,7 +25,7 @@ use super::udp::udp_transport; /// queries. You can create a new resoler using the system’s configuration /// using the [`new()`] associate function or using your own configuration /// with [`from_conf()`]. Either function will spawn everything necessary -/// into a tokio_core reactor core represented by a handle. +/// into a `tokio_core` reactor core represented by a handle. /// /// Resolver values can be cloned relatively cheaply as they keep all /// information behind an arc. This is may already be useful when starting @@ -78,10 +78,10 @@ impl Resolver { let mut tcp = Vec::new(); for server in &conf.servers { - if let Some(transport) = udp_transport(reactor, &server) { + if let Some(transport) = udp_transport(reactor, server) { udp.push(transport) } - if let Some(transport) = tcp_transport(reactor, &server) { + if let Some(transport) = tcp_transport(reactor, server) { tcp.push(transport) } } diff --git a/src/resolv/transport/multiplex.rs b/src/resolv/transport/multiplex.rs index 93088dc6..5799a6c1 100644 --- a/src/resolv/transport/multiplex.rs +++ b/src/resolv/transport/multiplex.rs @@ -84,15 +84,14 @@ impl Future for Transport { type Error = (); fn poll(&mut self) -> Poll<(), ()> { - let res = match self.poll_step() { + match self.poll_step() { Ok(()) => Ok(Async::NotReady), Err(_) => { self.pending.fail_all(); self.receiver = None; Ok(Async::Ready(())) } - }; - res + } } } diff --git a/src/resolv/transport/sequential.rs b/src/resolv/transport/sequential.rs index d68c2715..3542f8eb 100644 --- a/src/resolv/transport/sequential.rs +++ b/src/resolv/transport/sequential.rs @@ -175,7 +175,7 @@ impl Transport { /// the receiver has been closed. fn poll_idle(&mut self) -> Poll { match self.receiver.poll().unwrap() { - Async::NotReady => return Ok(Async::NotReady), + Async::NotReady => Ok(Async::NotReady), Async::Ready(None) => Ok(Async::Ready(State::Closed)), Async::Ready(Some(request)) => { self.request = Some(request); diff --git a/src/resolv/transport/single.rs b/src/resolv/transport/single.rs index d93c8463..c2211a9a 100644 --- a/src/resolv/transport/single.rs +++ b/src/resolv/transport/single.rs @@ -156,7 +156,7 @@ impl Transport { /// the receiver has been closed. fn poll_idle(&mut self) -> Poll { match self.receiver.poll().unwrap() { - Async::NotReady => return Ok(Async::NotReady), + Async::NotReady => Ok(Async::NotReady), Async::Ready(None) => Ok(Async::Ready(State::Closed)), Async::Ready(Some(request)) => { self.request = Some(request); diff --git a/src/resolv/udp.rs b/src/resolv/udp.rs index 1a2a5eeb..91f6a0f4 100644 --- a/src/resolv/udp.rs +++ b/src/resolv/udp.rs @@ -34,8 +34,9 @@ pub fn udp_transport(reactor: &reactor::Handle, conf: &ServerConf) /// A channel using UDP as the transport protocol. /// -/// Note that tokio_core currently does not support connecting UDP sockets so -/// we have to do some filtering on our side. This should probably be fixed. +/// Note that `tokio_core` currently does not support connecting UDP sockets +/// so we have to do some filtering on our side. This should probably be +/// fixed. struct UdpChannel { /// The address of the peer. peer: SocketAddr,