Skip to content

Commit

Permalink
Restore compatibility with rustc 1.31 in RenameRule error
Browse files Browse the repository at this point in the history
str::escape_debug wasn't stabilized until 1.34, whereas serde_derive
currently supports an oldest version of 1.31.
  • Loading branch information
dtolnay committed Jan 23, 2021
1 parent 4e002ec commit b7bad3a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions serde_derive/src/internals/case.rs
Expand Up @@ -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::*;

Expand Down Expand Up @@ -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(())
}
Expand Down

0 comments on commit b7bad3a

Please sign in to comment.