Skip to content

Commit 30d2e3e

Browse files
committed
Fix all warnings in vendored buf_redux and multipart
buf_redux/src/lib.rs: - Remove deprecated description() impl from IntoInnerError Error trait multipart/src/server/field.rs: - Remove unused GENERIC_PARSE_ERR constant - Remove unused std::error::Error import - Replace x.description() calls with x (Display) in quick_error! macros multipart/src/server/save.rs: - Replace deprecated TempDir::into_path() with TempDir::keep() (both return PathBuf)
1 parent 0552674 commit 30d2e3e

3 files changed

Lines changed: 17 additions & 24 deletions

File tree

vendor/buf_redux/src/lib.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ impl<R: Read, P> BufReader<R, P> {
370370
}
371371

372372
/// Box the inner reader without losing data.
373-
pub fn boxed<'a>(self) -> BufReader<Box<Read + 'a>, P> where R: 'a {
374-
let inner: Box<Read + 'a> = Box::new(self.inner);
373+
pub fn boxed<'a>(self) -> BufReader<Box<dyn Read + 'a>, P> where R: 'a {
374+
let inner: Box<dyn Read + 'a> = Box::new(self.inner);
375375

376376
BufReader {
377377
inner,
@@ -864,11 +864,7 @@ impl<W> Into<io::Error> for IntoInnerError<W> {
864864
}
865865

866866
impl<W: Any + Send + fmt::Debug> error::Error for IntoInnerError<W> {
867-
fn description(&self) -> &str {
868-
error::Error::description(self.error())
869-
}
870-
871-
fn cause(&self) -> Option<&error::Error> {
867+
fn cause(&self) -> Option<&dyn error::Error> {
872868
Some(&self.1)
873869
}
874870
}
@@ -1047,7 +1043,7 @@ impl Buffer {
10471043
}
10481044

10491045
let read = {
1050-
let mut buf = unsafe { self.buf.write_buf() };
1046+
let buf = unsafe { self.buf.write_buf() };
10511047
rdr.read(buf)?
10521048
};
10531049

@@ -1065,7 +1061,7 @@ impl Buffer {
10651061
/// space, this returns 0.
10661062
pub fn copy_from_slice(&mut self, src: &[u8]) -> usize {
10671063
let len = unsafe {
1068-
let mut buf = self.buf.write_buf();
1064+
let buf = self.buf.write_buf();
10691065
let len = cmp::min(buf.len(), src.len());
10701066
buf[..len].copy_from_slice(&src[..len]);
10711067
len
@@ -1270,7 +1266,7 @@ pub fn copy_buf<B: BufRead, W: Write>(b: &mut B, w: &mut W) -> io::Result<u64> {
12701266
}
12711267

12721268
thread_local!(
1273-
static DROP_ERR_HANDLER: RefCell<Box<Fn(&mut Write, &mut Buffer, io::Error)>>
1269+
static DROP_ERR_HANDLER: RefCell<Box<dyn Fn(&mut dyn Write, &mut Buffer, io::Error)>>
12741270
= RefCell::new(Box::new(|_, _, _| ()))
12751271
);
12761272

@@ -1283,7 +1279,7 @@ thread_local!(
12831279
/// ### Panics
12841280
/// If called from within a handler previously provided to this function.
12851281
pub fn set_drop_err_handler<F: 'static>(handler: F)
1286-
where F: Fn(&mut Write, &mut Buffer, io::Error)
1282+
where F: Fn(&mut dyn Write, &mut Buffer, io::Error)
12871283
{
12881284
DROP_ERR_HANDLER.with(|deh| *deh.borrow_mut() = Box::new(handler))
12891285
}

vendor/multipart/src/server/field.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
//! `multipart` field header parsing.
99
use mime::Mime;
1010

11-
use std::error::Error;
1211
use std::io::{self, BufRead, Read};
1312
use std::{fmt, str};
1413

@@ -531,38 +530,36 @@ impl<M: ReadEntry, Entry> ReadEntryResult<M, Entry> {
531530
}
532531
}
533532

534-
const GENERIC_PARSE_ERR: &str = "an error occurred while parsing field headers";
535-
536533
quick_error! {
537534
#[derive(Debug)]
538535
enum ParseHeaderError {
539536
/// The `Content-Disposition` header was not found
540537
MissingContentDisposition(headers: String) {
541-
display(x) -> ("{}:\n{}", x.description(), headers)
538+
display(x) -> ("{}:\n{}", x, headers)
542539
description("\"Content-Disposition\" header not found in field headers")
543540
}
544541
InvalidContDisp(reason: &'static str, cause: String) {
545-
display(x) -> ("{}: {}: {}", x.description(), reason, cause)
542+
display(x) -> ("{}: {}: {}", x, reason, cause)
546543
description("invalid \"Content-Disposition\" header")
547544
}
548545
/// The header was found but could not be parsed
549546
TokenizeError(err: HttparseError) {
550-
description(GENERIC_PARSE_ERR)
551-
display(x) -> ("{}: {}", x.description(), err)
547+
description("an error occurred while parsing field headers")
548+
display(x) -> ("{}: {}", x, err)
552549
cause(err)
553550
from()
554551
}
555552
MimeError(cont_type: String) {
556553
description("Failed to parse Content-Type")
557-
display(this) -> ("{}: {}", this.description(), cont_type)
554+
display(this) -> ("{}: {}", this, cont_type)
558555
}
559556
TooLarge {
560557
description("field headers section ridiculously long or missing trailing CRLF-CRLF")
561558
}
562559
/// IO error
563560
Io(err: io::Error) {
564561
description("an io error occurred while parsing the headers")
565-
display(x) -> ("{}: {}", x.description(), err)
562+
display(x) -> ("{}: {}", x, err)
566563
cause(err)
567564
from()
568565
}

vendor/multipart/src/server/save.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ impl SavedData {
510510
/// Get an adapter for this data which implements `Read`.
511511
///
512512
/// If the data is in a file, the file is opened in read-only mode.
513-
pub fn readable(&self) -> io::Result<DataReader> {
513+
pub fn readable(&self) -> io::Result<DataReader<'_>> {
514514
use self::SavedData::*;
515515

516516
match *self {
@@ -664,7 +664,7 @@ impl Entries {
664664
Occupied(occupied) => {
665665
// dedup the field name by reusing the key's `Arc`
666666
headers.name = occupied.key().clone();
667-
occupied.into_mut().push({ SavedField { headers, data }});
667+
occupied.into_mut().push(SavedField { headers, data });
668668
},
669669
}
670670

@@ -733,7 +733,7 @@ impl SaveDir {
733733
use self::SaveDir::*;
734734

735735
match self {
736-
Temp(tempdir) => tempdir.into_path(),
736+
Temp(tempdir) => tempdir.keep(),
737737
Perm(pathbuf) => pathbuf,
738738
}
739739
}
@@ -751,7 +751,7 @@ impl SaveDir {
751751
pub fn keep(&mut self) {
752752
use self::SaveDir::*;
753753
*self = match mem::replace(self, Perm(PathBuf::new())) {
754-
Temp(tempdir) => Perm(tempdir.into_path()),
754+
Temp(tempdir) => Perm(tempdir.keep()),
755755
old_self => old_self,
756756
};
757757
}

0 commit comments

Comments
 (0)