Bug 1529117 - Re-vendor rust dependencies. r=jrmuizel
☠☠ backed out by d819234834aa ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 27 Feb 2019 11:09:58 +0000
changeset 461427 82cfcc2f5fac53e2c989bff17e84e8fa0f7a1c85
parent 461426 d9fd8225a95f9a83186d4e39a94da62b9d3b83a3
child 461428 d819234834aad12e3388ceb0b09dfb6c8cdd3da9
push id35624
push userdvarga@mozilla.com
push dateWed, 27 Feb 2019 16:31:04 +0000
treeherdermozilla-central@198cd4a81bf2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1529117
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1529117 - Re-vendor rust dependencies. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D20461
Cargo.lock
third_party/rust/serde/.cargo-checksum.json
third_party/rust/serde/Cargo.toml
third_party/rust/serde/LICENSE-MIT
third_party/rust/serde/README.md
third_party/rust/serde/build.rs
third_party/rust/serde/crates-io.md
third_party/rust/serde/src/de/from_primitive.rs
third_party/rust/serde/src/de/ignored_any.rs
third_party/rust/serde/src/de/impls.rs
third_party/rust/serde/src/de/mod.rs
third_party/rust/serde/src/de/utf8.rs
third_party/rust/serde/src/de/value.rs
third_party/rust/serde/src/export.rs
third_party/rust/serde/src/integer128.rs
third_party/rust/serde/src/lib.rs
third_party/rust/serde/src/macros.rs
third_party/rust/serde/src/private/de.rs
third_party/rust/serde/src/private/macros.rs
third_party/rust/serde/src/private/mod.rs
third_party/rust/serde/src/private/ser.rs
third_party/rust/serde/src/ser/impls.rs
third_party/rust/serde/src/ser/impossible.rs
third_party/rust/serde/src/ser/mod.rs
third_party/rust/serde_derive/.cargo-checksum.json
third_party/rust/serde_derive/Cargo.toml
third_party/rust/serde_derive/LICENSE-MIT
third_party/rust/serde_derive/README.md
third_party/rust/serde_derive/crates-io.md
third_party/rust/serde_derive/src/bound.rs
third_party/rust/serde_derive/src/de.rs
third_party/rust/serde_derive/src/dummy.rs
third_party/rust/serde_derive/src/fragment.rs
third_party/rust/serde_derive/src/internals/ast.rs
third_party/rust/serde_derive/src/internals/attr.rs
third_party/rust/serde_derive/src/internals/case.rs
third_party/rust/serde_derive/src/internals/check.rs
third_party/rust/serde_derive/src/internals/ctxt.rs
third_party/rust/serde_derive/src/internals/mod.rs
third_party/rust/serde_derive/src/lib.rs
third_party/rust/serde_derive/src/pretend.rs
third_party/rust/serde_derive/src/ser.rs
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,12 +1,8 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
 [[package]]
 name = "Inflector"
 version = "0.11.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
--- a/third_party/rust/serde/.cargo-checksum.json
+++ b/third_party/rust/serde/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{"Cargo.toml":"d370184a37692fbf66fc20feef381e5ce9a1a7c6e95fd855c03c796b15f28f0e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"c4218d07d775c036cd50495b0354c5b59435472b12e159042cacb30b6ef1a7c1","build.rs":"f3fdadb2b0f8c9f1568903f47cfc48a8e5ec3f81dd54a067fda5e4fa084d0d30","crates-io.md":"8dce715dfbd2e9bbdd87e401d1f7974a60089f0673f7a84f4c5d840411075d14","src/de/from_primitive.rs":"3cf03cb47d884ff32555673831d79de8f6bf0c58a22783d73077d1f694c1494d","src/de/ignored_any.rs":"90b6b3c79472fd6c8997f4456dae9f28d4dbaa87efdbbc5fb304d6a83c560d00","src/de/impls.rs":"76b2b181e9cd9e748fae1bdb1e30a256f9ea3d5398be191a23fe56164c6792dd","src/de/mod.rs":"5def657ab51bf031c7706b98a19d369abef80a8c1c5b46267dc8223c904ba52b","src/de/utf8.rs":"956b124b7ce98353cb781b56e43a6fed2e67f1389d35b7a468d5be75b1485853","src/de/value.rs":"5883ea09fb61c30fcb7422a000688481f4fae4c0980ca4618f8b5747b573d545","src/export.rs":"4e3ed8aa2b0e5d9c18f462183dff7fa4772a30e88e6b3cc0fb9712282ecbe0c5","src/integer128.rs":"1bf9e18047a4a3f95a43b8d253e4f844b6be62e71684e47d980582462bce4223","src/lib.rs":"d6d7291950ff051c9958a31eb39f34edfbb5fd1692185bf99e0f55b3aa6f802f","src/macros.rs":"953b42721810eb26239231849af2f9f461721497695317e7672001c27d2cb25c","src/private/de.rs":"29a62d208e9439f8ce6dff4bca746a9e85b36b88da13f187a320be84a66cebc0","src/private/macros.rs":"0bebda4a3c1b794280d21581fc0d5e3cf130647f53b6a8ac157164c74e14df51","src/private/mod.rs":"0c774d86042cefdb447857070a1d4d2c0b9f519a7f5db588a1e7fcc16ca5a511","src/private/ser.rs":"56b61986a7c57d37d65d763cb69119889a3dc06eb27a9e95cd5e758acf0e4535","src/ser/impls.rs":"d3bb23bc5860e7ed4b7cdf01c66d22e1ac6e2ec2efb52ba831298fd63a27baed","src/ser/impossible.rs":"91da408362284ec567b2316050900251ff66a1134413963720154fb70f3919c0","src/ser/mod.rs":"feba74b5c928ce00c2fcc5d8602e7255a0731428fefd2de45353170334cdbea4"},"package":"15c141fc7027dd265a47c090bf864cf62b42c4d228bbcf4e51a0c9e2b0d3f7ef"}
\ No newline at end of file
+{"files":{"Cargo.toml":"3084cb56ac54d166ae7c7ef988c63ab8fd2718f06f09eadbb510c7150608d5e9","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"11f6eec1a694070311f8ff191c53e67b90bf1d5064f32d684a1b73b1c3264ac1","build.rs":"35a17dedfe5d52409eb3932a52698a20da2ba6b28b606a31116385aa3c627c44","crates-io.md":"131dee2d4beaf83485aed22942b98815ef65af9bcfb65f02b5b90c59b8bc7b8b","src/de/from_primitive.rs":"058fa17313ed3a9c29ec04c6ec67f21a756f6f28cdeb4b0dfcd7012b3e702d0b","src/de/ignored_any.rs":"3c199f3e4c3f8775ab30439c6868b61aa0a32fa23232b218afb94d1aadb15f0a","src/de/impls.rs":"902c73687e37b13acbbd6ce4089742a6be3ee12a7e9e1cab1719fad7dcdd8e04","src/de/mod.rs":"1e4b0fde0bb8e0fc64da23fe6b70291554162a8eed434250a0469dae0bf55a97","src/de/utf8.rs":"f17524ee0af98ec3abcfd7d0b812fbd1033263bd8e2ce2f57c1e1999ce153558","src/de/value.rs":"c738089a0309ba1749f69a4bb01e237d6ddaecba0799db009a2661c5269873c3","src/export.rs":"dceb648800cd6a4ee651259a203c6d98bffe768b943f090e4a06ff0c1cfc701f","src/integer128.rs":"f8298a559f1fae7579819cb68f6cba8c01cdda11737cf1fb498bf52810c130b6","src/lib.rs":"79fc780521079f4fef7c500d1dccba339cd21b9f00929948b6fe96ebef442cea","src/macros.rs":"f18fc25c5fb857238bf119cdee5c7987a8584dea69c51f27ca718b7dfd871d0f","src/private/de.rs":"2a4b0b7145135b1116f7b0af4adebe74b7d3aa4cc96896584066a654aa4b6c6c","src/private/macros.rs":"ebb6affd4c89e3b5f9a42e03f8b7d966bc588875e9b44e962d0b7aba7f80a10f","src/private/mod.rs":"f8f2cd5edbfc26c268b34cdb89db1b34e6348f81384f03d18532e7568575006d","src/private/ser.rs":"946bf9910bb646a4c1732fd17f8c98db2515fe23edeb6e622e3618ff4de46b33","src/ser/impls.rs":"a3863d6d8c2bcf711fb146021680dc698814dadc1fb1415b9909ad1f0b19982e","src/ser/impossible.rs":"3dd0e165b88fc67e698e675f16569b91fab9e054caa4c3e1997f929ba364fe90","src/ser/mod.rs":"20784f4f03a49071a519232026580bf9079bd1544c01eb18ce618eeb9c6ccd89"},"package":"9f301d728f2b94c9a7691c90f07b0b4e8a4517181d9461be94c04bddeb4bd850"}
\ No newline at end of file
--- a/third_party/rust/serde/Cargo.toml
+++ b/third_party/rust/serde/Cargo.toml
@@ -7,28 +7,30 @@
 #
 # If you believe there's an error in this file please file an
 # issue against the rust-lang/cargo repository. If you're
 # editing this file be aware that the upstream Cargo.toml
 # will likely look very different (and much more reasonable)
 
 [package]
 name = "serde"
-version = "1.0.80"
+version = "1.0.88"
 authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
 build = "build.rs"
 include = ["Cargo.toml", "build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
 description = "A generic serialization/deserialization framework"
 homepage = "https://serde.rs"
 documentation = "https://docs.serde.rs/serde/"
 readme = "crates-io.md"
 keywords = ["serde", "serialization", "no_std"]
 categories = ["encoding"]
 license = "MIT/Apache-2.0"
 repository = "https://github.com/serde-rs/serde"
+[package.metadata.playground]
+features = ["derive", "rc"]
 [dependencies.serde_derive]
 version = "1.0"
 optional = true
 [dev-dependencies.serde_derive]
 version = "1.0"
 
 [features]
 alloc = ["unstable"]
--- a/third_party/rust/serde/LICENSE-MIT
+++ b/third_party/rust/serde/LICENSE-MIT
@@ -1,10 +1,8 @@
-Copyright (c) 2014 The Rust Project Developers
-
 Permission is hereby granted, free of charge, to any
 person obtaining a copy of this software and associated
 documentation files (the "Software"), to deal in the
 Software without restriction, including without
 limitation the rights to use, copy, modify, merge,
 publish, distribute, sublicense, and/or sell copies of
 the Software, and to permit persons to whom the Software
 is furnished to do so, subject to the following
--- a/third_party/rust/serde/README.md
+++ b/third_party/rust/serde/README.md
@@ -20,44 +20,38 @@ You may be looking for:
 - [API documentation](https://docs.serde.rs/serde/)
 - [Release notes](https://github.com/serde-rs/serde/releases)
 
 ## Serde in action
 
 <details>
 <summary>
 Click to show Cargo.toml.
-<a href="https://play.rust-lang.org/?gist=9003c5b88c1f4989941925d7190c6eec" target="_blank">Run this code in the playground.</a>
+<a href="https://play.rust-lang.org/?edition=2018&gist=72755f28f99afc95e01d63174b28c1f5" target="_blank">Run this code in the playground.</a>
 </summary>
 
 ```toml
 [dependencies]
 
 # The core APIs, including the Serialize and Deserialize traits. Always
-# required when using Serde.
-serde = "1.0"
-
-# Support for #[derive(Serialize, Deserialize)]. Required if you want Serde
-# to work for structs and enums defined in your crate.
-serde_derive = "1.0"
+# required when using Serde. The "derive" feature is only required when
+# using #[derive(Serialize, Deserialize)] to make Serde work with structs
+# and enums defined in your crate.
+serde = { version = "1.0", features = ["derive"] }
 
 # Each data format lives in its own crate; the sample code below uses JSON
 # but you may be using a different one.
 serde_json = "1.0"
 ```
 
 </details>
 <p></p>
 
 ```rust
-#[macro_use]
-extern crate serde_derive;
-
-extern crate serde;
-extern crate serde_json;
+use serde::{Serialize, Deserialize};
 
 #[derive(Serialize, Deserialize, Debug)]
 struct Point {
     x: i32,
     y: i32,
 }
 
 fn main() {
--- a/third_party/rust/serde/build.rs
+++ b/third_party/rust/serde/build.rs
@@ -9,16 +9,25 @@ fn main() {
     let minor = match rustc_minor_version() {
         Some(minor) => minor,
         None => return,
     };
 
     let target = env::var("TARGET").unwrap();
     let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten";
 
+    // std::collections::Bound was stabilized in Rust 1.17
+    // but it was moved to core::ops later in Rust 1.26:
+    // https://doc.rust-lang.org/core/ops/enum.Bound.html
+    if minor >= 26 {
+        println!("cargo:rustc-cfg=ops_bound");
+    } else if minor >= 17 && cfg!(feature = "std") {
+        println!("cargo:rustc-cfg=collections_bound");
+    }
+
     // CString::into_boxed_c_str stabilized in Rust 1.20:
     // https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_boxed_c_str
     if minor >= 20 {
         println!("cargo:rustc-cfg=de_boxed_c_str");
     }
 
     // From<Box<T>> for Rc<T> / Arc<T> stabilized in Rust 1.21:
     // https://doc.rust-lang.org/std/rc/struct.Rc.html#impl-From<Box<T>>
@@ -66,21 +75,16 @@ fn rustc_minor_version() -> Option<u32> 
         Err(_) => return None,
     };
 
     let version = match str::from_utf8(&output.stdout) {
         Ok(version) => version,
         Err(_) => return None,
     };
 
-    // Temporary workaround to support the old 1.26-dev compiler on docs.rs.
-    if version.contains("0eb87c9bf") {
-        return Some(25);
-    }
-
     let mut pieces = version.split('.');
     if pieces.next() != Some("rustc 1") {
         return None;
     }
 
     let next = match pieces.next() {
         Some(next) => next,
         None => return None,
--- a/third_party/rust/serde/crates-io.md
+++ b/third_party/rust/serde/crates-io.md
@@ -11,21 +11,17 @@ You may be looking for:
 - [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/derive.html)
 - [Examples](https://serde.rs/examples.html)
 - [API documentation](https://docs.serde.rs/serde/)
 - [Release notes](https://github.com/serde-rs/serde/releases)
 
 ## Serde in action
 
 ```rust
-#[macro_use]
-extern crate serde_derive;
-
-extern crate serde;
-extern crate serde_json;
+use serde::{Serialize, Deserialize};
 
 #[derive(Serialize, Deserialize, Debug)]
 struct Point {
     x: i32,
     y: i32,
 }
 
 fn main() {
--- a/third_party/rust/serde/src/de/from_primitive.rs
+++ b/third_party/rust/serde/src/de/from_primitive.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use lib::*;
 
 macro_rules! int_to_int {
     ($dst:ident, $n:ident) => {
         if $dst::min_value() as i64 <= $n as i64 && $n as i64 <= $dst::max_value() as i64 {
             Some($n as $dst)
         } else {
             None
--- a/third_party/rust/serde/src/de/ignored_any.rs
+++ b/third_party/rust/serde/src/de/ignored_any.rs
@@ -1,40 +1,32 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use lib::*;
 
 use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
 
 /// An efficient way of discarding data from a deserializer.
 ///
 /// Think of this like `serde_json::Value` in that it can be deserialized from
 /// any type, except that it does not store any information about the data that
 /// gets deserialized.
 ///
-/// ```rust
+/// ```edition2018
 /// use std::fmt;
 /// use std::marker::PhantomData;
 ///
 /// use serde::de::{
 ///     self, Deserialize, DeserializeSeed, Deserializer, IgnoredAny, SeqAccess, Visitor,
 /// };
 ///
 /// /// A seed that can be used to deserialize only the `n`th element of a sequence
 /// /// while efficiently discarding elements of any type before or after index `n`.
 /// ///
 /// /// For example to deserialize only the element at index 3:
 /// ///
-/// /// ```rust
+/// /// ```
 /// /// NthElement::new(3).deserialize(deserializer)
 /// /// ```
 /// pub struct NthElement<T> {
 ///     n: usize,
 ///     marker: PhantomData<T>,
 /// }
 ///
 /// impl<T> NthElement<T> {
--- a/third_party/rust/serde/src/de/impls.rs
+++ b/third_party/rust/serde/src/de/impls.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use lib::*;
 
 use de::{
     Deserialize, Deserializer, EnumAccess, Error, SeqAccess, Unexpected, VariantAccess, Visitor,
 };
 
 #[cfg(any(core_duration, feature = "std", feature = "alloc"))]
 use de::MapAccess;
@@ -869,17 +861,19 @@ where
                 while let Some(value) = try!(seq.next_element()) {
                     values.push(value);
                 }
 
                 Ok(values)
             }
         }
 
-        let visitor = VecVisitor { marker: PhantomData };
+        let visitor = VecVisitor {
+            marker: PhantomData,
+        };
         deserializer.deserialize_seq(visitor)
     }
 
     fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error>
     where
         D: Deserializer<'de>,
     {
         struct VecInPlaceVisitor<'a, T: 'a>(&'a mut Vec<T>);
@@ -1420,17 +1414,17 @@ impl<'de> Deserialize<'de> for net::IpAd
                 {
                     s.parse().map_err(Error::custom)
                 }
             }
 
             deserializer.deserialize_str(IpAddrVisitor)
         } else {
             use lib::net::IpAddr;
-            deserialize_enum!{
+            deserialize_enum! {
                 IpAddr IpAddrKind (V4; b"V4"; 0, V6; b"V6"; 1)
                 "`V4` or `V6`",
                 deserializer
             }
         }
     }
 }
 
@@ -1497,17 +1491,17 @@ impl<'de> Deserialize<'de> for net::Sock
                 {
                     s.parse().map_err(Error::custom)
                 }
             }
 
             deserializer.deserialize_str(SocketAddrVisitor)
         } else {
             use lib::net::SocketAddr;
-            deserialize_enum!{
+            deserialize_enum! {
                 SocketAddr SocketAddrKind (V4; b"V4"; 0, V6; b"V6"; 1)
                 "`V4` or `V6`",
                 deserializer
             }
         }
     }
 }
 
@@ -1597,17 +1591,17 @@ impl<'de> Deserialize<'de> for PathBuf {
 
 ////////////////////////////////////////////////////////////////////////////////
 
 // If this were outside of the serde crate, it would just use:
 //
 //    #[derive(Deserialize)]
 //    #[serde(variant_identifier)]
 #[cfg(all(feature = "std", any(unix, windows)))]
-variant_identifier!{
+variant_identifier! {
     OsStringKind (Unix; b"Unix"; 0, Windows; b"Windows"; 1)
     "`Unix` or `Windows`",
     OSSTR_VARIANTS
 }
 
 #[cfg(all(feature = "std", any(unix, windows)))]
 struct OsStringVisitor;
 
@@ -1755,21 +1749,17 @@ where
     {
         try!(Option::<T>::deserialize(deserializer));
         Ok(ArcWeak::new())
     }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
-#[cfg(all(
-    de_rc_dst,
-    feature = "rc",
-    any(feature = "std", feature = "alloc")
-))]
+#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
 macro_rules! box_forwarded_impl {
     (
         $(#[doc = $doc:tt])*
         $t:ident
     ) => {
         $(#[doc = $doc])*
         impl<'de, T: ?Sized> Deserialize<'de> for $t<T>
         where
@@ -1780,37 +1770,29 @@ macro_rules! box_forwarded_impl {
                 D: Deserializer<'de>,
             {
                 Box::deserialize(deserializer).map(Into::into)
             }
         }
     };
 }
 
-#[cfg(all(
-    de_rc_dst,
-    feature = "rc",
-    any(feature = "std", feature = "alloc")
-))]
+#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
 box_forwarded_impl! {
     /// This impl requires the [`"rc"`] Cargo feature of Serde.
     ///
     /// Deserializing a data structure containing `Rc` will not attempt to
     /// deduplicate `Rc` references to the same data. Every deserialized `Rc`
     /// will end up with a strong count of 1.
     ///
     /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
     Rc
 }
 
-#[cfg(all(
-    de_rc_dst,
-    feature = "rc",
-    any(feature = "std", feature = "alloc")
-))]
+#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
 box_forwarded_impl! {
     /// This impl requires the [`"rc"`] Cargo feature of Serde.
     ///
     /// Deserializing a data structure containing `Arc` will not attempt to
     /// deduplicate `Arc` references to the same data. Every deserialized `Arc`
     /// will end up with a strong count of 1.
     ///
     /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
@@ -2282,16 +2264,127 @@ mod range {
             };
             Ok((start, end))
         }
     }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
+#[cfg(any(ops_bound, collections_bound))]
+impl<'de, T> Deserialize<'de> for Bound<T>
+where
+    T: Deserialize<'de>,
+{
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+    where
+        D: Deserializer<'de>,
+    {
+        enum Field {
+            Unbounded,
+            Included,
+            Excluded,
+        }
+
+        impl<'de> Deserialize<'de> for Field {
+            #[inline]
+            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+            where
+                D: Deserializer<'de>,
+            {
+                struct FieldVisitor;
+
+                impl<'de> Visitor<'de> for FieldVisitor {
+                    type Value = Field;
+
+                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                        formatter.write_str("`Unbounded`, `Included` or `Excluded`")
+                    }
+
+                    fn visit_u32<E>(self, value: u32) -> Result<Self::Value, E>
+                    where
+                        E: Error,
+                    {
+                        match value {
+                            0 => Ok(Field::Unbounded),
+                            1 => Ok(Field::Included),
+                            2 => Ok(Field::Excluded),
+                            _ => Err(Error::invalid_value(
+                                Unexpected::Unsigned(value as u64),
+                                &self,
+                            )),
+                        }
+                    }
+
+                    fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
+                    where
+                        E: Error,
+                    {
+                        match value {
+                            "Unbounded" => Ok(Field::Unbounded),
+                            "Included" => Ok(Field::Included),
+                            "Excluded" => Ok(Field::Excluded),
+                            _ => Err(Error::unknown_variant(value, VARIANTS)),
+                        }
+                    }
+
+                    fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E>
+                    where
+                        E: Error,
+                    {
+                        match value {
+                            b"Unbounded" => Ok(Field::Unbounded),
+                            b"Included" => Ok(Field::Included),
+                            b"Excluded" => Ok(Field::Excluded),
+                            _ => match str::from_utf8(value) {
+                                Ok(value) => Err(Error::unknown_variant(value, VARIANTS)),
+                                Err(_) => {
+                                    Err(Error::invalid_value(Unexpected::Bytes(value), &self))
+                                }
+                            },
+                        }
+                    }
+                }
+
+                deserializer.deserialize_identifier(FieldVisitor)
+            }
+        }
+
+        struct BoundVisitor<T>(PhantomData<Bound<T>>);
+
+        impl<'de, T> Visitor<'de> for BoundVisitor<T>
+        where
+            T: Deserialize<'de>,
+        {
+            type Value = Bound<T>;
+
+            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                formatter.write_str("enum Bound")
+            }
+
+            fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
+            where
+                A: EnumAccess<'de>,
+            {
+                match try!(data.variant()) {
+                    (Field::Unbounded, v) => v.unit_variant().map(|()| Bound::Unbounded),
+                    (Field::Included, v) => v.newtype_variant().map(Bound::Included),
+                    (Field::Excluded, v) => v.newtype_variant().map(Bound::Excluded),
+                }
+            }
+        }
+
+        const VARIANTS: &'static [&'static str] = &["Unbounded", "Included", "Excluded"];
+
+        deserializer.deserialize_enum("Bound", VARIANTS, BoundVisitor(PhantomData))
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
 macro_rules! nonzero_integers {
     ( $( $T: ident, )+ ) => {
         $(
             #[cfg(num_nonzero)]
             impl<'de> Deserialize<'de> for num::$T {
                 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
                 where
                     D: Deserializer<'de>,
--- a/third_party/rust/serde/src/de/mod.rs
+++ b/third_party/rust/serde/src/de/mod.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 //! Generic data structure deserialization framework.
 //!
 //! The two most important traits in this module are [`Deserialize`] and
 //! [`Deserializer`].
 //!
 //!  - **A type that implements `Deserialize` is a data structure** that can be
 //!    deserialized from any data format supported by Serde, and conversely
 //!  - **A type that implements `Deserializer` is a data format** that can
@@ -92,16 +84,17 @@
 //!    - OsString
 //!  - **Miscellaneous standard library types**:
 //!    - Duration
 //!    - SystemTime
 //!    - Path
 //!    - PathBuf
 //!    - Range\<T\>
 //!    - RangeInclusive\<T\>
+//!    - Bound\<T\>
 //!    - num::NonZero*
 //!    - `!` *(unstable)*
 //!  - **Net types**:
 //!    - IpAddr
 //!    - Ipv4Addr
 //!    - Ipv6Addr
 //!    - SocketAddr
 //!    - SocketAddrV4
@@ -156,17 +149,17 @@ macro_rules! declare_error_trait {
         /// type appropriate for a basic JSON data format.
         ///
         /// [example data format]: https://serde.rs/data-format.html
         pub trait Error: Sized $(+ $($supertrait)::+)* {
             /// Raised when there is general error when deserializing a type.
             ///
             /// The message should not be capitalized and should not end with a period.
             ///
-            /// ```rust
+            /// ```edition2018
             /// # use std::str::FromStr;
             /// #
             /// # struct IpAddr;
             /// #
             /// # impl FromStr for IpAddr {
             /// #     type Err = String;
             /// #
             /// #     fn from_str(_: &str) -> Result<Self, String> {
@@ -176,17 +169,17 @@ macro_rules! declare_error_trait {
             /// #
             /// use serde::de::{self, Deserialize, Deserializer};
             ///
             /// impl<'de> Deserialize<'de> for IpAddr {
             ///     fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
             ///     where
             ///         D: Deserializer<'de>,
             ///     {
-            ///         let s = try!(String::deserialize(deserializer));
+            ///         let s = String::deserialize(deserializer)?;
             ///         s.parse().map_err(de::Error::custom)
             ///     }
             /// }
             /// ```
             fn custom<T>(msg: T) -> Self
             where
                 T: Display;
 
@@ -240,36 +233,44 @@ macro_rules! declare_error_trait {
                 Error::custom(format_args!("invalid length {}, expected {}", len, exp))
             }
 
             /// Raised when a `Deserialize` enum type received a variant with an
             /// unrecognized name.
             #[cold]
             fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self {
                 if expected.is_empty() {
-                    Error::custom(format_args!("unknown variant `{}`, there are no variants",
-                                               variant))
+                    Error::custom(format_args!(
+                        "unknown variant `{}`, there are no variants",
+                        variant
+                    ))
                 } else {
-                    Error::custom(format_args!("unknown variant `{}`, expected {}",
-                                               variant,
-                                               OneOf { names: expected }))
+                    Error::custom(format_args!(
+                        "unknown variant `{}`, expected {}",
+                        variant,
+                        OneOf { names: expected }
+                    ))
                 }
             }
 
             /// Raised when a `Deserialize` struct type received a field with an
             /// unrecognized name.
             #[cold]
             fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self {
                 if expected.is_empty() {
-                    Error::custom(format_args!("unknown field `{}`, there are no fields",
-                                               field))
+                    Error::custom(format_args!(
+                        "unknown field `{}`, there are no fields",
+                        field
+                    ))
                 } else {
-                    Error::custom(format_args!("unknown field `{}`, expected {}",
-                                               field,
-                                               OneOf { names: expected }))
+                    Error::custom(format_args!(
+                        "unknown field `{}`, expected {}",
+                        field,
+                        OneOf { names: expected }
+                    ))
                 }
             }
 
             /// Raised when a `Deserialize` struct type expected to receive a required
             /// field with a particular name but that field was not present in the
             /// input.
             #[cold]
             fn missing_field(field: &'static str) -> Self {
@@ -293,17 +294,17 @@ declare_error_trait!(Error: Sized + erro
 declare_error_trait!(Error: Sized + Debug + Display);
 
 /// `Unexpected` represents an unexpected invocation of any one of the `Visitor`
 /// trait methods.
 ///
 /// This is used as an argument to the `invalid_type`, `invalid_value`, and
 /// `invalid_length` methods of the `Error` trait to build error messages.
 ///
-/// ```rust
+/// ```edition2018
 /// # use std::fmt;
 /// #
 /// # use serde::de::{self, Unexpected, Visitor};
 /// #
 /// # struct Example;
 /// #
 /// # impl<'de> Visitor<'de> for Example {
 /// #     type Value = ();
@@ -418,17 +419,17 @@ impl<'a> fmt::Display for Unexpected<'a>
 /// message should be a noun or noun phrase that completes the sentence "This
 /// Visitor expects to receive ...", for example the message could be "an
 /// integer between 0 and 64". The message should not be capitalized and should
 /// not end with a period.
 ///
 /// Within the context of a `Visitor` implementation, the `Visitor` itself
 /// (`&self`) is an implementation of this trait.
 ///
-/// ```rust
+/// ```edition2018
 /// # use std::fmt;
 /// #
 /// # use serde::de::{self, Unexpected, Visitor};
 /// #
 /// # struct Example;
 /// #
 /// # impl<'de> Visitor<'de> for Example {
 /// #     type Value = ();
@@ -443,17 +444,17 @@ impl<'a> fmt::Display for Unexpected<'a>
 /// {
 ///     Err(de::Error::invalid_type(Unexpected::Bool(v), &self))
 /// }
 /// # }
 /// ```
 ///
 /// Outside of a `Visitor`, `&"..."` can be used.
 ///
-/// ```rust
+/// ```edition2018
 /// # use serde::de::{self, Unexpected};
 /// #
 /// # fn example<E>() -> Result<(), E>
 /// # where
 /// #     E: de::Error,
 /// # {
 /// #     let v = true;
 /// return Err(de::Error::invalid_type(Unexpected::Bool(v), &"a negative integer"));
@@ -564,17 +565,17 @@ pub trait Deserialize<'de>: Sized {
 /// A data structure that can be deserialized without borrowing any data from
 /// the deserializer.
 ///
 /// This is primarily useful for trait bounds on functions. For example a
 /// `from_str` function may be able to deserialize a data structure that borrows
 /// from the input string, but a `from_reader` function may only deserialize
 /// owned data.
 ///
-/// ```rust
+/// ```edition2018
 /// # use serde::de::{Deserialize, DeserializeOwned};
 /// # use std::io::{Read, Result};
 /// #
 /// # trait Ignore {
 /// fn from_str<'a, T>(s: &'a str) -> Result<T>
 /// where
 ///     T: Deserialize<'a>;
 ///
@@ -603,31 +604,31 @@ impl<T> DeserializeOwned for T where T: 
 /// array into an existing buffer. Using the `Deserialize` trait we could
 /// deserialize a JSON array into a `Vec<T>` but it would be a freshly allocated
 /// `Vec<T>`; there is no way for `Deserialize` to reuse a previously allocated
 /// buffer. Using `DeserializeSeed` instead makes this possible as in the
 /// example code below.
 ///
 /// The canonical API for stateless deserialization looks like this:
 ///
-/// ```rust
+/// ```edition2018
 /// # use serde::Deserialize;
 /// #
 /// # enum Error {}
 /// #
 /// fn func<'de, T: Deserialize<'de>>() -> Result<T, Error>
 /// # {
 /// #     unimplemented!()
 /// # }
 /// ```
 ///
 /// Adjusting an API like this to support stateful deserialization is a matter
 /// of accepting a seed as input:
 ///
-/// ```rust
+/// ```edition2018
 /// # use serde::de::DeserializeSeed;
 /// #
 /// # enum Error {}
 /// #
 /// fn func_seed<'de, T: DeserializeSeed<'de>>(seed: T) -> Result<T::Value, Error>
 /// # {
 /// #     let _ = seed;
 /// #     unimplemented!()
@@ -650,17 +651,17 @@ impl<T> DeserializeOwned for T where T: 
 ///
 /// Suppose we have JSON that looks like `[[1, 2], [3, 4, 5], [6]]` and we need
 /// to deserialize it into a flat representation like `vec![1, 2, 3, 4, 5, 6]`.
 /// Allocating a brand new `Vec<T>` for each subarray would be slow. Instead we
 /// would like to allocate a single `Vec<T>` and then deserialize each subarray
 /// into it. This requires stateful deserialization using the `DeserializeSeed`
 /// trait.
 ///
-/// ```rust
+/// ```edition2018
 /// use std::fmt;
 /// use std::marker::PhantomData;
 ///
 /// use serde::de::{Deserialize, DeserializeSeed, Deserializer, SeqAccess, Visitor};
 ///
 /// // A DeserializeSeed implementation that uses stateful deserialization to
 /// // append array elements onto the end of an existing vector. The preexisting
 /// // state ("seed") in this case is the Vec<T>. The `deserialize` method of
@@ -1140,17 +1141,17 @@ pub trait Deserializer<'de>: Sized {
     /// deserialize their human-readable form.
     ///
     /// Some types have a human-readable form that may be somewhat expensive to
     /// construct, as well as a binary form that is compact and efficient.
     /// Generally text-based formats like JSON and YAML will prefer to use the
     /// human-readable one and binary formats like Bincode will prefer the
     /// compact one.
     ///
-    /// ```
+    /// ```edition2018
     /// # use std::ops::Add;
     /// # use std::str::FromStr;
     /// #
     /// # struct Timestamp;
     /// #
     /// # impl Timestamp {
     /// #     const EPOCH: Timestamp = Timestamp;
     /// # }
@@ -1217,17 +1218,17 @@ pub trait Deserializer<'de>: Sized {
 /// The `'de` lifetime of this trait is the requirement for lifetime of data
 /// that may be borrowed by `Self::Value`. See the page [Understanding
 /// deserializer lifetimes] for a more detailed explanation of these lifetimes.
 ///
 /// [Understanding deserializer lifetimes]: https://serde.rs/lifetimes.html
 ///
 /// # Example
 ///
-/// ```rust
+/// ```edition2018
 /// # use std::fmt;
 /// #
 /// # use serde::de::{self, Unexpected, Visitor};
 /// #
 /// /// A visitor that deserializes a long string - a string containing at least
 /// /// some minimum number of bytes.
 /// struct LongString {
 ///     min: usize,
@@ -1258,17 +1259,17 @@ pub trait Visitor<'de>: Sized {
 
     /// Format a message stating what data this Visitor expects to receive.
     ///
     /// This is used in error messages. The message should complete the sentence
     /// "This Visitor expects to receive ...", for example the message could be
     /// "an integer between 0 and 64". The message should not be capitalized and
     /// should not end with a period.
     ///
-    /// ```rust
+    /// ```edition2018
     /// # use std::fmt;
     /// #
     /// # struct S {
     /// #     max: usize,
     /// # }
     /// #
     /// # impl<'de> serde::de::Visitor<'de> for S {
     /// #     type Value = ();
@@ -1999,17 +2000,17 @@ pub trait VariantAccess<'de>: Sized {
     /// deserialization. Must match the error type of our `EnumAccess`.
     type Error: Error;
 
     /// Called when deserializing a variant with no values.
     ///
     /// If the data contains a different type of variant, the following
     /// `invalid_type` error should be constructed:
     ///
-    /// ```rust
+    /// ```edition2018
     /// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
     /// #
     /// # struct X;
     /// #
     /// # impl<'de> VariantAccess<'de> for X {
     /// #     type Error = value::Error;
     /// #
     /// fn unit_variant(self) -> Result<(), Self::Error> {
@@ -2039,17 +2040,17 @@ pub trait VariantAccess<'de>: Sized {
     /// Called when deserializing a variant with a single value.
     ///
     /// `Deserialize` implementations should typically use
     /// `VariantAccess::newtype_variant` instead.
     ///
     /// If the data contains a different type of variant, the following
     /// `invalid_type` error should be constructed:
     ///
-    /// ```rust
+    /// ```edition2018
     /// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
     /// #
     /// # struct X;
     /// #
     /// # impl<'de> VariantAccess<'de> for X {
     /// #     type Error = value::Error;
     /// #
     /// #     fn unit_variant(self) -> Result<(), Self::Error> {
@@ -2095,17 +2096,17 @@ pub trait VariantAccess<'de>: Sized {
 
     /// Called when deserializing a tuple-like variant.
     ///
     /// The `len` is the number of fields expected in the tuple variant.
     ///
     /// If the data contains a different type of variant, the following
     /// `invalid_type` error should be constructed:
     ///
-    /// ```rust
+    /// ```edition2018
     /// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
     /// #
     /// # struct X;
     /// #
     /// # impl<'de> VariantAccess<'de> for X {
     /// #     type Error = value::Error;
     /// #
     /// #     fn unit_variant(self) -> Result<(), Self::Error> {
@@ -2142,17 +2143,17 @@ pub trait VariantAccess<'de>: Sized {
 
     /// Called when deserializing a struct-like variant.
     ///
     /// The `fields` are the names of the fields of the struct variant.
     ///
     /// If the data contains a different type of variant, the following
     /// `invalid_type` error should be constructed:
     ///
-    /// ```rust
+    /// ```edition2018
     /// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
     /// #
     /// # struct X;
     /// #
     /// # impl<'de> VariantAccess<'de> for X {
     /// #     type Error = value::Error;
     /// #
     /// #     fn unit_variant(self) -> Result<(), Self::Error> {
@@ -2202,40 +2203,34 @@ pub trait VariantAccess<'de>: Sized {
 /// The `'de` lifetime of this trait is the lifetime of data that may be
 /// borrowed from the resulting `Deserializer`. See the page [Understanding
 /// deserializer lifetimes] for a more detailed explanation of these lifetimes.
 ///
 /// [Understanding deserializer lifetimes]: https://serde.rs/lifetimes.html
 ///
 /// # Example
 ///
-/// ```rust
-/// #[macro_use]
-/// extern crate serde_derive;
-///
-/// extern crate serde;
-///
+/// ```edition2018
 /// use std::str::FromStr;
-/// use serde::de::{value, Deserialize, IntoDeserializer};
+/// use serde::Deserialize;
+/// use serde::de::{value, IntoDeserializer};
 ///
 /// #[derive(Deserialize)]
 /// enum Setting {
 ///     On,
 ///     Off,
 /// }
 ///
 /// impl FromStr for Setting {
 ///     type Err = value::Error;
 ///
 ///     fn from_str(s: &str) -> Result<Self, Self::Err> {
 ///         Self::deserialize(s.into_deserializer())
 ///     }
 /// }
-/// #
-/// # fn main() {}
 /// ```
 pub trait IntoDeserializer<'de, E: Error = value::Error> {
     /// The type of the deserializer being converted into.
     type Deserializer: Deserializer<'de, Error = E>;
 
     /// Convert this value into a deserializer.
     fn into_deserializer(self) -> Self::Deserializer;
 }
--- a/third_party/rust/serde/src/de/utf8.rs
+++ b/third_party/rust/serde/src/de/utf8.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use lib::*;
 
 const TAG_CONT: u8 = 0b1000_0000;
 const TAG_TWO_B: u8 = 0b1100_0000;
 const TAG_THREE_B: u8 = 0b1110_0000;
 const TAG_FOUR_B: u8 = 0b1111_0000;
 const MAX_ONE_B: u32 = 0x80;
 const MAX_TWO_B: u32 = 0x800;
--- a/third_party/rust/serde/src/de/value.rs
+++ b/third_party/rust/serde/src/de/value.rs
@@ -1,43 +1,29 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 //! Building blocks for deserializing basic values using the `IntoDeserializer`
 //! trait.
 //!
-//! ```rust
-//! #[macro_use]
-//! extern crate serde_derive;
-//!
-//! extern crate serde;
-//!
+//! ```edition2018
 //! use std::str::FromStr;
-//! use serde::de::{value, Deserialize, IntoDeserializer};
+//! use serde::Deserialize;
+//! use serde::de::{value, IntoDeserializer};
 //!
 //! #[derive(Deserialize)]
 //! enum Setting {
 //!     On,
 //!     Off,
 //! }
 //!
 //! impl FromStr for Setting {
 //!     type Err = value::Error;
 //!
 //!     fn from_str(s: &str) -> Result<Self, Self::Err> {
 //!         Self::deserialize(s.into_deserializer())
 //!     }
 //! }
-//! #
-//! # fn main() {}
 //! ```
 
 use lib::*;
 
 use self::private::{First, Second};
 use de::{self, Expected, IntoDeserializer, SeqAccess};
 use private::de::size_hint;
 use ser;
--- a/third_party/rust/serde/src/export.rs
+++ b/third_party/rust/serde/src/export.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 pub use lib::clone::Clone;
 pub use lib::convert::{From, Into};
 pub use lib::default::Default;
 pub use lib::fmt::{self, Formatter};
 pub use lib::marker::PhantomData;
 pub use lib::option::Option::{self, None, Some};
 pub use lib::result::Result::{self, Err, Ok};
 
--- a/third_party/rust/serde/src/integer128.rs
+++ b/third_party/rust/serde/src/integer128.rs
@@ -4,24 +4,22 @@
 /// Data formats that wish to support Rust compiler versions older than 1.26 may
 /// place the i128 / u128 methods of their Serializer and Deserializer behind
 /// this macro.
 ///
 /// Data formats that require a minimum Rust compiler version of at least 1.26
 /// do not need to bother with this macro and may assume support for 128-bit
 /// integers.
 ///
-/// ```rust
-/// #[macro_use]
-/// extern crate serde;
-///
-/// use serde::Serializer;
+/// ```edition2018
 /// # use serde::private::ser::Error;
 /// #
 /// # struct MySerializer;
+/// #
+/// use serde::{serde_if_integer128, Serializer};
 ///
 /// impl Serializer for MySerializer {
 ///     type Ok = ();
 ///     type Error = Error;
 ///
 ///     fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error> {
 ///         /* ... */
 /// #         unimplemented!()
@@ -36,41 +34,39 @@
 ///         }
 ///
 ///         fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error> {
 ///             /* ... */
 /// #             unimplemented!()
 ///         }
 ///     }
 /// #
-/// #     __serialize_unimplemented! {
+/// #     serde::__serialize_unimplemented! {
 /// #         bool i8 i16 i32 u8 u16 u32 u64 f32 f64 char str bytes none some
 /// #         unit unit_struct unit_variant newtype_struct newtype_variant seq
 /// #         tuple tuple_struct tuple_variant map struct struct_variant
 /// #     }
 /// }
-/// #
-/// # fn main() {}
 /// ```
 ///
 /// When Serde is built with support for 128-bit integers, this macro expands
 /// transparently into just the input tokens.
 ///
-/// ```rust
+/// ```edition2018
 /// macro_rules! serde_if_integer128 {
 ///     ($($tt:tt)*) => {
 ///         $($tt)*
 ///     };
 /// }
 /// ```
 ///
 /// When built without support for 128-bit integers, this macro expands to
 /// nothing.
 ///
-/// ```rust
+/// ```edition2018
 /// macro_rules! serde_if_integer128 {
 ///     ($($tt:tt)*) => {};
 /// }
 /// ```
 #[cfg(integer128)]
 #[macro_export]
 macro_rules! serde_if_integer128 {
     ($($tt:tt)*) => {
--- a/third_party/rust/serde/src/lib.rs
+++ b/third_party/rust/serde/src/lib.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 //! # Serde
 //!
 //! Serde is a framework for ***ser***ializing and ***de***serializing Rust data
 //! structures efficiently and generically.
 //!
 //! The Serde ecosystem consists of data structures that know how to serialize
 //! and deserialize themselves along with data formats that know how to
 //! serialize and deserialize other things. Serde provides the layer by which
@@ -45,105 +37,89 @@
 //!   used for IPC within the Servo rendering engine.
 //! - [CBOR], a Concise Binary Object Representation designed for small message
 //!   size without the need for version negotiation.
 //! - [YAML], a popular human-friendly configuration language that ain't markup
 //!   language.
 //! - [MessagePack], an efficient binary format that resembles a compact JSON.
 //! - [TOML], a minimal configuration format used by [Cargo].
 //! - [Pickle], a format common in the Python world.
-//! - [Hjson], a variant of JSON designed to be readable and writable by humans.
+//! - [RON], a Rusty Object Notation.
 //! - [BSON], the data storage and network transfer format used by MongoDB.
 //! - [Avro], a binary format used within Apache Hadoop, with support for schema
 //!   definition.
+//! - [Hjson], a variant of JSON designed to be readable and writable by humans.
+//! - [JSON5], A superset of JSON including some productions from ES5.
 //! - [URL], the x-www-form-urlencoded format.
-//! - [XML], the flexible machine-friendly W3C standard.
-//!   *(deserialization only)*
 //! - [Envy], a way to deserialize environment variables into Rust structs.
 //!   *(deserialization only)*
-//! - [Redis], deserialize values from Redis when using [redis-rs].
-//!   *(deserialization only)*
+//! - [Envy Store], a way to deserialize [AWS Parameter Store] parameters into
+//!   Rust structs. *(deserialization only)*
 //!
 //! [JSON]: https://github.com/serde-rs/json
 //! [Bincode]: https://github.com/TyOverby/bincode
 //! [CBOR]: https://github.com/pyfisch/cbor
 //! [YAML]: https://github.com/dtolnay/serde-yaml
 //! [MessagePack]: https://github.com/3Hren/msgpack-rust
 //! [TOML]: https://github.com/alexcrichton/toml-rs
 //! [Pickle]: https://github.com/birkenfeld/serde-pickle
-//! [Hjson]: https://github.com/laktak/hjson-rust
+//! [RON]: https://github.com/ron-rs/ron
 //! [BSON]: https://github.com/zonyitoo/bson-rs
 //! [Avro]: https://github.com/flavray/avro-rs
+//! [Hjson]: https://github.com/laktak/hjson-rust
+//! [JSON5]: https://github.com/callum-oakley/json5-rs
 //! [URL]: https://github.com/nox/serde_urlencoded
-//! [XML]: https://github.com/RReverser/serde-xml-rs
 //! [Envy]: https://github.com/softprops/envy
-//! [Redis]: https://github.com/OneSignal/serde-redis
+//! [Envy Store]: https://github.com/softprops/envy-store
 //! [Cargo]: http://doc.crates.io/manifest.html
-//! [redis-rs]: https://crates.io/crates/redis
+//! [AWS Parameter Store]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html
 
 ////////////////////////////////////////////////////////////////////////////////
 
 // Serde types in rustdoc of other crates get linked to here.
-#![doc(html_root_url = "https://docs.rs/serde/1.0.80")]
+#![doc(html_root_url = "https://docs.rs/serde/1.0.88")]
 // Support using Serde without the standard library!
 #![cfg_attr(not(feature = "std"), no_std)]
 // Unstable functionality only if the user asks for it. For tracking and
 // discussion of these features please refer to this issue:
 //
 //    https://github.com/serde-rs/serde/issues/812
 #![cfg_attr(feature = "unstable", feature(specialization, never_type))]
 #![cfg_attr(feature = "alloc", feature(alloc))]
 #![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
 #![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
-// Whitelisted clippy lints
+// Ignored clippy and clippy_pedantic lints
 #![cfg_attr(
     feature = "cargo-clippy",
     allow(
-        cast_lossless,
+        // not available in our oldest supported compiler
         const_static_lifetime,
-        doc_markdown,
-        linkedlist,
+        empty_enum,
+        redundant_field_names,
+        // integer and float ser/de requires these sorts of casts
+        cast_possible_truncation,
+        cast_possible_wrap,
+        cast_precision_loss,
+        cast_sign_loss,
+        // things are often more readable this way
+        cast_lossless,
+        module_name_repetitions,
+        single_match_else,
+        type_complexity,
+        use_self,
+        zero_prefixed_literal,
+        // not practical
         needless_pass_by_value,
-        redundant_field_names,
-        type_complexity,
-        unreadable_literal,
-        zero_prefixed_literal
+        similar_names,
+        // preference
+        doc_markdown,
     )
 )]
-// Whitelisted clippy_pedantic lints
-#![cfg_attr(feature = "cargo-clippy", allow(
-// integer and float ser/de requires these sorts of casts
-    cast_possible_truncation,
-    cast_possible_wrap,
-    cast_precision_loss,
-    cast_sign_loss,
-// simplifies some macros
-    invalid_upcast_comparisons,
-// things are often more readable this way
-    decimal_literal_representation,
-    option_unwrap_used,
-    result_unwrap_used,
-    shadow_reuse,
-    single_match_else,
-    stutter,
-    use_self,
-// not practical
-    indexing_slicing,
-    many_single_char_names,
-    missing_docs_in_private_items,
-    similar_names,
-// alternative is not stable
-    empty_enum,
-    use_debug,
-))]
-// Blacklisted Rust lints.
-//
-// Compiler bug involving unused_imports:
-// https://github.com/rust-lang/rust/issues/51661
-#![deny(missing_docs, /*unused_imports*/)]
+// Rustc lints.
+#![deny(missing_docs, unused_imports)]
 
 ////////////////////////////////////////////////////////////////////////////////
 
 #[cfg(feature = "alloc")]
 extern crate alloc;
 
 /// A facade around all the types we need from the `std`, `core`, and `alloc`
 /// crates. This avoids elaborate import wrangling having to happen in every
@@ -226,16 +202,22 @@ mod lib {
     #[cfg(feature = "std")]
     pub use std::time::{SystemTime, UNIX_EPOCH};
 
     #[cfg(any(core_duration, feature = "std"))]
     pub use self::core::time::Duration;
 
     #[cfg(range_inclusive)]
     pub use self::core::ops::RangeInclusive;
+
+    #[cfg(all(feature = "std", collections_bound))]
+    pub use std::collections::Bound;
+
+    #[cfg(ops_bound)]
+    pub use self::core::ops::Bound;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 #[macro_use]
 mod macros;
 
 #[macro_use]
@@ -254,50 +236,16 @@ pub use ser::{Serialize, Serializer};
 pub mod export;
 
 // Helpers used by generated code and doc tests. Not public API.
 #[doc(hidden)]
 pub mod private;
 
 // Re-export #[derive(Serialize, Deserialize)].
 //
-// This is a workaround for https://github.com/rust-lang/cargo/issues/1286.
-// Without this re-export, crates that put Serde derives behind a cfg_attr would
-// need to use some silly feature name that depends on both serde and
-// serde_derive.
-//
-//     [features]
-//     serde-impls = ["serde", "serde_derive"]
-//
-//     [dependencies]
-//     serde = { version = "1.0", optional = true }
-//     serde_derive = { version = "1.0", optional = true }
-//
-//     # Used like this:
-//     # #[cfg(feature = "serde-impls")]
-//     # #[macro_use]
-//     # extern crate serde_derive;
-//     #
-//     # #[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))]
-//     # struct S { /* ... */ }
-//
-// The re-exported derives allow crates to use "serde" as the name of their
-// Serde feature which is more intuitive.
-//
-//     [dependencies]
-//     serde = { version = "1.0", optional = true, features = ["derive"] }
-//
-//     # Used like this:
-//     # #[cfg(feature = "serde")]
-//     # #[macro_use]
-//     # extern crate serde;
-//     #
-//     # #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
-//     # struct S { /* ... */ }
-//
 // The reason re-exporting is not enabled by default is that disabling it would
 // be annoying for crates that provide handwritten impls or data formats. They
 // would need to disable default features and then explicitly re-enable std.
 #[cfg(feature = "serde_derive")]
 #[allow(unused_imports)]
 #[macro_use]
 extern crate serde_derive;
 #[cfg(feature = "serde_derive")]
--- a/third_party/rust/serde/src/macros.rs
+++ b/third_party/rust/serde/src/macros.rs
@@ -1,33 +1,23 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 // Super explicit first paragraph because this shows up at the top level and
 // trips up people who are just looking for basic Serialize / Deserialize
 // documentation.
 //
 /// Helper macro when implementing the `Deserializer` part of a new data format
 /// for Serde.
 ///
 /// Some [`Deserializer`] implementations for self-describing formats do not
 /// care what hint the [`Visitor`] gives them, they just want to blindly call
 /// the [`Visitor`] method corresponding to the data they can tell is in the
 /// input. This requires repetitive implementations of all the [`Deserializer`]
 /// trait methods.
 ///
-/// ```rust
-/// # #[macro_use]
-/// # extern crate serde;
-/// #
+/// ```edition2018
+/// # use serde::forward_to_deserialize_any;
 /// # use serde::de::{value, Deserializer, Visitor};
 /// #
 /// # struct MyDeserializer;
 /// #
 /// # impl<'de> Deserializer<'de> for MyDeserializer {
 /// #     type Error = value::Error;
 /// #
 /// #     fn deserialize_any<V>(self, _: V) -> Result<V::Value, Self::Error>
@@ -46,28 +36,24 @@
 /// }
 /// #
 /// #     forward_to_deserialize_any! {
 /// #         i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
 /// #         bytes byte_buf option unit unit_struct newtype_struct seq tuple
 /// #         tuple_struct map struct enum identifier ignored_any
 /// #     }
 /// # }
-/// #
-/// # fn main() {}
 /// ```
 ///
 /// The `forward_to_deserialize_any!` macro implements these simple forwarding
 /// methods so that they forward directly to [`Deserializer::deserialize_any`].
 /// You can choose which methods to forward.
 ///
-/// ```rust
-/// # #[macro_use]
-/// # extern crate serde;
-/// #
+/// ```edition2018
+/// # use serde::forward_to_deserialize_any;
 /// # use serde::de::{value, Deserializer, Visitor};
 /// #
 /// # struct MyDeserializer;
 /// #
 /// impl<'de> Deserializer<'de> for MyDeserializer {
 /// #   type Error = value::Error;
 /// #
 ///     fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
@@ -80,31 +66,27 @@
 ///     }
 ///
 ///     forward_to_deserialize_any! {
 ///         bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
 ///         bytes byte_buf option unit unit_struct newtype_struct seq tuple
 ///         tuple_struct map struct enum identifier ignored_any
 ///     }
 /// }
-/// #
-/// # fn main() {}
 /// ```
 ///
 /// The macro assumes the convention that your `Deserializer` lifetime parameter
 /// is called `'de` and that the `Visitor` type parameters on each method are
 /// called `V`. A different type parameter and a different lifetime can be
 /// specified explicitly if necessary.
 ///
-/// ```rust
-/// # #[macro_use]
-/// # extern crate serde;
-/// #
+/// ```edition2018
 /// # use std::marker::PhantomData;
 /// #
+/// # use serde::forward_to_deserialize_any;
 /// # use serde::de::{value, Deserializer, Visitor};
 /// #
 /// # struct MyDeserializer<V>(PhantomData<V>);
 /// #
 /// # impl<'q, V> Deserializer<'q> for MyDeserializer<V> {
 /// #     type Error = value::Error;
 /// #
 /// #     fn deserialize_any<W>(self, visitor: W) -> Result<W::Value, Self::Error>
@@ -116,18 +98,16 @@
 /// #
 /// forward_to_deserialize_any! {
 ///     <W: Visitor<'q>>
 ///     bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
 ///     bytes byte_buf option unit unit_struct newtype_struct seq tuple
 ///     tuple_struct map struct enum identifier ignored_any
 /// }
 /// # }
-/// #
-/// # fn main() {}
 /// ```
 ///
 /// [`Deserializer`]: trait.Deserializer.html
 /// [`Visitor`]: de/trait.Visitor.html
 /// [`Deserializer::deserialize_any`]: trait.Deserializer.html#tymethod.deserialize_any
 #[macro_export(local_inner_macros)]
 macro_rules! forward_to_deserialize_any {
     (<$visitor:ident: Visitor<$lifetime:tt>> $($func:ident)*) => {
--- a/third_party/rust/serde/src/private/de.rs
+++ b/third_party/rust/serde/src/private/de.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use lib::*;
 
 use de::{Deserialize, DeserializeSeed, Deserializer, Error, IntoDeserializer, Visitor};
 
 #[cfg(any(feature = "std", feature = "alloc"))]
 use de::{MapAccess, Unexpected};
 
 #[cfg(any(feature = "std", feature = "alloc"))]
@@ -1422,16 +1414,17 @@ mod content {
         where
             V: Visitor<'de>,
         {
             match self.content {
                 Content::String(v) => visitor.visit_string(v),
                 Content::Str(v) => visitor.visit_borrowed_str(v),
                 Content::ByteBuf(v) => visitor.visit_byte_buf(v),
                 Content::Bytes(v) => visitor.visit_borrowed_bytes(v),
+                Content::U8(v) => visitor.visit_u8(v),
                 _ => Err(self.invalid_type(&visitor)),
             }
         }
 
         fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
         where
             V: Visitor<'de>,
         {
@@ -1758,32 +1751,32 @@ mod content {
     fn visit_content_seq_ref<'a, 'de, V, E>(
         content: &'a [Content<'de>],
         visitor: V,
     ) -> Result<V::Value, E>
     where
         V: Visitor<'de>,
         E: de::Error,
     {
-        let seq = content.into_iter().map(ContentRefDeserializer::new);
+        let seq = content.iter().map(ContentRefDeserializer::new);
         let mut seq_visitor = de::value::SeqDeserializer::new(seq);
         let value = try!(visitor.visit_seq(&mut seq_visitor));
         try!(seq_visitor.end());
         Ok(value)
     }
 
     fn visit_content_map_ref<'a, 'de, V, E>(
         content: &'a [(Content<'de>, Content<'de>)],
         visitor: V,
     ) -> Result<V::Value, E>
     where
         V: Visitor<'de>,
         E: de::Error,
     {
-        let map = content.into_iter().map(|&(ref k, ref v)| {
+        let map = content.iter().map(|&(ref k, ref v)| {
             (
                 ContentRefDeserializer::new(k),
                 ContentRefDeserializer::new(v),
             )
         });
         let mut map_visitor = de::value::MapDeserializer::new(map);
         let value = try!(visitor.visit_map(&mut map_visitor));
         try!(map_visitor.end());
@@ -2080,17 +2073,17 @@ mod content {
             _variants: &'static [&'static str],
             visitor: V,
         ) -> Result<V::Value, Self::Error>
         where
             V: Visitor<'de>,
         {
             let (variant, value) = match *self.content {
                 Content::Map(ref value) => {
-                    let mut iter = value.into_iter();
+                    let mut iter = value.iter();
                     let &(ref variant, ref value) = match iter.next() {
                         Some(v) => v,
                         None => {
                             return Err(de::Error::invalid_value(
                                 de::Unexpected::Map,
                                 &"map with a single key",
                             ));
                         }
@@ -2124,16 +2117,17 @@ mod content {
         where
             V: Visitor<'de>,
         {
             match *self.content {
                 Content::String(ref v) => visitor.visit_str(v),
                 Content::Str(v) => visitor.visit_borrowed_str(v),
                 Content::ByteBuf(ref v) => visitor.visit_bytes(v),
                 Content::Bytes(v) => visitor.visit_borrowed_bytes(v),
+                Content::U8(v) => visitor.visit_u8(v),
                 _ => Err(self.invalid_type(&visitor)),
             }
         }
 
         fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
         where
             V: Visitor<'de>,
         {
@@ -2267,19 +2261,19 @@ mod content {
         iter: <&'a [Content<'de>] as IntoIterator>::IntoIter,
         err: PhantomData<E>,
     }
 
     impl<'a, 'de, E> SeqRefDeserializer<'a, 'de, E>
     where
         E: de::Error,
     {
-        fn new(vec: &'a [Content<'de>]) -> Self {
+        fn new(slice: &'a [Content<'de>]) -> Self {
             SeqRefDeserializer {
-                iter: vec.into_iter(),
+                iter: slice.iter(),
                 err: PhantomData,
             }
         }
     }
 
     impl<'de, 'a, E> de::Deserializer<'de> for SeqRefDeserializer<'a, 'de, E>
     where
         E: de::Error,
@@ -2345,17 +2339,17 @@ mod content {
     }
 
     impl<'a, 'de, E> MapRefDeserializer<'a, 'de, E>
     where
         E: de::Error,
     {
         fn new(map: &'a [(Content<'de>, Content<'de>)]) -> Self {
             MapRefDeserializer {
-                iter: map.into_iter(),
+                iter: map.iter(),
                 value: None,
                 err: PhantomData,
             }
         }
     }
 
     impl<'de, 'a, E> de::MapAccess<'de> for MapRefDeserializer<'a, 'de, E>
     where
@@ -2710,17 +2704,17 @@ where
 
             if use_item {
                 let (key, value) = item.take().unwrap();
                 return visitor.visit_enum(EnumDeserializer::new(key, Some(value)));
             }
         }
 
         Err(Error::custom(format_args!(
-            "no variant of enum {} not found in flattened data",
+            "no variant of enum {} found in flattened data",
             name
         )))
     }
 
     fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>
     where
         V: Visitor<'de>,
     {
--- a/third_party/rust/serde/src/private/macros.rs
+++ b/third_party/rust/serde/src/private/macros.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 #[doc(hidden)]
 #[macro_export]
 macro_rules! __private_serialize {
     () => {
         trait Serialize {
             fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
             where
                 S: $crate::Serializer;
--- a/third_party/rust/serde/src/private/mod.rs
+++ b/third_party/rust/serde/src/private/mod.rs
@@ -1,12 +1,4 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 mod macros;
 
 pub mod de;
 pub mod ser;
--- a/third_party/rust/serde/src/private/ser.rs
+++ b/third_party/rust/serde/src/private/ser.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use lib::*;
 
 use ser::{self, Impossible, Serialize, SerializeMap, SerializeStruct, Serializer};
 
 #[cfg(any(feature = "std", feature = "alloc"))]
 use self::content::{
     Content, ContentSerializer, SerializeStructVariantAsMapValue, SerializeTupleVariantAsMapValue,
 };
@@ -404,20 +396,19 @@ mod content {
             T: Serialize,
         {
             let value = try!(value.serialize(ContentSerializer::<M::Error>::new()));
             self.fields.push(value);
             Ok(())
         }
 
         fn end(mut self) -> Result<M::Ok, M::Error> {
-            try!(
-                self.map
-                    .serialize_value(&Content::TupleStruct(self.name, self.fields))
-            );
+            try!(self
+                .map
+                .serialize_value(&Content::TupleStruct(self.name, self.fields)));
             self.map.end()
         }
     }
 
     pub struct SerializeStructVariantAsMapValue<M> {
         map: M,
         name: &'static str,
         fields: Vec<(&'static str, Content)>,
@@ -449,20 +440,19 @@ mod content {
             T: Serialize,
         {
             let value = try!(value.serialize(ContentSerializer::<M::Error>::new()));
             self.fields.push((key, value));
             Ok(())
         }
 
         fn end(mut self) -> Result<M::Ok, M::Error> {
-            try!(
-                self.map
-                    .serialize_value(&Content::Struct(self.name, self.fields))
-            );
+            try!(self
+                .map
+                .serialize_value(&Content::Struct(self.name, self.fields)));
             self.map.end()
         }
     }
 
     #[derive(Debug)]
     pub enum Content {
         Bool(bool),
 
@@ -1323,15 +1313,14 @@ where
         T: Serialize,
     {
         let value = try!(value.serialize(ContentSerializer::<M::Error>::new()));
         self.fields.push((key, value));
         Ok(())
     }
 
     fn end(self) -> Result<(), Self::Error> {
-        try!(
-            self.map
-                .serialize_value(&Content::Struct(self.name, self.fields))
-        );
+        try!(self
+            .map
+            .serialize_value(&Content::Struct(self.name, self.fields)));
         Ok(())
     }
 }
--- a/third_party/rust/serde/src/ser/impls.rs
+++ b/third_party/rust/serde/src/ser/impls.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use lib::*;
 
 use ser::{Error, Serialize, SerializeTuple, Serializer};
 
 ////////////////////////////////////////////////////////////////////////////////
 
 macro_rules! primitive_impl {
     ($ty:ident, $method:ident $($cast:tt)*) => {
@@ -259,16 +251,39 @@ where
         try!(state.serialize_field("start", &self.start()));
         try!(state.serialize_field("end", &self.end()));
         state.end()
     }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
+#[cfg(any(ops_bound, collections_bound))]
+impl<T> Serialize for Bound<T>
+where
+    T: Serialize,
+{
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+    where
+        S: Serializer,
+    {
+        match *self {
+            Bound::Unbounded => serializer.serialize_unit_variant("Bound", 0, "Unbounded"),
+            Bound::Included(ref value) => {
+                serializer.serialize_newtype_variant("Bound", 1, "Included", value)
+            }
+            Bound::Excluded(ref value) => {
+                serializer.serialize_newtype_variant("Bound", 2, "Excluded", value)
+            }
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
 impl Serialize for () {
     #[inline]
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     where
         S: Serializer,
     {
         serializer.serialize_unit()
     }
--- a/third_party/rust/serde/src/ser/impossible.rs
+++ b/third_party/rust/serde/src/ser/impossible.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 //! This module contains `Impossible` serializer and its implementations.
 
 use lib::*;
 
 use ser::{
     self, Serialize, SerializeMap, SerializeSeq, SerializeStruct, SerializeStructVariant,
     SerializeTuple, SerializeTupleStruct, SerializeTupleVariant,
 };
@@ -18,20 +10,17 @@ use ser::{
 /// Helper type for implementing a `Serializer` that does not support
 /// serializing one of the compound types.
 ///
 /// This type cannot be instantiated, but implements every one of the traits
 /// corresponding to the [`Serializer`] compound types: [`SerializeSeq`],
 /// [`SerializeTuple`], [`SerializeTupleStruct`], [`SerializeTupleVariant`],
 /// [`SerializeMap`], [`SerializeStruct`], and [`SerializeStructVariant`].
 ///
-/// ```rust
-/// # #[macro_use]
-/// # extern crate serde;
-/// #
+/// ```edition2018
 /// # use serde::ser::{Serializer, Impossible};
 /// # use serde::private::ser::Error;
 /// #
 /// # struct MySerializer;
 /// #
 /// impl Serializer for MySerializer {
 ///     type Ok = ();
 ///     type Error = Error;
@@ -47,24 +36,22 @@ use ser::{
 ///         // thing we can do here is to return an error.
 /// #         stringify! {
 ///         Err(...)
 /// #         };
 /// #         unimplemented!()
 ///     }
 ///
 ///     /* other Serializer methods */
-/// #     __serialize_unimplemented! {
+/// #     serde::__serialize_unimplemented! {
 /// #         bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str bytes none some
 /// #         unit unit_struct unit_variant newtype_struct newtype_variant
 /// #         tuple tuple_struct tuple_variant map struct struct_variant
 /// #     }
 /// }
-/// #
-/// # fn main() {}
 /// ```
 ///
 /// [`Serializer`]: trait.Serializer.html
 /// [`SerializeSeq`]: trait.SerializeSeq.html
 /// [`SerializeTuple`]: trait.SerializeTuple.html
 /// [`SerializeTupleStruct`]: trait.SerializeTupleStruct.html
 /// [`SerializeTupleVariant`]: trait.SerializeTupleVariant.html
 /// [`SerializeMap`]: trait.SerializeMap.html
--- a/third_party/rust/serde/src/ser/mod.rs
+++ b/third_party/rust/serde/src/ser/mod.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 //! Generic data structure serialization framework.
 //!
 //! The two most important traits in this module are [`Serialize`] and
 //! [`Serializer`].
 //!
 //!  - **A type that implements `Serialize` is a data structure** that can be
 //!    serialized to any data format supported by Serde, and conversely
 //!  - **A type that implements `Serializer` is a data format** that can
@@ -87,16 +79,17 @@
 //!    - OsString
 //!  - **Miscellaneous standard library types**:
 //!    - Duration
 //!    - SystemTime
 //!    - Path
 //!    - PathBuf
 //!    - Range\<T\>
 //!    - RangeInclusive\<T\>
+//!    - Bound\<T\>
 //!    - num::NonZero*
 //!    - `!` *(unstable)*
 //!  - **Net types**:
 //!    - IpAddr
 //!    - Ipv4Addr
 //!    - Ipv6Addr
 //!    - SocketAddr
 //!    - SocketAddrV4
@@ -140,17 +133,17 @@ macro_rules! declare_error_trait {
             /// while serializing a type.
             ///
             /// The message should not be capitalized and should not end with a
             /// period.
             ///
             /// For example, a filesystem [`Path`] may refuse to serialize
             /// itself if it contains invalid UTF-8 data.
             ///
-            /// ```rust
+            /// ```edition2018
             /// # struct Path;
             /// #
             /// # impl Path {
             /// #     fn to_str(&self) -> Option<&str> {
             /// #         unimplemented!()
             /// #     }
             /// # }
             /// #
@@ -213,17 +206,17 @@ declare_error_trait!(Error: Sized + Debu
 /// [derive section of the manual]: https://serde.rs/derive.html
 /// [ser]: https://docs.serde.rs/serde/ser/index.html
 pub trait Serialize {
     /// Serialize this value into the given Serde serializer.
     ///
     /// See the [Implementing `Serialize`] section of the manual for more
     /// information about how to implement this method.
     ///
-    /// ```rust
+    /// ```edition2018
     /// use serde::ser::{Serialize, SerializeStruct, Serializer};
     ///
     /// struct Person {
     ///     name: String,
     ///     age: u8,
     ///     phones: Vec<String>,
     /// }
     ///
@@ -380,418 +373,340 @@ pub trait Serializer: Sized {
     /// Type returned from [`serialize_struct_variant`] for serializing the
     /// content of the struct variant.
     ///
     /// [`serialize_struct_variant`]: #tymethod.serialize_struct_variant
     type SerializeStructVariant: SerializeStructVariant<Ok = Self::Ok, Error = Self::Error>;
 
     /// Serialize a `bool` value.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for bool {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_bool(*self)
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize an `i8` value.
     ///
     /// If the format does not differentiate between `i8` and `i64`, a
     /// reasonable implementation would be to cast the value to `i64` and
     /// forward to `serialize_i64`.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for i8 {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_i8(*self)
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize an `i16` value.
     ///
     /// If the format does not differentiate between `i16` and `i64`, a
     /// reasonable implementation would be to cast the value to `i64` and
     /// forward to `serialize_i64`.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for i16 {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_i16(*self)
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize an `i32` value.
     ///
     /// If the format does not differentiate between `i32` and `i64`, a
     /// reasonable implementation would be to cast the value to `i64` and
     /// forward to `serialize_i64`.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for i32 {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_i32(*self)
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize an `i64` value.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for i64 {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_i64(*self)
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error>;
 
     serde_if_integer128! {
         /// Serialize an `i128` value.
         ///
-        /// ```rust
-        /// # #[macro_use]
-        /// # extern crate serde;
-        /// #
+        /// ```edition2018
         /// # use serde::Serializer;
         /// #
-        /// # __private_serialize!();
+        /// # serde::__private_serialize!();
         /// #
         /// impl Serialize for i128 {
         ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
         ///     where
         ///         S: Serializer,
         ///     {
         ///         serializer.serialize_i128(*self)
         ///     }
         /// }
-        /// #
-        /// # fn main() {}
         /// ```
         ///
         /// This method is available only on Rust compiler versions >=1.26. The
         /// default behavior unconditionally returns an error.
         fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error> {
             let _ = v;
             Err(Error::custom("i128 is not supported"))
         }
     }
 
     /// Serialize a `u8` value.
     ///
     /// If the format does not differentiate between `u8` and `u64`, a
     /// reasonable implementation would be to cast the value to `u64` and
     /// forward to `serialize_u64`.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for u8 {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_u8(*self)
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_u8(self, v: u8) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize a `u16` value.
     ///
     /// If the format does not differentiate between `u16` and `u64`, a
     /// reasonable implementation would be to cast the value to `u64` and
     /// forward to `serialize_u64`.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for u16 {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_u16(*self)
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize a `u32` value.
     ///
     /// If the format does not differentiate between `u32` and `u64`, a
     /// reasonable implementation would be to cast the value to `u64` and
     /// forward to `serialize_u64`.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for u32 {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_u32(*self)
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize a `u64` value.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for u64 {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_u64(*self)
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error>;
 
     serde_if_integer128! {
         /// Serialize a `u128` value.
         ///
-        /// ```rust
-        /// # #[macro_use]
-        /// # extern crate serde;
-        /// #
+        /// ```edition2018
         /// # use serde::Serializer;
         /// #
-        /// # __private_serialize!();
+        /// # serde::__private_serialize!();
         /// #
         /// impl Serialize for u128 {
         ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
         ///     where
         ///         S: Serializer,
         ///     {
         ///         serializer.serialize_u128(*self)
         ///     }
         /// }
-        /// #
-        /// # fn main() {}
         /// ```
         ///
         /// This method is available only on Rust compiler versions >=1.26. The
         /// default behavior unconditionally returns an error.
         fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error> {
             let _ = v;
             Err(Error::custom("u128 is not supported"))
         }
     }
 
     /// Serialize an `f32` value.
     ///
     /// If the format does not differentiate between `f32` and `f64`, a
     /// reasonable implementation would be to cast the value to `f64` and
     /// forward to `serialize_f64`.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for f32 {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_f32(*self)
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize an `f64` value.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for f64 {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_f64(*self)
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize a character.
     ///
     /// If the format does not support characters, it is reasonable to serialize
     /// it as a single element `str` or a `u32`.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for char {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_char(*self)
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_char(self, v: char) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize a `&str`.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for str {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_str(self)
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize a chunk of raw byte data.
     ///
     /// Enables serializers to serialize byte slices more compactly or more
     /// efficiently than other types of slices. If no efficient implementation
     /// is available, a reasonable implementation would be to forward to
     /// `serialize_seq`. If forwarded, the implementation looks usually just
     /// like this:
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::ser::{Serializer, SerializeSeq};
     /// # use serde::private::ser::Error;
     /// #
     /// # struct MySerializer;
     /// #
     /// # impl Serializer for MySerializer {
     /// #     type Ok = ();
     /// #     type Error = Error;
@@ -799,40 +714,36 @@ pub trait Serializer: Sized {
     /// fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error> {
     ///     let mut seq = self.serialize_seq(Some(v.len()))?;
     ///     for b in v {
     ///         seq.serialize_element(b)?;
     ///     }
     ///     seq.end()
     /// }
     /// #
-    /// #     __serialize_unimplemented! {
+    /// #     serde::__serialize_unimplemented! {
     /// #         bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str none some
     /// #         unit unit_struct unit_variant newtype_struct newtype_variant
     /// #         seq tuple tuple_struct tuple_variant map struct struct_variant
     /// #     }
     /// # }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize a [`None`] value.
     ///
-    /// ```rust
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::{Serialize, Serializer};
     /// #
     /// # enum Option<T> {
     /// #     Some(T),
     /// #     None,
     /// # }
     /// #
-    /// # use Option::{Some, None};
+    /// # use self::Option::{Some, None};
     /// #
     /// impl<T> Serialize for Option<T>
     /// where
     ///     T: Serialize,
     /// {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
@@ -847,27 +758,25 @@ pub trait Serializer: Sized {
     /// # fn main() {}
     /// ```
     ///
     /// [`None`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.None
     fn serialize_none(self) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize a [`Some(T)`] value.
     ///
-    /// ```rust
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::{Serialize, Serializer};
     /// #
     /// # enum Option<T> {
     /// #     Some(T),
     /// #     None,
     /// # }
     /// #
-    /// # use Option::{Some, None};
+    /// # use self::Option::{Some, None};
     /// #
     /// impl<T> Serialize for Option<T>
     /// where
     ///     T: Serialize,
     /// {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
@@ -884,42 +793,37 @@ pub trait Serializer: Sized {
     ///
     /// [`Some(T)`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.Some
     fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
     where
         T: Serialize;
 
     /// Serialize a `()` value.
     ///
-    /// ```rust
-    /// # #[macro_use]
-    /// # extern crate serde;
-    /// #
+    /// ```edition2018
     /// # use serde::Serializer;
     /// #
-    /// # __private_serialize!();
+    /// # serde::__private_serialize!();
     /// #
     /// impl Serialize for () {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
     ///     {
     ///         serializer.serialize_unit()
     ///     }
     /// }
-    /// #
-    /// # fn main() {}
     /// ```
     fn serialize_unit(self) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize a unit struct like `struct Unit` or `PhantomData<T>`.
     ///
     /// A reasonable implementation would be to forward to `serialize_unit`.
     ///
-    /// ```rust
+    /// ```edition2018
     /// use serde::{Serialize, Serializer};
     ///
     /// struct Nothing;
     ///
     /// impl Serialize for Nothing {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
@@ -931,17 +835,17 @@ pub trait Serializer: Sized {
     fn serialize_unit_struct(self, name: &'static str) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize a unit variant like `E::A` in `enum E { A, B }`.
     ///
     /// The `name` is the name of the enum, the `variant_index` is the index of
     /// this variant within the enum, and the `variant` is the name of the
     /// variant.
     ///
-    /// ```rust
+    /// ```edition2018
     /// use serde::{Serialize, Serializer};
     ///
     /// enum E {
     ///     A,
     ///     B,
     /// }
     ///
     /// impl Serialize for E {
@@ -964,17 +868,17 @@ pub trait Serializer: Sized {
     ) -> Result<Self::Ok, Self::Error>;
 
     /// Serialize a newtype struct like `struct Millimeters(u8)`.
     ///
     /// Serializers are encouraged to treat newtype structs as insignificant
     /// wrappers around the data they contain. A reasonable implementation would
     /// be to forward to `value.serialize(self)`.
     ///
-    /// ```rust
+    /// ```edition2018
     /// use serde::{Serialize, Serializer};
     ///
     /// struct Millimeters(u8);
     ///
     /// impl Serialize for Millimeters {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
@@ -992,17 +896,17 @@ pub trait Serializer: Sized {
         T: Serialize;
 
     /// Serialize a newtype variant like `E::N` in `enum E { N(u8) }`.
     ///
     /// The `name` is the name of the enum, the `variant_index` is the index of
     /// this variant within the enum, and the `variant` is the name of the
     /// variant. The `value` is the data contained within this newtype variant.
     ///
-    /// ```rust
+    /// ```edition2018
     /// use serde::{Serialize, Serializer};
     ///
     /// enum E {
     ///     M(String),
     ///     N(u8),
     /// }
     ///
     /// impl Serialize for E {
@@ -1030,17 +934,17 @@ pub trait Serializer: Sized {
     /// Begin to serialize a variably sized sequence. This call must be
     /// followed by zero or more calls to `serialize_element`, then a call to
     /// `end`.
     ///
     /// The argument is the number of elements in the sequence, which may or may
     /// not be computable before the sequence is iterated. Some serializers only
     /// support sequences whose length is known up front.
     ///
-    /// ```rust
+    /// ```edition2018
     /// # use std::marker::PhantomData;
     /// #
     /// # struct Vec<T>(PhantomData<T>);
     /// #
     /// # impl<T> Vec<T> {
     /// #     fn len(&self) -> usize {
     /// #         unimplemented!()
     /// #     }
@@ -1075,17 +979,17 @@ pub trait Serializer: Sized {
     /// ```
     fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq, Self::Error>;
 
     /// Begin to serialize a statically sized sequence whose length will be
     /// known at deserialization time without looking at the serialized data.
     /// This call must be followed by zero or more calls to `serialize_element`,
     /// then a call to `end`.
     ///
-    /// ```rust
+    /// ```edition2018
     /// use serde::ser::{Serialize, Serializer, SerializeTuple};
     ///
     /// # mod fool {
     /// #     trait Serialize {}
     /// impl<A, B, C> Serialize for (A, B, C)
     /// #     {}
     /// # }
     /// #
@@ -1105,17 +1009,17 @@ pub trait Serializer: Sized {
     ///         tup.serialize_element(&self.0)?;
     ///         tup.serialize_element(&self.1)?;
     ///         tup.serialize_element(&self.2)?;
     ///         tup.end()
     ///     }
     /// }
     /// ```
     ///
-    /// ```rust
+    /// ```edition2018
     /// use serde::ser::{Serialize, SerializeTuple, Serializer};
     ///
     /// const VRAM_SIZE: usize = 386;
     /// struct Vram([u16; VRAM_SIZE]);
     ///
     /// impl Serialize for Vram {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
@@ -1133,17 +1037,17 @@ pub trait Serializer: Sized {
 
     /// Begin to serialize a tuple struct like `struct Rgb(u8, u8, u8)`. This
     /// call must be followed by zero or more calls to `serialize_field`, then a
     /// call to `end`.
     ///
     /// The `name` is the name of the tuple struct and the `len` is the number
     /// of data fields that will be serialized.
     ///
-    /// ```rust
+    /// ```edition2018
     /// use serde::ser::{Serialize, SerializeTupleStruct, Serializer};
     ///
     /// struct Rgb(u8, u8, u8);
     ///
     /// impl Serialize for Rgb {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     ///     where
     ///         S: Serializer,
@@ -1165,17 +1069,17 @@ pub trait Serializer: Sized {
     /// Begin to serialize a tuple variant like `E::T` in `enum E { T(u8, u8)
     /// }`. This call must be followed by zero or more calls to
     /// `serialize_field`, then a call to `end`.
     ///
     /// The `name` is the name of the enum, the `variant_index` is the index of
     /// this variant within the enum, the `variant` is the name of the variant,
     /// and the `len` is the number of data fields that will be serialized.
     ///
-    /// ```rust
+    /// ```edition2018
     /// use serde::ser::{Serialize, SerializeTupleVariant, Serializer};
     ///
     /// enum E {
     ///     T(u8, u8),
     ///     U(String, u32, u32),
     /// }
     ///
     /// impl Serialize for E {
@@ -1211,17 +1115,17 @@ pub trait Serializer: Sized {
 
     /// Begin to serialize a map. This call must be followed by zero or more
     /// calls to `serialize_key` and `serialize_value`, then a call to `end`.
     ///
     /// The argument is the number of elements in the map, which may or may not
     /// be computable before the map is iterated. Some serializers only support
     /// maps whose length is known up front.
     ///
-    /// ```rust
+    /// ```edition2018
     /// # use std::marker::PhantomData;
     /// #
     /// # struct HashMap<K, V>(PhantomData<K>, PhantomData<V>);
     /// #
     /// # impl<K, V> HashMap<K, V> {
     /// #     fn len(&self) -> usize {
     /// #         unimplemented!()
     /// #     }
@@ -1259,17 +1163,17 @@ pub trait Serializer: Sized {
 
     /// Begin to serialize a struct like `struct Rgb { r: u8, g: u8, b: u8 }`.
     /// This call must be followed by zero or more calls to `serialize_field`,
     /// then a call to `end`.
     ///
     /// The `name` is the name of the struct and the `len` is the number of
     /// data fields that will be serialized.
     ///
-    /// ```rust
+    /// ```edition2018
     /// use serde::ser::{Serialize, SerializeStruct, Serializer};
     ///
     /// struct Rgb {
     ///     r: u8,
     ///     g: u8,
     ///     b: u8,
     /// }
     ///
@@ -1295,17 +1199,17 @@ pub trait Serializer: Sized {
     /// Begin to serialize a struct variant like `E::S` in `enum E { S { r: u8,
     /// g: u8, b: u8 } }`. This call must be followed by zero or more calls to
     /// `serialize_field`, then a call to `end`.
     ///
     /// The `name` is the name of the enum, the `variant_index` is the index of
     /// this variant within the enum, the `variant` is the name of the variant,
     /// and the `len` is the number of data fields that will be serialized.
     ///
-    /// ```rust
+    /// ```edition2018
     /// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
     ///
     /// enum E {
     ///     S { r: u8, g: u8, b: u8 },
     /// }
     ///
     /// impl Serialize for E {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
@@ -1337,17 +1241,17 @@ pub trait Serializer: Sized {
     ) -> Result<Self::SerializeStructVariant, Self::Error>;
 
     /// Collect an iterator as a sequence.
     ///
     /// The default implementation serializes each item yielded by the iterator
     /// using [`serialize_seq`]. Implementors should not need to override this
     /// method.
     ///
-    /// ```rust
+    /// ```edition2018
     /// use serde::{Serialize, Serializer};
     ///
     /// struct SecretlyOneHigher {
     ///     data: Vec<i32>,
     /// }
     ///
     /// impl Serialize for SecretlyOneHigher {
     ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
@@ -1374,17 +1278,17 @@ pub trait Serializer: Sized {
     }
 
     /// Collect an iterator as a map.
     ///
     /// The default implementation serializes each pair yielded by the iterator
     /// using [`serialize_map`]. Implementors should not need to override this
     /// method.
     ///
-    /// ```rust
+    /// ```edition2018
     /// use serde::{Serialize, Serializer};
     /// use std::collections::BTreeSet;
     ///
     /// struct MapToUnit {
     ///     keys: BTreeSet<i32>,
     /// }
     ///
     /// // Serializes as a map in which the values are all unit.
@@ -1414,17 +1318,17 @@ pub trait Serializer: Sized {
     }
 
     /// Serialize a string produced by an implementation of `Display`.
     ///
     /// The default implementation builds a heap-allocated [`String`] and
     /// delegates to [`serialize_str`]. Serializers are encouraged to provide a
     /// more efficient implementation if possible.
     ///
-    /// ```rust
+    /// ```edition2018
     /// # struct DateTime;
     /// #
     /// # impl DateTime {
     /// #     fn naive_local(&self) -> () { () }
     /// #     fn offset(&self) -> () { () }
     /// # }
     /// #
     /// use serde::{Serialize, Serializer};
@@ -1455,17 +1359,17 @@ pub trait Serializer: Sized {
     }
 
     /// Serialize a string produced by an implementation of `Display`.
     ///
     /// Serializers that use `no_std` are required to provide an implementation
     /// of this method. If no more sensible behavior is possible, the
     /// implementation is expected to return an error.
     ///
-    /// ```rust
+    /// ```edition2018
     /// # struct DateTime;
     /// #
     /// # impl DateTime {
     /// #     fn naive_local(&self) -> () { () }
     /// #     fn offset(&self) -> () { () }
     /// # }
     /// #
     /// use serde::{Serialize, Serializer};
@@ -1490,17 +1394,17 @@ pub trait Serializer: Sized {
     /// human-readable form.
     ///
     /// Some types have a human-readable form that may be somewhat expensive to
     /// construct, as well as a binary form that is compact and efficient.
     /// Generally text-based formats like JSON and YAML will prefer to use the
     /// human-readable one and binary formats like Bincode will prefer the
     /// compact one.
     ///
-    /// ```
+    /// ```edition2018
     /// # use std::fmt::{self, Display};
     /// #
     /// # struct Timestamp;
     /// #
     /// # impl Timestamp {
     /// #     fn seconds_since_epoch(&self) -> u64 { unimplemented!() }
     /// # }
     /// #
@@ -1539,17 +1443,17 @@ pub trait Serializer: Sized {
         true
     }
 }
 
 /// Returned from `Serializer::serialize_seq`.
 ///
 /// # Example use
 ///
-/// ```rust
+/// ```edition2018
 /// # use std::marker::PhantomData;
 /// #
 /// # struct Vec<T>(PhantomData<T>);
 /// #
 /// # impl<T> Vec<T> {
 /// #     fn len(&self) -> usize {
 /// #         unimplemented!()
 /// #     }
@@ -1603,17 +1507,17 @@ pub trait SerializeSeq {
     /// Finish serializing a sequence.
     fn end(self) -> Result<Self::Ok, Self::Error>;
 }
 
 /// Returned from `Serializer::serialize_tuple`.
 ///
 /// # Example use
 ///
-/// ```rust
+/// ```edition2018
 /// use serde::ser::{Serialize, Serializer, SerializeTuple};
 ///
 /// # mod fool {
 /// #     trait Serialize {}
 /// impl<A, B, C> Serialize for (A, B, C)
 /// #     {}
 /// # }
 /// #
@@ -1633,17 +1537,17 @@ pub trait SerializeSeq {
 ///         tup.serialize_element(&self.0)?;
 ///         tup.serialize_element(&self.1)?;
 ///         tup.serialize_element(&self.2)?;
 ///         tup.end()
 ///     }
 /// }
 /// ```
 ///
-/// ```rust
+/// ```edition2018
 /// # use std::marker::PhantomData;
 /// #
 /// # struct Array<T>(PhantomData<T>);
 /// #
 /// # impl<T> Array<T> {
 /// #     fn len(&self) -> usize {
 /// #         unimplemented!()
 /// #     }
@@ -1703,17 +1607,17 @@ pub trait SerializeTuple {
     /// Finish serializing a tuple.
     fn end(self) -> Result<Self::Ok, Self::Error>;
 }
 
 /// Returned from `Serializer::serialize_tuple_struct`.
 ///
 /// # Example use
 ///
-/// ```rust
+/// ```edition2018
 /// use serde::ser::{Serialize, SerializeTupleStruct, Serializer};
 ///
 /// struct Rgb(u8, u8, u8);
 ///
 /// impl Serialize for Rgb {
 ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
 ///     where
 ///         S: Serializer,
@@ -1748,17 +1652,17 @@ pub trait SerializeTupleStruct {
     /// Finish serializing a tuple struct.
     fn end(self) -> Result<Self::Ok, Self::Error>;
 }
 
 /// Returned from `Serializer::serialize_tuple_variant`.
 ///
 /// # Example use
 ///
-/// ```rust
+/// ```edition2018
 /// use serde::ser::{Serialize, SerializeTupleVariant, Serializer};
 ///
 /// enum E {
 ///     T(u8, u8),
 ///     U(String, u32, u32),
 /// }
 ///
 /// impl Serialize for E {
@@ -1806,17 +1710,17 @@ pub trait SerializeTupleVariant {
     /// Finish serializing a tuple variant.
     fn end(self) -> Result<Self::Ok, Self::Error>;
 }
 
 /// Returned from `Serializer::serialize_map`.
 ///
 /// # Example use
 ///
-/// ```rust
+/// ```edition2018
 /// # use std::marker::PhantomData;
 /// #
 /// # struct HashMap<K, V>(PhantomData<K>, PhantomData<V>);
 /// #
 /// # impl<K, V> HashMap<K, V> {
 /// #     fn len(&self) -> usize {
 /// #         unimplemented!()
 /// #     }
@@ -1917,17 +1821,17 @@ pub trait SerializeMap {
     /// Finish serializing a map.
     fn end(self) -> Result<Self::Ok, Self::Error>;
 }
 
 /// Returned from `Serializer::serialize_struct`.
 ///
 /// # Example use
 ///
-/// ```rust
+/// ```edition2018
 /// use serde::ser::{Serialize, SerializeStruct, Serializer};
 ///
 /// struct Rgb {
 ///     r: u8,
 ///     g: u8,
 ///     b: u8,
 /// }
 ///
@@ -1977,17 +1881,17 @@ pub trait SerializeStruct {
     /// Finish serializing a struct.
     fn end(self) -> Result<Self::Ok, Self::Error>;
 }
 
 /// Returned from `Serializer::serialize_struct_variant`.
 ///
 /// # Example use
 ///
-/// ```rust
+/// ```edition2018
 /// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
 ///
 /// enum E {
 ///     S { r: u8, g: u8, b: u8 },
 /// }
 ///
 /// impl Serialize for E {
 ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
--- a/third_party/rust/serde_derive/.cargo-checksum.json
+++ b/third_party/rust/serde_derive/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{"Cargo.toml":"32062c9ba07dc467d292a81d4843923933ef60006849646df3f15ea1a9329762","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"c4218d07d775c036cd50495b0354c5b59435472b12e159042cacb30b6ef1a7c1","crates-io.md":"8dce715dfbd2e9bbdd87e401d1f7974a60089f0673f7a84f4c5d840411075d14","src/bound.rs":"3f52688c06ee268f5cea4003acba1dce1631cf2ca04384a1b96845e100a7b5b3","src/de.rs":"534ddd51f8b2b0c29f30319ec553fe20aa717b87e0f5cecf21bbdcdc600c3724","src/fragment.rs":"9a8539d2bda80c62e4fdaf42816f371a2add62f9cf27b4646d90b636de40f56f","src/internals/ast.rs":"3260313fbbd7c8fab2b93710a7b4c806ac3aa4ce364a8bf7e83a5c38006b3f2f","src/internals/attr.rs":"70a87942eee113eadbec9c04cc9a0b7860afe1d25c839a4245ad48322ad11975","src/internals/case.rs":"868d8ddc4adfcd0d55ece44ae7d4de8445cb65ddfd8b0e6b90dd5ab3d23c1e57","src/internals/check.rs":"c325d8b42647689c1eb982e8c878d75a547c698f6040b72ef47d93e312518494","src/internals/ctxt.rs":"1f9d7e385ab188c7716c4d3f1e4c943f45dcb29bab8c42812b9e537deeee0889","src/internals/mod.rs":"414477f6fb187268ec87f917c0db9d328f4e6d188dfde93ab7479763e93e2aca","src/lib.rs":"f1a606372aa7dfaf40791f98e357fa4d4911d6d5b735605dd27db4f481787aed","src/pretend.rs":"2b51a8c14b62735cfc80b3624522a02465820a14a1eab55abebf3a63fd5f150a","src/ser.rs":"9a8e01afdd47641377a24442d92c637eaba061d56a9ff499d91294bba21f2f69","src/try.rs":"b9a10c8690d442a57fc7097d42c9a4f13034c7b4a30b7eb02d538fdbf8ae0a8d"},"package":null}
\ No newline at end of file
+{"files":{"Cargo.toml":"071ea0d1ef1e899f01b0e90383b7dfefdf1b23c733444c59815ce345e7833054","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"11f6eec1a694070311f8ff191c53e67b90bf1d5064f32d684a1b73b1c3264ac1","crates-io.md":"131dee2d4beaf83485aed22942b98815ef65af9bcfb65f02b5b90c59b8bc7b8b","src/bound.rs":"47b4018d54220862c2546589fe3cbccdd72c5d90438c265c258c1a2ee98e9210","src/de.rs":"09ba5a4cab60dfc713ea66f69d1989786a913e060f1ec6f9b701e83f37448931","src/dummy.rs":"413f639118681cecff6188e790c88636e34dd8e1b247bbbaa7b6a121b5cf6921","src/fragment.rs":"5819ac5b16f5945c05ce47c3370745f2e73deb415367ae6afbd8208867f611d2","src/internals/ast.rs":"64cd449a627a3489053407735f0d1de669272d879a75afc66051e323a1c1ebd4","src/internals/attr.rs":"f95eb8481822f4b5eca5e28483469c020d73335d60980cb20e1c28a073b90f52","src/internals/case.rs":"b2024f414f5d832bafa53b9ae7924b2d43a29175b19bb3da36f15c9071666558","src/internals/check.rs":"d101f08b2bd007602c4a7b3f6ae2d4cb9fbe0c179cde55809a666ed4a7043a12","src/internals/ctxt.rs":"ceb74c96802f89de896a30b774b49d4954d6c3344596cbbc1ff8fad2ac754fe1","src/internals/mod.rs":"8e363739bbfcd43bcaedd1746b2d17cebd5964167c145bd0db473f0ff4521edc","src/lib.rs":"fd6883d899ea98448aee074374388fdfd8792363928cc1ddd3812737c5921a76","src/pretend.rs":"ea5aa1b338038ce1791cef34fd20091abb062cd61c0384ac931d0069413a5302","src/ser.rs":"843b2a66a17511640c4e5ebd08e16b8f58f9772c7a8283e1bb2f043b302f21be","src/try.rs":"b9a10c8690d442a57fc7097d42c9a4f13034c7b4a30b7eb02d538fdbf8ae0a8d"},"package":null}
\ No newline at end of file
--- a/third_party/rust/serde_derive/Cargo.toml
+++ b/third_party/rust/serde_derive/Cargo.toml
@@ -1,11 +1,11 @@
 [package]
 name = "serde_derive"
-version = "1.0.80" # remember to update html_root_url
+version = "1.0.88" # remember to update html_root_url
 authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
 license = "MIT/Apache-2.0"
 description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
 homepage = "https://serde.rs"
 repository = "https://github.com/serde-rs/serde"
 documentation = "https://serde.rs/derive.html"
 keywords = ["serde", "serialization", "no_std"]
 readme = "crates-io.md"
@@ -21,12 +21,12 @@ deserialize_in_place = []
 
 [lib]
 name = "serde_derive"
 proc-macro = true
 
 [dependencies]
 proc-macro2 = "0.4"
 quote = "0.6.3"
-syn = { version = "0.15", features = ["visit", "extra-traits"] }
+syn = { version = "0.15.22", features = ["visit", "extra-traits"] }
 
 [dev-dependencies]
 serde = { version = "1.0", path = "../serde" }
--- a/third_party/rust/serde_derive/LICENSE-MIT
+++ b/third_party/rust/serde_derive/LICENSE-MIT
@@ -1,10 +1,8 @@
-Copyright (c) 2014 The Rust Project Developers
-
 Permission is hereby granted, free of charge, to any
 person obtaining a copy of this software and associated
 documentation files (the "Software"), to deal in the
 Software without restriction, including without
 limitation the rights to use, copy, modify, merge,
 publish, distribute, sublicense, and/or sell copies of
 the Software, and to permit persons to whom the Software
 is furnished to do so, subject to the following
--- a/third_party/rust/serde_derive/README.md
+++ b/third_party/rust/serde_derive/README.md
@@ -20,44 +20,38 @@ You may be looking for:
 - [API documentation](https://docs.serde.rs/serde/)
 - [Release notes](https://github.com/serde-rs/serde/releases)
 
 ## Serde in action
 
 <details>
 <summary>
 Click to show Cargo.toml.
-<a href="https://play.rust-lang.org/?gist=9003c5b88c1f4989941925d7190c6eec" target="_blank">Run this code in the playground.</a>
+<a href="https://play.rust-lang.org/?edition=2018&gist=72755f28f99afc95e01d63174b28c1f5" target="_blank">Run this code in the playground.</a>
 </summary>
 
 ```toml
 [dependencies]
 
 # The core APIs, including the Serialize and Deserialize traits. Always
-# required when using Serde.
-serde = "1.0"
-
-# Support for #[derive(Serialize, Deserialize)]. Required if you want Serde
-# to work for structs and enums defined in your crate.
-serde_derive = "1.0"
+# required when using Serde. The "derive" feature is only required when
+# using #[derive(Serialize, Deserialize)] to make Serde work with structs
+# and enums defined in your crate.
+serde = { version = "1.0", features = ["derive"] }
 
 # Each data format lives in its own crate; the sample code below uses JSON
 # but you may be using a different one.
 serde_json = "1.0"
 ```
 
 </details>
 <p></p>
 
 ```rust
-#[macro_use]
-extern crate serde_derive;
-
-extern crate serde;
-extern crate serde_json;
+use serde::{Serialize, Deserialize};
 
 #[derive(Serialize, Deserialize, Debug)]
 struct Point {
     x: i32,
     y: i32,
 }
 
 fn main() {
--- a/third_party/rust/serde_derive/crates-io.md
+++ b/third_party/rust/serde_derive/crates-io.md
@@ -11,21 +11,17 @@ You may be looking for:
 - [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/derive.html)
 - [Examples](https://serde.rs/examples.html)
 - [API documentation](https://docs.serde.rs/serde/)
 - [Release notes](https://github.com/serde-rs/serde/releases)
 
 ## Serde in action
 
 ```rust
-#[macro_use]
-extern crate serde_derive;
-
-extern crate serde;
-extern crate serde_json;
+use serde::{Serialize, Deserialize};
 
 #[derive(Serialize, Deserialize, Debug)]
 struct Point {
     x: i32,
     y: i32,
 }
 
 fn main() {
--- a/third_party/rust/serde_derive/src/bound.rs
+++ b/third_party/rust/serde_derive/src/bound.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use std::collections::HashSet;
 
 use syn;
 use syn::punctuated::{Pair, Punctuated};
 use syn::visit::{self, Visit};
 
 use internals::ast::{Container, Data};
 use internals::attr;
@@ -27,30 +19,31 @@ pub fn without_defaults(generics: &syn::
             .iter()
             .map(|param| match *param {
                 syn::GenericParam::Type(ref param) => syn::GenericParam::Type(syn::TypeParam {
                     eq_token: None,
                     default: None,
                     ..param.clone()
                 }),
                 _ => param.clone(),
-            }).collect(),
+            })
+            .collect(),
         ..generics.clone()
     }
 }
 
 pub fn with_where_predicates(
     generics: &syn::Generics,
     predicates: &[syn::WherePredicate],
 ) -> syn::Generics {
     let mut generics = generics.clone();
     generics
         .make_where_clause()
         .predicates
-        .extend(predicates.into_iter().cloned());
+        .extend(predicates.iter().cloned());
     generics
 }
 
 pub fn with_where_predicates_from_fields(
     cont: &Container,
     generics: &syn::Generics,
     from_field: fn(&attr::Field) -> Option<&[syn::WherePredicate]>,
 ) -> syn::Generics {
@@ -163,55 +156,59 @@ pub fn with_bound(
         .collect();
 
     let mut visitor = FindTyParams {
         all_type_params: all_type_params,
         relevant_type_params: HashSet::new(),
         associated_type_usage: Vec::new(),
     };
     match cont.data {
-        Data::Enum(_, ref variants) => for variant in variants.iter() {
-            let relevant_fields = variant
-                .fields
-                .iter()
-                .filter(|field| filter(&field.attrs, Some(&variant.attrs)));
-            for field in relevant_fields {
-                visitor.visit_field(field.original);
+        Data::Enum(_, ref variants) => {
+            for variant in variants.iter() {
+                let relevant_fields = variant
+                    .fields
+                    .iter()
+                    .filter(|field| filter(&field.attrs, Some(&variant.attrs)));
+                for field in relevant_fields {
+                    visitor.visit_field(field.original);
+                }
             }
-        },
+        }
         Data::Struct(_, ref fields) => {
             for field in fields.iter().filter(|field| filter(&field.attrs, None)) {
                 visitor.visit_field(field.original);
             }
         }
     }
 
     let relevant_type_params = visitor.relevant_type_params;
     let associated_type_usage = visitor.associated_type_usage;
     let new_predicates = generics
         .type_params()
         .map(|param| param.ident.clone())
         .filter(|id| relevant_type_params.contains(id))
         .map(|id| syn::TypePath {
             qself: None,
             path: id.into(),
-        }).chain(associated_type_usage.into_iter().cloned())
+        })
+        .chain(associated_type_usage.into_iter().cloned())
         .map(|bounded_ty| {
             syn::WherePredicate::Type(syn::PredicateType {
                 lifetimes: None,
                 // the type parameter that is being bounded e.g. T
                 bounded_ty: syn::Type::Path(bounded_ty),
                 colon_token: <Token![:]>::default(),
                 // the bound e.g. Serialize
                 bounds: vec![syn::TypeParamBound::Trait(syn::TraitBound {
                     paren_token: None,
                     modifier: syn::TraitBoundModifier::None,
                     lifetimes: None,
                     path: bound.clone(),
-                })].into_iter()
+                })]
+                .into_iter()
                 .collect(),
             })
         });
 
     let mut generics = generics.clone();
     generics
         .make_where_clause()
         .predicates
@@ -234,17 +231,18 @@ pub fn with_self_bound(
             bounded_ty: type_of_item(cont),
             colon_token: <Token![:]>::default(),
             // the bound e.g. Default
             bounds: vec![syn::TypeParamBound::Trait(syn::TraitBound {
                 paren_token: None,
                 modifier: syn::TraitBoundModifier::None,
                 lifetimes: None,
                 path: bound.clone(),
-            })].into_iter()
+            })]
+            .into_iter()
             .collect(),
         }));
     generics
 }
 
 pub fn with_lifetime_bound(generics: &syn::Generics, lifetime: &str) -> syn::Generics {
     let bound = syn::Lifetime::new(lifetime, Span::call_site());
     let def = syn::LifetimeDef {
@@ -264,17 +262,18 @@ pub fn with_lifetime_bound(generics: &sy
                 syn::GenericParam::Type(ref mut param) => {
                     param
                         .bounds
                         .push(syn::TypeParamBound::Lifetime(bound.clone()));
                 }
                 syn::GenericParam::Const(_) => {}
             }
             param
-        })).collect();
+        }))
+        .collect();
 
     syn::Generics {
         params: params,
         ..generics.clone()
     }
 }
 
 fn type_of_item(cont: &Container) -> syn::Type {
@@ -300,17 +299,19 @@ fn type_of_item(cont: &Container) -> syn
                                     }))
                                 }
                                 syn::GenericParam::Lifetime(ref param) => {
                                     syn::GenericArgument::Lifetime(param.lifetime.clone())
                                 }
                                 syn::GenericParam::Const(_) => {
                                     panic!("Serde does not support const generics yet");
                                 }
-                            }).collect(),
+                            })
+                            .collect(),
                         gt_token: <Token![>]>::default(),
                     },
                 ),
-            }].into_iter()
+            }]
+            .into_iter()
             .collect(),
         },
     })
 }
--- a/third_party/rust/serde_derive/src/de.rs
+++ b/third_party/rust/serde_derive/src/de.rs
@@ -1,49 +1,39 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use proc_macro2::{Literal, Span, TokenStream};
 use quote::ToTokens;
 use syn::punctuated::Punctuated;
 use syn::spanned::Spanned;
 use syn::{self, Ident, Index, Member};
 
 use bound;
+use dummy;
 use fragment::{Expr, Fragment, Match, Stmts};
 use internals::ast::{Container, Data, Field, Style, Variant};
 use internals::{attr, Ctxt, Derive};
 use pretend;
-use try;
 
 #[cfg(feature = "deserialize_in_place")]
 use internals::ast::Repr;
 
 
 use std::collections::BTreeSet;
 
-pub fn expand_derive_deserialize(input: &syn::DeriveInput) -> Result<TokenStream, String> {
+pub fn expand_derive_deserialize(input: &syn::DeriveInput) -> Result<TokenStream, Vec<syn::Error>> {
     let ctxt = Ctxt::new();
-    let cont = Container::from_ast(&ctxt, input, Derive::Deserialize);
+    let cont = match Container::from_ast(&ctxt, input, Derive::Deserialize) {
+        Some(cont) => cont,
+        None => return Err(ctxt.check().unwrap_err()),
+    };
     precondition(&ctxt, &cont);
     try!(ctxt.check());
 
     let ident = &cont.ident;
     let params = Parameters::new(&cont);
     let (de_impl_generics, _, ty_generics, where_clause) = split_with_de_lifetime(&params);
-    let suffix = ident.to_string().trim_left_matches("r#").to_owned();
-    let dummy_const = Ident::new(
-        &format!("_IMPL_DESERIALIZE_FOR_{}", suffix),
-        Span::call_site(),
-    );
     let body = Stmts(deserialize_body(&cont, &params));
     let delife = params.borrowed.de_lifetime();
 
     let impl_block = if let Some(remote) = cont.attrs.remote() {
         let vis = &input.vis;
         let used = pretend::pretend_used(&cont);
         quote! {
             impl #de_impl_generics #ident #ty_generics #where_clause {
@@ -69,51 +59,45 @@ pub fn expand_derive_deserialize(input: 
                     #body
                 }
 
                 #fn_deserialize_in_place
             }
         }
     };
 
-    let try_replacement = try::replacement();
-    let generated = quote! {
-        #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
-        const #dummy_const: () = {
-            #[allow(unknown_lints)]
-            #[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
-            #[allow(rust_2018_idioms)]
-            extern crate serde as _serde;
-            #try_replacement
-            #impl_block
-        };
-    };
-    Ok(generated)
+    Ok(dummy::wrap_in_const("DESERIALIZE", ident, impl_block))
 }
 
 fn precondition(cx: &Ctxt, cont: &Container) {
     precondition_sized(cx, cont);
     precondition_no_de_lifetime(cx, cont);
 }
 
 fn precondition_sized(cx: &Ctxt, cont: &Container) {
     if let Data::Struct(_, ref fields) = cont.data {
         if let Some(last) = fields.last() {
             if let syn::Type::Slice(_) = *last.ty {
-                cx.error("cannot deserialize a dynamically sized struct");
+                cx.error_spanned_by(
+                    cont.original,
+                    "cannot deserialize a dynamically sized struct",
+                );
             }
         }
     }
 }
 
 fn precondition_no_de_lifetime(cx: &Ctxt, cont: &Container) {
     if let BorrowedLifetimes::Borrowed(_) = borrowed_lifetimes(cont) {
         for param in cont.generics.lifetimes() {
             if param.lifetime.to_string() == "'de" {
-                cx.error("cannot deserialize when there is a lifetime parameter called 'de");
+                cx.error_spanned_by(
+                    &param.lifetime,
+                    "cannot deserialize when there is a lifetime parameter called 'de",
+                );
                 return;
             }
         }
     }
 }
 
 #[derive(Clone)]
 struct Parameters {
@@ -373,17 +357,20 @@ fn deserialize_transparent(cont: &Contai
         Data::Enum(_, _) => unreachable!(),
     };
 
     let this = &params.this;
     let transparent_field = fields.iter().find(|f| f.attrs.transparent()).unwrap();
 
     let path = match transparent_field.attrs.deserialize_with() {
         Some(path) => quote!(#path),
-        None => quote!(_serde::Deserialize::deserialize),
+        None => {
+            let span = transparent_field.original.span();
+            quote_spanned!(span=> _serde::Deserialize::deserialize)
+        }
     };
 
     let assign = fields.iter().map(|field| {
         let member = &field.member;
         if field as *const Field == transparent_field as *const Field {
             quote!(#member: __transparent)
         } else {
             let value = match *field.attrs.default() {
@@ -677,21 +664,28 @@ fn deserialize_seq(
                     quote!({
                         #wrapper
                         _serde::export::Option::map(
                             try!(_serde::de::SeqAccess::next_element::<#wrapper_ty>(&mut __seq)),
                             |__wrap| __wrap.value)
                     })
                 }
             };
+            let value_if_none = match *field.attrs.default() {
+                attr::Default::Default => quote!(_serde::export::Default::default()),
+                attr::Default::Path(ref path) => quote!(#path()),
+                attr::Default::None => quote!(
+                    return _serde::export::Err(_serde::de::Error::invalid_length(#index_in_seq, &#expecting));
+                ),
+            };
             let assign = quote! {
                 let #var = match #visit {
                     _serde::export::Some(__value) => __value,
                     _serde::export::None => {
-                        return _serde::export::Err(_serde::de::Error::invalid_length(#index_in_seq, &#expecting));
+                        #value_if_none
                     }
                 };
             };
             index_in_seq += 1;
             assign
         }
     });
 
@@ -758,42 +752,50 @@ fn deserialize_seq_in_place(
         let member = &field.member;
 
         if field.attrs.skip_deserializing() {
             let default = Expr(expr_is_missing(field, cattrs));
             quote! {
                 self.place.#member = #default;
             }
         } else {
-            let return_invalid_length = quote! {
-                return _serde::export::Err(_serde::de::Error::invalid_length(#index_in_seq, &#expecting));
+            let value_if_none = match *field.attrs.default() {
+                attr::Default::Default => quote!(
+                    self.place.#member = _serde::export::Default::default();
+                ),
+                attr::Default::Path(ref path) => quote!(
+                    self.place.#member = #path();
+                ),
+                attr::Default::None => quote!(
+                    return _serde::export::Err(_serde::de::Error::invalid_length(#index_in_seq, &#expecting));
+                ),
             };
             let write = match field.attrs.deserialize_with() {
                 None => {
                     quote! {
                         if let _serde::export::None = try!(_serde::de::SeqAccess::next_element_seed(&mut __seq,
                             _serde::private::de::InPlaceSeed(&mut self.place.#member)))
                         {
-                            #return_invalid_length
+                            #value_if_none
                         }
                     }
                 }
                 Some(path) => {
                     let (wrapper, wrapper_ty) = wrap_deserialize_field_with(params, field.ty, path);
                     quote!({
-                            #wrapper
-                            match try!(_serde::de::SeqAccess::next_element::<#wrapper_ty>(&mut __seq)) {
-                                _serde::export::Some(__wrap) => {
-                                    self.place.#member = __wrap.value;
-                                }
-                                _serde::export::None => {
-                                    #return_invalid_length
-                                }
+                        #wrapper
+                        match try!(_serde::de::SeqAccess::next_element::<#wrapper_ty>(&mut __seq)) {
+                            _serde::export::Some(__wrap) => {
+                                self.place.#member = __wrap.value;
                             }
-                        })
+                            _serde::export::None => {
+                                #value_if_none
+                            }
+                        }
+                    })
                 }
             };
             index_in_seq += 1;
             write
         }
     });
 
     let this = &params.this;
@@ -824,18 +826,20 @@ fn deserialize_newtype_struct(
     params: &Parameters,
     field: &Field,
 ) -> TokenStream {
     let delife = params.borrowed.de_lifetime();
     let field_ty = field.ty;
 
     let value = match field.attrs.deserialize_with() {
         None => {
+            let span = field.original.span();
+            let func = quote_spanned!(span=> <#field_ty as _serde::Deserialize>::deserialize);
             quote! {
-                try!(<#field_ty as _serde::Deserialize>::deserialize(__e))
+                try!(#func(__e))
             }
         }
         Some(path) => {
             quote! {
                 try!(#path(__e))
             }
         }
     };
@@ -1143,79 +1147,93 @@ fn deserialize_struct_in_place(
 }
 
 fn deserialize_enum(
     params: &Parameters,
     variants: &[Variant],
     cattrs: &attr::Container,
 ) -> Fragment {
     match *cattrs.tag() {
-        attr::EnumTag::External => deserialize_externally_tagged_enum(params, variants, cattrs),
-        attr::EnumTag::Internal { ref tag } => {
+        attr::TagType::External => deserialize_externally_tagged_enum(params, variants, cattrs),
+        attr::TagType::Internal { ref tag } => {
             deserialize_internally_tagged_enum(params, variants, cattrs, tag)
         }
-        attr::EnumTag::Adjacent {
+        attr::TagType::Adjacent {
             ref tag,
             ref content,
         } => deserialize_adjacently_tagged_enum(params, variants, cattrs, tag, content),
-        attr::EnumTag::None => deserialize_untagged_enum(params, variants, cattrs),
+        attr::TagType::None => deserialize_untagged_enum(params, variants, cattrs),
     }
 }
 
 #[cfg(feature = "deserialize_in_place")]
 fn deserialize_enum_in_place(
     params: &Parameters,
     repr: &Repr,
     variants: &[Variant],
     cattrs: &attr::Container,
 ) -> Option<Fragment> {
     match *cattrs.tag() {
-        attr::EnumTag::External => deserialize_externally_tagged_enum_in_place(params, repr, variants, cattrs),
+        attr::TagType::External => deserialize_externally_tagged_enum_in_place(params, repr, variants, cattrs),
         _ => None,
     }
 }
 
+fn prepare_enum_variant_enum(
+    variants: &[Variant],
+    cattrs: &attr::Container,
+) -> (TokenStream, Stmts) {
+    let variant_names_idents: Vec<_> = variants
+        .iter()
+        .enumerate()
+        .filter(|&(_, variant)| !variant.attrs.skip_deserializing())
+        .map(|(i, variant)| {
+            (
+                variant.attrs.name().deserialize_name(),
+                field_i(i),
+                variant.attrs.aliases(),
+            )
+        })
+        .collect();
+
+    let other_idx = variants
+        .iter()
+        .position(|ref variant| variant.attrs.other());
+
+    let variants_stmt = {
+        let variant_names = variant_names_idents.iter().map(|&(ref name, _, _)| name);
+        quote! {
+            const VARIANTS: &'static [&'static str] = &[ #(#variant_names),* ];
+        }
+    };
+
+    let variant_visitor = Stmts(deserialize_generated_identifier(
+        &variant_names_idents,
+        cattrs,
+        true,
+        other_idx,
+    ));
+
+    (variants_stmt, variant_visitor)
+}
+
 fn deserialize_externally_tagged_enum(
     params: &Parameters,
     variants: &[Variant],
     cattrs: &attr::Container,
 ) -> Fragment {
     let this = &params.this;
     let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
         split_with_de_lifetime(params);
     let delife = params.borrowed.de_lifetime();
 
     let type_name = cattrs.name().deserialize_name();
-
     let expecting = format!("enum {}", params.type_name());
 
-    let variant_names_idents: Vec<_> = variants
-        .iter()
-        .enumerate()
-        .filter(|&(_, variant)| !variant.attrs.skip_deserializing())
-        .map(|(i, variant)| (variant.attrs.name().deserialize_name(), field_i(i)))
-        .collect();
-
-    let other_idx = variants
-        .iter()
-        .position(|ref variant| variant.attrs.other());
-
-    let variants_stmt = {
-        let variant_names = variant_names_idents.iter().map(|&(ref name, _)| name);
-        quote! {
-            const VARIANTS: &'static [&'static str] = &[ #(#variant_names),* ];
-        }
-    };
-
-    let variant_visitor = Stmts(deserialize_generated_identifier(
-        &variant_names_idents,
-        cattrs,
-        true,
-        other_idx,
-    ));
+    let (variants_stmt, variant_visitor) = prepare_enum_variant_enum(variants, cattrs);
 
     // Match arms to extract a variant from a string
     let variant_arms = variants
         .iter()
         .enumerate()
         .filter(|&(_, variant)| !variant.attrs.skip_deserializing())
         .map(|(i, variant)| {
             let variant_name = field_i(i);
@@ -1271,21 +1289,25 @@ fn deserialize_externally_tagged_enum(
                 __A: _serde::de::EnumAccess<#delife>,
             {
                 #match_variant
             }
         }
 
         #variants_stmt
 
-        _serde::Deserializer::deserialize_enum(__deserializer, #type_name, VARIANTS,
-                                               __Visitor {
-                                                   marker: _serde::export::PhantomData::<#this #ty_generics>,
-                                                   lifetime: _serde::export::PhantomData,
-                                               })
+        _serde::Deserializer::deserialize_enum(
+            __deserializer,
+            #type_name,
+            VARIANTS,
+            __Visitor {
+                marker: _serde::export::PhantomData::<#this #ty_generics>,
+                lifetime: _serde::export::PhantomData,
+            },
+        )
     }
 }
 
 #[cfg(feature = "deserialize_in_place")]
 fn deserialize_externally_tagged_enum_in_place(
     params: &Parameters,
     repr: &Repr,
     variants: &[Variant],
@@ -1315,21 +1337,27 @@ fn deserialize_externally_tagged_enum_in
     let type_name = cattrs.name().deserialize_name();
 
     let expecting = format!("enum {}", params.type_name());
 
     let variant_names_idents: Vec<_> = variants
         .iter()
         .enumerate()
         .filter(|&(_, variant)| !variant.attrs.skip_deserializing())
-        .map(|(i, variant)| (variant.attrs.name().deserialize_name(), field_i(i)),)
+        .map(|(i, variant)| {
+            (
+                variant.attrs.name().deserialize_name(),
+                field_i(i),
+                variant.attrs.aliases(),
+            )
+        })
         .collect();
 
     let variants_stmt = {
-        let variant_names = variant_names_idents.iter().map(|&(ref name, _)| name);
+        let variant_names = variant_names_idents.iter().map(|&(ref name, _, _)| name);
         quote! {
             const VARIANTS: &'static [&'static str] = &[ #(#variant_names),* ];
         }
     };
 
     let variant_visitor = Stmts(deserialize_generated_identifier(&variant_names_idents, cattrs, true, None),);
 
     let non_unit_field = field_i(non_unit_index);
@@ -1532,40 +1560,17 @@ fn deserialize_externally_tagged_enum_in
 }
 
 fn deserialize_internally_tagged_enum(
     params: &Parameters,
     variants: &[Variant],
     cattrs: &attr::Container,
     tag: &str,
 ) -> Fragment {
-    let variant_names_idents: Vec<_> = variants
-        .iter()
-        .enumerate()
-        .filter(|&(_, variant)| !variant.attrs.skip_deserializing())
-        .map(|(i, variant)| (variant.attrs.name().deserialize_name(), field_i(i)))
-        .collect();
-
-    let other_idx = variants
-        .iter()
-        .position(|ref variant| variant.attrs.other());
-
-    let variants_stmt = {
-        let variant_names = variant_names_idents.iter().map(|&(ref name, _)| name);
-        quote! {
-            const VARIANTS: &'static [&'static str] = &[ #(#variant_names),* ];
-        }
-    };
-
-    let variant_visitor = Stmts(deserialize_generated_identifier(
-        &variant_names_idents,
-        cattrs,
-        true,
-        other_idx,
-    ));
+    let (variants_stmt, variant_visitor) = prepare_enum_variant_enum(variants, cattrs);
 
     // Match arms to extract a variant from a string
     let variant_arms = variants
         .iter()
         .enumerate()
         .filter(|&(_, variant)| !variant.attrs.skip_deserializing())
         .map(|(i, variant)| {
             let variant_name = field_i(i);
@@ -1606,40 +1611,17 @@ fn deserialize_adjacently_tagged_enum(
     tag: &str,
     content: &str,
 ) -> Fragment {
     let this = &params.this;
     let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
         split_with_de_lifetime(params);
     let delife = params.borrowed.de_lifetime();
 
-    let variant_names_idents: Vec<_> = variants
-        .iter()
-        .enumerate()
-        .filter(|&(_, variant)| !variant.attrs.skip_deserializing())
-        .map(|(i, variant)| (variant.attrs.name().deserialize_name(), field_i(i)))
-        .collect();
-
-    let other_idx = variants
-        .iter()
-        .position(|ref variant| variant.attrs.other());
-
-    let variants_stmt = {
-        let variant_names = variant_names_idents.iter().map(|&(ref name, _)| name);
-        quote! {
-            const VARIANTS: &'static [&'static str] = &[ #(#variant_names),* ];
-        }
-    };
-
-    let variant_visitor = Stmts(deserialize_generated_identifier(
-        &variant_names_idents,
-        cattrs,
-        true,
-        other_idx,
-    ));
+    let (variants_stmt, variant_visitor) = prepare_enum_variant_enum(variants, cattrs);
 
     let variant_arms: &Vec<_> = &variants
         .iter()
         .enumerate()
         .filter(|&(_, variant)| !variant.attrs.skip_deserializing())
         .map(|(i, variant)| {
             let variant_index = field_i(i);
 
@@ -1648,17 +1630,18 @@ fn deserialize_adjacently_tagged_enum(
                 variant,
                 cattrs,
                 quote!(__deserializer),
             ));
 
             quote! {
                 __Field::#variant_index => #block
             }
-        }).collect();
+        })
+        .collect();
 
     let expecting = format!("adjacently tagged enum {}", params.type_name());
     let type_name = cattrs.name().deserialize_name();
     let deny_unknown_fields = cattrs.deny_unknown_fields();
 
     // If unknown fields are allowed, we pick the visitor that can step over
     // those. Otherwise we pick the visitor that fails on unknown keys.
     let field_visitor_ty = if deny_unknown_fields {
@@ -1865,43 +1848,49 @@ fn deserialize_adjacently_tagged_enum(
             fn visit_seq<__A>(self, mut __seq: __A) -> _serde::export::Result<Self::Value, __A::Error>
             where
                 __A: _serde::de::SeqAccess<#delife>,
             {
                 // Visit the first element - the tag.
                 match try!(_serde::de::SeqAccess::next_element(&mut __seq)) {
                     _serde::export::Some(__field) => {
                         // Visit the second element - the content.
-                        match try!(_serde::de::SeqAccess::next_element_seed(&mut __seq,
-                                __Seed {
-                                    field: __field,
-                                    marker: _serde::export::PhantomData,
-                                    lifetime: _serde::export::PhantomData,
-                                })) {
+                        match try!(_serde::de::SeqAccess::next_element_seed(
+                            &mut __seq,
+                            __Seed {
+                                field: __field,
+                                marker: _serde::export::PhantomData,
+                                lifetime: _serde::export::PhantomData,
+                            },
+                        )) {
                             _serde::export::Some(__ret) => _serde::export::Ok(__ret),
                             // There is no second element.
                             _serde::export::None => {
                                 _serde::export::Err(_serde::de::Error::invalid_length(1, &self))
                             }
                         }
                     }
                     // There is no first element.
                     _serde::export::None => {
                         _serde::export::Err(_serde::de::Error::invalid_length(0, &self))
                     }
                 }
             }
         }
 
         const FIELDS: &'static [&'static str] = &[#tag, #content];
-        _serde::Deserializer::deserialize_struct(__deserializer, #type_name, FIELDS,
+        _serde::Deserializer::deserialize_struct(
+            __deserializer,
+            #type_name,
+            FIELDS,
             __Visitor {
                 marker: _serde::export::PhantomData::<#this #ty_generics>,
                 lifetime: _serde::export::PhantomData,
-            })
+            },
+        )
     }
 }
 
 fn deserialize_untagged_enum(
     params: &Parameters,
     variants: &[Variant],
     cattrs: &attr::Container,
 ) -> Fragment {
@@ -2122,20 +2111,21 @@ fn deserialize_externally_tagged_newtype
     variant_ident: &syn::Ident,
     params: &Parameters,
     field: &Field,
 ) -> Fragment {
     let this = &params.this;
     match field.attrs.deserialize_with() {
         None => {
             let field_ty = field.ty;
+            let span = field.original.span();
+            let func =
+                quote_spanned!(span=> _serde::de::VariantAccess::newtype_variant::<#field_ty>);
             quote_expr! {
-                _serde::export::Result::map(
-                    _serde::de::VariantAccess::newtype_variant::<#field_ty>(__variant),
-                    #this::#variant_ident)
+                _serde::export::Result::map(#func(__variant), #this::#variant_ident)
             }
         }
         Some(path) => {
             let (wrapper, wrapper_ty) = wrap_deserialize_field_with(params, field.ty, path);
             quote_block! {
                 #wrapper
                 _serde::export::Result::map(
                     _serde::de::VariantAccess::newtype_variant::<#wrapper_ty>(__variant),
@@ -2178,39 +2168,39 @@ fn deserialize_untagged_newtype_variant(
     params: &Parameters,
     field: &Field,
     deserializer: &TokenStream,
 ) -> Fragment {
     let this = &params.this;
     let field_ty = field.ty;
     match field.attrs.deserialize_with() {
         None => {
+            let span = field.original.span();
+            let func = quote_spanned!(span=> <#field_ty as _serde::Deserialize>::deserialize);
             quote_expr! {
-                _serde::export::Result::map(
-                    <#field_ty as _serde::Deserialize>::deserialize(#deserializer),
-                    #this::#variant_ident)
+                _serde::export::Result::map(#func(#deserializer), #this::#variant_ident)
             }
         }
         Some(path) => {
             quote_block! {
                 let __value: _serde::export::Result<#field_ty, _> = #path(#deserializer);
                 _serde::export::Result::map(__value, #this::#variant_ident)
             }
         }
     }
 }
 
 fn deserialize_generated_identifier(
-    fields: &[(String, Ident)],
+    fields: &[(String, Ident, Vec<String>)],
     cattrs: &attr::Container,
     is_variant: bool,
     other_idx: Option<usize>,
 ) -> Fragment {
     let this = quote!(__Field);
-    let field_idents: &Vec<_> = &fields.iter().map(|&(_, ref ident)| ident).collect();
+    let field_idents: &Vec<_> = &fields.iter().map(|&(_, ref ident, _)| ident).collect();
 
     let (ignore_variant, fallthrough) = if !is_variant && cattrs.has_flatten() {
         let ignore_variant = quote!(__other(_serde::private::de::Content<'de>),);
         let fallthrough = quote!(_serde::export::Ok(__Field::__other(__value)));
         (Some(ignore_variant), Some(fallthrough))
     } else if let Some(other_idx) = other_idx {
         let ignore_variant = fields[other_idx].1.clone();
         let fallthrough = quote!(_serde::export::Ok(__Field::#ignore_variant));
@@ -2301,20 +2291,22 @@ fn deserialize_custom_identifier(
     };
 
     let names_idents: Vec<_> = ordinary
         .iter()
         .map(|variant| {
             (
                 variant.attrs.name().deserialize_name(),
                 variant.ident.clone(),
+                variant.attrs.aliases(),
             )
-        }).collect();
-
-    let names = names_idents.iter().map(|&(ref name, _)| name);
+        })
+        .collect();
+
+    let names = names_idents.iter().map(|&(ref name, _, _)| name);
 
     let names_const = if fallthrough.is_some() {
         None
     } else if is_variant {
         let variants = quote! {
             const VARIANTS: &'static [&'static str] = &[ #(#names),* ];
         };
         Some(variants)
@@ -2355,34 +2347,43 @@ fn deserialize_custom_identifier(
             lifetime: _serde::export::PhantomData,
         };
         _serde::Deserializer::deserialize_identifier(__deserializer, __visitor)
     }
 }
 
 fn deserialize_identifier(
     this: &TokenStream,
-    fields: &[(String, Ident)],
+    fields: &[(String, Ident, Vec<String>)],
     is_variant: bool,
     fallthrough: Option<TokenStream>,
     collect_other_fields: bool,
 ) -> Fragment {
-    let field_strs = fields.iter().map(|&(ref name, _)| name);
-    let field_borrowed_strs = fields.iter().map(|&(ref name, _)| name);
-    let field_bytes = fields
+    let mut flat_fields = Vec::new();
+    for &(_, ref ident, ref aliases) in fields {
+        flat_fields.extend(aliases.iter().map(|alias| (alias, ident)))
+    }
+
+    let field_strs = flat_fields.iter().map(|&(ref name, _)| name);
+    let field_borrowed_strs = flat_fields.iter().map(|&(ref name, _)| name);
+    let field_bytes = flat_fields
         .iter()
         .map(|&(ref name, _)| Literal::byte_string(name.as_bytes()));
-    let field_borrowed_bytes = fields
+    let field_borrowed_bytes = flat_fields
         .iter()
         .map(|&(ref name, _)| Literal::byte_string(name.as_bytes()));
 
-    let constructors: &Vec<_> = &fields
+    let constructors: &Vec<_> = &flat_fields
         .iter()
         .map(|&(_, ref ident)| quote!(#this::#ident))
         .collect();
+    let main_constructors: &Vec<_> = &fields
+        .iter()
+        .map(|&(_, ref ident, _)| quote!(#this::#ident))
+        .collect();
 
     let expecting = if is_variant {
         "variant identifier"
     } else {
         "field identifier"
     };
 
     let index_expecting = if is_variant { "variant" } else { "field" };
@@ -2560,21 +2561,22 @@ fn deserialize_identifier(
     } else {
         quote! {
             fn visit_u64<__E>(self, __value: u64) -> _serde::export::Result<Self::Value, __E>
             where
                 __E: _serde::de::Error,
             {
                 match __value {
                     #(
-                        #variant_indices => _serde::export::Ok(#constructors),
+                        #variant_indices => _serde::export::Ok(#main_constructors),
                     )*
                     _ => _serde::export::Err(_serde::de::Error::invalid_value(
-                                _serde::de::Unexpected::Unsigned(__value),
-                                &#fallthrough_msg))
+                        _serde::de::Unexpected::Unsigned(__value),
+                        &#fallthrough_msg,
+                    ))
                 }
             }
         }
     };
 
     quote_block! {
         fn expecting(&self, __formatter: &mut _serde::export::Formatter) -> _serde::export::fmt::Result {
             _serde::export::Formatter::write_str(__formatter, #expecting)
@@ -2622,21 +2624,27 @@ fn deserialize_struct_as_struct_visitor(
     cattrs: &attr::Container,
 ) -> (Fragment, Option<Fragment>, Fragment) {
     assert!(!cattrs.has_flatten());
 
     let field_names_idents: Vec<_> = fields
         .iter()
         .enumerate()
         .filter(|&(_, field)| !field.attrs.skip_deserializing())
-        .map(|(i, field)| (field.attrs.name().deserialize_name(), field_i(i)))
+        .map(|(i, field)| {
+            (
+                field.attrs.name().deserialize_name(),
+                field_i(i),
+                field.attrs.aliases(),
+            )
+        })
         .collect();
 
     let fields_stmt = {
-        let field_names = field_names_idents.iter().map(|&(ref name, _)| name);
+        let field_names = field_names_idents.iter().map(|&(ref name, _, _)| name);
         quote_block! {
             const FIELDS: &'static [&'static str] = &[ #(#field_names),* ];
         }
     };
 
     let field_visitor = deserialize_generated_identifier(&field_names_idents, cattrs, false, None);
 
     let visit_map = deserialize_map(struct_path, params, fields, cattrs);
@@ -2649,17 +2657,23 @@ fn deserialize_struct_as_map_visitor(
     params: &Parameters,
     fields: &[Field],
     cattrs: &attr::Container,
 ) -> (Fragment, Option<Fragment>, Fragment) {
     let field_names_idents: Vec<_> = fields
         .iter()
         .enumerate()
         .filter(|&(_, field)| !field.attrs.skip_deserializing() && !field.attrs.flatten())
-        .map(|(i, field)| (field.attrs.name().deserialize_name(), field_i(i)))
+        .map(|(i, field)| {
+            (
+                field.attrs.name().deserialize_name(),
+                field_i(i),
+                field.attrs.aliases(),
+            )
+        })
         .collect();
 
     let field_visitor = deserialize_generated_identifier(&field_names_idents, cattrs, false, None);
 
     let visit_map = deserialize_map(struct_path, params, fields, cattrs);
 
     (field_visitor, None, visit_map)
 }
@@ -2716,17 +2730,22 @@ fn deserialize_map(
                     quote! {
                         try!(#func(&mut __map))
                     }
                 }
                 Some(path) => {
                     let (wrapper, wrapper_ty) = wrap_deserialize_field_with(params, field.ty, path);
                     quote!({
                         #wrapper
-                        try!(_serde::de::MapAccess::next_value::<#wrapper_ty>(&mut __map)).value
+                        match _serde::de::MapAccess::next_value::<#wrapper_ty>(&mut __map) {
+                            _serde::export::Ok(__wrapper) => __wrapper.value,
+                            _serde::export::Err(__err) => {
+                                return _serde::export::Err(__err);
+                            }
+                        }
                     })
                 }
             };
             quote! {
                 __Field::#name => {
                     if _serde::export::Option::is_some(&#name) {
                         return _serde::export::Err(<__A::Error as _serde::de::Error>::duplicate_field(#deser_name));
                     }
@@ -2783,21 +2802,24 @@ fn deserialize_map(
                     _serde::export::Some(#name) => #name,
                     _serde::export::None => #missing_expr
                 };
             }
         });
 
     let extract_collected = fields_names
         .iter()
-        .filter(|&&(field, _)| field.attrs.flatten())
+        .filter(|&&(field, _)| field.attrs.flatten() && !field.attrs.skip_deserializing())
         .map(|&(field, ref name)| {
             let field_ty = field.ty;
             let func = match field.attrs.deserialize_with() {
-                None => quote!(_serde::de::Deserialize::deserialize),
+                None => {
+                    let span = field.original.span();
+                    quote_spanned!(span=> _serde::de::Deserialize::deserialize)
+                }
                 Some(path) => quote!(#path),
             };
             quote! {
                 let #name: #field_ty = try!(#func(
                     _serde::private::de::FlatMapDeserializer(
                         &mut __collect,
                         _serde::export::PhantomData)));
             }
@@ -2877,21 +2899,27 @@ fn deserialize_struct_as_struct_in_place
     cattrs: &attr::Container,
 ) -> (Fragment, Fragment, Fragment) {
     assert!(!cattrs.has_flatten());
 
     let field_names_idents: Vec<_> = fields
         .iter()
         .enumerate()
         .filter(|&(_, field)| !field.attrs.skip_deserializing())
-        .map(|(i, field)| (field.attrs.name().deserialize_name(), field_i(i)))
+        .map(|(i, field)| {
+            (
+                field.attrs.name().deserialize_name(),
+                field_i(i),
+                field.attrs.aliases(),
+            )
+        })
         .collect();
 
     let fields_stmt = {
-        let field_names = field_names_idents.iter().map(|&(ref name, _)| name);
+        let field_names = field_names_idents.iter().map(|&(ref name, _, _)| name);
         quote_block! {
             const FIELDS: &'static [&'static str] = &[ #(#field_names),* ];
         }
     };
 
     let field_visitor = deserialize_generated_identifier(&field_names_idents, cattrs, false, None);
 
     let visit_map = deserialize_map_in_place(params, fields, cattrs);
@@ -2938,17 +2966,22 @@ fn deserialize_map_in_place(
                     quote! {
                         try!(_serde::de::MapAccess::next_value_seed(&mut __map, _serde::private::de::InPlaceSeed(&mut self.place.#member)))
                     }
                 }
                 Some(path) => {
                     let (wrapper, wrapper_ty) = wrap_deserialize_field_with(params, field.ty, path);
                     quote!({
                         #wrapper
-                        self.place.#member = try!(_serde::de::MapAccess::next_value::<#wrapper_ty>(&mut __map)).value
+                        self.place.#member = match _serde::de::MapAccess::next_value::<#wrapper_ty>(&mut __map) {
+                            _serde::export::Ok(__wrapper) => __wrapper.value,
+                            _serde::export::Err(__err) => {
+                                return _serde::export::Err(__err);
+                            }
+                        };
                     })
                 }
             };
             quote! {
                 __Field::#name => {
                     if #name {
                         return _serde::export::Err(<__A::Error as _serde::de::Error>::duplicate_field(#deser_name));
                     }
@@ -3139,17 +3172,19 @@ fn wrap_deserialize_variant_with(
     };
 
     (wrapper, wrapper_ty, unwrap_fn)
 }
 
 fn expr_is_missing(field: &Field, cattrs: &attr::Container) -> Fragment {
     match *field.attrs.default() {
         attr::Default::Default => {
-            return quote_expr!(_serde::export::Default::default());
+            let span = field.original.span();
+            let func = quote_spanned!(span=> _serde::export::Default::default);
+            return quote_expr!(#func());
         }
         attr::Default::Path(ref path) => {
             return quote_expr!(#path());
         }
         attr::Default::None => { /* below */ }
     }
 
     match *cattrs.default() {
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde_derive/src/dummy.rs
@@ -0,0 +1,32 @@
+use proc_macro2::{Ident, Span, TokenStream};
+
+use try;
+
+pub fn wrap_in_const(trait_: &str, ty: &Ident, code: TokenStream) -> TokenStream {
+    let try_replacement = try::replacement();
+
+    let dummy_const = Ident::new(
+        &format!("_IMPL_{}_FOR_{}", trait_, unraw(ty)),
+        Span::call_site(),
+    );
+
+    quote! {
+        #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
+        const #dummy_const: () = {
+            #[allow(unknown_lints)]
+            #[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
+            #[allow(rust_2018_idioms)]
+            extern crate serde as _serde;
+            #try_replacement
+            #code
+        };
+    }
+}
+
+#[allow(deprecated)]
+fn unraw(ident: &Ident) -> String {
+    // str::trim_start_matches was added in 1.30, trim_left_matches deprecated
+    // in 1.33. We currently support rustc back to 1.15 so we need to continue
+    // to use the deprecated one.
+    ident.to_string().trim_left_matches("r#").to_owned()
+}
--- a/third_party/rust/serde_derive/src/fragment.rs
+++ b/third_party/rust/serde_derive/src/fragment.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use proc_macro2::TokenStream;
 use quote::ToTokens;
 use syn::token;
 
 pub enum Fragment {
     /// Tokens that can be used as an expression.
     Expr(TokenStream),
     /// Tokens that can be used inside a block. The surrounding curly braces are
--- a/third_party/rust/serde_derive/src/internals/ast.rs
+++ b/third_party/rust/serde_derive/src/internals/ast.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 //! A Serde ast, parsed from the Syn ast and ready to generate Rust code.
 
 use internals::attr;
 use internals::check;
 use internals::{Ctxt, Derive};
 use syn;
 use syn::punctuated::Punctuated;
 
@@ -20,32 +12,35 @@ pub struct Container<'a> {
     /// The struct or enum name (without generics).
     pub ident: syn::Ident,
     /// Attributes on the structure, parsed for Serde.
     pub attrs: attr::Container,
     /// The contents of the struct or enum.
     pub data: Data<'a>,
     /// Any generics on the struct or enum.
     pub generics: &'a syn::Generics,
+    /// Original input.
+    pub original: &'a syn::DeriveInput,
 }
 
 /// The fields of a struct or enum.
 ///
 /// Analagous to `syn::Data`.
 pub enum Data<'a> {
     Enum(Repr, Vec<Variant<'a>>),
     Struct(Style, Vec<Field<'a>>),
 }
 
 /// A variant of an enum.
 pub struct Variant<'a> {
     pub ident: syn::Ident,
     pub attrs: attr::Variant,
     pub style: Style,
     pub fields: Vec<Field<'a>>,
+    pub original: &'a syn::Variant,
 }
 
 /// A field of a struct.
 pub struct Field<'a> {
     pub member: syn::Member,
     pub attrs: attr::Field,
     pub ty: &'a syn::Type,
     pub original: &'a syn::Field,
@@ -66,64 +61,76 @@ pub enum Style {
     /// One unnamed field.
     Newtype,
     /// No fields.
     Unit,
 }
 
 impl<'a> Container<'a> {
     /// Convert the raw Syn ast into a parsed container object, collecting errors in `cx`.
-    pub fn from_ast(cx: &Ctxt, item: &'a syn::DeriveInput, derive: Derive) -> Container<'a> {
+    pub fn from_ast(
+        cx: &Ctxt,
+        item: &'a syn::DeriveInput,
+        derive: Derive,
+    ) -> Option<Container<'a>> {
         let mut attrs = attr::Container::from_ast(cx, item);
 
         let mut data = match item.data {
             syn::Data::Enum(ref data) => {
                 let (repr, variants) = enum_from_ast(cx, item, &data.variants, attrs.default());
                 Data::Enum(repr, variants)
             }
             syn::Data::Struct(ref data) => {
                 let (style, fields) = struct_from_ast(cx, &data.fields, None, attrs.default());
                 Data::Struct(style, fields)
             }
             syn::Data::Union(_) => {
-                panic!("Serde does not support derive for unions");
+                cx.error_spanned_by(item, "Serde does not support derive for unions");
+                return None;
             }
         };
 
         let mut has_flatten = false;
         match data {
-            Data::Enum(_, ref mut variants) => for variant in variants {
-                variant.attrs.rename_by_rule(attrs.rename_all());
-                for field in &mut variant.fields {
+            Data::Enum(_, ref mut variants) => {
+                for variant in variants {
+                    variant.attrs.rename_by_rules(attrs.rename_all_rules());
+                    for field in &mut variant.fields {
+                        if field.attrs.flatten() {
+                            has_flatten = true;
+                        }
+                        field
+                            .attrs
+                            .rename_by_rules(variant.attrs.rename_all_rules());
+                    }
+                }
+            }
+            Data::Struct(_, ref mut fields) => {
+                for field in fields {
                     if field.attrs.flatten() {
                         has_flatten = true;
                     }
-                    field.attrs.rename_by_rule(variant.attrs.rename_all());
+                    field.attrs.rename_by_rules(attrs.rename_all_rules());
                 }
-            },
-            Data::Struct(_, ref mut fields) => for field in fields {
-                if field.attrs.flatten() {
-                    has_flatten = true;
-                }
-                field.attrs.rename_by_rule(attrs.rename_all());
-            },
+            }
         }
 
         if has_flatten {
             attrs.mark_has_flatten();
         }
 
         let mut item = Container {
             ident: item.ident.clone(),
             attrs: attrs,
             data: data,
             generics: &item.generics,
+            original: item,
         };
         check::check(cx, &mut item, derive);
-        item
+        Some(item)
     }
 }
 
 impl<'a> Data<'a> {
     pub fn all_fields(&'a self) -> Box<Iterator<Item = &'a Field<'a>> + 'a> {
         match *self {
             Data::Enum(_, ref variants) => {
                 Box::new(variants.iter().flat_map(|variant| variant.fields.iter()))
@@ -153,36 +160,35 @@ impl Repr {
             None
         } else {
             self.int_repr
         }
     }
 }
 
 fn enum_from_ast<'a>(
-    cx: &Ctxt, 
-    item: &'a syn::DeriveInput, 
+    cx: &Ctxt,
+    item: &'a syn::DeriveInput,
     variants: &'a Punctuated<syn::Variant, Token![,]>,
     container_default: &attr::Default
 ) -> (Repr, Vec<Variant<'a>>) {
     let variants = variants
         .iter()
-        .map(
-            |variant| {
-                let attrs = attr::Variant::from_ast(cx, variant);
-                let (style, fields) = 
-                    struct_from_ast(cx, &variant.fields, Some(&attrs), container_default);
-                Variant {
-                    ident: variant.ident.clone(),
-                    attrs: attrs,
-                    style: style,
-                    fields: fields,
-                }
-            },
-        )
+        .map(|variant| {
+            let attrs = attr::Variant::from_ast(cx, variant);
+            let (style, fields) = 
+                struct_from_ast(cx, &variant.fields, Some(&attrs), container_default);
+            Variant {
+                ident: variant.ident.clone(),
+                attrs: attrs,
+                style: style,
+                fields: fields,
+                original: variant,
+            }
+        })
         .collect();
 
     // Compute repr info for enum optimizations
     static INT_TYPES: [&'static str; 12] = [
         "u8", "u16", "u32", "u64", "u128", "usize",
         "i8", "i16", "i32", "i64", "i128", "isize",
     ];
 
@@ -257,10 +263,11 @@ fn fields_from_ast<'a>(
         .map(|(i, field)| Field {
             member: match field.ident {
                 Some(ref ident) => syn::Member::Named(ident.clone()),
                 None => syn::Member::Unnamed(i.into()),
             },
             attrs: attr::Field::from_ast(cx, i, field, attrs, container_default),
             ty: &field.ty,
             original: field,
-        }).collect()
+        })
+        .collect()
 }
--- a/third_party/rust/serde_derive/src/internals/attr.rs
+++ b/third_party/rust/serde_derive/src/internals/attr.rs
@@ -1,18 +1,11 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use internals::Ctxt;
 use proc_macro2::{Group, Span, TokenStream, TokenTree};
+use quote::ToTokens;
 use std::collections::BTreeSet;
 use std::str::FromStr;
 use syn;
 use syn::parse::{self, Parse, ParseStream};
 use syn::punctuated::Punctuated;
 use syn::Ident;
 use syn::Meta::{List, NameValue, Word};
 use syn::NestedMeta::{Literal, Meta};
@@ -22,114 +15,218 @@ use syn::NestedMeta::{Literal, Meta};
 // `attr::Field::from_ast`. Each returns an instance of the corresponding
 // struct. Note that none of them return a Result. Unrecognized, malformed, or
 // duplicated attributes result in a span_err but otherwise are ignored. The
 // user will see errors simultaneously for all bad attributes in the crate
 // rather than just the first.
 
 pub use internals::case::RenameRule;
 
-#[derive(Copy, Clone)]
 struct Attr<'c, T> {
     cx: &'c Ctxt,
     name: &'static str,
+    tokens: TokenStream,
     value: Option<T>,
 }
 
 impl<'c, T> Attr<'c, T> {
     fn none(cx: &'c Ctxt, name: &'static str) -> Self {
         Attr {
             cx: cx,
             name: name,
+            tokens: TokenStream::new(),
             value: None,
         }
     }
 
-    fn set(&mut self, value: T) {
+    fn set<A: ToTokens>(&mut self, obj: A, value: T) {
+        let tokens = obj.into_token_stream();
+
         if self.value.is_some() {
             self.cx
-                .error(format!("duplicate serde attribute `{}`", self.name));
+                .error_spanned_by(tokens, format!("duplicate serde attribute `{}`", self.name));
         } else {
+            self.tokens = tokens;
             self.value = Some(value);
         }
     }
 
-    fn set_opt(&mut self, value: Option<T>) {
+    fn set_opt<A: ToTokens>(&mut self, obj: A, value: Option<T>) {
         if let Some(value) = value {
-            self.set(value);
+            self.set(obj, value);
         }
     }
 
     fn set_if_none(&mut self, value: T) {
         if self.value.is_none() {
             self.value = Some(value);
         }
     }
 
     fn get(self) -> Option<T> {
         self.value
     }
+
+    fn get_with_tokens(self) -> Option<(TokenStream, T)> {
+        match self.value {
+            Some(v) => Some((self.tokens, v)),
+            None => None,
+        }
+    }
 }
 
 struct BoolAttr<'c>(Attr<'c, ()>);
 
 impl<'c> BoolAttr<'c> {
     fn none(cx: &'c Ctxt, name: &'static str) -> Self {
         BoolAttr(Attr::none(cx, name))
     }
 
-    fn set_true(&mut self) {
-        self.0.set(());
+    fn set_true<A: ToTokens>(&mut self, obj: A) {
+        self.0.set(obj, ());
     }
 
     fn get(&self) -> bool {
         self.0.value.is_some()
     }
 }
 
+struct VecAttr<'c, T> {
+    cx: &'c Ctxt,
+    name: &'static str,
+    first_dup_tokens: TokenStream,
+    values: Vec<T>,
+}
+
+impl<'c, T> VecAttr<'c, T> {
+    fn none(cx: &'c Ctxt, name: &'static str) -> Self {
+        VecAttr {
+            cx: cx,
+            name: name,
+            first_dup_tokens: TokenStream::new(),
+            values: Vec::new(),
+        }
+    }
+
+    fn insert<A: ToTokens>(&mut self, obj: A, value: T) {
+        if self.values.len() == 1 {
+            self.first_dup_tokens = obj.into_token_stream();
+        }
+        self.values.push(value);
+    }
+
+    fn at_most_one(mut self) -> Result<Option<T>, ()> {
+        if self.values.len() > 1 {
+            let dup_token = self.first_dup_tokens;
+            self.cx.error_spanned_by(
+                dup_token,
+                format!("duplicate serde attribute `{}`", self.name),
+            );
+            Err(())
+        } else {
+            Ok(self.values.pop())
+        }
+    }
+
+    fn get(self) -> Vec<T> {
+        self.values
+    }
+}
+
 pub struct Name {
     serialize: String,
+    serialize_renamed: bool,
     deserialize: String,
+    deserialize_renamed: bool,
+    deserialize_aliases: Vec<String>,
 }
 
+#[allow(deprecated)]
 fn unraw(ident: &Ident) -> String {
+    // str::trim_start_matches was added in 1.30, trim_left_matches deprecated
+    // in 1.33. We currently support rustc back to 1.15 so we need to continue
+    // to use the deprecated one.
     ident.to_string().trim_left_matches("r#").to_owned()
 }
 
 impl Name {
+    fn from_attrs(
+        source_name: String,
+        ser_name: Attr<String>,
+        de_name: Attr<String>,
+        de_aliases: Option<VecAttr<String>>,
+    ) -> Name {
+        let deserialize_aliases = match de_aliases {
+            Some(de_aliases) => {
+                let mut alias_list = BTreeSet::new();
+                for alias_name in de_aliases.get() {
+                    alias_list.insert(alias_name);
+                }
+                alias_list.into_iter().collect()
+            }
+            None => Vec::new(),
+        };
+
+        let ser_name = ser_name.get();
+        let ser_renamed = ser_name.is_some();
+        let de_name = de_name.get();
+        let de_renamed = de_name.is_some();
+        Name {
+            serialize: ser_name.unwrap_or_else(|| source_name.clone()),
+            serialize_renamed: ser_renamed,
+            deserialize: de_name.unwrap_or(source_name),
+            deserialize_renamed: de_renamed,
+            deserialize_aliases: deserialize_aliases,
+        }
+    }
+
     /// Return the container name for the container when serializing.
     pub fn serialize_name(&self) -> String {
         self.serialize.clone()
     }
 
     /// Return the container name for the container when deserializing.
     pub fn deserialize_name(&self) -> String {
         self.deserialize.clone()
     }
+
+    fn deserialize_aliases(&self) -> Vec<String> {
+        let mut aliases = self.deserialize_aliases.clone();
+        let main_name = self.deserialize_name();
+        if !aliases.contains(&main_name) {
+            aliases.push(main_name);
+        }
+        aliases
+    }
+}
+
+pub struct RenameAllRules {
+    serialize: RenameRule,
+    deserialize: RenameRule,
 }
 
 /// Represents struct or enum attribute information.
 pub struct Container {
     name: Name,
     transparent: bool,
     deny_unknown_fields: bool,
     default: Default,
-    rename_all: RenameRule,
+    rename_all_rules: RenameAllRules,
     ser_bound: Option<Vec<syn::WherePredicate>>,
     de_bound: Option<Vec<syn::WherePredicate>>,
-    tag: EnumTag,
+    tag: TagType,
     type_from: Option<syn::Type>,
     type_into: Option<syn::Type>,
     remote: Option<syn::Path>,
     identifier: Identifier,
     has_flatten: bool,
 }
 
 /// Styles of representing an enum.
-pub enum EnumTag {
+pub enum TagType {
     /// The default.
     ///
     /// ```json
     /// {"variant1": {"key1": "value1", "key2": "value2"}}
     /// ```
     External,
 
     /// `#[serde(tag = "type")]`
@@ -184,17 +281,18 @@ impl Identifier {
 impl Container {
     /// Extract out the `#[serde(...)]` attributes from an item.
     pub fn from_ast(cx: &Ctxt, item: &syn::DeriveInput) -> Self {
         let mut ser_name = Attr::none(cx, "rename");
         let mut de_name = Attr::none(cx, "rename");
         let mut transparent = BoolAttr::none(cx, "transparent");
         let mut deny_unknown_fields = BoolAttr::none(cx, "deny_unknown_fields");
         let mut default = Attr::none(cx, "default");
-        let mut rename_all = Attr::none(cx, "rename_all");
+        let mut rename_all_ser_rule = Attr::none(cx, "rename_all");
+        let mut rename_all_de_rule = Attr::none(cx, "rename_all");
         let mut ser_bound = Attr::none(cx, "bound");
         let mut de_bound = Attr::none(cx, "bound");
         let mut untagged = BoolAttr::none(cx, "untagged");
         let mut internal_tag = Attr::none(cx, "tag");
         let mut content = Attr::none(cx, "content");
         let mut type_from = Attr::none(cx, "from");
         let mut type_into = Attr::none(cx, "into");
         let mut remote = Attr::none(cx, "remote");
@@ -202,217 +300,333 @@ impl Container {
         let mut variant_identifier = BoolAttr::none(cx, "variant_identifier");
 
         for meta_items in item.attrs.iter().filter_map(get_serde_meta_items) {
             for meta_item in meta_items {
                 match meta_item {
                     // Parse `#[serde(rename = "foo")]`
                     Meta(NameValue(ref m)) if m.ident == "rename" => {
                         if let Ok(s) = get_lit_str(cx, &m.ident, &m.ident, &m.lit) {
-                            ser_name.set(s.value());
-                            de_name.set(s.value());
+                            ser_name.set(&m.ident, s.value());
+                            de_name.set(&m.ident, s.value());
                         }
                     }
 
                     // Parse `#[serde(rename(serialize = "foo", deserialize = "bar"))]`
                     Meta(List(ref m)) if m.ident == "rename" => {
                         if let Ok((ser, de)) = get_renames(cx, &m.nested) {
-                            ser_name.set_opt(ser.map(syn::LitStr::value));
-                            de_name.set_opt(de.map(syn::LitStr::value));
+                            ser_name.set_opt(&m.ident, ser.map(syn::LitStr::value));
+                            de_name.set_opt(&m.ident, de.map(syn::LitStr::value));
                         }
                     }
 
                     // Parse `#[serde(rename_all = "foo")]`
                     Meta(NameValue(ref m)) if m.ident == "rename_all" => {
                         if let Ok(s) = get_lit_str(cx, &m.ident, &m.ident, &m.lit) {
                             match RenameRule::from_str(&s.value()) {
-                                Ok(rename_rule) => rename_all.set(rename_rule),
-                                Err(()) => cx.error(format!(
-                                    "unknown rename rule for #[serde(rename_all \
-                                     = {:?})]",
-                                    s.value()
-                                )),
+                                Ok(rename_rule) => {
+                                    rename_all_ser_rule.set(&m.ident, rename_rule);
+                                    rename_all_de_rule.set(&m.ident, rename_rule);
+                                }
+                                Err(()) => cx.error_spanned_by(
+                                    s,
+                                    format!(
+                                        "unknown rename rule for #[serde(rename_all \
+                                         = {:?})]",
+                                        s.value(),
+                                    ),
+                                ),
+                            }
+                        }
+                    }
+
+                    // Parse `#[serde(rename_all(serialize = "foo", deserialize = "bar"))]`
+                    Meta(List(ref m)) if m.ident == "rename_all" => {
+                        if let Ok((ser, de)) = get_renames(cx, &m.nested) {
+                            if let Some(ser) = ser {
+                                match RenameRule::from_str(&ser.value()) {
+                                    Ok(rename_rule) => {
+                                        rename_all_ser_rule.set(&m.ident, rename_rule)
+                                    }
+                                    Err(()) => cx.error_spanned_by(
+                                        ser,
+                                        format!(
+                                            "unknown rename rule for #[serde(rename_all \
+                                             = {:?})]",
+                                            ser.value(),
+                                        ),
+                                    ),
+                                }
+                            }
+                            if let Some(de) = de {
+                                match RenameRule::from_str(&de.value()) {
+                                    Ok(rename_rule) => {
+                                        rename_all_de_rule.set(&m.ident, rename_rule)
+                                    }
+                                    Err(()) => cx.error_spanned_by(
+                                        de,
+                                        format!(
+                                            "unknown rename rule for #[serde(rename_all \
+                                             = {:?})]",
+                                            de.value(),
+                                        ),
+                                    ),
+                                }
                             }
                         }
                     }
 
                     // Parse `#[serde(transparent)]`
                     Meta(Word(ref word)) if word == "transparent" => {
-                        transparent.set_true();
+                        transparent.set_true(word);
                     }
 
                     // Parse `#[serde(deny_unknown_fields)]`
                     Meta(Word(ref word)) if word == "deny_unknown_fields" => {
-                        deny_unknown_fields.set_true();
+                        deny_unknown_fields.set_true(word);
                     }
 
                     // Parse `#[serde(default)]`
                     Meta(Word(ref word)) if word == "default" => match item.data {
-                        syn::Data::Struct(syn::DataStruct {
-                            fields: syn::Fields::Named(_),
-                            ..
-                        }) => {
-                            default.set(Default::Default);
-                        }
-                        _ => cx.error(
+                        syn::Data::Struct(syn::DataStruct { ref fields, .. }) => match *fields {
+                            syn::Fields::Named(_) => {
+                                default.set(word, Default::Default);
+                            }
+                            syn::Fields::Unnamed(_) | syn::Fields::Unit => cx.error_spanned_by(
+                                fields,
+                                "#[serde(default)] can only be used on structs \
+                                 with named fields",
+                            ),
+                        },
+                        syn::Data::Enum(syn::DataEnum { ref enum_token, .. }) => cx
+                            .error_spanned_by(
+                                enum_token,
+                                "#[serde(default)] can only be used on structs \
+                                 with named fields",
+                            ),
+                        syn::Data::Union(syn::DataUnion {
+                            ref union_token, ..
+                        }) => cx.error_spanned_by(
+                            union_token,
                             "#[serde(default)] can only be used on structs \
                              with named fields",
                         ),
                     },
 
                     // Parse `#[serde(default = "...")]`
                     Meta(NameValue(ref m)) if m.ident == "default" => {
                         if let Ok(path) = parse_lit_into_expr_path(cx, &m.ident, &m.lit) {
                             match item.data {
-                                syn::Data::Struct(syn::DataStruct {
-                                    fields: syn::Fields::Named(_),
-                                    ..
-                                }) => {
-                                    default.set(Default::Path(path));
+                                syn::Data::Struct(syn::DataStruct { ref fields, .. }) => {
+                                    match *fields {
+                                        syn::Fields::Named(_) => {
+                                            default.set(&m.ident, Default::Path(path));
+                                        }
+                                        syn::Fields::Unnamed(_) | syn::Fields::Unit => cx
+                                            .error_spanned_by(
+                                                fields,
+                                                "#[serde(default = \"...\")] can only be used \
+                                                 on structs with named fields",
+                                            ),
+                                    }
                                 }
-                                _ => cx.error(
+                                syn::Data::Enum(syn::DataEnum { ref enum_token, .. }) => cx
+                                    .error_spanned_by(
+                                        enum_token,
+                                        "#[serde(default = \"...\")] can only be used \
+                                         on structs with named fields",
+                                    ),
+                                syn::Data::Union(syn::DataUnion {
+                                    ref union_token, ..
+                                }) => cx.error_spanned_by(
+                                    union_token,
                                     "#[serde(default = \"...\")] can only be used \
                                      on structs with named fields",
                                 ),
                             }
                         }
                     }
 
                     // Parse `#[serde(bound = "T: SomeBound")]`
                     Meta(NameValue(ref m)) if m.ident == "bound" => {
                         if let Ok(where_predicates) =
                             parse_lit_into_where(cx, &m.ident, &m.ident, &m.lit)
                         {
-                            ser_bound.set(where_predicates.clone());
-                            de_bound.set(where_predicates);
+                            ser_bound.set(&m.ident, where_predicates.clone());
+                            de_bound.set(&m.ident, where_predicates);
                         }
                     }
 
                     // Parse `#[serde(bound(serialize = "...", deserialize = "..."))]`
                     Meta(List(ref m)) if m.ident == "bound" => {
                         if let Ok((ser, de)) = get_where_predicates(cx, &m.nested) {
-                            ser_bound.set_opt(ser);
-                            de_bound.set_opt(de);
+                            ser_bound.set_opt(&m.ident, ser);
+                            de_bound.set_opt(&m.ident, de);
                         }
                     }
 
                     // Parse `#[serde(untagged)]`
                     Meta(Word(ref word)) if word == "untagged" => match item.data {
                         syn::Data::Enum(_) => {
-                            untagged.set_true();
+                            untagged.set_true(word);
                         }
-                        syn::Data::Struct(_) | syn::Data::Union(_) => {
-                            cx.error("#[serde(untagged)] can only be used on enums")
+                        syn::Data::Struct(syn::DataStruct {
+                            ref struct_token, ..
+                        }) => {
+                            cx.error_spanned_by(
+                                struct_token,
+                                "#[serde(untagged)] can only be used on enums",
+                            );
+                        }
+                        syn::Data::Union(syn::DataUnion {
+                            ref union_token, ..
+                        }) => {
+                            cx.error_spanned_by(
+                                union_token,
+                                "#[serde(untagged)] can only be used on enums",
+                            );
                         }
                     },
 
                     // Parse `#[serde(tag = "type")]`
                     Meta(NameValue(ref m)) if m.ident == "tag" => {
                         if let Ok(s) = get_lit_str(cx, &m.ident, &m.ident, &m.lit) {
                             match item.data {
                                 syn::Data::Enum(_) => {
-                                    internal_tag.set(s.value());
+                                    internal_tag.set(&m.ident, s.value());
                                 }
-                                syn::Data::Struct(_) | syn::Data::Union(_) => {
-                                    cx.error("#[serde(tag = \"...\")] can only be used on enums")
+                                syn::Data::Struct(syn::DataStruct { ref fields, .. }) => {
+                                    match *fields {
+                                        syn::Fields::Named(_) => {
+                                            internal_tag.set(&m.ident, s.value());
+                                        }
+                                        syn::Fields::Unnamed(_) | syn::Fields::Unit => {
+                                            cx.error_spanned_by(
+                                                fields,
+                                                "#[serde(tag = \"...\")] can only be used on enums \
+                                                and structs with named fields",
+                                            );
+                                        }
+                                    }
+                                }
+                                syn::Data::Union(syn::DataUnion {
+                                    ref union_token, ..
+                                }) => {
+                                    cx.error_spanned_by(
+                                        union_token,
+                                        "#[serde(tag = \"...\")] can only be used on enums \
+                                         and structs with named fields",
+                                    );
                                 }
                             }
                         }
                     }
 
                     // Parse `#[serde(content = "c")]`
                     Meta(NameValue(ref m)) if m.ident == "content" => {
                         if let Ok(s) = get_lit_str(cx, &m.ident, &m.ident, &m.lit) {
                             match item.data {
                                 syn::Data::Enum(_) => {
-                                    content.set(s.value());
+                                    content.set(&m.ident, s.value());
                                 }
-                                syn::Data::Struct(_) | syn::Data::Union(_) => cx.error(
-                                    "#[serde(content = \"...\")] can only be used on \
-                                     enums",
-                                ),
+                                syn::Data::Struct(syn::DataStruct {
+                                    ref struct_token, ..
+                                }) => {
+                                    cx.error_spanned_by(
+                                        struct_token,
+                                        "#[serde(content = \"...\")] can only be used on enums",
+                                    );
+                                }
+                                syn::Data::Union(syn::DataUnion {
+                                    ref union_token, ..
+                                }) => {
+                                    cx.error_spanned_by(
+                                        union_token,
+                                        "#[serde(content = \"...\")] can only be used on enums",
+                                    );
+                                }
                             }
                         }
                     }
 
                     // Parse `#[serde(from = "Type")]
                     Meta(NameValue(ref m)) if m.ident == "from" => {
                         if let Ok(from_ty) = parse_lit_into_ty(cx, &m.ident, &m.lit) {
-                            type_from.set_opt(Some(from_ty));
+                            type_from.set_opt(&m.ident, Some(from_ty));
                         }
                     }
 
                     // Parse `#[serde(into = "Type")]
                     Meta(NameValue(ref m)) if m.ident == "into" => {
                         if let Ok(into_ty) = parse_lit_into_ty(cx, &m.ident, &m.lit) {
-                            type_into.set_opt(Some(into_ty));
+                            type_into.set_opt(&m.ident, Some(into_ty));
                         }
                     }
 
                     // Parse `#[serde(remote = "...")]`
                     Meta(NameValue(ref m)) if m.ident == "remote" => {
                         if let Ok(path) = parse_lit_into_path(cx, &m.ident, &m.lit) {
                             if is_primitive_path(&path, "Self") {
-                                remote.set(item.ident.clone().into());
+                                remote.set(&m.ident, item.ident.clone().into());
                             } else {
-                                remote.set(path);
+                                remote.set(&m.ident, path);
                             }
                         }
                     }
 
                     // Parse `#[serde(field_identifier)]`
                     Meta(Word(ref word)) if word == "field_identifier" => {
-                        field_identifier.set_true();
+                        field_identifier.set_true(word);
                     }
 
                     // Parse `#[serde(variant_identifier)]`
                     Meta(Word(ref word)) if word == "variant_identifier" => {
-                        variant_identifier.set_true();
+                        variant_identifier.set_true(word);
                     }
 
                     Meta(ref meta_item) => {
-                        cx.error(format!(
-                            "unknown serde container attribute `{}`",
-                            meta_item.name()
-                        ));
+                        cx.error_spanned_by(
+                            meta_item.name(),
+                            format!("unknown serde container attribute `{}`", meta_item.name()),
+                        );
                     }
 
-                    Literal(_) => {
-                        cx.error("unexpected literal in serde container attribute");
+                    Literal(ref lit) => {
+                        cx.error_spanned_by(lit, "unexpected literal in serde container attribute");
                     }
                 }
             }
         }
 
         Container {
-            name: Name {
-                serialize: ser_name.get().unwrap_or_else(|| unraw(&item.ident)),
-                deserialize: de_name.get().unwrap_or_else(|| unraw(&item.ident)),
-            },
+            name: Name::from_attrs(unraw(&item.ident), ser_name, de_name, None),
             transparent: transparent.get(),
             deny_unknown_fields: deny_unknown_fields.get(),
             default: default.get().unwrap_or(Default::None),
-            rename_all: rename_all.get().unwrap_or(RenameRule::None),
+            rename_all_rules: RenameAllRules {
+                serialize: rename_all_ser_rule.get().unwrap_or(RenameRule::None),
+                deserialize: rename_all_de_rule.get().unwrap_or(RenameRule::None),
+            },
             ser_bound: ser_bound.get(),
             de_bound: de_bound.get(),
-            tag: decide_tag(cx, item, &untagged, internal_tag, content),
+            tag: decide_tag(cx, item, untagged, internal_tag, content),
             type_from: type_from.get(),
             type_into: type_into.get(),
             remote: remote.get(),
-            identifier: decide_identifier(cx, item, &field_identifier, &variant_identifier),
+            identifier: decide_identifier(cx, item, field_identifier, variant_identifier),
             has_flatten: false,
         }
     }
 
     pub fn name(&self) -> &Name {
         &self.name
     }
 
-    pub fn rename_all(&self) -> &RenameRule {
-        &self.rename_all
+    pub fn rename_all_rules(&self) -> &RenameAllRules {
+        &self.rename_all_rules
     }
 
     pub fn transparent(&self) -> bool {
         self.transparent
     }
 
     pub fn deny_unknown_fields(&self) -> bool {
         self.deny_unknown_fields
@@ -425,17 +639,17 @@ impl Container {
     pub fn ser_bound(&self) -> Option<&[syn::WherePredicate]> {
         self.ser_bound.as_ref().map(|vec| &vec[..])
     }
 
     pub fn de_bound(&self) -> Option<&[syn::WherePredicate]> {
         self.de_bound.as_ref().map(|vec| &vec[..])
     }
 
-    pub fn tag(&self) -> &EnumTag {
+    pub fn tag(&self) -> &TagType {
         &self.tag
     }
 
     pub fn type_from(&self) -> Option<&syn::Type> {
         self.type_from.as_ref()
     }
 
     pub fn type_into(&self) -> Option<&syn::Type> {
@@ -457,287 +671,429 @@ impl Container {
     pub fn mark_has_flatten(&mut self) {
         self.has_flatten = true;
     }
 }
 
 fn decide_tag(
     cx: &Ctxt,
     item: &syn::DeriveInput,
-    untagged: &BoolAttr,
+    untagged: BoolAttr,
     internal_tag: Attr<String>,
     content: Attr<String>,
-) -> EnumTag {
-    match (untagged.get(), internal_tag.get(), content.get()) {
-        (false, None, None) => EnumTag::External,
-        (true, None, None) => EnumTag::None,
-        (false, Some(tag), None) => {
+) -> TagType {
+    match (
+        untagged.0.get_with_tokens(),
+        internal_tag.get_with_tokens(),
+        content.get_with_tokens(),
+    ) {
+        (None, None, None) => TagType::External,
+        (Some(_), None, None) => TagType::None,
+        (None, Some((_, tag)), None) => {
             // Check that there are no tuple variants.
             if let syn::Data::Enum(ref data) = item.data {
                 for variant in &data.variants {
                     match variant.fields {
                         syn::Fields::Named(_) | syn::Fields::Unit => {}
                         syn::Fields::Unnamed(ref fields) => {
                             if fields.unnamed.len() != 1 {
-                                cx.error(
+                                cx.error_spanned_by(
+                                    variant,
                                     "#[serde(tag = \"...\")] cannot be used with tuple \
                                      variants",
                                 );
                                 break;
                             }
                         }
                     }
                 }
             }
-            EnumTag::Internal { tag: tag }
+            TagType::Internal { tag: tag }
         }
-        (true, Some(_), None) => {
-            cx.error("enum cannot be both untagged and internally tagged");
-            EnumTag::External // doesn't matter, will error
+        (Some((untagged_tokens, _)), Some((tag_tokens, _)), None) => {
+            cx.error_spanned_by(
+                untagged_tokens,
+                "enum cannot be both untagged and internally tagged",
+            );
+            cx.error_spanned_by(
+                tag_tokens,
+                "enum cannot be both untagged and internally tagged",
+            );
+            TagType::External // doesn't matter, will error
         }
-        (false, None, Some(_)) => {
-            cx.error("#[serde(tag = \"...\", content = \"...\")] must be used together");
-            EnumTag::External
+        (None, None, Some((content_tokens, _))) => {
+            cx.error_spanned_by(
+                content_tokens,
+                "#[serde(tag = \"...\", content = \"...\")] must be used together",
+            );
+            TagType::External
         }
-        (true, None, Some(_)) => {
-            cx.error("untagged enum cannot have #[serde(content = \"...\")]");
-            EnumTag::External
+        (Some((untagged_tokens, _)), None, Some((content_tokens, _))) => {
+            cx.error_spanned_by(
+                untagged_tokens,
+                "untagged enum cannot have #[serde(content = \"...\")]",
+            );
+            cx.error_spanned_by(
+                content_tokens,
+                "untagged enum cannot have #[serde(content = \"...\")]",
+            );
+            TagType::External
         }
-        (false, Some(tag), Some(content)) => EnumTag::Adjacent {
+        (None, Some((_, tag)), Some((_, content))) => TagType::Adjacent {
             tag: tag,
             content: content,
         },
-        (true, Some(_), Some(_)) => {
-            cx.error("untagged enum cannot have #[serde(tag = \"...\", content = \"...\")]");
-            EnumTag::External
+        (Some((untagged_tokens, _)), Some((tag_tokens, _)), Some((content_tokens, _))) => {
+            cx.error_spanned_by(
+                untagged_tokens,
+                "untagged enum cannot have #[serde(tag = \"...\", content = \"...\")]",
+            );
+            cx.error_spanned_by(
+                tag_tokens,
+                "untagged enum cannot have #[serde(tag = \"...\", content = \"...\")]",
+            );
+            cx.error_spanned_by(
+                content_tokens,
+                "untagged enum cannot have #[serde(tag = \"...\", content = \"...\")]",
+            );
+            TagType::External
         }
     }
 }
 
 fn decide_identifier(
     cx: &Ctxt,
     item: &syn::DeriveInput,
-    field_identifier: &BoolAttr,
-    variant_identifier: &BoolAttr,
+    field_identifier: BoolAttr,
+    variant_identifier: BoolAttr,
 ) -> Identifier {
-    match (&item.data, field_identifier.get(), variant_identifier.get()) {
-        (_, false, false) => Identifier::No,
-        (_, true, true) => {
-            cx.error("`field_identifier` and `variant_identifier` cannot both be set");
+    match (
+        &item.data,
+        field_identifier.0.get_with_tokens(),
+        variant_identifier.0.get_with_tokens(),
+    ) {
+        (_, None, None) => Identifier::No,
+        (_, Some((field_identifier_tokens, _)), Some((variant_identifier_tokens, _))) => {
+            cx.error_spanned_by(
+                field_identifier_tokens,
+                "#[serde(field_identifier)] and #[serde(variant_identifier)] cannot both be set",
+            );
+            cx.error_spanned_by(
+                variant_identifier_tokens,
+                "#[serde(field_identifier)] and #[serde(variant_identifier)] cannot both be set",
+            );
+            Identifier::No
+        }
+        (&syn::Data::Enum(_), Some(_), None) => Identifier::Field,
+        (&syn::Data::Enum(_), None, Some(_)) => Identifier::Variant,
+        (
+            &syn::Data::Struct(syn::DataStruct {
+                ref struct_token, ..
+            }),
+            Some(_),
+            None,
+        ) => {
+            cx.error_spanned_by(
+                struct_token,
+                "#[serde(field_identifier)] can only be used on an enum",
+            );
             Identifier::No
         }
-        (&syn::Data::Enum(_), true, false) => Identifier::Field,
-        (&syn::Data::Enum(_), false, true) => Identifier::Variant,
-        (&syn::Data::Struct(_), true, false) | (&syn::Data::Union(_), true, false) => {
-            cx.error("`field_identifier` can only be used on an enum");
+        (
+            &syn::Data::Union(syn::DataUnion {
+                ref union_token, ..
+            }),
+            Some(_),
+            None,
+        ) => {
+            cx.error_spanned_by(
+                union_token,
+                "#[serde(field_identifier)] can only be used on an enum",
+            );
             Identifier::No
         }
-        (&syn::Data::Struct(_), false, true) | (&syn::Data::Union(_), false, true) => {
-            cx.error("`variant_identifier` can only be used on an enum");
+        (
+            &syn::Data::Struct(syn::DataStruct {
+                ref struct_token, ..
+            }),
+            None,
+            Some(_),
+        ) => {
+            cx.error_spanned_by(
+                struct_token,
+                "#[serde(variant_identifier)] can only be used on an enum",
+            );
+            Identifier::No
+        }
+        (
+            &syn::Data::Union(syn::DataUnion {
+                ref union_token, ..
+            }),
+            None,
+            Some(_),
+        ) => {
+            cx.error_spanned_by(
+                union_token,
+                "#[serde(variant_identifier)] can only be used on an enum",
+            );
             Identifier::No
         }
     }
 }
 
 /// Represents variant attribute information
 pub struct Variant {
     name: Name,
-    ser_renamed: bool,
-    de_renamed: bool,
-    rename_all: RenameRule,
+    rename_all_rules: RenameAllRules,
     ser_bound: Option<Vec<syn::WherePredicate>>,
     de_bound: Option<Vec<syn::WherePredicate>>,
     skip_deserializing: bool,
     skip_serializing: bool,
     other: bool,
     serialize_with: Option<syn::ExprPath>,
     deserialize_with: Option<syn::ExprPath>,
     borrow: Option<syn::Meta>,
 }
 
 impl Variant {
     pub fn from_ast(cx: &Ctxt, variant: &syn::Variant) -> Self {
         let mut ser_name = Attr::none(cx, "rename");
         let mut de_name = Attr::none(cx, "rename");
+        let mut de_aliases = VecAttr::none(cx, "rename");
         let mut skip_deserializing = BoolAttr::none(cx, "skip_deserializing");
         let mut skip_serializing = BoolAttr::none(cx, "skip_serializing");
-        let mut rename_all = Attr::none(cx, "rename_all");
+        let mut rename_all_ser_rule = Attr::none(cx, "rename_all");
+        let mut rename_all_de_rule = Attr::none(cx, "rename_all");
         let mut ser_bound = Attr::none(cx, "bound");
         let mut de_bound = Attr::none(cx, "bound");
         let mut other = BoolAttr::none(cx, "other");
         let mut serialize_with = Attr::none(cx, "serialize_with");
         let mut deserialize_with = Attr::none(cx, "deserialize_with");
         let mut borrow = Attr::none(cx, "borrow");
 
         for meta_items in variant.attrs.iter().filter_map(get_serde_meta_items) {
             for meta_item in meta_items {
                 match meta_item {
                     // Parse `#[serde(rename = "foo")]`
                     Meta(NameValue(ref m)) if m.ident == "rename" => {
                         if let Ok(s) = get_lit_str(cx, &m.ident, &m.ident, &m.lit) {
-                            ser_name.set(s.value());
-                            de_name.set(s.value());
+                            ser_name.set(&m.ident, s.value());
+                            de_name.set_if_none(s.value());
+                            de_aliases.insert(&m.ident, s.value());
                         }
                     }
 
                     // Parse `#[serde(rename(serialize = "foo", deserialize = "bar"))]`
                     Meta(List(ref m)) if m.ident == "rename" => {
-                        if let Ok((ser, de)) = get_renames(cx, &m.nested) {
-                            ser_name.set_opt(ser.map(syn::LitStr::value));
-                            de_name.set_opt(de.map(syn::LitStr::value));
+                        if let Ok((ser, de)) = get_multiple_renames(cx, &m.nested) {
+                            ser_name.set_opt(&m.ident, ser.map(syn::LitStr::value));
+                            for de_value in de {
+                                de_name.set_if_none(de_value.value());
+                                de_aliases.insert(&m.ident, de_value.value());
+                            }
+                        }
+                    }
+
+                    // Parse `#[serde(alias = "foo")]`
+                    Meta(NameValue(ref m)) if m.ident == "alias" => {
+                        if let Ok(s) = get_lit_str(cx, &m.ident, &m.ident, &m.lit) {
+                            de_aliases.insert(&m.ident, s.value());
                         }
                     }
 
                     // Parse `#[serde(rename_all = "foo")]`
                     Meta(NameValue(ref m)) if m.ident == "rename_all" => {
                         if let Ok(s) = get_lit_str(cx, &m.ident, &m.ident, &m.lit) {
                             match RenameRule::from_str(&s.value()) {
-                                Ok(rename_rule) => rename_all.set(rename_rule),
-                                Err(()) => cx.error(format!(
-                                    "unknown rename rule for #[serde(rename_all \
-                                     = {:?})]",
-                                    s.value()
-                                )),
+                                Ok(rename_rule) => {
+                                    rename_all_ser_rule.set(&m.ident, rename_rule);
+                                    rename_all_de_rule.set(&m.ident, rename_rule);
+                                }
+                                Err(()) => cx.error_spanned_by(
+                                    s,
+                                    format!(
+                                        "unknown rename rule for #[serde(rename_all \
+                                         = {:?})]",
+                                        s.value()
+                                    ),
+                                ),
+                            }
+                        }
+                    }
+
+                    // Parse `#[serde(rename_all(serialize = "foo", deserialize = "bar"))]`
+                    Meta(List(ref m)) if m.ident == "rename_all" => {
+                        if let Ok((ser, de)) = get_renames(cx, &m.nested) {
+                            if let Some(ser) = ser {
+                                match RenameRule::from_str(&ser.value()) {
+                                    Ok(rename_rule) => {
+                                        rename_all_ser_rule.set(&m.ident, rename_rule)
+                                    }
+                                    Err(()) => cx.error_spanned_by(
+                                        ser,
+                                        format!(
+                                            "unknown rename rule for #[serde(rename_all \
+                                             = {:?})]",
+                                            ser.value(),
+                                        ),
+                                    ),
+                                }
+                            }
+                            if let Some(de) = de {
+                                match RenameRule::from_str(&de.value()) {
+                                    Ok(rename_rule) => {
+                                        rename_all_de_rule.set(&m.ident, rename_rule)
+                                    }
+                                    Err(()) => cx.error_spanned_by(
+                                        de,
+                                        format!(
+                                            "unknown rename rule for #[serde(rename_all \
+                                             = {:?})]",
+                                            de.value(),
+                                        ),
+                                    ),
+                                }
                             }
                         }
                     }
 
                     // Parse `#[serde(skip)]`
                     Meta(Word(ref word)) if word == "skip" => {
-                        skip_serializing.set_true();
-                        skip_deserializing.set_true();
+                        skip_serializing.set_true(word);
+                        skip_deserializing.set_true(word);
                     }
 
                     // Parse `#[serde(skip_deserializing)]`
                     Meta(Word(ref word)) if word == "skip_deserializing" => {
-                        skip_deserializing.set_true();
+                        skip_deserializing.set_true(word);
                     }
 
                     // Parse `#[serde(skip_serializing)]`
                     Meta(Word(ref word)) if word == "skip_serializing" => {
-                        skip_serializing.set_true();
+                        skip_serializing.set_true(word);
                     }
 
                     // Parse `#[serde(other)]`
                     Meta(Word(ref word)) if word == "other" => {
-                        other.set_true();
+                        other.set_true(word);
                     }
 
                     // Parse `#[serde(bound = "T: SomeBound")]`
                     Meta(NameValue(ref m)) if m.ident == "bound" => {
                         if let Ok(where_predicates) =
                             parse_lit_into_where(cx, &m.ident, &m.ident, &m.lit)
                         {
-                            ser_bound.set(where_predicates.clone());
-                            de_bound.set(where_predicates);
+                            ser_bound.set(&m.ident, where_predicates.clone());
+                            de_bound.set(&m.ident, where_predicates);
                         }
                     }
 
                     // Parse `#[serde(bound(serialize = "...", deserialize = "..."))]`
                     Meta(List(ref m)) if m.ident == "bound" => {
                         if let Ok((ser, de)) = get_where_predicates(cx, &m.nested) {
-                            ser_bound.set_opt(ser);
-                            de_bound.set_opt(de);
+                            ser_bound.set_opt(&m.ident, ser);
+                            de_bound.set_opt(&m.ident, de);
                         }
                     }
 
                     // Parse `#[serde(with = "...")]`
                     Meta(NameValue(ref m)) if m.ident == "with" => {
                         if let Ok(path) = parse_lit_into_expr_path(cx, &m.ident, &m.lit) {
                             let mut ser_path = path.clone();
                             ser_path
                                 .path
                                 .segments
                                 .push(Ident::new("serialize", Span::call_site()).into());
-                            serialize_with.set(ser_path);
+                            serialize_with.set(&m.ident, ser_path);
                             let mut de_path = path;
                             de_path
                                 .path
                                 .segments
                                 .push(Ident::new("deserialize", Span::call_site()).into());
-                            deserialize_with.set(de_path);
+                            deserialize_with.set(&m.ident, de_path);
                         }
                     }
 
                     // Parse `#[serde(serialize_with = "...")]`
                     Meta(NameValue(ref m)) if m.ident == "serialize_with" => {
                         if let Ok(path) = parse_lit_into_expr_path(cx, &m.ident, &m.lit) {
-                            serialize_with.set(path);
+                            serialize_with.set(&m.ident, path);
                         }
                     }
 
                     // Parse `#[serde(deserialize_with = "...")]`
                     Meta(NameValue(ref m)) if m.ident == "deserialize_with" => {
                         if let Ok(path) = parse_lit_into_expr_path(cx, &m.ident, &m.lit) {
-                            deserialize_with.set(path);
+                            deserialize_with.set(&m.ident, path);
                         }
                     }
 
                     // Defer `#[serde(borrow)]` and `#[serde(borrow = "'a + 'b")]`
                     Meta(ref m) if m.name() == "borrow" => match variant.fields {
                         syn::Fields::Unnamed(ref fields) if fields.unnamed.len() == 1 => {
-                            borrow.set(m.clone());
+                            borrow.set(m.name(), m.clone());
                         }
                         _ => {
-                            cx.error("#[serde(borrow)] may only be used on newtype variants");
+                            cx.error_spanned_by(
+                                variant,
+                                "#[serde(borrow)] may only be used on newtype variants",
+                            );
                         }
                     },
 
                     Meta(ref meta_item) => {
-                        cx.error(format!(
-                            "unknown serde variant attribute `{}`",
-                            meta_item.name()
-                        ));
+                        cx.error_spanned_by(
+                            meta_item.name(),
+                            format!("unknown serde variant attribute `{}`", meta_item.name()),
+                        );
                     }
 
-                    Literal(_) => {
-                        cx.error("unexpected literal in serde variant attribute");
+                    Literal(ref lit) => {
+                        cx.error_spanned_by(lit, "unexpected literal in serde variant attribute");
                     }
                 }
             }
         }
 
-        let ser_name = ser_name.get();
-        let ser_renamed = ser_name.is_some();
-        let de_name = de_name.get();
-        let de_renamed = de_name.is_some();
         Variant {
-            name: Name {
-                serialize: ser_name.unwrap_or_else(|| unraw(&variant.ident)),
-                deserialize: de_name.unwrap_or_else(|| unraw(&variant.ident)),
+            name: Name::from_attrs(unraw(&variant.ident), ser_name, de_name, Some(de_aliases)),
+            rename_all_rules: RenameAllRules {
+                serialize: rename_all_ser_rule.get().unwrap_or(RenameRule::None),
+                deserialize: rename_all_de_rule.get().unwrap_or(RenameRule::None),
             },
-            ser_renamed: ser_renamed,
-            de_renamed: de_renamed,
-            rename_all: rename_all.get().unwrap_or(RenameRule::None),
             ser_bound: ser_bound.get(),
             de_bound: de_bound.get(),
             skip_deserializing: skip_deserializing.get(),
             skip_serializing: skip_serializing.get(),
             other: other.get(),
             serialize_with: serialize_with.get(),
             deserialize_with: deserialize_with.get(),
             borrow: borrow.get(),
         }
     }
 
     pub fn name(&self) -> &Name {
         &self.name
     }
 
-    pub fn rename_by_rule(&mut self, rule: &RenameRule) {
-        if !self.ser_renamed {
-            self.name.serialize = rule.apply_to_variant(&self.name.serialize);
+    pub fn aliases(&self) -> Vec<String> {
+        self.name.deserialize_aliases()
+    }
+
+    pub fn rename_by_rules(&mut self, rules: &RenameAllRules) {
+        if !self.name.serialize_renamed {
+            self.name.serialize = rules.serialize.apply_to_variant(&self.name.serialize);
         }
-        if !self.de_renamed {
-            self.name.deserialize = rule.apply_to_variant(&self.name.deserialize);
+        if !self.name.deserialize_renamed {
+            self.name.deserialize = rules.deserialize.apply_to_variant(&self.name.deserialize);
         }
     }
 
-    pub fn rename_all(&self) -> &RenameRule {
-        &self.rename_all
+    pub fn rename_all_rules(&self) -> &RenameAllRules {
+        &self.rename_all_rules
     }
 
     pub fn ser_bound(&self) -> Option<&[syn::WherePredicate]> {
         self.ser_bound.as_ref().map(|vec| &vec[..])
     }
 
     pub fn de_bound(&self) -> Option<&[syn::WherePredicate]> {
         self.de_bound.as_ref().map(|vec| &vec[..])
@@ -762,18 +1118,16 @@ impl Variant {
     pub fn deserialize_with(&self) -> Option<&syn::ExprPath> {
         self.deserialize_with.as_ref()
     }
 }
 
 /// Represents field attribute information
 pub struct Field {
     name: Name,
-    ser_renamed: bool,
-    de_renamed: bool,
     skip_serializing: bool,
     skip_deserializing: bool,
     skip_serializing_if: Option<syn::ExprPath>,
     default: Default,
     serialize_with: Option<syn::ExprPath>,
     deserialize_with: Option<syn::ExprPath>,
     ser_bound: Option<Vec<syn::WherePredicate>>,
     de_bound: Option<Vec<syn::WherePredicate>>,
@@ -808,16 +1162,17 @@ impl Field {
         cx: &Ctxt,
         index: usize,
         field: &syn::Field,
         attrs: Option<&Variant>,
         container_default: &Default,
     ) -> Self {
         let mut ser_name = Attr::none(cx, "rename");
         let mut de_name = Attr::none(cx, "rename");
+        let mut de_aliases = VecAttr::none(cx, "rename");
         let mut skip_serializing = BoolAttr::none(cx, "skip_serializing");
         let mut skip_deserializing = BoolAttr::none(cx, "skip_deserializing");
         let mut skip_serializing_if = Attr::none(cx, "skip_serializing_if");
         let mut default = Attr::none(cx, "default");
         let mut serialize_with = Attr::none(cx, "serialize_with");
         let mut deserialize_with = Attr::none(cx, "deserialize_with");
         let mut ser_bound = Attr::none(cx, "bound");
         let mut de_bound = Attr::none(cx, "bound");
@@ -840,159 +1195,173 @@ impl Field {
             .filter_map(get_serde_meta_items)
             .chain(variant_borrow)
         {
             for meta_item in meta_items {
                 match meta_item {
                     // Parse `#[serde(rename = "foo")]`
                     Meta(NameValue(ref m)) if m.ident == "rename" => {
                         if let Ok(s) = get_lit_str(cx, &m.ident, &m.ident, &m.lit) {
-                            ser_name.set(s.value());
-                            de_name.set(s.value());
+                            ser_name.set(&m.ident, s.value());
+                            de_name.set_if_none(s.value());
+                            de_aliases.insert(&m.ident, s.value());
                         }
                     }
 
                     // Parse `#[serde(rename(serialize = "foo", deserialize = "bar"))]`
                     Meta(List(ref m)) if m.ident == "rename" => {
-                        if let Ok((ser, de)) = get_renames(cx, &m.nested) {
-                            ser_name.set_opt(ser.map(syn::LitStr::value));
-                            de_name.set_opt(de.map(syn::LitStr::value));
+                        if let Ok((ser, de)) = get_multiple_renames(cx, &m.nested) {
+                            ser_name.set_opt(&m.ident, ser.map(syn::LitStr::value));
+                            for de_value in de {
+                                de_name.set_if_none(de_value.value());
+                                de_aliases.insert(&m.ident, de_value.value());
+                            }
+                        }
+                    }
+
+                    // Parse `#[serde(alias = "foo")]`
+                    Meta(NameValue(ref m)) if m.ident == "alias" => {
+                        if let Ok(s) = get_lit_str(cx, &m.ident, &m.ident, &m.lit) {
+                            de_aliases.insert(&m.ident, s.value());
                         }
                     }
 
                     // Parse `#[serde(default)]`
                     Meta(Word(ref word)) if word == "default" => {
-                        default.set(Default::Default);
+                        default.set(word, Default::Default);
                     }
 
                     // Parse `#[serde(default = "...")]`
                     Meta(NameValue(ref m)) if m.ident == "default" => {
                         if let Ok(path) = parse_lit_into_expr_path(cx, &m.ident, &m.lit) {
-                            default.set(Default::Path(path));
+                            default.set(&m.ident, Default::Path(path));
                         }
                     }
 
                     // Parse `#[serde(skip_serializing)]`
                     Meta(Word(ref word)) if word == "skip_serializing" => {
-                        skip_serializing.set_true();
+                        skip_serializing.set_true(word);
                     }
 
                     // Parse `#[serde(skip_deserializing)]`
                     Meta(Word(ref word)) if word == "skip_deserializing" => {
-                        skip_deserializing.set_true();
+                        skip_deserializing.set_true(word);
                     }
 
                     // Parse `#[serde(skip)]`
                     Meta(Word(ref word)) if word == "skip" => {
-                        skip_serializing.set_true();
-                        skip_deserializing.set_true();
+                        skip_serializing.set_true(word);
+                        skip_deserializing.set_true(word);
                     }
 
                     // Parse `#[serde(skip_serializing_if = "...")]`
                     Meta(NameValue(ref m)) if m.ident == "skip_serializing_if" => {
                         if let Ok(path) = parse_lit_into_expr_path(cx, &m.ident, &m.lit) {
-                            skip_serializing_if.set(path);
+                            skip_serializing_if.set(&m.ident, path);
                         }
                     }
 
                     // Parse `#[serde(serialize_with = "...")]`
                     Meta(NameValue(ref m)) if m.ident == "serialize_with" => {
                         if let Ok(path) = parse_lit_into_expr_path(cx, &m.ident, &m.lit) {
-                            serialize_with.set(path);
+                            serialize_with.set(&m.ident, path);
                         }
                     }
 
                     // Parse `#[serde(deserialize_with = "...")]`
                     Meta(NameValue(ref m)) if m.ident == "deserialize_with" => {
                         if let Ok(path) = parse_lit_into_expr_path(cx, &m.ident, &m.lit) {
-                            deserialize_with.set(path);
+                            deserialize_with.set(&m.ident, path);
                         }
                     }
 
                     // Parse `#[serde(with = "...")]`
                     Meta(NameValue(ref m)) if m.ident == "with" => {
                         if let Ok(path) = parse_lit_into_expr_path(cx, &m.ident, &m.lit) {
                             let mut ser_path = path.clone();
                             ser_path
                                 .path
                                 .segments
                                 .push(Ident::new("serialize", Span::call_site()).into());
-                            serialize_with.set(ser_path);
+                            serialize_with.set(&m.ident, ser_path);
                             let mut de_path = path;
                             de_path
                                 .path
                                 .segments
                                 .push(Ident::new("deserialize", Span::call_site()).into());
-                            deserialize_with.set(de_path);
+                            deserialize_with.set(&m.ident, de_path);
                         }
                     }
 
                     // Parse `#[serde(bound = "T: SomeBound")]`
                     Meta(NameValue(ref m)) if m.ident == "bound" => {
                         if let Ok(where_predicates) =
                             parse_lit_into_where(cx, &m.ident, &m.ident, &m.lit)
                         {
-                            ser_bound.set(where_predicates.clone());
-                            de_bound.set(where_predicates);
+                            ser_bound.set(&m.ident, where_predicates.clone());
+                            de_bound.set(&m.ident, where_predicates);
                         }
                     }
 
                     // Parse `#[serde(bound(serialize = "...", deserialize = "..."))]`
                     Meta(List(ref m)) if m.ident == "bound" => {
                         if let Ok((ser, de)) = get_where_predicates(cx, &m.nested) {
-                            ser_bound.set_opt(ser);
-                            de_bound.set_opt(de);
+                            ser_bound.set_opt(&m.ident, ser);
+                            de_bound.set_opt(&m.ident, de);
                         }
                     }
 
                     // Parse `#[serde(borrow)]`
                     Meta(Word(ref word)) if word == "borrow" => {
-                        if let Ok(borrowable) = borrowable_lifetimes(cx, &ident, &field.ty) {
-                            borrowed_lifetimes.set(borrowable);
+                        if let Ok(borrowable) = borrowable_lifetimes(cx, &ident, field) {
+                            borrowed_lifetimes.set(word, borrowable);
                         }
                     }
 
                     // Parse `#[serde(borrow = "'a + 'b")]`
                     Meta(NameValue(ref m)) if m.ident == "borrow" => {
                         if let Ok(lifetimes) = parse_lit_into_lifetimes(cx, &m.ident, &m.lit) {
-                            if let Ok(borrowable) = borrowable_lifetimes(cx, &ident, &field.ty) {
+                            if let Ok(borrowable) = borrowable_lifetimes(cx, &ident, field) {
                                 for lifetime in &lifetimes {
                                     if !borrowable.contains(lifetime) {
-                                        cx.error(format!(
-                                            "field `{}` does not have lifetime {}",
-                                            ident, lifetime
-                                        ));
+                                        cx.error_spanned_by(
+                                            field,
+                                            format!(
+                                                "field `{}` does not have lifetime {}",
+                                                ident, lifetime
+                                            ),
+                                        );
                                     }
                                 }
-                                borrowed_lifetimes.set(lifetimes);
+                                borrowed_lifetimes.set(&m.ident, lifetimes);
                             }
                         }
                     }
 
                     // Parse `#[serde(getter = "...")]`
                     Meta(NameValue(ref m)) if m.ident == "getter" => {
                         if let Ok(path) = parse_lit_into_expr_path(cx, &m.ident, &m.lit) {
-                            getter.set(path);
+                            getter.set(&m.ident, path);
                         }
                     }
 
                     // Parse `#[serde(flatten)]`
                     Meta(Word(ref word)) if word == "flatten" => {
-                        flatten.set_true();
+                        flatten.set_true(word);
                     }
 
                     Meta(ref meta_item) => {
-                        cx.error(format!(
-                            "unknown serde field attribute `{}`",
-                            meta_item.name()
-                        ));
+                        cx.error_spanned_by(
+                            meta_item.name(),
+                            format!("unknown serde field attribute `{}`", meta_item.name()),
+                        );
                     }
 
-                    Literal(_) => {
-                        cx.error("unexpected literal in serde field attribute");
+                    Literal(ref lit) => {
+                        cx.error_spanned_by(lit, "unexpected literal in serde field attribute");
                     }
                 }
             }
         }
 
         // Is skip_deserializing, initialize the field to Default::default() unless a
         // different default is specified by `#[serde(default = "...")]` on
         // ourselves or our container (e.g. the struct we are in).
@@ -1053,27 +1422,18 @@ impl Field {
                 deserialize_with.set_if_none(expr);
             }
         } else if is_implicitly_borrowed(&field.ty) {
             // Types &str and &[u8] are always implicitly borrowed. No need for
             // a #[serde(borrow)].
             collect_lifetimes(&field.ty, &mut borrowed_lifetimes);
         }
 
-        let ser_name = ser_name.get();
-        let ser_renamed = ser_name.is_some();
-        let de_name = de_name.get();
-        let de_renamed = de_name.is_some();
         Field {
-            name: Name {
-                serialize: ser_name.unwrap_or_else(|| ident.clone()),
-                deserialize: de_name.unwrap_or(ident),
-            },
-            ser_renamed: ser_renamed,
-            de_renamed: de_renamed,
+            name: Name::from_attrs(ident, ser_name, de_name, Some(de_aliases)),
             skip_serializing: skip_serializing.get(),
             skip_deserializing: skip_deserializing.get(),
             skip_serializing_if: skip_serializing_if.get(),
             default: default.get().unwrap_or(Default::None),
             serialize_with: serialize_with.get(),
             deserialize_with: deserialize_with.get(),
             ser_bound: ser_bound.get(),
             de_bound: de_bound.get(),
@@ -1083,22 +1443,26 @@ impl Field {
             transparent: false,
         }
     }
 
     pub fn name(&self) -> &Name {
         &self.name
     }
 
-    pub fn rename_by_rule(&mut self, rule: &RenameRule) {
-        if !self.ser_renamed {
-            self.name.serialize = rule.apply_to_field(&self.name.serialize);
+    pub fn aliases(&self) -> Vec<String> {
+        self.name.deserialize_aliases()
+    }
+
+    pub fn rename_by_rules(&mut self, rules: &RenameAllRules) {
+        if !self.name.serialize_renamed {
+            self.name.serialize = rules.serialize.apply_to_field(&self.name.serialize);
         }
-        if !self.de_renamed {
-            self.name.deserialize = rule.apply_to_field(&self.name.deserialize);
+        if !self.name.deserialize_renamed {
+            self.name.deserialize = rules.deserialize.apply_to_field(&self.name.deserialize);
         }
     }
 
     pub fn skip_serializing(&self) -> bool {
         self.skip_serializing
     }
 
     pub fn skip_deserializing(&self) -> bool {
@@ -1147,70 +1511,83 @@ impl Field {
 
     pub fn mark_transparent(&mut self) {
         self.transparent = true;
     }
 }
 
 type SerAndDe<T> = (Option<T>, Option<T>);
 
-fn get_ser_and_de<'a, T, F>(
-    cx: &Ctxt,
+fn get_ser_and_de<'a, 'b, T, F>(
+    cx: &'b Ctxt,
     attr_name: &'static str,
     metas: &'a Punctuated<syn::NestedMeta, Token![,]>,
     f: F,
-) -> Result<SerAndDe<T>, ()>
+) -> Result<(VecAttr<'b, T>, VecAttr<'b, T>), ()>
 where
     T: 'a,
     F: Fn(&Ctxt, &Ident, &Ident, &'a syn::Lit) -> Result<T, ()>,
 {
-    let mut ser_meta = Attr::none(cx, attr_name);
-    let mut de_meta = Attr::none(cx, attr_name);
+    let mut ser_meta = VecAttr::none(cx, attr_name);
+    let mut de_meta = VecAttr::none(cx, attr_name);
     let attr_name = Ident::new(attr_name, Span::call_site());
 
     for meta in metas {
         match *meta {
             Meta(NameValue(ref meta)) if meta.ident == "serialize" => {
                 if let Ok(v) = f(cx, &attr_name, &meta.ident, &meta.lit) {
-                    ser_meta.set(v);
+                    ser_meta.insert(&meta.ident, v);
                 }
             }
 
             Meta(NameValue(ref meta)) if meta.ident == "deserialize" => {
                 if let Ok(v) = f(cx, &attr_name, &meta.ident, &meta.lit) {
-                    de_meta.set(v);
+                    de_meta.insert(&meta.ident, v);
                 }
             }
 
             _ => {
-                cx.error(format!(
-                    "malformed {0} attribute, expected `{0}(serialize = ..., \
-                     deserialize = ...)`",
-                    attr_name
-                ));
+                cx.error_spanned_by(
+                    meta,
+                    format!(
+                        "malformed {0} attribute, expected `{0}(serialize = ..., \
+                         deserialize = ...)`",
+                        attr_name
+                    ),
+                );
                 return Err(());
             }
         }
     }
 
-    Ok((ser_meta.get(), de_meta.get()))
+    Ok((ser_meta, de_meta))
 }
 
 fn get_renames<'a>(
     cx: &Ctxt,
     items: &'a Punctuated<syn::NestedMeta, Token![,]>,
 ) -> Result<SerAndDe<&'a syn::LitStr>, ()> {
-    get_ser_and_de(cx, "rename", items, get_lit_str)
+    let (ser, de) = try!(get_ser_and_de(cx, "rename", items, get_lit_str));
+    Ok((try!(ser.at_most_one()), try!(de.at_most_one())))
+}
+
+fn get_multiple_renames<'a>(
+    cx: &Ctxt,
+    items: &'a Punctuated<syn::NestedMeta, Token![,]>,
+) -> Result<(Option<&'a syn::LitStr>, Vec<&'a syn::LitStr>), ()> {
+    let (ser, de) = try!(get_ser_and_de(cx, "rename", items, get_lit_str));
+    Ok((try!(ser.at_most_one()), de.get()))
 }
 
 fn get_where_predicates(
     cx: &Ctxt,
     items: &Punctuated<syn::NestedMeta, Token![,]>,
 ) -> Result<SerAndDe<Vec<syn::WherePredicate>>, ()> {
-    get_ser_and_de(cx, "bound", items, parse_lit_into_where)
+    let (ser, de) = try!(get_ser_and_de(cx, "bound", items, parse_lit_into_where));
+    Ok((try!(ser.at_most_one()), try!(de.at_most_one())))
 }
 
 pub fn get_serde_meta_items(attr: &syn::Attribute) -> Option<Vec<syn::NestedMeta>> {
     if attr.path.segments.len() == 1 && attr.path.segments[0].ident == "serde" {
         match attr.interpret_meta() {
             Some(List(ref meta)) => Some(meta.nested.iter().cloned().collect()),
             _ => {
                 // TODO: produce an error
@@ -1226,38 +1603,43 @@ fn get_lit_str<'a>(
     cx: &Ctxt,
     attr_name: &Ident,
     meta_item_name: &Ident,
     lit: &'a syn::Lit,
 ) -> Result<&'a syn::LitStr, ()> {
     if let syn::Lit::Str(ref lit) = *lit {
         Ok(lit)
     } else {
-        cx.error(format!(
-            "expected serde {} attribute to be a string: `{} = \"...\"`",
-            attr_name, meta_item_name
-        ));
+        cx.error_spanned_by(
+            lit,
+            format!(
+                "expected serde {} attribute to be a string: `{} = \"...\"`",
+                attr_name, meta_item_name
+            ),
+        );
         Err(())
     }
 }
 
 fn parse_lit_into_path(cx: &Ctxt, attr_name: &Ident, lit: &syn::Lit) -> Result<syn::Path, ()> {
     let string = try!(get_lit_str(cx, attr_name, attr_name, lit));
-    parse_lit_str(string)
-        .map_err(|_| cx.error(format!("failed to parse path: {:?}", string.value())))
+    parse_lit_str(string).map_err(|_| {
+        cx.error_spanned_by(lit, format!("failed to parse path: {:?}", string.value()))
+    })
 }
 
 fn parse_lit_into_expr_path(
     cx: &Ctxt,
     attr_name: &Ident,
     lit: &syn::Lit,
 ) -> Result<syn::ExprPath, ()> {
     let string = try!(get_lit_str(cx, attr_name, attr_name, lit));
-    parse_lit_str(string)
-        .map_err(|_| cx.error(format!("failed to parse path: {:?}", string.value())))
+    parse_lit_str(string).map_err(|_| {
+        cx.error_spanned_by(lit, format!("failed to parse path: {:?}", string.value()))
+    })
 }
 
 fn parse_lit_into_where(
     cx: &Ctxt,
     attr_name: &Ident,
     meta_item_name: &Ident,
     lit: &syn::Lit,
 ) -> Result<Vec<syn::WherePredicate>, ()> {
@@ -1265,66 +1647,65 @@ fn parse_lit_into_where(
     if string.value().is_empty() {
         return Ok(Vec::new());
     }
 
     let where_string = syn::LitStr::new(&format!("where {}", string.value()), string.span());
 
     parse_lit_str::<syn::WhereClause>(&where_string)
         .map(|wh| wh.predicates.into_iter().collect())
-        .map_err(|err| cx.error(err))
+        .map_err(|err| cx.error_spanned_by(lit, err))
 }
 
 fn parse_lit_into_ty(cx: &Ctxt, attr_name: &Ident, lit: &syn::Lit) -> Result<syn::Type, ()> {
     let string = try!(get_lit_str(cx, attr_name, attr_name, lit));
 
     parse_lit_str(string).map_err(|_| {
-        cx.error(format!(
-            "failed to parse type: {} = {:?}",
-            attr_name,
-            string.value()
-        ))
+        cx.error_spanned_by(
+            lit,
+            format!("failed to parse type: {} = {:?}", attr_name, string.value()),
+        )
     })
 }
 
 // Parses a string literal like "'a + 'b + 'c" containing a nonempty list of
 // lifetimes separated by `+`.
 fn parse_lit_into_lifetimes(
     cx: &Ctxt,
     attr_name: &Ident,
     lit: &syn::Lit,
 ) -> Result<BTreeSet<syn::Lifetime>, ()> {
     let string = try!(get_lit_str(cx, attr_name, attr_name, lit));
     if string.value().is_empty() {
-        cx.error("at least one lifetime must be borrowed");
+        cx.error_spanned_by(lit, "at least one lifetime must be borrowed");
         return Err(());
     }
 
     struct BorrowedLifetimes(Punctuated<syn::Lifetime, Token![+]>);
 
     impl Parse for BorrowedLifetimes {
         fn parse(input: ParseStream) -> parse::Result<Self> {
             Punctuated::parse_separated_nonempty(input).map(BorrowedLifetimes)
         }
     }
 
     if let Ok(BorrowedLifetimes(lifetimes)) = parse_lit_str(string) {
         let mut set = BTreeSet::new();
         for lifetime in lifetimes {
             if !set.insert(lifetime.clone()) {
-                cx.error(format!("duplicate borrowed lifetime `{}`", lifetime));
+                cx.error_spanned_by(lit, format!("duplicate borrowed lifetime `{}`", lifetime));
             }
         }
         return Ok(set);
     }
 
-    cx.error(format!(
-        "failed to parse borrowed lifetimes: {:?}",
-        string.value()
-    ));
+    cx.error_spanned_by(
+        lit,
+        format!("failed to parse borrowed lifetimes: {:?}", string.value()),
+    );
     Err(())
 }
 
 fn is_implicitly_borrowed(ty: &syn::Type) -> bool {
     is_implicitly_borrowed_reference(ty) || is_option(ty, is_implicitly_borrowed_reference)
 }
 
 fn is_implicitly_borrowed_reference(ty: &syn::Type) -> bool {
@@ -1367,20 +1748,22 @@ fn is_cow(ty: &syn::Type, elem: fn(&syn:
         }
     };
     let args = match seg.arguments {
         syn::PathArguments::AngleBracketed(ref bracketed) => &bracketed.args,
         _ => {
             return false;
         }
     };
-    seg.ident == "Cow" && args.len() == 2 && match (&args[0], &args[1]) {
-        (&syn::GenericArgument::Lifetime(_), &syn::GenericArgument::Type(ref arg)) => elem(arg),
-        _ => false,
-    }
+    seg.ident == "Cow"
+        && args.len() == 2
+        && match (&args[0], &args[1]) {
+            (&syn::GenericArgument::Lifetime(_), &syn::GenericArgument::Type(ref arg)) => elem(arg),
+            _ => false,
+        }
 }
 
 fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
     let path = match *ty {
         syn::Type::Path(ref ty) => &ty.path,
         _ => {
             return false;
         }
@@ -1392,20 +1775,22 @@ fn is_option(ty: &syn::Type, elem: fn(&s
         }
     };
     let args = match seg.arguments {
         syn::PathArguments::AngleBracketed(ref bracketed) => &bracketed.args,
         _ => {
             return false;
         }
     };
-    seg.ident == "Option" && args.len() == 1 && match args[0] {
-        syn::GenericArgument::Type(ref arg) => elem(arg),
-        _ => false,
-    }
+    seg.ident == "Option"
+        && args.len() == 1
+        && match args[0] {
+            syn::GenericArgument::Type(ref arg) => elem(arg),
+            _ => false,
+        }
 }
 
 // Whether the type looks like it might be `&T` where elem="T". This can have
 // false negatives and false positives.
 //
 // False negative:
 //
 //     type Yarn = str;
@@ -1460,22 +1845,25 @@ fn is_primitive_path(path: &syn::Path, p
 // For example a type `S<'a, 'b>` could borrow `'a` and `'b`. On the other hand
 // a type `for<'a> fn(&'a str)` could not borrow `'a` from the Deserializer.
 //
 // This is used when there is an explicit or implicit `#[serde(borrow)]`
 // attribute on the field so there must be at least one borrowable lifetime.
 fn borrowable_lifetimes(
     cx: &Ctxt,
     name: &str,
-    ty: &syn::Type,
+    field: &syn::Field,
 ) -> Result<BTreeSet<syn::Lifetime>, ()> {
     let mut lifetimes = BTreeSet::new();
-    collect_lifetimes(ty, &mut lifetimes);
+    collect_lifetimes(&field.ty, &mut lifetimes);
     if lifetimes.is_empty() {
-        cx.error(format!("field `{}` has no lifetimes to borrow", name));
+        cx.error_spanned_by(
+            field,
+            format!("field `{}` has no lifetimes to borrow", name),
+        );
         Err(())
     } else {
         Ok(lifetimes)
     }
 }
 
 fn collect_lifetimes(ty: &syn::Type, out: &mut BTreeSet<syn::Lifetime>) {
     match *ty {
@@ -1487,19 +1875,21 @@ fn collect_lifetimes(ty: &syn::Type, out
         }
         syn::Type::Ptr(ref ty) => {
             collect_lifetimes(&ty.elem, out);
         }
         syn::Type::Reference(ref ty) => {
             out.extend(ty.lifetime.iter().cloned());
             collect_lifetimes(&ty.elem, out);
         }
-        syn::Type::Tuple(ref ty) => for elem in &ty.elems {
-            collect_lifetimes(elem, out);
-        },
+        syn::Type::Tuple(ref ty) => {
+            for elem in &ty.elems {
+                collect_lifetimes(elem, out);
+            }
+        }
         syn::Type::Path(ref ty) => {
             if let Some(ref qself) = ty.qself {
                 collect_lifetimes(&qself.ty, out);
             }
             for seg in &ty.path.segments {
                 if let syn::PathArguments::AngleBracketed(ref bracketed) = seg.arguments {
                     for arg in &bracketed.args {
                         match *arg {
--- a/third_party/rust/serde_derive/src/internals/case.rs
+++ b/third_party/rust/serde_derive/src/internals/case.rs
@@ -1,29 +1,21 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 //! Code to convert the Rust-styled field/variant (e.g. `my_field`, `MyType`) to the
 //! case of the source (e.g. `my-field`, `MY_FIELD`).
 
 // See https://users.rust-lang.org/t/psa-dealing-with-warning-unused-import-std-ascii-asciiext-in-today-s-nightly/13726
 #[allow(deprecated, unused_imports)]
 use std::ascii::AsciiExt;
 
 use std::str::FromStr;
 
 use self::RenameRule::*;
 
 /// The different possible ways to change case of fields in a struct, or variants in an enum.
-#[derive(PartialEq)]
+#[derive(Copy, Clone, PartialEq)]
 pub enum RenameRule {
     /// Don't apply a default rename rule.
     None,
     /// Rename direct children to "lowercase" style.
     LowerCase,
     /// Rename direct children to "UPPERCASE" style.
     UPPERCASE,
     /// Rename direct children to "PascalCase" style, as typically used for
--- a/third_party/rust/serde_derive/src/internals/check.rs
+++ b/third_party/rust/serde_derive/src/internals/check.rs
@@ -1,18 +1,10 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use internals::ast::{Container, Data, Field, Style};
-use internals::attr::{EnumTag, Identifier};
+use internals::attr::{Identifier, TagType};
 use internals::{Ctxt, Derive};
 use syn::{Member, Type};
 
 /// Cross-cutting checks that require looking at more than a single attrs
 /// object. Simpler checks should happen when parsing and building the attrs.
 pub fn check(cx: &Ctxt, cont: &mut Container, derive: Derive) {
     check_getter(cx, cont);
     check_flatten(cx, cont);
@@ -24,22 +16,26 @@ pub fn check(cx: &Ctxt, cont: &mut Conta
 }
 
 /// Getters are only allowed inside structs (not enums) with the `remote`
 /// attribute.
 fn check_getter(cx: &Ctxt, cont: &Container) {
     match cont.data {
         Data::Enum(_, _) => {
             if cont.data.has_getter() {
-                cx.error("#[serde(getter = \"...\")] is not allowed in an enum");
+                cx.error_spanned_by(
+                    cont.original,
+                    "#[serde(getter = \"...\")] is not allowed in an enum",
+                );
             }
         }
         Data::Struct(_, _) => {
             if cont.data.has_getter() && cont.attrs.remote().is_none() {
-                cx.error(
+                cx.error_spanned_by(
+                    cont.original,
                     "#[serde(getter = \"...\")] can only be used in structs \
                      that have #[serde(remote = \"...\")]",
                 );
             }
         }
     }
 }
 
@@ -62,39 +58,29 @@ fn check_flatten(cx: &Ctxt, cont: &Conta
 }
 
 fn check_flatten_field(cx: &Ctxt, style: Style, field: &Field) {
     if !field.attrs.flatten() {
         return;
     }
     match style {
         Style::Tuple => {
-            cx.error("#[serde(flatten)] cannot be used on tuple structs");
+            cx.error_spanned_by(
+                field.original,
+                "#[serde(flatten)] cannot be used on tuple structs",
+            );
         }
         Style::Newtype => {
-            cx.error("#[serde(flatten)] cannot be used on newtype structs");
+            cx.error_spanned_by(
+                field.original,
+                "#[serde(flatten)] cannot be used on newtype structs",
+            );
         }
         _ => {}
     }
-    if field.attrs.skip_serializing() {
-        cx.error(
-            "#[serde(flatten] can not be combined with \
-             #[serde(skip_serializing)]",
-        );
-    } else if field.attrs.skip_serializing_if().is_some() {
-        cx.error(
-            "#[serde(flatten] can not be combined with \
-             #[serde(skip_serializing_if = \"...\")]",
-        );
-    } else if field.attrs.skip_deserializing() {
-        cx.error(
-            "#[serde(flatten] can not be combined with \
-             #[serde(skip_deserializing)]",
-        );
-    }
 }
 
 /// The `other` attribute must be used at most once and it must be the last
 /// variant of an enum.
 ///
 /// Inside a `variant_identifier` all variants must be unit variants. Inside a
 /// `field_identifier` all but possibly one variant must be unit variants. The
 /// last variant may be a newtype variant which is an implicit "other" case.
@@ -110,55 +96,76 @@ fn check_identifier(cx: &Ctxt, cont: &Co
         match (
             variant.style,
             cont.attrs.identifier(),
             variant.attrs.other(),
             cont.attrs.tag(),
         ) {
             // The `other` attribute may not be used in a variant_identifier.
             (_, Identifier::Variant, true, _) => {
-                cx.error("#[serde(other)] may not be used on a variant_identifier");
+                cx.error_spanned_by(
+                    variant.original,
+                    "#[serde(other)] may not be used on a variant identifier",
+                );
             }
 
             // Variant with `other` attribute cannot appear in untagged enum
-            (_, Identifier::No, true, &EnumTag::None) => {
-                cx.error("#[serde(other)] cannot appear on untagged enum");
+            (_, Identifier::No, true, &TagType::None) => {
+                cx.error_spanned_by(
+                    variant.original,
+                    "#[serde(other)] cannot appear on untagged enum",
+                );
             }
 
             // Variant with `other` attribute must be the last one.
             (Style::Unit, Identifier::Field, true, _) | (Style::Unit, Identifier::No, true, _) => {
                 if i < variants.len() - 1 {
-                    cx.error("#[serde(other)] must be the last variant");
+                    cx.error_spanned_by(
+                        variant.original,
+                        "#[serde(other)] must be on the last variant",
+                    );
                 }
             }
 
             // Variant with `other` attribute must be a unit variant.
             (_, Identifier::Field, true, _) | (_, Identifier::No, true, _) => {
-                cx.error("#[serde(other)] must be on a unit variant");
+                cx.error_spanned_by(
+                    variant.original,
+                    "#[serde(other)] must be on a unit variant",
+                );
             }
 
             // Any sort of variant is allowed if this is not an identifier.
             (_, Identifier::No, false, _) => {}
 
             // Unit variant without `other` attribute is always fine.
             (Style::Unit, _, false, _) => {}
 
             // The last field is allowed to be a newtype catch-all.
             (Style::Newtype, Identifier::Field, false, _) => {
                 if i < variants.len() - 1 {
-                    cx.error(format!("`{}` must be the last variant", variant.ident));
+                    cx.error_spanned_by(
+                        variant.original,
+                        format!("`{}` must be the last variant", variant.ident),
+                    );
                 }
             }
 
             (_, Identifier::Field, false, _) => {
-                cx.error("field_identifier may only contain unit variants");
+                cx.error_spanned_by(
+                    variant.original,
+                    "#[serde(field_identifier)] may only contain unit variants",
+                );
             }
 
             (_, Identifier::Variant, false, _) => {
-                cx.error("variant_identifier may only contain unit variants");
+                cx.error_spanned_by(
+                    variant.original,
+                    "#[serde(variant_identifier)] may only contain unit variants",
+                );
             }
         }
     }
 }
 
 /// Skip-(de)serializing attributes are not allowed on variants marked
 /// (de)serialize_with.
 fn check_variant_skip_attrs(cx: &Ctxt, cont: &Container) {
@@ -167,62 +174,77 @@ fn check_variant_skip_attrs(cx: &Ctxt, c
         Data::Struct(_, _) => {
             return;
         }
     };
 
     for variant in variants.iter() {
         if variant.attrs.serialize_with().is_some() {
             if variant.attrs.skip_serializing() {
-                cx.error(format!(
-                    "variant `{}` cannot have both #[serde(serialize_with)] and \
-                     #[serde(skip_serializing)]",
-                    variant.ident
-                ));
+                cx.error_spanned_by(
+                    variant.original,
+                    format!(
+                        "variant `{}` cannot have both #[serde(serialize_with)] and \
+                         #[serde(skip_serializing)]",
+                        variant.ident
+                    ),
+                );
             }
 
             for field in &variant.fields {
                 let member = member_message(&field.member);
 
                 if field.attrs.skip_serializing() {
-                    cx.error(format!(
-                        "variant `{}` cannot have both #[serde(serialize_with)] and \
-                         a field {} marked with #[serde(skip_serializing)]",
-                        variant.ident, member
-                    ));
+                    cx.error_spanned_by(
+                        variant.original,
+                        format!(
+                            "variant `{}` cannot have both #[serde(serialize_with)] and \
+                             a field {} marked with #[serde(skip_serializing)]",
+                            variant.ident, member
+                        ),
+                    );
                 }
 
                 if field.attrs.skip_serializing_if().is_some() {
-                    cx.error(format!(
-                        "variant `{}` cannot have both #[serde(serialize_with)] and \
-                         a field {} marked with #[serde(skip_serializing_if)]",
-                        variant.ident, member
-                    ));
+                    cx.error_spanned_by(
+                        variant.original,
+                        format!(
+                            "variant `{}` cannot have both #[serde(serialize_with)] and \
+                             a field {} marked with #[serde(skip_serializing_if)]",
+                            variant.ident, member
+                        ),
+                    );
                 }
             }
         }
 
         if variant.attrs.deserialize_with().is_some() {
             if variant.attrs.skip_deserializing() {
-                cx.error(format!(
-                    "variant `{}` cannot have both #[serde(deserialize_with)] and \
-                     #[serde(skip_deserializing)]",
-                    variant.ident
-                ));
+                cx.error_spanned_by(
+                    variant.original,
+                    format!(
+                        "variant `{}` cannot have both #[serde(deserialize_with)] and \
+                         #[serde(skip_deserializing)]",
+                        variant.ident
+                    ),
+                );
             }
 
             for field in &variant.fields {
                 if field.attrs.skip_deserializing() {
                     let member = member_message(&field.member);
 
-                    cx.error(format!(
-                        "variant `{}` cannot have both #[serde(deserialize_with)] \
-                         and a field {} marked with #[serde(skip_deserializing)]",
-                        variant.ident, member
-                    ));
+                    cx.error_spanned_by(
+                        variant.original,
+                        format!(
+                            "variant `{}` cannot have both #[serde(deserialize_with)] \
+                             and a field {} marked with #[serde(skip_deserializing)]",
+                            variant.ident, member
+                        ),
+                    );
                 }
             }
         }
     }
 }
 
 /// The tag of an internally-tagged struct variant must not be
 /// the same as either one of its fields, as this would result in
@@ -230,123 +252,152 @@ fn check_variant_skip_attrs(cx: &Ctxt, c
 /// the to-be-deserialized input.
 fn check_internal_tag_field_name_conflict(cx: &Ctxt, cont: &Container) {
     let variants = match cont.data {
         Data::Enum(_, ref variants) => variants,
         Data::Struct(_, _) => return,
     };
 
     let tag = match *cont.attrs.tag() {
-        EnumTag::Internal { ref tag } => tag.as_str(),
-        EnumTag::External | EnumTag::Adjacent { .. } | EnumTag::None => return,
+        TagType::Internal { ref tag } => tag.as_str(),
+        TagType::External | TagType::Adjacent { .. } | TagType::None => return,
     };
 
     let diagnose_conflict = || {
-        let message = format!("variant field name `{}` conflicts with internal tag", tag);
-        cx.error(message);
+        cx.error_spanned_by(
+            cont.original,
+            format!("variant field name `{}` conflicts with internal tag", tag),
+        )
     };
 
     for variant in variants {
         match variant.style {
             Style::Struct => {
                 for field in &variant.fields {
                     let check_ser = !field.attrs.skip_serializing();
                     let check_de = !field.attrs.skip_deserializing();
                     let name = field.attrs.name();
                     let ser_name = name.serialize_name();
-                    let de_name = name.deserialize_name();
 
-                    if check_ser && ser_name == tag || check_de && de_name == tag {
+                    if check_ser && ser_name == tag {
                         diagnose_conflict();
                         return;
                     }
+
+                    for de_name in field.attrs.aliases() {
+                        if check_de && de_name == tag {
+                            diagnose_conflict();
+                            return;
+                        }
+                    }
                 }
             }
             Style::Unit | Style::Newtype | Style::Tuple => {}
         }
     }
 }
 
 /// In the case of adjacently-tagged enums, the type and the
 /// contents tag must differ, for the same reason.
 fn check_adjacent_tag_conflict(cx: &Ctxt, cont: &Container) {
     let (type_tag, content_tag) = match *cont.attrs.tag() {
-        EnumTag::Adjacent {
+        TagType::Adjacent {
             ref tag,
             ref content,
         } => (tag, content),
-        EnumTag::Internal { .. } | EnumTag::External | EnumTag::None => return,
+        TagType::Internal { .. } | TagType::External | TagType::None => return,
     };
 
     if type_tag == content_tag {
-        let message = format!(
-            "enum tags `{}` for type and content conflict with each other",
-            type_tag
+        cx.error_spanned_by(
+            cont.original,
+            format!(
+                "enum tags `{}` for type and content conflict with each other",
+                type_tag
+            ),
         );
-        cx.error(message);
     }
 }
 
 /// Enums and unit structs cannot be transparent.
 fn check_transparent(cx: &Ctxt, cont: &mut Container, derive: Derive) {
     if !cont.attrs.transparent() {
         return;
     }
 
     if cont.attrs.type_from().is_some() {
-        cx.error("#[serde(transparent)] is not allowed with #[serde(from = \"...\")]");
+        cx.error_spanned_by(
+            cont.original,
+            "#[serde(transparent)] is not allowed with #[serde(from = \"...\")]",
+        );
     }
 
     if cont.attrs.type_into().is_some() {
-        cx.error("#[serde(transparent)] is not allowed with #[serde(into = \"...\")]");
+        cx.error_spanned_by(
+            cont.original,
+            "#[serde(transparent)] is not allowed with #[serde(into = \"...\")]",
+        );
     }
 
     let fields = match cont.data {
         Data::Enum(_, _) => {
-            cx.error("#[serde(transparent)] is not allowed on an enum");
+            cx.error_spanned_by(
+                cont.original,
+                "#[serde(transparent)] is not allowed on an enum",
+            );
             return;
         }
         Data::Struct(Style::Unit, _) => {
-            cx.error("#[serde(transparent)] is not allowed on a unit struct");
+            cx.error_spanned_by(
+                cont.original,
+                "#[serde(transparent)] is not allowed on a unit struct",
+            );
             return;
         }
         Data::Struct(_, ref mut fields) => fields,
     };
 
     let mut transparent_field = None;
 
     for field in fields {
         if allow_transparent(field, derive) {
             if transparent_field.is_some() {
-                cx.error(
+                cx.error_spanned_by(
+                    cont.original,
                     "#[serde(transparent)] requires struct to have at most one transparent field",
                 );
                 return;
             }
             transparent_field = Some(field);
         }
     }
 
     match transparent_field {
         Some(transparent_field) => transparent_field.attrs.mark_transparent(),
         None => match derive {
             Derive::Serialize => {
-                cx.error("#[serde(transparent)] requires at least one field that is not skipped");
+                cx.error_spanned_by(
+                    cont.original,
+                    "#[serde(transparent)] requires at least one field that is not skipped",
+                );
             }
             Derive::Deserialize => {
-                cx.error("#[serde(transparent)] requires at least one field that is neither skipped nor has a default");
+                cx.error_spanned_by(
+                    cont.original,
+                    "#[serde(transparent)] requires at least one field that is neither skipped nor has a default",
+                );
             }
         },
     }
 }
 
 fn member_message(member: &Member) -> String {
     match *member {
         Member::Named(ref ident) => format!("`{}`", ident),
-        Member::Unnamed(ref i) => i.index.to_string(),
+        Member::Unnamed(ref i) => format!("#{}", i.index),
     }
 }
 
 fn allow_transparent(field: &Field, derive: Derive) -> bool {
     if let Type::Path(ref ty) = *field.ty {
         if let Some(seg) = ty.path.segments.last() {
             if seg.into_value().ident == "PhantomData" {
                 return false;
--- a/third_party/rust/serde_derive/src/internals/ctxt.rs
+++ b/third_party/rust/serde_derive/src/internals/ctxt.rs
@@ -1,65 +1,54 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
+use quote::ToTokens;
 use std::cell::RefCell;
 use std::fmt::Display;
 use std::thread;
+use syn;
 
 /// A type to collect errors together and format them.
 ///
 /// Dropping this object will cause a panic. It must be consumed using `check`.
 ///
 /// References can be shared since this type uses run-time exclusive mut checking.
 #[derive(Default)]
 pub struct Ctxt {
     // The contents will be set to `None` during checking. This is so that checking can be
     // enforced.
-    errors: RefCell<Option<Vec<String>>>,
+    errors: RefCell<Option<Vec<syn::Error>>>,
 }
 
 impl Ctxt {
     /// Create a new context object.
     ///
     /// This object contains no errors, but will still trigger a panic if it is not `check`ed.
     pub fn new() -> Self {
         Ctxt {
             errors: RefCell::new(Some(Vec::new())),
         }
     }
 
-    /// Add an error to the context object.
-    pub fn error<T: Display>(&self, msg: T) {
+    /// Add an error to the context object with a tokenenizable object.
+    ///
+    /// The object is used for spanning in error messages.
+    pub fn error_spanned_by<A: ToTokens, T: Display>(&self, obj: A, msg: T) {
         self.errors
             .borrow_mut()
             .as_mut()
             .unwrap()
-            .push(msg.to_string());
+            // Curb monomorphization from generating too many identical methods.
+            .push(syn::Error::new_spanned(obj.into_token_stream(), msg));
     }
 
     /// Consume this object, producing a formatted error string if there are errors.
-    pub fn check(self) -> Result<(), String> {
-        let mut errors = self.errors.borrow_mut().take().unwrap();
+    pub fn check(self) -> Result<(), Vec<syn::Error>> {
+        let errors = self.errors.borrow_mut().take().unwrap();
         match errors.len() {
             0 => Ok(()),
-            1 => Err(errors.pop().unwrap()),
-            n => {
-                let mut msg = format!("{} errors:", n);
-                for err in errors {
-                    msg.push_str("\n\t# ");
-                    msg.push_str(&err);
-                }
-                Err(msg)
-            }
+            _ => Err(errors),
         }
     }
 }
 
 impl Drop for Ctxt {
     fn drop(&mut self) {
         if !thread::panicking() && self.errors.borrow().is_some() {
             panic!("forgot to check for errors");
--- a/third_party/rust/serde_derive/src/internals/mod.rs
+++ b/third_party/rust/serde_derive/src/internals/mod.rs
@@ -1,16 +1,8 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 pub mod ast;
 pub mod attr;
 
 mod ctxt;
 pub use self::ctxt::Ctxt;
 
 mod case;
 mod check;
--- a/third_party/rust/serde_derive/src/lib.rs
+++ b/third_party/rust/serde_derive/src/lib.rs
@@ -1,61 +1,53 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 //! This crate provides Serde's two derive macros.
 //!
-//! ```rust
-//! # #[macro_use]
-//! # extern crate serde_derive;
+//! ```edition2018
+//! # use serde_derive::{Serialize, Deserialize};
 //! #
 //! #[derive(Serialize, Deserialize)]
 //! # struct S;
 //! #
 //! # fn main() {}
 //! ```
 //!
 //! Please refer to [https://serde.rs/derive.html] for how to set this up.
 //!
 //! [https://serde.rs/derive.html]: https://serde.rs/derive.html
 
-#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.80")]
+#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.88")]
 #![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
 #![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
-// Whitelisted clippy lints
+// Ignored clippy lints
 #![cfg_attr(
     feature = "cargo-clippy",
     allow(
         cyclomatic_complexity,
         enum_variant_names,
         needless_pass_by_value,
         redundant_field_names,
         too_many_arguments,
+        trivially_copy_pass_by_ref,
         used_underscore_binding,
     )
 )]
-// Whitelisted clippy_pedantic lints
+// Ignored clippy_pedantic lints
 #![cfg_attr(
     feature = "cargo-clippy",
     allow(
         cast_possible_truncation,
         doc_markdown,
         enum_glob_use,
         filter_map,
         indexing_slicing,
         items_after_statements,
         match_same_arms,
+        module_name_repetitions,
         similar_names,
         single_match_else,
-        stutter,
         unseparated_literal_suffix,
         use_self,
     )
 )]
 // The `quote!` macro requires deep recursion.
 #![recursion_limit = "512"]
 
 #[macro_use]
@@ -72,33 +64,33 @@ use proc_macro::TokenStream;
 use syn::DeriveInput;
 
 #[macro_use]
 mod bound;
 #[macro_use]
 mod fragment;
 
 mod de;
+mod dummy;
 mod pretend;
 mod ser;
 mod try;
 
 #[proc_macro_derive(Serialize, attributes(serde))]
 pub fn derive_serialize(input: TokenStream) -> TokenStream {
     let input = parse_macro_input!(input as DeriveInput);
     ser::expand_derive_serialize(&input)
-        .unwrap_or_else(compile_error)
+        .unwrap_or_else(to_compile_errors)
         .into()
 }
 
 #[proc_macro_derive(Deserialize, attributes(serde))]
 pub fn derive_deserialize(input: TokenStream) -> TokenStream {
     let input = parse_macro_input!(input as DeriveInput);
     de::expand_derive_deserialize(&input)
-        .unwrap_or_else(compile_error)
+        .unwrap_or_else(to_compile_errors)
         .into()
 }
 
-fn compile_error(message: String) -> proc_macro2::TokenStream {
-    quote! {
-        compile_error!(#message);
-    }
+fn to_compile_errors(errors: Vec<syn::Error>) -> proc_macro2::TokenStream {
+    let compile_errors = errors.iter().map(syn::Error::to_compile_error);
+    quote!(#(#compile_errors)*)
 }
--- a/third_party/rust/serde_derive/src/pretend.rs
+++ b/third_party/rust/serde_derive/src/pretend.rs
@@ -57,17 +57,18 @@ fn pretend_fields_used(cont: &Container)
             .iter()
             .filter_map(|variant| match variant.style {
                 Style::Struct => {
                     let variant_ident = &variant.ident;
                     let pat = struct_pattern(&variant.fields);
                     Some(quote!(#type_ident::#variant_ident #pat))
                 }
                 _ => None,
-            }).collect::<Vec<_>>(),
+            })
+            .collect::<Vec<_>>(),
         Data::Struct(Style::Struct, ref fields) => {
             let pat = struct_pattern(fields);
             vec![quote!(#type_ident #pat)]
         }
         Data::Struct(_, _) => {
             return quote!();
         }
     };
--- a/third_party/rust/serde_derive/src/ser.rs
+++ b/third_party/rust/serde_derive/src/ser.rs
@@ -1,41 +1,31 @@
-// Copyright 2017 Serde Developers
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use proc_macro2::{Span, TokenStream};
 use syn::spanned::Spanned;
 use syn::{self, Ident, Index, Member};
 
 use bound;
+use dummy;
 use fragment::{Fragment, Match, Stmts};
 use internals::ast::{Container, Data, Field, Style, Variant};
 use internals::{attr, Ctxt, Derive};
 use pretend;
-use try;
 
-pub fn expand_derive_serialize(input: &syn::DeriveInput) -> Result<TokenStream, String> {
+pub fn expand_derive_serialize(input: &syn::DeriveInput) -> Result<TokenStream, Vec<syn::Error>> {
     let ctxt = Ctxt::new();
-    let cont = Container::from_ast(&ctxt, input, Derive::Serialize);
+    let cont = match Container::from_ast(&ctxt, input, Derive::Serialize) {
+        Some(cont) => cont,
+        None => return Err(ctxt.check().unwrap_err()),
+    };
     precondition(&ctxt, &cont);
     try!(ctxt.check());
 
     let ident = &cont.ident;
     let params = Parameters::new(&cont);
     let (impl_generics, ty_generics, where_clause) = params.generics.split_for_impl();
-    let suffix = ident.to_string().trim_left_matches("r#").to_owned();
-    let dummy_const = Ident::new(
-        &format!("_IMPL_SERIALIZE_FOR_{}", suffix),
-        Span::call_site(),
-    );
     let body = Stmts(serialize_body(&cont, &params));
 
     let impl_block = if let Some(remote) = cont.attrs.remote() {
         let vis = &input.vis;
         let used = pretend::pretend_used(&cont);
         quote! {
             impl #impl_generics #ident #ty_generics #where_clause {
                 #vis fn serialize<__S>(__self: &#remote #ty_generics, __serializer: __S) -> _serde::export::Result<__S::Ok, __S::Error>
@@ -56,39 +46,27 @@ pub fn expand_derive_serialize(input: &s
                     __S: _serde::Serializer,
                 {
                     #body
                 }
             }
         }
     };
 
-    let try_replacement = try::replacement();
-    let generated = quote! {
-        #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
-        const #dummy_const: () = {
-            #[allow(unknown_lints)]
-            #[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
-            #[allow(rust_2018_idioms)]
-            extern crate serde as _serde;
-            #try_replacement
-            #impl_block
-        };
-    };
-    Ok(generated)
+    Ok(dummy::wrap_in_const("SERIALIZE", ident, impl_block))
 }
 
 fn precondition(cx: &Ctxt, cont: &Container) {
     match cont.attrs.identifier() {
         attr::Identifier::No => {}
         attr::Identifier::Field => {
-            cx.error("field identifiers cannot be serialized");
+            cx.error_spanned_by(cont.original, "field identifiers cannot be serialized");
         }
         attr::Identifier::Variant => {
-            cx.error("variant identifiers cannot be serialized");
+            cx.error_spanned_by(cont.original, "variant identifiers cannot be serialized");
         }
     }
 }
 
 struct Parameters {
     /// Variable holding the value being serialized. Either `self` for local
     /// types or `__self` for remote types.
     self_var: Ident,
@@ -203,17 +181,20 @@ fn serialize_transparent(cont: &Containe
     };
 
     let self_var = &params.self_var;
     let transparent_field = fields.iter().find(|f| f.attrs.transparent()).unwrap();
     let member = &transparent_field.member;
 
     let path = match transparent_field.attrs.serialize_with() {
         Some(path) => quote!(#path),
-        None => quote!(_serde::Serialize::serialize),
+        None => {
+            let span = transparent_field.original.span();
+            quote_spanned!(span=> _serde::Serialize::serialize)
+        }
     };
 
     quote_block! {
         #path(&#self_var.#member, __serializer)
     }
 }
 
 fn serialize_into(params: &Parameters, type_into: &syn::Type) -> Fragment {
@@ -283,17 +264,18 @@ fn serialize_tuple_struct(
             Some(path) => {
                 let index = syn::Index {
                     index: i as u32,
                     span: Span::call_site(),
                 };
                 let field_expr = get_member(params, field, &Member::Unnamed(index));
                 quote!(if #path(#field_expr) { 0 } else { 1 })
             }
-        }).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
+        })
+        .fold(quote!(0), |sum, expr| quote!(#sum + #expr));
 
     quote_block! {
         let #let_mut __serde_state = try!(_serde::Serializer::serialize_tuple_struct(__serializer, #type_name, #len));
         #(#serialize_stmts)*
         _serde::ser::SerializeTupleStruct::end(__serde_state)
     }
 }
 
@@ -302,96 +284,126 @@ fn serialize_struct(params: &Parameters,
 
     if cattrs.has_flatten() {
         serialize_struct_as_map(params, fields, cattrs)
     } else {
         serialize_struct_as_struct(params, fields, cattrs)
     }
 }
 
+fn serialize_struct_tag_field(cattrs: &attr::Container, struct_trait: &StructTrait) -> TokenStream {
+    match *cattrs.tag() {
+        attr::TagType::Internal { ref tag } => {
+            let type_name = cattrs.name().serialize_name();
+            let func = struct_trait.serialize_field(Span::call_site());
+            quote! {
+                try!(#func(&mut __serde_state, #tag, #type_name));
+            }
+        }
+        _ => quote! {},
+    }
+}
+
 fn serialize_struct_as_struct(
     params: &Parameters,
     fields: &[Field],
     cattrs: &attr::Container,
 ) -> Fragment {
     let serialize_fields =
         serialize_struct_visitor(fields, params, false, &StructTrait::SerializeStruct);
 
     let type_name = cattrs.name().serialize_name();
 
+    let tag_field = serialize_struct_tag_field(cattrs, &StructTrait::SerializeStruct);
+    let tag_field_exists = !tag_field.is_empty();
+
     let mut serialized_fields = fields
         .iter()
         .filter(|&field| !field.attrs.skip_serializing())
         .peekable();
 
-    let let_mut = mut_if(serialized_fields.peek().is_some());
+    let let_mut = mut_if(serialized_fields.peek().is_some() || tag_field_exists);
 
     let len = serialized_fields
         .map(|field| match field.attrs.skip_serializing_if() {
             None => quote!(1),
             Some(path) => {
                 let field_expr = get_member(params, field, &field.member);
                 quote!(if #path(#field_expr) { 0 } else { 1 })
             }
-        }).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
+        })
+        .fold(
+            quote!(#tag_field_exists as usize),
+            |sum, expr| quote!(#sum + #expr),
+        );
 
     quote_block! {
         let #let_mut __serde_state = try!(_serde::Serializer::serialize_struct(__serializer, #type_name, #len));
+        #tag_field
         #(#serialize_fields)*
         _serde::ser::SerializeStruct::end(__serde_state)
     }
 }
 
 fn serialize_struct_as_map(
     params: &Parameters,
     fields: &[Field],
     cattrs: &attr::Container,
 ) -> Fragment {
     let serialize_fields =
         serialize_struct_visitor(fields, params, false, &StructTrait::SerializeMap);
 
+    let tag_field = serialize_struct_tag_field(cattrs, &StructTrait::SerializeMap);
+    let tag_field_exists = !tag_field.is_empty();
+
     let mut serialized_fields = fields
         .iter()
         .filter(|&field| !field.attrs.skip_serializing())
         .peekable();
 
-    let let_mut = mut_if(serialized_fields.peek().is_some());
+    let let_mut = mut_if(serialized_fields.peek().is_some() || tag_field_exists);
 
     let len = if cattrs.has_flatten() {
         quote!(_serde::export::None)
     } else {
         let len = serialized_fields
             .map(|field| match field.attrs.skip_serializing_if() {
                 None => quote!(1),
                 Some(path) => {
                     let field_expr = get_member(params, field, &field.member);
                     quote!(if #path(#field_expr) { 0 } else { 1 })
                 }
-            }).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
+            })
+            .fold(
+                quote!(#tag_field_exists as usize),
+                |sum, expr| quote!(#sum + #expr),
+            );
         quote!(_serde::export::Some(#len))
     };
 
     quote_block! {
         let #let_mut __serde_state = try!(_serde::Serializer::serialize_map(__serializer, #len));
+        #tag_field
         #(#serialize_fields)*
         _serde::ser::SerializeMap::end(__serde_state)
     }
 }
 
 fn serialize_enum(params: &Parameters, variants: &[Variant], cattrs: &attr::Container) -> Fragment {
     assert!(variants.len() as u64 <= u64::from(u32::max_value()));
 
     let self_var = &params.self_var;
 
     let arms: Vec<_> = variants
         .iter()
         .enumerate()
         .map(|(variant_index, variant)| {
             serialize_variant(params, variant, variant_index as u32, cattrs)
-        }).collect();
+        })
+        .collect();
 
     quote_expr! {
         match *#self_var {
             #(#arms)*
         }
     }
 }
 
@@ -445,27 +457,27 @@ fn serialize_variant(
                 let members = variant.fields.iter().map(|f| &f.member);
                 quote! {
                     #this::#variant_ident { #(ref #members),* }
                 }
             }
         };
 
         let body = Match(match *cattrs.tag() {
-            attr::EnumTag::External => {
+            attr::TagType::External => {
                 serialize_externally_tagged_variant(params, variant, variant_index, cattrs)
             }
-            attr::EnumTag::Internal { ref tag } => {
+            attr::TagType::Internal { ref tag } => {
                 serialize_internally_tagged_variant(params, variant, cattrs, tag)
             }
-            attr::EnumTag::Adjacent {
+            attr::TagType::Adjacent {
                 ref tag,
                 ref content,
             } => serialize_adjacently_tagged_variant(params, variant, cattrs, tag, content),
-            attr::EnumTag::None => serialize_untagged_variant(params, variant, cattrs),
+            attr::TagType::None => serialize_untagged_variant(params, variant, cattrs),
         });
 
         quote! {
             #case => #body
         }
     }
 }
 
@@ -504,18 +516,20 @@ fn serialize_externally_tagged_variant(
         }
         Style::Newtype => {
             let field = &variant.fields[0];
             let mut field_expr = quote!(__field0);
             if let Some(path) = field.attrs.serialize_with() {
                 field_expr = wrap_serialize_field_with(params, field.ty, path, &field_expr);
             }
 
+            let span = field.original.span();
+            let func = quote_spanned!(span=> _serde::Serializer::serialize_newtype_variant);
             quote_expr! {
-                _serde::Serializer::serialize_newtype_variant(
+                #func(
                     __serializer,
                     #type_name,
                     #variant_index,
                     #variant_name,
                     #field_expr,
                 )
             }
         }
@@ -578,18 +592,20 @@ fn serialize_internally_tagged_variant(
         }
         Style::Newtype => {
             let field = &variant.fields[0];
             let mut field_expr = quote!(__field0);
             if let Some(path) = field.attrs.serialize_with() {
                 field_expr = wrap_serialize_field_with(params, field.ty, path, &field_expr);
             }
 
+            let span = field.original.span();
+            let func = quote_spanned!(span=> _serde::private::ser::serialize_tagged_newtype);
             quote_expr! {
-                _serde::private::ser::serialize_tagged_newtype(
+                #func(
                     __serializer,
                     #enum_ident_str,
                     #variant_ident_str,
                     #tag,
                     #variant_name,
                     #field_expr,
                 )
             }
@@ -636,22 +652,24 @@ fn serialize_adjacently_tagged_variant(
             }
             Style::Newtype => {
                 let field = &variant.fields[0];
                 let mut field_expr = quote!(__field0);
                 if let Some(path) = field.attrs.serialize_with() {
                     field_expr = wrap_serialize_field_with(params, field.ty, path, &field_expr);
                 }
 
+                let span = field.original.span();
+                let func = quote_spanned!(span=> _serde::ser::SerializeStruct::serialize_field);
                 return quote_block! {
                     let mut __struct = try!(_serde::Serializer::serialize_struct(
                         __serializer, #type_name, 2));
                     try!(_serde::ser::SerializeStruct::serialize_field(
                         &mut __struct, #tag, #variant_name));
-                    try!(_serde::ser::SerializeStruct::serialize_field(
+                    try!(#func(
                         &mut __struct, #content, #field_expr));
                     _serde::ser::SerializeStruct::end(__struct)
                 };
             }
             Style::Tuple => {
                 serialize_tuple_variant(TupleVariant::Untagged, params, &variant.fields)
             }
             Style::Struct => serialize_struct_variant(
@@ -737,18 +755,20 @@ fn serialize_untagged_variant(
         }
         Style::Newtype => {
             let field = &variant.fields[0];
             let mut field_expr = quote!(__field0);
             if let Some(path) = field.attrs.serialize_with() {
                 field_expr = wrap_serialize_field_with(params, field.ty, path, &field_expr);
             }
 
+            let span = field.original.span();
+            let func = quote_spanned!(span=> _serde::Serialize::serialize);
             quote_expr! {
-                _serde::Serialize::serialize(#field_expr, __serializer)
+                #func(#field_expr, __serializer)
             }
         }
         Style::Tuple => serialize_tuple_variant(TupleVariant::Untagged, params, &variant.fields),
         Style::Struct => {
             let type_name = cattrs.name().serialize_name();
             serialize_struct_variant(StructVariant::Untagged, params, &variant.fields, &type_name)
         }
     }
@@ -785,17 +805,18 @@ fn serialize_tuple_variant(
 
     let len = serialized_fields
         .map(|(i, field)| match field.attrs.skip_serializing_if() {
             None => quote!(1),
             Some(path) => {
                 let field_expr = Ident::new(&format!("__field{}", i), Span::call_site());
                 quote!(if #path(#field_expr) { 0 } else { 1 })
             }
-        }).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
+        })
+        .fold(quote!(0), |sum, expr| quote!(#sum + #expr));
 
     match context {
         TupleVariant::ExternallyTagged {
             type_name,
             variant_index,
             variant_name,
         } => {
             quote_block! {
@@ -862,17 +883,18 @@ fn serialize_struct_variant<'a>(
     let len = serialized_fields
         .map(|field| {
             let member = &field.member;
 
             match field.attrs.skip_serializing_if() {
                 Some(path) => quote!(if #path(#member) { 0 } else { 1 }),
                 None => quote!(1),
             }
-        }).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
+        })
+        .fold(quote!(0), |sum, expr| quote!(#sum + #expr));
 
     match context {
         StructVariant::ExternallyTagged {
             variant_index,
             variant_name,
         } => {
             quote_block! {
                 let #let_mut __serde_state = try!(_serde::Serializer::serialize_struct_variant(
@@ -1041,17 +1063,18 @@ fn serialize_tuple_struct_visitor(
             let ser = quote! {
                 try!(#func(&mut __serde_state, #field_expr));
             };
 
             match skip {
                 None => ser,
                 Some(skip) => quote!(if !#skip { #ser }),
             }
-        }).collect()
+        })
+        .collect()
 }
 
 fn serialize_struct_visitor(
     fields: &[Field],
     params: &Parameters,
     is_enum: bool,
     struct_trait: &StructTrait,
 ) -> Vec<TokenStream> {
@@ -1075,18 +1098,19 @@ fn serialize_struct_visitor(
                 .map(|path| quote!(#path(#field_expr)));
 
             if let Some(path) = field.attrs.serialize_with() {
                 field_expr = wrap_serialize_field_with(params, field.ty, path, &field_expr);
             }
 
             let span = field.original.span();
             let ser = if field.attrs.flatten() {
+                let func = quote_spanned!(span=> _serde::Serialize::serialize);
                 quote! {
-                    try!(_serde::Serialize::serialize(&#field_expr, _serde::private::ser::FlatMapSerializer(&mut __serde_state)));
+                    try!(#func(&#field_expr, _serde::private::ser::FlatMapSerializer(&mut __serde_state)));
                 }
             } else {
                 let func = struct_trait.serialize_field(span);
                 quote! {
                     try!(#func(&mut __serde_state, #key_expr, #field_expr));
                 }
             };
 
@@ -1135,17 +1159,18 @@ fn wrap_serialize_variant_with(
         .map(|field| {
             let id = match field.member {
                 Member::Named(ref ident) => ident.clone(),
                 Member::Unnamed(ref member) => {
                     Ident::new(&format!("__field{}", member.index), Span::call_site())
                 }
             };
             quote!(#id)
-        }).collect();
+        })
+        .collect();
     wrap_serialize_with(
         params,
         serialize_with,
         field_tys.as_slice(),
         field_exprs.as_slice(),
     )
 }