mirror of
https://github.com/NLnetLabs/domain.git
synced 2026-09-27 04:04:53 +02:00
Fix most of Clippy’s complaints.
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
||||
doc-valid-idents = ["CLASSes", "IPv4", "IPv6", "OpCodes", "RRset"]
|
||||
doc-valid-idents = ["CLASSes", "IPv4", "IPv6", "OpCodes", "RRset", "RRsets"]
|
||||
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@ impl Options {
|
||||
|
||||
fn qtype(&self) -> Result<Rtype> {
|
||||
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<Class> {
|
||||
Ok((Class::In))
|
||||
Ok(Class::In)
|
||||
}
|
||||
|
||||
fn conf(&self) -> &ResolvConf { &self.conf }
|
||||
|
||||
+13
-13
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Item=&'a Label> {
|
||||
for item in iter.into_iter() {
|
||||
for item in iter {
|
||||
self.push(item)?
|
||||
}
|
||||
Ok(())
|
||||
|
||||
+13
-11
@@ -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,
|
||||
|
||||
@@ -30,7 +30,7 @@ impl MasterRecord {
|
||||
origin: &Option<Rc<DNameBuf>>,
|
||||
default_ttl: Option<u32>) -> ScanResult<Self> {
|
||||
let owner = try!(MasterRecord::scan_owner(stream, last_owner,
|
||||
&origin));
|
||||
origin));
|
||||
let (ttl, class) = try!(MasterRecord::scan_ttl_class(stream,
|
||||
default_ttl,
|
||||
last_class));
|
||||
|
||||
@@ -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<T: AsRef<[u8]>> Txt<T> {
|
||||
/// 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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,15 +84,14 @@ impl<C: Channel> Future for Transport<C> {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ impl<C: Channel> Transport<C> {
|
||||
/// the receiver has been closed.
|
||||
fn poll_idle(&mut self) -> Poll<State, io::Error> {
|
||||
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);
|
||||
|
||||
@@ -156,7 +156,7 @@ impl<C: Channel> Transport<C> {
|
||||
/// the receiver has been closed.
|
||||
fn poll_idle(&mut self) -> Poll<State, io::Error> {
|
||||
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);
|
||||
|
||||
+3
-2
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user