Restore compatibility with rustc 1.31 in RenameRule error

str::escape_debug wasn't stabilized until 1.34, whereas serde_derive
currently supports an oldest version of 1.31.
This commit is contained in:
David Tolnay 2021-01-23 14:40:43 -08:00
parent 4e002ece07
commit b7bad3a165
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -5,7 +5,7 @@
#[allow(deprecated, unused_imports)]
use std::ascii::AsciiExt;
use std::fmt::{self, Display};
use std::fmt::{self, Debug, Display};
use self::RenameRule::*;
@ -120,16 +120,14 @@ pub struct ParseError<'a> {
impl<'a> Display for ParseError<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("unknown rename rule `rename_all = \"")?;
self.unknown.escape_debug().fmt(f)?;
f.write_str("\"`, expected one of ")?;
f.write_str("unknown rename rule `rename_all = ")?;
Debug::fmt(self.unknown, f)?;
f.write_str("`, expected one of ")?;
for (i, (name, _rule)) in RENAME_RULES.iter().enumerate() {
if i > 0 {
f.write_str(", ")?;
}
f.write_str("\"")?;
name.escape_debug().fmt(f)?;
f.write_str("\"")?;
Debug::fmt(name, f)?;
}
Ok(())
}