Fix all bare_trait_objects warnings, and deny them.

This commit is contained in:
Emmanuel Gil Peyrot 2019-06-12 16:29:55 +02:00
parent 07304d7fee
commit 956193e0da
6 changed files with 8 additions and 8 deletions

View file

@ -16,12 +16,12 @@ use crate::{AuthError, Error, ProtocolError};
const NS_XMPP_SASL: &str = "urn:ietf:params:xml:ns:xmpp-sasl";
pub struct ClientAuth<S: AsyncRead + AsyncWrite> {
future: Box<Future<Item = XMPPStream<S>, Error = Error>>,
future: Box<dyn Future<Item = XMPPStream<S>, Error = Error>>,
}
impl<S: AsyncRead + AsyncWrite + 'static> ClientAuth<S> {
pub fn new(stream: XMPPStream<S>, creds: Credentials) -> Result<Self, Error> {
let local_mechs: Vec<Box<Fn() -> Box<Mechanism>>> = vec![
let local_mechs: Vec<Box<dyn Fn() -> Box<dyn Mechanism>>> = vec![
Box::new(|| Box::new(Scram::<Sha256>::from_credentials(creds.clone()).unwrap())),
Box::new(|| Box::new(Scram::<Sha1>::from_credentials(creds.clone()).unwrap())),
Box::new(|| Box::new(Plain::from_credentials(creds.clone()).unwrap())),
@ -62,7 +62,7 @@ impl<S: AsyncRead + AsyncWrite + 'static> ClientAuth<S> {
Err(AuthError::NoMechanism)?
}
fn handle_challenge(stream: XMPPStream<S>, mut mechanism: Box<Mechanism>) -> Box<Future<Item = XMPPStream<S>, Error = Error>> {
fn handle_challenge(stream: XMPPStream<S>, mut mechanism: Box<dyn Mechanism>) -> Box<dyn Future<Item = XMPPStream<S>, Error = Error>> {
Box::new(
stream.into_future()
.map_err(|(e, _stream)| e.into())

View file

@ -33,7 +33,7 @@ const NS_JABBER_CLIENT: &str = "jabber:client";
enum ClientState {
Invalid,
Disconnected,
Connecting(Box<Future<Item = XMPPStream, Error = Error>>),
Connecting(Box<dyn Future<Item = XMPPStream, Error = Error>>),
Connected(XMPPStream),
}

View file

@ -30,7 +30,7 @@ const NS_JABBER_COMPONENT_ACCEPT: &str = "jabber:component:accept";
enum ComponentState {
Invalid,
Disconnected,
Connecting(Box<Future<Item = XMPPStream, Error = Error>>),
Connecting(Box<dyn Future<Item = XMPPStream, Error = Error>>),
Connected(XMPPStream),
}

View file

@ -59,7 +59,7 @@ impl StdError for ParseError {
fn description(&self) -> &str {
self.0.as_ref()
}
fn cause(&self) -> Option<&StdError> {
fn cause(&self) -> Option<&dyn StdError> {
None
}
}

View file

@ -1,4 +1,4 @@
#![deny(unsafe_code, unused, missing_docs)]
#![deny(unsafe_code, unused, missing_docs, bare_trait_objects)]
//! XMPP implementation with asynchronous I/O using Tokio.

View file

@ -219,7 +219,7 @@ impl Decoder for XMPPCodec {
type Error = ParserError;
fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
let buf1: Box<AsRef<[u8]>> = if !self.buf.is_empty() && !buf.is_empty() {
let buf1: Box<dyn AsRef<[u8]>> = if !self.buf.is_empty() && !buf.is_empty() {
let mut prefix = std::mem::replace(&mut self.buf, vec![]);
prefix.extend_from_slice(buf.take().as_ref());
Box::new(prefix)