Bug 1408461 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel
☠☠ backed out by 34685b6d5efa ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 18 Oct 2017 09:38:43 -0400
changeset 440149 c654a712755b1576912bd1e71a58420812aec3c6
parent 440148 dd8eb671df757dddd4b0975a75394bc86408b255
child 440150 cd0e3778a5ba542575a2eaee5cb6dda98e7dfc0f
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1408461
milestone58.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 1408461 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel MozReview-Commit-ID: L5AVB95yUtP
third_party/rust/bitflags-0.9.1/.cargo-checksum.json
third_party/rust/bitflags-0.9.1/.cargo-ok
third_party/rust/bitflags-0.9.1/.travis.yml
third_party/rust/bitflags-0.9.1/Cargo.toml
third_party/rust/bitflags-0.9.1/LICENSE-APACHE
third_party/rust/bitflags-0.9.1/LICENSE-MIT
third_party/rust/bitflags-0.9.1/README.md
third_party/rust/bitflags-0.9.1/src/example_generated.rs
third_party/rust/bitflags-0.9.1/src/lib.rs
third_party/rust/bitflags-0.9.1/tests/conflicting_trait_impls.rs
third_party/rust/bitflags-0.9.1/tests/external.rs
third_party/rust/bitflags-0.9.1/tests/external_no_std.rs
third_party/rust/bitflags-0.9.1/tests/i128_bitflags.rs
third_party/rust/bitflags/.cargo-checksum.json
third_party/rust/bitflags/.travis.yml
third_party/rust/bitflags/Cargo.toml
third_party/rust/bitflags/README.md
third_party/rust/bitflags/src/example_generated.rs
third_party/rust/bitflags/src/lib.rs
third_party/rust/bitflags/tests/conflicting_trait_impls.rs
third_party/rust/bitflags/tests/external.rs
third_party/rust/bitflags/tests/external_no_std.rs
third_party/rust/bitflags/tests/i128_bitflags.rs
toolkit/library/gtest/rust/Cargo.lock
toolkit/library/rust/Cargo.lock
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitflags-0.9.1/.cargo-checksum.json
@@ -0,0 +1,1 @@
+{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"e7a77c1800f9852e4c9a2acb9df041773ecd0bc005bd1b0657ae0512c67100ac","Cargo.toml":"f35826eec96c765ae8aee4f8a66c6b3cb0d918b49935baf05bae79b6df8e1077","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"602c63819e332e93c85dc8426db4855f18fe0fabbd642c5b2303ed83f1ba926f","src/example_generated.rs":"161b69d92cf6e5fa4b5dc30f06031f3a0fb590b44be2bcf0f31cb8be4fab36fa","src/lib.rs":"56e86a16356d9322fa6b4e9b910041e2e7558c08b52ffbdacc647eba36b37abc","tests/conflicting_trait_impls.rs":"79993ea67ef09a5f99fddd69d8b73b1c137e41d0e8f8535f03865d6766dcc498","tests/external.rs":"15f7901698e286197666ccd309ad1debd3c35eaff680ca090368494e8b06ccf2","tests/external_no_std.rs":"c3556fd19dd91d1b093eb6a65d09a9d0985544f0377ba3d30c0e265c956f7237","tests/i128_bitflags.rs":"c955ef2c9fd385848195bb416e660e946ccbe59acc87862ef2646eb082d82e3f"},"package":"4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"}
\ No newline at end of file
new file mode 100644
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitflags-0.9.1/.travis.yml
@@ -0,0 +1,29 @@
+os:
+  - linux
+  - osx
+language: rust
+rust:
+  - stable
+  - beta
+  - nightly
+sudo: false
+before_script:
+  - pip install -v 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
+  - if [[ -e ~/Library/Python/2.7/bin ]]; then export PATH=~/Library/Python/2.7/bin:$PATH; fi
+script:
+  - cargo build --verbose
+  - cargo test --verbose
+  - travis-cargo --only nightly test
+  - cargo doc --no-deps
+after_success:
+  - travis-cargo --only nightly doc-upload
+env:
+  global:
+    - TRAVIS_CARGO_NIGHTLY_FEATURE=unstable_testing
+    - secure: "DoZ8g8iPs+X3xEEucke0Ae02JbkQ1qd1SSv/L2aQqxULmREtRcbzRauhiT+ToQO5Ft1Lul8uck14nPfs4gMr/O3jFFBhEBVpSlbkJx7eNL3kwUdp95UNroA8I43xPN/nccJaHDN6TMTD3+uajTQTje2SyzOQP+1gvdKg17kguvE="
+
+
+
+notifications:
+  email:
+    on_success: never
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitflags-0.9.1/Cargo.toml
@@ -0,0 +1,31 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g. crates.io) dependencies
+#
+# 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 = "bitflags"
+version = "0.9.1"
+authors = ["The Rust Project Developers"]
+description = "A macro to generate structures which behave like bitflags.\n"
+homepage = "https://github.com/rust-lang-nursery/bitflags"
+documentation = "https://docs.rs/bitflags"
+readme = "README.md"
+keywords = ["bit", "bitmask", "bitflags"]
+categories = ["no-std"]
+license = "MIT/Apache-2.0"
+repository = "https://github.com/rust-lang-nursery/bitflags"
+
+[features]
+example_generated = []
+unstable_testing = []
+default = ["example_generated"]
+[badges.travis-ci]
+repository = "rust-lang-nursery/bitflags"
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitflags-0.9.1/LICENSE-APACHE
@@ -0,0 +1,201 @@
+                              Apache License
+                        Version 2.0, January 2004
+                     http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+   "License" shall mean the terms and conditions for use, reproduction,
+   and distribution as defined by Sections 1 through 9 of this document.
+
+   "Licensor" shall mean the copyright owner or entity authorized by
+   the copyright owner that is granting the License.
+
+   "Legal Entity" shall mean the union of the acting entity and all
+   other entities that control, are controlled by, or are under common
+   control with that entity. For the purposes of this definition,
+   "control" means (i) the power, direct or indirect, to cause the
+   direction or management of such entity, whether by contract or
+   otherwise, or (ii) ownership of fifty percent (50%) or more of the
+   outstanding shares, or (iii) beneficial ownership of such entity.
+
+   "You" (or "Your") shall mean an individual or Legal Entity
+   exercising permissions granted by this License.
+
+   "Source" form shall mean the preferred form for making modifications,
+   including but not limited to software source code, documentation
+   source, and configuration files.
+
+   "Object" form shall mean any form resulting from mechanical
+   transformation or translation of a Source form, including but
+   not limited to compiled object code, generated documentation,
+   and conversions to other media types.
+
+   "Work" shall mean the work of authorship, whether in Source or
+   Object form, made available under the License, as indicated by a
+   copyright notice that is included in or attached to the work
+   (an example is provided in the Appendix below).
+
+   "Derivative Works" shall mean any work, whether in Source or Object
+   form, that is based on (or derived from) the Work and for which the
+   editorial revisions, annotations, elaborations, or other modifications
+   represent, as a whole, an original work of authorship. For the purposes
+   of this License, Derivative Works shall not include works that remain
+   separable from, or merely link (or bind by name) to the interfaces of,
+   the Work and Derivative Works thereof.
+
+   "Contribution" shall mean any work of authorship, including
+   the original version of the Work and any modifications or additions
+   to that Work or Derivative Works thereof, that is intentionally
+   submitted to Licensor for inclusion in the Work by the copyright owner
+   or by an individual or Legal Entity authorized to submit on behalf of
+   the copyright owner. For the purposes of this definition, "submitted"
+   means any form of electronic, verbal, or written communication sent
+   to the Licensor or its representatives, including but not limited to
+   communication on electronic mailing lists, source code control systems,
+   and issue tracking systems that are managed by, or on behalf of, the
+   Licensor for the purpose of discussing and improving the Work, but
+   excluding communication that is conspicuously marked or otherwise
+   designated in writing by the copyright owner as "Not a Contribution."
+
+   "Contributor" shall mean Licensor and any individual or Legal Entity
+   on behalf of whom a Contribution has been received by Licensor and
+   subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+   this License, each Contributor hereby grants to You a perpetual,
+   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+   copyright license to reproduce, prepare Derivative Works of,
+   publicly display, publicly perform, sublicense, and distribute the
+   Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+   this License, each Contributor hereby grants to You a perpetual,
+   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+   (except as stated in this section) patent license to make, have made,
+   use, offer to sell, sell, import, and otherwise transfer the Work,
+   where such license applies only to those patent claims licensable
+   by such Contributor that are necessarily infringed by their
+   Contribution(s) alone or by combination of their Contribution(s)
+   with the Work to which such Contribution(s) was submitted. If You
+   institute patent litigation against any entity (including a
+   cross-claim or counterclaim in a lawsuit) alleging that the Work
+   or a Contribution incorporated within the Work constitutes direct
+   or contributory patent infringement, then any patent licenses
+   granted to You under this License for that Work shall terminate
+   as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+   Work or Derivative Works thereof in any medium, with or without
+   modifications, and in Source or Object form, provided that You
+   meet the following conditions:
+
+   (a) You must give any other recipients of the Work or
+       Derivative Works a copy of this License; and
+
+   (b) You must cause any modified files to carry prominent notices
+       stating that You changed the files; and
+
+   (c) You must retain, in the Source form of any Derivative Works
+       that You distribute, all copyright, patent, trademark, and
+       attribution notices from the Source form of the Work,
+       excluding those notices that do not pertain to any part of
+       the Derivative Works; and
+
+   (d) If the Work includes a "NOTICE" text file as part of its
+       distribution, then any Derivative Works that You distribute must
+       include a readable copy of the attribution notices contained
+       within such NOTICE file, excluding those notices that do not
+       pertain to any part of the Derivative Works, in at least one
+       of the following places: within a NOTICE text file distributed
+       as part of the Derivative Works; within the Source form or
+       documentation, if provided along with the Derivative Works; or,
+       within a display generated by the Derivative Works, if and
+       wherever such third-party notices normally appear. The contents
+       of the NOTICE file are for informational purposes only and
+       do not modify the License. You may add Your own attribution
+       notices within Derivative Works that You distribute, alongside
+       or as an addendum to the NOTICE text from the Work, provided
+       that such additional attribution notices cannot be construed
+       as modifying the License.
+
+   You may add Your own copyright statement to Your modifications and
+   may provide additional or different license terms and conditions
+   for use, reproduction, or distribution of Your modifications, or
+   for any such Derivative Works as a whole, provided Your use,
+   reproduction, and distribution of the Work otherwise complies with
+   the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+   any Contribution intentionally submitted for inclusion in the Work
+   by You to the Licensor shall be under the terms and conditions of
+   this License, without any additional terms or conditions.
+   Notwithstanding the above, nothing herein shall supersede or modify
+   the terms of any separate license agreement you may have executed
+   with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+   names, trademarks, service marks, or product names of the Licensor,
+   except as required for reasonable and customary use in describing the
+   origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+   agreed to in writing, Licensor provides the Work (and each
+   Contributor provides its Contributions) on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+   implied, including, without limitation, any warranties or conditions
+   of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+   PARTICULAR PURPOSE. You are solely responsible for determining the
+   appropriateness of using or redistributing the Work and assume any
+   risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+   whether in tort (including negligence), contract, or otherwise,
+   unless required by applicable law (such as deliberate and grossly
+   negligent acts) or agreed to in writing, shall any Contributor be
+   liable to You for damages, including any direct, indirect, special,
+   incidental, or consequential damages of any character arising as a
+   result of this License or out of the use or inability to use the
+   Work (including but not limited to damages for loss of goodwill,
+   work stoppage, computer failure or malfunction, or any and all
+   other commercial damages or losses), even if such Contributor
+   has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+   the Work or Derivative Works thereof, You may choose to offer,
+   and charge a fee for, acceptance of support, warranty, indemnity,
+   or other liability obligations and/or rights consistent with this
+   License. However, in accepting such obligations, You may act only
+   on Your own behalf and on Your sole responsibility, not on behalf
+   of any other Contributor, and only if You agree to indemnify,
+   defend, and hold each Contributor harmless for any liability
+   incurred by, or claims asserted against, such Contributor by reason
+   of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+   To apply the Apache License to your work, attach the following
+   boilerplate notice, with the fields enclosed by brackets "[]"
+   replaced with your own identifying information. (Don't include
+   the brackets!)  The text should be enclosed in the appropriate
+   comment syntax for the file format. We also recommend that a
+   file or class name and description of purpose be included on the
+   same "printed page" as the copyright notice for easier
+   identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+	http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitflags-0.9.1/LICENSE-MIT
@@ -0,0 +1,25 @@
+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
+conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitflags-0.9.1/README.md
@@ -0,0 +1,24 @@
+bitflags
+========
+
+A Rust macro to generate structures which behave like a set of bitflags
+
+[![Build Status](https://travis-ci.org/rust-lang-nursery/bitflags.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/bitflags)
+
+[Documentation](https://docs.rs/bitflags)
+
+## Usage
+
+Add this to your `Cargo.toml`:
+
+```toml
+[dependencies]
+bitflags = "0.9"
+```
+
+and this to your crate root:
+
+```rust
+#[macro_use]
+extern crate bitflags;
+```
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitflags-0.9.1/src/example_generated.rs
@@ -0,0 +1,16 @@
+//! This module shows an example of code generated by the macro. **IT MUST NOT BE USED OUTSIDE THIS
+//! CRATE**.
+
+bitflags! {
+    /// This is the same `Flags` struct defined in the [crate level example](../index.html#example).
+    /// Note that this struct is just for documentation purposes only, it must not be used outside
+    /// this crate.
+    pub struct Flags: u32 {
+        const FLAG_A       = 0b00000001;
+        const FLAG_B       = 0b00000010;
+        const FLAG_C       = 0b00000100;
+        const FLAG_ABC     = FLAG_A.bits
+                           | FLAG_B.bits
+                           | FLAG_C.bits;
+    }
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitflags-0.9.1/src/lib.rs
@@ -0,0 +1,990 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// 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 typesafe bitmask flag generator useful for sets of C-style bitmask flags.
+//! It can be used for creating typesafe wrappers around C APIs.
+//!
+//! The `bitflags!` macro generates a `struct` that manages a set of flags. The
+//! flags should only be defined for integer types, otherwise unexpected type
+//! errors may occur at compile time.
+//!
+//! # Example
+//!
+//! ```
+//! #[macro_use]
+//! extern crate bitflags;
+//!
+//! bitflags! {
+//!     struct Flags: u32 {
+//!         const FLAG_A       = 0b00000001;
+//!         const FLAG_B       = 0b00000010;
+//!         const FLAG_C       = 0b00000100;
+//!         const FLAG_ABC     = FLAG_A.bits
+//!                            | FLAG_B.bits
+//!                            | FLAG_C.bits;
+//!     }
+//! }
+//!
+//! fn main() {
+//!     let e1 = FLAG_A | FLAG_C;
+//!     let e2 = FLAG_B | FLAG_C;
+//!     assert_eq!((e1 | e2), FLAG_ABC);   // union
+//!     assert_eq!((e1 & e2), FLAG_C);     // intersection
+//!     assert_eq!((e1 - e2), FLAG_A);     // set difference
+//!     assert_eq!(!e2, FLAG_A);           // set complement
+//! }
+//! ```
+//!
+//! See [`example_generated::Flags`](./example_generated/struct.Flags.html) for documentation of code
+//! generated by the above `bitflags!` expansion.
+//!
+//! The generated `struct`s can also be extended with type and trait
+//! implementations:
+//!
+//! ```
+//! #[macro_use]
+//! extern crate bitflags;
+//!
+//! use std::fmt;
+//!
+//! bitflags! {
+//!     struct Flags: u32 {
+//!         const FLAG_A   = 0b00000001;
+//!         const FLAG_B   = 0b00000010;
+//!     }
+//! }
+//!
+//! impl Flags {
+//!     pub fn clear(&mut self) {
+//!         self.bits = 0;  // The `bits` field can be accessed from within the
+//!                         // same module where the `bitflags!` macro was invoked.
+//!     }
+//! }
+//!
+//! impl fmt::Display for Flags {
+//!     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+//!         write!(f, "hi!")
+//!     }
+//! }
+//!
+//! fn main() {
+//!     let mut flags = FLAG_A | FLAG_B;
+//!     flags.clear();
+//!     assert!(flags.is_empty());
+//!     assert_eq!(format!("{}", flags), "hi!");
+//!     assert_eq!(format!("{:?}", FLAG_A | FLAG_B), "FLAG_A | FLAG_B");
+//!     assert_eq!(format!("{:?}", FLAG_B), "FLAG_B");
+//! }
+//! ```
+//!
+//! # Visibility
+//!
+//! The generated struct and its associated flag constants are not exported
+//! out of the current module by default. A definition can be exported out of
+//! the current module by adding `pub` before `flags`:
+//!
+//! ```ignore
+//! #[macro_use]
+//! extern crate bitflags;
+//!
+//! mod example {
+//!     bitflags! {
+//!         pub struct Flags1: u32 {
+//!             const FLAG_A   = 0b00000001;
+//!         }
+//!     }
+//!     bitflags! {
+//!         struct Flags2: u32 {
+//!             const FLAG_B   = 0b00000010;
+//!         }
+//!     }
+//! }
+//!
+//! fn main() {
+//!     let flag1 = example::FLAG_A;
+//!     let flag2 = example::FLAG_B; // error: const `FLAG_B` is private
+//! }
+//! ```
+//!
+//! # Attributes
+//!
+//! Attributes can be attached to the generated `struct` by placing them
+//! before the `flags` keyword.
+//!
+//! # Trait implementations
+//!
+//! The `Copy`, `Clone`, `PartialEq`, `Eq`, `PartialOrd`, `Ord` and `Hash`
+//! traits automatically derived for the `struct` using the `derive` attribute.
+//! Additional traits can be derived by providing an explicit `derive`
+//! attribute on `flags`.
+//!
+//! The `Extend` and `FromIterator` traits are implemented for the `struct`,
+//! too: `Extend` adds the union of the instances of the `struct` iterated over,
+//! while `FromIterator` calculates the union.
+//!
+//! The `Binary`, `Debug`, `LowerExp`, `Octal` and `UpperExp` trait is also
+//! implemented by displaying the bits value of the internal struct.
+//!
+//! ## Operators
+//!
+//! The following operator traits are implemented for the generated `struct`:
+//!
+//! - `BitOr` and `BitOrAssign`: union
+//! - `BitAnd` and `BitAndAssign`: intersection
+//! - `BitXor` and `BitXorAssign`: toggle
+//! - `Sub` and `SubAssign`: set difference
+//! - `Not`: set complement
+//!
+//! # Methods
+//!
+//! The following methods are defined for the generated `struct`:
+//!
+//! - `empty`: an empty set of flags
+//! - `all`: the set of all flags
+//! - `bits`: the raw value of the flags currently stored
+//! - `from_bits`: convert from underlying bit representation, unless that
+//!                representation contains bits that do not correspond to a flag
+//! - `from_bits_truncate`: convert from underlying bit representation, dropping
+//!                         any bits that do not correspond to flags
+//! - `is_empty`: `true` if no flags are currently stored
+//! - `is_all`: `true` if all flags are currently set
+//! - `intersects`: `true` if there are flags common to both `self` and `other`
+//! - `contains`: `true` all of the flags in `other` are contained within `self`
+//! - `insert`: inserts the specified flags in-place
+//! - `remove`: removes the specified flags in-place
+//! - `toggle`: the specified flags will be inserted if not present, and removed
+//!             if they are.
+//!
+//! ## Default
+//!
+//! The `Default` trait is not automatically implemented for the generated struct.
+//!
+//! If your default value is equal to `0` (which is the same value as calling `empty()`
+//! on the generated struct), you can simply derive `Default`:
+//!
+//! ```
+//! #[macro_use]
+//! extern crate bitflags;
+//!
+//! bitflags! {
+//!     // Results in default value with bits: 0
+//!     #[derive(Default)]
+//!     struct Flags: u32 {
+//!         const FLAG_A       = 0b00000001;
+//!         const FLAG_B       = 0b00000010;
+//!         const FLAG_C       = 0b00000100;
+//!     }
+//! }
+//!
+//! fn main() {
+//!     let derived_default: Flags = Default::default();
+//!     assert_eq!(derived_default.bits(), 0);
+//! }
+//! ```
+//!
+//! If your default value is not equal to `0` you need to implement `Default` yourself:
+//!
+//! ```
+//! #[macro_use]
+//! extern crate bitflags;
+//!
+//! bitflags! {
+//!     struct Flags: u32 {
+//!         const FLAG_A       = 0b00000001;
+//!         const FLAG_B       = 0b00000010;
+//!         const FLAG_C       = 0b00000100;
+//!     }
+//! }
+//!
+//! // explicit `Default` implementation
+//! impl Default for Flags {
+//!     fn default() -> Flags {
+//!         FLAG_A | FLAG_C
+//!     }
+//! }
+//!
+//! fn main() {
+//!     let implemented_default: Flags = Default::default();
+//!     assert_eq!(implemented_default, (FLAG_A | FLAG_C));
+//! }
+//! ```
+
+#![no_std]
+
+#![doc(html_root_url = "https://docs.rs/bitflags/0.9.1")]
+// When compiled for the rustc compiler itself we want to make sure that this is
+// an unstable crate.
+#![cfg_attr(rustbuild, feature(staged_api))]
+#![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))]
+
+#[cfg(test)]
+#[macro_use]
+extern crate std;
+
+// Re-export libstd/libcore using an alias so that the macros can work in no_std
+// crates while remaining compatible with normal crates.
+#[doc(hidden)]
+pub extern crate core as _core;
+
+/// The macro used to generate the flag structure.
+///
+/// See the [crate level docs](../bitflags/index.html) for complete documentation.
+///
+/// # Example
+///
+/// ```
+/// #[macro_use]
+/// extern crate bitflags;
+///
+/// bitflags! {
+///     struct Flags: u32 {
+///         const FLAG_A       = 0b00000001;
+///         const FLAG_B       = 0b00000010;
+///         const FLAG_C       = 0b00000100;
+///         const FLAG_ABC     = FLAG_A.bits
+///                            | FLAG_B.bits
+///                            | FLAG_C.bits;
+///     }
+/// }
+///
+/// fn main() {
+///     let e1 = FLAG_A | FLAG_C;
+///     let e2 = FLAG_B | FLAG_C;
+///     assert_eq!((e1 | e2), FLAG_ABC);   // union
+///     assert_eq!((e1 & e2), FLAG_C);     // intersection
+///     assert_eq!((e1 - e2), FLAG_A);     // set difference
+///     assert_eq!(!e2, FLAG_A);           // set complement
+/// }
+/// ```
+///
+/// The generated `struct`s can also be extended with type and trait
+/// implementations:
+///
+/// ```
+/// #[macro_use]
+/// extern crate bitflags;
+///
+/// use std::fmt;
+///
+/// bitflags! {
+///     struct Flags: u32 {
+///         const FLAG_A   = 0b00000001;
+///         const FLAG_B   = 0b00000010;
+///     }
+/// }
+///
+/// impl Flags {
+///     pub fn clear(&mut self) {
+///         self.bits = 0;  // The `bits` field can be accessed from within the
+///                         // same module where the `bitflags!` macro was invoked.
+///     }
+/// }
+///
+/// impl fmt::Display for Flags {
+///     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+///         write!(f, "hi!")
+///     }
+/// }
+///
+/// fn main() {
+///     let mut flags = FLAG_A | FLAG_B;
+///     flags.clear();
+///     assert!(flags.is_empty());
+///     assert_eq!(format!("{}", flags), "hi!");
+///     assert_eq!(format!("{:?}", FLAG_A | FLAG_B), "FLAG_A | FLAG_B");
+///     assert_eq!(format!("{:?}", FLAG_B), "FLAG_B");
+/// }
+/// ```
+#[macro_export]
+macro_rules! bitflags {
+    ($(#[$attr:meta])* pub struct $BitFlags:ident: $T:ty {
+        $($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr;)+
+    }) => {
+        #[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
+        $(#[$attr])*
+        pub struct $BitFlags {
+            bits: $T,
+        }
+
+        $($(#[$Flag_attr])* pub const $Flag: $BitFlags = $BitFlags { bits: $value };)+
+
+        __impl_bitflags! {
+            struct $BitFlags: $T {
+                $($(#[$Flag_attr])* const $Flag = $value;)+
+            }
+        }
+    };
+    ($(#[$attr:meta])* struct $BitFlags:ident: $T:ty {
+        $($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr;)+
+    }) => {
+        #[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
+        $(#[$attr])*
+        struct $BitFlags {
+            bits: $T,
+        }
+
+        $($(#[$Flag_attr])* const $Flag: $BitFlags = $BitFlags { bits: $value };)+
+
+        __impl_bitflags! {
+            struct $BitFlags: $T {
+                $($(#[$Flag_attr])* const $Flag = $value;)+
+            }
+        }
+
+    };
+}
+
+#[macro_export]
+#[doc(hidden)]
+macro_rules! __impl_bitflags {
+    (struct $BitFlags:ident: $T:ty {
+        $($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr;)+
+    }) => {
+        impl $crate::_core::fmt::Debug for $BitFlags {
+            fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
+                // This convoluted approach is to handle #[cfg]-based flag
+                // omission correctly. For example it needs to support:
+                //
+                //    #[cfg(unix)] const A: Flag = /* ... */;
+                //    #[cfg(windows)] const B: Flag = /* ... */;
+
+                // Unconditionally define a check for every flag, even disabled
+                // ones.
+                #[allow(non_snake_case)]
+                trait __BitFlags {
+                    $(
+                        fn $Flag(&self) -> bool { false }
+                    )+
+                }
+
+                // Conditionally override the check for just those flags that
+                // are not #[cfg]ed away.
+                impl __BitFlags for $BitFlags {
+                    $(
+                        $(#[$Flag_attr])*
+                        fn $Flag(&self) -> bool {
+                            self.bits & $Flag.bits == $Flag.bits
+                        }
+                    )+
+                }
+
+                let mut first = true;
+                $(
+                    if <$BitFlags as __BitFlags>::$Flag(self) {
+                        if !first {
+                            try!(f.write_str(" | "));
+                        }
+                        first = false;
+                        try!(f.write_str(stringify!($Flag)));
+                    }
+                )+
+                if first {
+                    try!(f.write_str("(empty)"));
+                }
+                Ok(())
+            }
+        }
+        impl $crate::_core::fmt::Binary for $BitFlags {
+            fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
+                $crate::_core::fmt::Binary::fmt(&self.bits, f)
+            }
+        }
+        impl $crate::_core::fmt::Octal for $BitFlags {
+            fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
+                $crate::_core::fmt::Octal::fmt(&self.bits, f)
+            }
+        }
+        impl $crate::_core::fmt::LowerHex for $BitFlags {
+            fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
+                $crate::_core::fmt::LowerHex::fmt(&self.bits, f)
+            }
+        }
+        impl $crate::_core::fmt::UpperHex for $BitFlags {
+            fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
+                $crate::_core::fmt::UpperHex::fmt(&self.bits, f)
+            }
+        }
+
+        #[allow(dead_code)]
+        impl $BitFlags {
+            /// Returns an empty set of flags.
+            #[inline]
+            pub fn empty() -> $BitFlags {
+                $BitFlags { bits: 0 }
+            }
+
+            /// Returns the set containing all flags.
+            #[inline]
+            pub fn all() -> $BitFlags {
+                // See `Debug::fmt` for why this approach is taken.
+                #[allow(non_snake_case)]
+                trait __BitFlags {
+                    $(
+                        fn $Flag() -> $T { 0 }
+                    )+
+                }
+                impl __BitFlags for $BitFlags {
+                    $(
+                        $(#[$Flag_attr])*
+                        fn $Flag() -> $T { $Flag.bits }
+                    )+
+                }
+                $BitFlags { bits: $(<$BitFlags as __BitFlags>::$Flag())|+ }
+            }
+
+            /// Returns the raw value of the flags currently stored.
+            #[inline]
+            pub fn bits(&self) -> $T {
+                self.bits
+            }
+
+            /// Convert from underlying bit representation, unless that
+            /// representation contains bits that do not correspond to a flag.
+            #[inline]
+            pub fn from_bits(bits: $T) -> $crate::_core::option::Option<$BitFlags> {
+                if (bits & !$BitFlags::all().bits()) == 0 {
+                    $crate::_core::option::Option::Some($BitFlags { bits: bits })
+                } else {
+                    $crate::_core::option::Option::None
+                }
+            }
+
+            /// Convert from underlying bit representation, dropping any bits
+            /// that do not correspond to flags.
+            #[inline]
+            pub fn from_bits_truncate(bits: $T) -> $BitFlags {
+                $BitFlags { bits: bits } & $BitFlags::all()
+            }
+
+            /// Returns `true` if no flags are currently stored.
+            #[inline]
+            pub fn is_empty(&self) -> bool {
+                *self == $BitFlags::empty()
+            }
+
+            /// Returns `true` if all flags are currently set.
+            #[inline]
+            pub fn is_all(&self) -> bool {
+                *self == $BitFlags::all()
+            }
+
+            /// Returns `true` if there are flags common to both `self` and `other`.
+            #[inline]
+            pub fn intersects(&self, other: $BitFlags) -> bool {
+                !(*self & other).is_empty()
+            }
+
+            /// Returns `true` all of the flags in `other` are contained within `self`.
+            #[inline]
+            pub fn contains(&self, other: $BitFlags) -> bool {
+                (*self & other) == other
+            }
+
+            /// Inserts the specified flags in-place.
+            #[inline]
+            pub fn insert(&mut self, other: $BitFlags) {
+                self.bits |= other.bits;
+            }
+
+            /// Removes the specified flags in-place.
+            #[inline]
+            pub fn remove(&mut self, other: $BitFlags) {
+                self.bits &= !other.bits;
+            }
+
+            /// Toggles the specified flags in-place.
+            #[inline]
+            pub fn toggle(&mut self, other: $BitFlags) {
+                self.bits ^= other.bits;
+            }
+
+            /// Inserts or removes the specified flags depending on the passed value.
+            #[inline]
+            pub fn set(&mut self, other: $BitFlags, value: bool) {
+                if value {
+                    self.insert(other);
+                } else {
+                    self.remove(other);
+                }
+            }
+        }
+
+        impl $crate::_core::ops::BitOr for $BitFlags {
+            type Output = $BitFlags;
+
+            /// Returns the union of the two sets of flags.
+            #[inline]
+            fn bitor(self, other: $BitFlags) -> $BitFlags {
+                $BitFlags { bits: self.bits | other.bits }
+            }
+        }
+
+        impl $crate::_core::ops::BitOrAssign for $BitFlags {
+
+            /// Adds the set of flags.
+            #[inline]
+            fn bitor_assign(&mut self, other: $BitFlags) {
+                self.bits |= other.bits;
+            }
+        }
+
+        impl $crate::_core::ops::BitXor for $BitFlags {
+            type Output = $BitFlags;
+
+            /// Returns the left flags, but with all the right flags toggled.
+            #[inline]
+            fn bitxor(self, other: $BitFlags) -> $BitFlags {
+                $BitFlags { bits: self.bits ^ other.bits }
+            }
+        }
+
+        impl $crate::_core::ops::BitXorAssign for $BitFlags {
+
+            /// Toggles the set of flags.
+            #[inline]
+            fn bitxor_assign(&mut self, other: $BitFlags) {
+                self.bits ^= other.bits;
+            }
+        }
+
+        impl $crate::_core::ops::BitAnd for $BitFlags {
+            type Output = $BitFlags;
+
+            /// Returns the intersection between the two sets of flags.
+            #[inline]
+            fn bitand(self, other: $BitFlags) -> $BitFlags {
+                $BitFlags { bits: self.bits & other.bits }
+            }
+        }
+
+        impl $crate::_core::ops::BitAndAssign for $BitFlags {
+
+            /// Disables all flags disabled in the set.
+            #[inline]
+            fn bitand_assign(&mut self, other: $BitFlags) {
+                self.bits &= other.bits;
+            }
+        }
+
+        impl $crate::_core::ops::Sub for $BitFlags {
+            type Output = $BitFlags;
+
+            /// Returns the set difference of the two sets of flags.
+            #[inline]
+            fn sub(self, other: $BitFlags) -> $BitFlags {
+                $BitFlags { bits: self.bits & !other.bits }
+            }
+        }
+
+        impl $crate::_core::ops::SubAssign for $BitFlags {
+
+            /// Disables all flags enabled in the set.
+            #[inline]
+            fn sub_assign(&mut self, other: $BitFlags) {
+                self.bits &= !other.bits;
+            }
+        }
+
+        impl $crate::_core::ops::Not for $BitFlags {
+            type Output = $BitFlags;
+
+            /// Returns the complement of this set of flags.
+            #[inline]
+            fn not(self) -> $BitFlags {
+                $BitFlags { bits: !self.bits } & $BitFlags::all()
+            }
+        }
+
+        impl $crate::_core::iter::Extend<$BitFlags> for $BitFlags {
+            fn extend<T: $crate::_core::iter::IntoIterator<Item=$BitFlags>>(&mut self, iterator: T) {
+                for item in iterator {
+                    self.insert(item)
+                }
+            }
+        }
+
+        impl $crate::_core::iter::FromIterator<$BitFlags> for $BitFlags {
+            fn from_iter<T: $crate::_core::iter::IntoIterator<Item=$BitFlags>>(iterator: T) -> $BitFlags {
+                let mut result = Self::empty();
+                result.extend(iterator);
+                result
+            }
+        }
+    };
+}
+
+#[cfg(feature = "example_generated")]
+pub mod example_generated;
+
+#[cfg(test)]
+#[allow(non_upper_case_globals, dead_code)]
+mod tests {
+    use std::hash::{Hash, Hasher};
+    use std::collections::hash_map::DefaultHasher;
+
+    bitflags! {
+        #[doc = "> The first principle is that you must not fool yourself — and"]
+        #[doc = "> you are the easiest person to fool."]
+        #[doc = "> "]
+        #[doc = "> - Richard Feynman"]
+        struct Flags: u32 {
+            const FlagA       = 0b00000001;
+            #[doc = "<pcwalton> macros are way better at generating code than trans is"]
+            const FlagB       = 0b00000010;
+            const FlagC       = 0b00000100;
+            #[doc = "* cmr bed"]
+            #[doc = "* strcat table"]
+            #[doc = "<strcat> wait what?"]
+            const FlagABC     = FlagA.bits
+                               | FlagB.bits
+                               | FlagC.bits;
+        }
+    }
+
+    bitflags! {
+        struct _CfgFlags: u32 {
+            #[cfg(windows)]
+            const _CfgA = 0b01;
+            #[cfg(unix)]
+            const _CfgB = 0b01;
+            #[cfg(windows)]
+            const _CfgC = _CfgA.bits | 0b10;
+        }
+    }
+
+    bitflags! {
+        struct AnotherSetOfFlags: i8 {
+            const AnotherFlag = -1_i8;
+        }
+    }
+
+    bitflags! {
+        struct LongFlags: u32 {
+            const LongFlagA = 0b1111111111111111;
+        }
+    }
+
+    #[test]
+    fn test_bits(){
+        assert_eq!(Flags::empty().bits(), 0b00000000);
+        assert_eq!(FlagA.bits(), 0b00000001);
+        assert_eq!(FlagABC.bits(), 0b00000111);
+
+        assert_eq!(AnotherSetOfFlags::empty().bits(), 0b00);
+        assert_eq!(AnotherFlag.bits(), !0_i8);
+    }
+
+    #[test]
+    fn test_from_bits() {
+        assert_eq!(Flags::from_bits(0), Some(Flags::empty()));
+        assert_eq!(Flags::from_bits(0b1), Some(FlagA));
+        assert_eq!(Flags::from_bits(0b10), Some(FlagB));
+        assert_eq!(Flags::from_bits(0b11), Some(FlagA | FlagB));
+        assert_eq!(Flags::from_bits(0b1000), None);
+
+        assert_eq!(AnotherSetOfFlags::from_bits(!0_i8), Some(AnotherFlag));
+    }
+
+    #[test]
+    fn test_from_bits_truncate() {
+        assert_eq!(Flags::from_bits_truncate(0), Flags::empty());
+        assert_eq!(Flags::from_bits_truncate(0b1), FlagA);
+        assert_eq!(Flags::from_bits_truncate(0b10), FlagB);
+        assert_eq!(Flags::from_bits_truncate(0b11), (FlagA | FlagB));
+        assert_eq!(Flags::from_bits_truncate(0b1000), Flags::empty());
+        assert_eq!(Flags::from_bits_truncate(0b1001), FlagA);
+
+        assert_eq!(AnotherSetOfFlags::from_bits_truncate(0_i8), AnotherSetOfFlags::empty());
+    }
+
+    #[test]
+    fn test_is_empty(){
+        assert!(Flags::empty().is_empty());
+        assert!(!FlagA.is_empty());
+        assert!(!FlagABC.is_empty());
+
+        assert!(!AnotherFlag.is_empty());
+    }
+
+    #[test]
+    fn test_is_all() {
+        assert!(Flags::all().is_all());
+        assert!(!FlagA.is_all());
+        assert!(FlagABC.is_all());
+
+        assert!(AnotherFlag.is_all());
+    }
+
+    #[test]
+    fn test_two_empties_do_not_intersect() {
+        let e1 = Flags::empty();
+        let e2 = Flags::empty();
+        assert!(!e1.intersects(e2));
+
+        assert!(AnotherFlag.intersects(AnotherFlag));
+    }
+
+    #[test]
+    fn test_empty_does_not_intersect_with_full() {
+        let e1 = Flags::empty();
+        let e2 = FlagABC;
+        assert!(!e1.intersects(e2));
+    }
+
+    #[test]
+    fn test_disjoint_intersects() {
+        let e1 = FlagA;
+        let e2 = FlagB;
+        assert!(!e1.intersects(e2));
+    }
+
+    #[test]
+    fn test_overlapping_intersects() {
+        let e1 = FlagA;
+        let e2 = FlagA | FlagB;
+        assert!(e1.intersects(e2));
+    }
+
+    #[test]
+    fn test_contains() {
+        let e1 = FlagA;
+        let e2 = FlagA | FlagB;
+        assert!(!e1.contains(e2));
+        assert!(e2.contains(e1));
+        assert!(FlagABC.contains(e2));
+
+        assert!(AnotherFlag.contains(AnotherFlag));
+    }
+
+    #[test]
+    fn test_insert(){
+        let mut e1 = FlagA;
+        let e2 = FlagA | FlagB;
+        e1.insert(e2);
+        assert_eq!(e1, e2);
+
+        let mut e3 = AnotherSetOfFlags::empty();
+        e3.insert(AnotherFlag);
+        assert_eq!(e3, AnotherFlag);
+    }
+
+    #[test]
+    fn test_remove(){
+        let mut e1 = FlagA | FlagB;
+        let e2 = FlagA | FlagC;
+        e1.remove(e2);
+        assert_eq!(e1, FlagB);
+
+        let mut e3 = AnotherFlag;
+        e3.remove(AnotherFlag);
+        assert_eq!(e3, AnotherSetOfFlags::empty());
+    }
+
+    #[test]
+    fn test_operators() {
+        let e1 = FlagA | FlagC;
+        let e2 = FlagB | FlagC;
+        assert_eq!((e1 | e2), FlagABC);     // union
+        assert_eq!((e1 & e2), FlagC);       // intersection
+        assert_eq!((e1 - e2), FlagA);       // set difference
+        assert_eq!(!e2, FlagA);             // set complement
+        assert_eq!(e1 ^ e2, FlagA | FlagB); // toggle
+        let mut e3 = e1;
+        e3.toggle(e2);
+        assert_eq!(e3, FlagA | FlagB);
+
+        let mut m4 = AnotherSetOfFlags::empty();
+        m4.toggle(AnotherSetOfFlags::empty());
+        assert_eq!(m4, AnotherSetOfFlags::empty());
+    }
+
+    #[test]
+    fn test_set() {
+        let mut e1 = FlagA | FlagC;
+        e1.set(FlagB, true);
+        e1.set(FlagC, false);
+
+        assert_eq!(e1, FlagA | FlagB);
+    }
+
+    #[test]
+    fn test_assignment_operators() {
+        let mut m1 = Flags::empty();
+        let e1 = FlagA | FlagC;
+        // union
+        m1 |= FlagA;
+        assert_eq!(m1, FlagA);
+        // intersection
+        m1 &= e1;
+        assert_eq!(m1, FlagA);
+        // set difference
+        m1 -= m1;
+        assert_eq!(m1, Flags::empty());
+        // toggle
+        m1 ^= e1;
+        assert_eq!(m1, e1);
+    }
+
+    #[test]
+    fn test_extend() {
+        let mut flags;
+
+        flags = Flags::empty();
+        flags.extend([].iter().cloned());
+        assert_eq!(flags, Flags::empty());
+
+        flags = Flags::empty();
+        flags.extend([FlagA, FlagB].iter().cloned());
+        assert_eq!(flags, FlagA | FlagB);
+
+        flags = FlagA;
+        flags.extend([FlagA, FlagB].iter().cloned());
+        assert_eq!(flags, FlagA | FlagB);
+
+        flags = FlagB;
+        flags.extend([FlagA, FlagABC].iter().cloned());
+        assert_eq!(flags, FlagABC);
+    }
+
+    #[test]
+    fn test_from_iterator() {
+        assert_eq!([].iter().cloned().collect::<Flags>(), Flags::empty());
+        assert_eq!([FlagA, FlagB].iter().cloned().collect::<Flags>(), FlagA | FlagB);
+        assert_eq!([FlagA, FlagABC].iter().cloned().collect::<Flags>(), FlagABC);
+    }
+
+    #[test]
+    fn test_lt() {
+        let mut a = Flags::empty();
+        let mut b = Flags::empty();
+
+        assert!(!(a < b) && !(b < a));
+        b = FlagB;
+        assert!(a < b);
+        a = FlagC;
+        assert!(!(a < b) && b < a);
+        b = FlagC | FlagB;
+        assert!(a < b);
+    }
+
+    #[test]
+    fn test_ord() {
+        let mut a = Flags::empty();
+        let mut b = Flags::empty();
+
+        assert!(a <= b && a >= b);
+        a = FlagA;
+        assert!(a > b && a >= b);
+        assert!(b < a && b <= a);
+        b = FlagB;
+        assert!(b > a && b >= a);
+        assert!(a < b && a <= b);
+    }
+
+    fn hash<T: Hash>(t: &T) -> u64 {
+        let mut s = DefaultHasher::new();
+        t.hash(&mut s);
+        s.finish()
+    }
+
+    #[test]
+    fn test_hash() {
+        let mut x = Flags::empty();
+        let mut y = Flags::empty();
+        assert_eq!(hash(&x), hash(&y));
+        x = Flags::all();
+        y = FlagABC;
+        assert_eq!(hash(&x), hash(&y));
+    }
+
+    #[test]
+    fn test_debug() {
+        assert_eq!(format!("{:?}", FlagA | FlagB), "FlagA | FlagB");
+        assert_eq!(format!("{:?}", Flags::empty()), "(empty)");
+        assert_eq!(format!("{:?}", FlagABC), "FlagA | FlagB | FlagC | FlagABC");
+    }
+
+    #[test]
+    fn test_binary() {
+        assert_eq!(format!("{:b}", FlagABC), "111");
+        assert_eq!(format!("{:#b}", FlagABC), "0b111");
+    }
+
+    #[test]
+    fn test_octal() {
+        assert_eq!(format!("{:o}", LongFlagA), "177777");
+        assert_eq!(format!("{:#o}", LongFlagA), "0o177777");
+    }
+
+    #[test]
+    fn test_lowerhex() {
+        assert_eq!(format!("{:x}", LongFlagA), "ffff");
+        assert_eq!(format!("{:#x}", LongFlagA), "0xffff");
+    }
+
+    #[test]
+    fn test_upperhex() {
+        assert_eq!(format!("{:X}", LongFlagA), "FFFF");
+        assert_eq!(format!("{:#X}", LongFlagA), "0xFFFF");
+    }
+
+    mod submodule {
+        bitflags! {
+            pub struct PublicFlags: i8 {
+                const FlagX = 0;
+            }
+        }
+        bitflags! {
+            struct PrivateFlags: i8 {
+                const FlagY = 0;
+            }
+        }
+
+        #[test]
+        fn test_private() {
+            let _ = FlagY;
+        }
+    }
+
+    #[test]
+    fn test_public() {
+        let _ = submodule::FlagX;
+    }
+
+    mod t1 {
+        mod foo {
+            pub type Bar = i32;
+        }
+
+        bitflags! {
+            /// baz
+            struct Flags: foo::Bar {
+                const A       = 0b00000001;
+                #[cfg(foo)]
+                const B       = 0b00000010;
+                #[cfg(foo)]
+                const C       = 0b00000010;
+            }
+        }
+    }
+
+    #[test]
+    fn test_in_function() {
+        bitflags! {
+           struct Flags: u8 {
+                const A = 1;
+                #[cfg(any())] // false
+                const B = 2;
+            }
+        }
+        assert_eq!(Flags::all(), A);
+        assert_eq!(format!("{:?}", A), "A");
+    }
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitflags-0.9.1/tests/conflicting_trait_impls.rs
@@ -0,0 +1,20 @@
+#![allow(dead_code)]
+#![no_std]
+
+#[macro_use]
+extern crate bitflags;
+
+#[allow(unused_imports)]
+use core::fmt::Display;
+
+bitflags! {
+    /// baz
+    struct Flags: u32 {
+        const A       = 0b00000001;
+    }
+}
+
+#[test]
+fn main() {
+
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitflags-0.9.1/tests/external.rs
@@ -0,0 +1,21 @@
+#![allow(dead_code)]
+
+#[macro_use]
+extern crate bitflags;
+
+bitflags! {
+    /// baz
+    struct Flags: u32 {
+        const A       = 0b00000001;
+        #[doc = "bar"]
+        const B       = 0b00000010;
+        const C       = 0b00000100;
+        #[doc = "foo"]
+        const ABC     = A.bits | B.bits | C.bits;
+    }
+}
+
+#[test]
+fn smoke() {
+    assert_eq!(ABC, A | B | C);
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitflags-0.9.1/tests/external_no_std.rs
@@ -0,0 +1,22 @@
+#![allow(dead_code)]
+#![no_std]
+
+#[macro_use]
+extern crate bitflags;
+
+bitflags! {
+    /// baz
+    struct Flags: u32 {
+        const A       = 0b00000001;
+        #[doc = "bar"]
+        const B       = 0b00000010;
+        const C       = 0b00000100;
+        #[doc = "foo"]
+        const ABC     = A.bits | B.bits | C.bits;
+    }
+}
+
+#[test]
+fn smoke() {
+    assert_eq!(ABC, A | B | C);
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitflags-0.9.1/tests/i128_bitflags.rs
@@ -0,0 +1,30 @@
+#![cfg(feature = "unstable_testing")]
+
+#![allow(dead_code, unused_imports)]
+#![feature(i128_type)]
+
+#[macro_use]
+extern crate bitflags;
+
+bitflags! {
+    /// baz
+    struct Flags128: u128 {
+        const A       = 0x0000_0000_0000_0000_0000_0000_0000_0001;
+        const B       = 0x0000_0000_0000_1000_0000_0000_0000_0000;
+        const C       = 0x8000_0000_0000_0000_0000_0000_0000_0000;
+        const ABC     = A.bits | B.bits | C.bits;
+    }
+}
+
+#[test]
+fn test_i128_bitflags() {
+    assert_eq!(ABC, A | B | C);
+    assert_eq!(A.bits, 0x0000_0000_0000_0000_0000_0000_0000_0001);
+    assert_eq!(B.bits, 0x0000_0000_0000_1000_0000_0000_0000_0000);
+    assert_eq!(C.bits, 0x8000_0000_0000_0000_0000_0000_0000_0000);
+    assert_eq!(ABC.bits, 0x8000_0000_0000_1000_0000_0000_0000_0001);
+    assert_eq!(format!("{:?}", A), "A");
+    assert_eq!(format!("{:?}", B), "B");
+    assert_eq!(format!("{:?}", C), "C");
+    assert_eq!(format!("{:?}", ABC), "A | B | C | ABC");
+}
--- a/third_party/rust/bitflags/.cargo-checksum.json
+++ b/third_party/rust/bitflags/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"e7a77c1800f9852e4c9a2acb9df041773ecd0bc005bd1b0657ae0512c67100ac","Cargo.toml":"f35826eec96c765ae8aee4f8a66c6b3cb0d918b49935baf05bae79b6df8e1077","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"602c63819e332e93c85dc8426db4855f18fe0fabbd642c5b2303ed83f1ba926f","src/example_generated.rs":"161b69d92cf6e5fa4b5dc30f06031f3a0fb590b44be2bcf0f31cb8be4fab36fa","src/lib.rs":"56e86a16356d9322fa6b4e9b910041e2e7558c08b52ffbdacc647eba36b37abc","tests/conflicting_trait_impls.rs":"79993ea67ef09a5f99fddd69d8b73b1c137e41d0e8f8535f03865d6766dcc498","tests/external.rs":"15f7901698e286197666ccd309ad1debd3c35eaff680ca090368494e8b06ccf2","tests/external_no_std.rs":"c3556fd19dd91d1b093eb6a65d09a9d0985544f0377ba3d30c0e265c956f7237","tests/i128_bitflags.rs":"c955ef2c9fd385848195bb416e660e946ccbe59acc87862ef2646eb082d82e3f"},"package":"4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"}
\ No newline at end of file
+{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"d0da6f63d93a5cfb6536e3be8714239386a79fbfdfe3e6ec92a78c8ddde62010","Cargo.toml":"5a87b6a8e0411a560659a73163f9a222b4b6fa46c6d3ef7bb4dc1e5152807b4a","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"aedcbbbefde11d7d8df61645aa93324695e7035d847e934a92e0250920287072","src/example_generated.rs":"8e8f188edaaefb8cc75064bd9e6dfdb8d776132ad838cff377a1acf08216186f","src/lib.rs":"d66cedd360642fcaf89a84408ea6b336f9d89948800e0a8149465cc3a022a621","tests/conflicting_trait_impls.rs":"a2a2e28dee83ead220bbc76653ae203242d9024e05aa47217049c91dd66e3b91","tests/external.rs":"1ec3fb8681056383397f34a9ae87c3d24f031715f88602cab19fa3c820e021b0","tests/external_no_std.rs":"75e0e2d6257b67d4ab9d975a9851f0a874ca7d2cdb0940df6212eafbb0fc2d88","tests/i128_bitflags.rs":"e55fbd7529839bffb8e3a8bf00516b7aca9f4a51cfda5177da17aece8328ad55"},"package":"f5cde24d1b2e2216a726368b2363a273739c91f4e3eb4e0dd12d672d396ad989"}
\ No newline at end of file
--- a/third_party/rust/bitflags/.travis.yml
+++ b/third_party/rust/bitflags/.travis.yml
@@ -1,13 +1,15 @@
 os:
   - linux
   - osx
 language: rust
 rust:
+  # This version is tested to avoid unintentional bumping of the minimum supported Rust version
+  - 1.20.0
   - stable
   - beta
   - nightly
 sudo: false
 before_script:
   - pip install -v 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
   - if [[ -e ~/Library/Python/2.7/bin ]]; then export PATH=~/Library/Python/2.7/bin:$PATH; fi
 script:
--- a/third_party/rust/bitflags/Cargo.toml
+++ b/third_party/rust/bitflags/Cargo.toml
@@ -7,25 +7,25 @@
 #
 # 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 = "bitflags"
-version = "0.9.1"
+version = "1.0.0"
 authors = ["The Rust Project Developers"]
 description = "A macro to generate structures which behave like bitflags.\n"
 homepage = "https://github.com/rust-lang-nursery/bitflags"
 documentation = "https://docs.rs/bitflags"
 readme = "README.md"
 keywords = ["bit", "bitmask", "bitflags"]
 categories = ["no-std"]
 license = "MIT/Apache-2.0"
 repository = "https://github.com/rust-lang-nursery/bitflags"
 
 [features]
-example_generated = []
 unstable_testing = []
 default = ["example_generated"]
+example_generated = []
 [badges.travis-ci]
 repository = "rust-lang-nursery/bitflags"
--- a/third_party/rust/bitflags/README.md
+++ b/third_party/rust/bitflags/README.md
@@ -1,24 +1,31 @@
 bitflags
 ========
 
 A Rust macro to generate structures which behave like a set of bitflags
 
 [![Build Status](https://travis-ci.org/rust-lang-nursery/bitflags.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/bitflags)
 
-[Documentation](https://docs.rs/bitflags)
+- [Documentation](https://docs.rs/bitflags)
+- [Release notes](https://github.com/rust-lang-nursery/bitflags/releases)
 
 ## Usage
 
 Add this to your `Cargo.toml`:
 
 ```toml
 [dependencies]
-bitflags = "0.9"
+bitflags = "1.0"
 ```
 
 and this to your crate root:
 
 ```rust
 #[macro_use]
 extern crate bitflags;
 ```
+
+## Rust Version Support
+
+The minimum supported* Rust version is 1.20 due to use of associated constants.
+
+_* As of the current master branch (unreleased)_
--- a/third_party/rust/bitflags/src/example_generated.rs
+++ b/third_party/rust/bitflags/src/example_generated.rs
@@ -4,13 +4,13 @@
 bitflags! {
     /// This is the same `Flags` struct defined in the [crate level example](../index.html#example).
     /// Note that this struct is just for documentation purposes only, it must not be used outside
     /// this crate.
     pub struct Flags: u32 {
         const FLAG_A       = 0b00000001;
         const FLAG_B       = 0b00000010;
         const FLAG_C       = 0b00000100;
-        const FLAG_ABC     = FLAG_A.bits
-                           | FLAG_B.bits
-                           | FLAG_C.bits;
+        const FLAG_ABC     = Self::FLAG_A.bits
+                           | Self::FLAG_B.bits
+                           | Self::FLAG_C.bits;
     }
 }
--- a/third_party/rust/bitflags/src/lib.rs
+++ b/third_party/rust/bitflags/src/lib.rs
@@ -21,29 +21,29 @@
 //! #[macro_use]
 //! extern crate bitflags;
 //!
 //! bitflags! {
 //!     struct Flags: u32 {
 //!         const FLAG_A       = 0b00000001;
 //!         const FLAG_B       = 0b00000010;
 //!         const FLAG_C       = 0b00000100;
-//!         const FLAG_ABC     = FLAG_A.bits
-//!                            | FLAG_B.bits
-//!                            | FLAG_C.bits;
+//!         const FLAG_ABC     = Self::FLAG_A.bits
+//!                            | Self::FLAG_B.bits
+//!                            | Self::FLAG_C.bits;
 //!     }
 //! }
 //!
 //! fn main() {
-//!     let e1 = FLAG_A | FLAG_C;
-//!     let e2 = FLAG_B | FLAG_C;
-//!     assert_eq!((e1 | e2), FLAG_ABC);   // union
-//!     assert_eq!((e1 & e2), FLAG_C);     // intersection
-//!     assert_eq!((e1 - e2), FLAG_A);     // set difference
-//!     assert_eq!(!e2, FLAG_A);           // set complement
+//!     let e1 = Flags::FLAG_A | Flags::FLAG_C;
+//!     let e2 = Flags::FLAG_B | Flags::FLAG_C;
+//!     assert_eq!((e1 | e2), Flags::FLAG_ABC);   // union
+//!     assert_eq!((e1 & e2), Flags::FLAG_C);     // intersection
+//!     assert_eq!((e1 - e2), Flags::FLAG_A);     // set difference
+//!     assert_eq!(!e2, Flags::FLAG_A);           // set complement
 //! }
 //! ```
 //!
 //! See [`example_generated::Flags`](./example_generated/struct.Flags.html) for documentation of code
 //! generated by the above `bitflags!` expansion.
 //!
 //! The generated `struct`s can also be extended with type and trait
 //! implementations:
@@ -70,22 +70,22 @@
 //!
 //! impl fmt::Display for Flags {
 //!     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 //!         write!(f, "hi!")
 //!     }
 //! }
 //!
 //! fn main() {
-//!     let mut flags = FLAG_A | FLAG_B;
+//!     let mut flags = Flags::FLAG_A | Flags::FLAG_B;
 //!     flags.clear();
 //!     assert!(flags.is_empty());
 //!     assert_eq!(format!("{}", flags), "hi!");
-//!     assert_eq!(format!("{:?}", FLAG_A | FLAG_B), "FLAG_A | FLAG_B");
-//!     assert_eq!(format!("{:?}", FLAG_B), "FLAG_B");
+//!     assert_eq!(format!("{:?}", Flags::FLAG_A | Flags::FLAG_B), "FLAG_A | FLAG_B");
+//!     assert_eq!(format!("{:?}", Flags::FLAG_B), "FLAG_B");
 //! }
 //! ```
 //!
 //! # Visibility
 //!
 //! The generated struct and its associated flag constants are not exported
 //! out of the current module by default. A definition can be exported out of
 //! the current module by adding `pub` before `flags`:
@@ -103,18 +103,18 @@
 //!     bitflags! {
 //!         struct Flags2: u32 {
 //!             const FLAG_B   = 0b00000010;
 //!         }
 //!     }
 //! }
 //!
 //! fn main() {
-//!     let flag1 = example::FLAG_A;
-//!     let flag2 = example::FLAG_B; // error: const `FLAG_B` is private
+//!     let flag1 = example::Flags1::FLAG_A;
+//!     let flag2 = example::Flags2::FLAG_B; // error: const `FLAG_B` is private
 //! }
 //! ```
 //!
 //! # Attributes
 //!
 //! Attributes can be attached to the generated `struct` by placing them
 //! before the `flags` keyword.
 //!
@@ -156,16 +156,17 @@
 //! - `is_empty`: `true` if no flags are currently stored
 //! - `is_all`: `true` if all flags are currently set
 //! - `intersects`: `true` if there are flags common to both `self` and `other`
 //! - `contains`: `true` all of the flags in `other` are contained within `self`
 //! - `insert`: inserts the specified flags in-place
 //! - `remove`: removes the specified flags in-place
 //! - `toggle`: the specified flags will be inserted if not present, and removed
 //!             if they are.
+//! - `set`: inserts or removes the specified flags depending on the passed value
 //!
 //! ## Default
 //!
 //! The `Default` trait is not automatically implemented for the generated struct.
 //!
 //! If your default value is equal to `0` (which is the same value as calling `empty()`
 //! on the generated struct), you can simply derive `Default`:
 //!
@@ -201,29 +202,29 @@
 //!         const FLAG_B       = 0b00000010;
 //!         const FLAG_C       = 0b00000100;
 //!     }
 //! }
 //!
 //! // explicit `Default` implementation
 //! impl Default for Flags {
 //!     fn default() -> Flags {
-//!         FLAG_A | FLAG_C
+//!         Flags::FLAG_A | Flags::FLAG_C
 //!     }
 //! }
 //!
 //! fn main() {
 //!     let implemented_default: Flags = Default::default();
-//!     assert_eq!(implemented_default, (FLAG_A | FLAG_C));
+//!     assert_eq!(implemented_default, (Flags::FLAG_A | Flags::FLAG_C));
 //! }
 //! ```
 
 #![no_std]
 
-#![doc(html_root_url = "https://docs.rs/bitflags/0.9.1")]
+#![doc(html_root_url = "https://docs.rs/bitflags/1.0.0")]
 // When compiled for the rustc compiler itself we want to make sure that this is
 // an unstable crate.
 #![cfg_attr(rustbuild, feature(staged_api))]
 #![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))]
 
 #[cfg(test)]
 #[macro_use]
 extern crate std;
@@ -243,29 +244,29 @@ pub extern crate core as _core;
 /// #[macro_use]
 /// extern crate bitflags;
 ///
 /// bitflags! {
 ///     struct Flags: u32 {
 ///         const FLAG_A       = 0b00000001;
 ///         const FLAG_B       = 0b00000010;
 ///         const FLAG_C       = 0b00000100;
-///         const FLAG_ABC     = FLAG_A.bits
-///                            | FLAG_B.bits
-///                            | FLAG_C.bits;
+///         const FLAG_ABC     = Self::FLAG_A.bits
+///                            | Self::FLAG_B.bits
+///                            | Self::FLAG_C.bits;
 ///     }
 /// }
 ///
 /// fn main() {
-///     let e1 = FLAG_A | FLAG_C;
-///     let e2 = FLAG_B | FLAG_C;
-///     assert_eq!((e1 | e2), FLAG_ABC);   // union
-///     assert_eq!((e1 & e2), FLAG_C);     // intersection
-///     assert_eq!((e1 - e2), FLAG_A);     // set difference
-///     assert_eq!(!e2, FLAG_A);           // set complement
+///     let e1 = Flags::FLAG_A | Flags::FLAG_C;
+///     let e2 = Flags::FLAG_B | Flags::FLAG_C;
+///     assert_eq!((e1 | e2), Flags::FLAG_ABC);   // union
+///     assert_eq!((e1 & e2), Flags::FLAG_C);     // intersection
+///     assert_eq!((e1 - e2), Flags::FLAG_A);     // set difference
+///     assert_eq!(!e2, Flags::FLAG_A);           // set complement
 /// }
 /// ```
 ///
 /// The generated `struct`s can also be extended with type and trait
 /// implementations:
 ///
 /// ```
 /// #[macro_use]
@@ -289,69 +290,87 @@ pub extern crate core as _core;
 ///
 /// impl fmt::Display for Flags {
 ///     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 ///         write!(f, "hi!")
 ///     }
 /// }
 ///
 /// fn main() {
-///     let mut flags = FLAG_A | FLAG_B;
+///     let mut flags = Flags::FLAG_A | Flags::FLAG_B;
 ///     flags.clear();
 ///     assert!(flags.is_empty());
 ///     assert_eq!(format!("{}", flags), "hi!");
-///     assert_eq!(format!("{:?}", FLAG_A | FLAG_B), "FLAG_A | FLAG_B");
-///     assert_eq!(format!("{:?}", FLAG_B), "FLAG_B");
+///     assert_eq!(format!("{:?}", Flags::FLAG_A | Flags::FLAG_B), "FLAG_A | FLAG_B");
+///     assert_eq!(format!("{:?}", Flags::FLAG_B), "FLAG_B");
 /// }
 /// ```
 #[macro_export]
 macro_rules! bitflags {
-    ($(#[$attr:meta])* pub struct $BitFlags:ident: $T:ty {
-        $($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr;)+
-    }) => {
+    (
+        $(#[$outer:meta])*
+        pub struct $BitFlags:ident: $T:ty {
+            $(
+                $(#[$inner:ident $($args:tt)*])*
+                const $Flag:ident = $value:expr;
+            )+
+        }
+    ) => {
         #[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
-        $(#[$attr])*
+        $(#[$outer])*
         pub struct $BitFlags {
             bits: $T,
         }
 
-        $($(#[$Flag_attr])* pub const $Flag: $BitFlags = $BitFlags { bits: $value };)+
-
         __impl_bitflags! {
             struct $BitFlags: $T {
-                $($(#[$Flag_attr])* const $Flag = $value;)+
+                $(
+                    $(#[$inner $($args)*])*
+                    const $Flag = $value;
+                )+
             }
         }
     };
-    ($(#[$attr:meta])* struct $BitFlags:ident: $T:ty {
-        $($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr;)+
-    }) => {
+    (
+        $(#[$outer:meta])*
+        struct $BitFlags:ident: $T:ty {
+            $(
+                $(#[$inner:ident $($args:tt)*])*
+                const $Flag:ident = $value:expr;
+            )+
+        }
+    ) => {
         #[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
-        $(#[$attr])*
+        $(#[$outer])*
         struct $BitFlags {
             bits: $T,
         }
 
-        $($(#[$Flag_attr])* const $Flag: $BitFlags = $BitFlags { bits: $value };)+
-
         __impl_bitflags! {
             struct $BitFlags: $T {
-                $($(#[$Flag_attr])* const $Flag = $value;)+
+                $(
+                    $(#[$inner $($args)*])*
+                    const $Flag = $value;
+                )+
             }
         }
-
     };
 }
 
 #[macro_export]
 #[doc(hidden)]
 macro_rules! __impl_bitflags {
-    (struct $BitFlags:ident: $T:ty {
-        $($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr;)+
-    }) => {
+    (
+        struct $BitFlags:ident: $T:ty {
+            $(
+                $(#[$attr:ident $($args:tt)*])*
+                const $Flag:ident = $value:expr;
+            )+
+        }
+    ) => {
         impl $crate::_core::fmt::Debug for $BitFlags {
             fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
                 // This convoluted approach is to handle #[cfg]-based flag
                 // omission correctly. For example it needs to support:
                 //
                 //    #[cfg(unix)] const A: Flag = /* ... */;
                 //    #[cfg(windows)] const B: Flag = /* ... */;
 
@@ -363,19 +382,22 @@ macro_rules! __impl_bitflags {
                         fn $Flag(&self) -> bool { false }
                     )+
                 }
 
                 // Conditionally override the check for just those flags that
                 // are not #[cfg]ed away.
                 impl __BitFlags for $BitFlags {
                     $(
-                        $(#[$Flag_attr])*
-                        fn $Flag(&self) -> bool {
-                            self.bits & $Flag.bits == $Flag.bits
+                        __impl_bitflags! {
+                            #[allow(deprecated)]
+                            $(? #[$attr $($args)*])*
+                            fn $Flag(&self) -> bool {
+                                self.bits & Self::$Flag.bits == Self::$Flag.bits
+                            }
                         }
                     )+
                 }
 
                 let mut first = true;
                 $(
                     if <$BitFlags as __BitFlags>::$Flag(self) {
                         if !first {
@@ -409,16 +431,21 @@ macro_rules! __impl_bitflags {
         impl $crate::_core::fmt::UpperHex for $BitFlags {
             fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
                 $crate::_core::fmt::UpperHex::fmt(&self.bits, f)
             }
         }
 
         #[allow(dead_code)]
         impl $BitFlags {
+            $(
+                $(#[$attr $($args)*])*
+                pub const $Flag: $BitFlags = $BitFlags { bits: $value };
+            )+
+
             /// Returns an empty set of flags.
             #[inline]
             pub fn empty() -> $BitFlags {
                 $BitFlags { bits: 0 }
             }
 
             /// Returns the set containing all flags.
             #[inline]
@@ -427,18 +454,21 @@ macro_rules! __impl_bitflags {
                 #[allow(non_snake_case)]
                 trait __BitFlags {
                     $(
                         fn $Flag() -> $T { 0 }
                     )+
                 }
                 impl __BitFlags for $BitFlags {
                     $(
-                        $(#[$Flag_attr])*
-                        fn $Flag() -> $T { $Flag.bits }
+                        __impl_bitflags! {
+                            #[allow(deprecated)]
+                            $(? #[$attr $($args)*])*
+                            fn $Flag() -> $T { Self::$Flag.bits }
+                        }
                     )+
                 }
                 $BitFlags { bits: $(<$BitFlags as __BitFlags>::$Flag())|+ }
             }
 
             /// Returns the raw value of the flags currently stored.
             #[inline]
             pub fn bits(&self) -> $T {
@@ -613,222 +643,274 @@ macro_rules! __impl_bitflags {
         impl $crate::_core::iter::FromIterator<$BitFlags> for $BitFlags {
             fn from_iter<T: $crate::_core::iter::IntoIterator<Item=$BitFlags>>(iterator: T) -> $BitFlags {
                 let mut result = Self::empty();
                 result.extend(iterator);
                 result
             }
         }
     };
+
+    // Every attribute that the user writes on a const is applied to the
+    // corresponding const that we generate, but within the implementation of
+    // Debug and all() we want to ignore everything but #[cfg] attributes. In
+    // particular, including a #[deprecated] attribute on those items would fail
+    // to compile.
+    // https://github.com/rust-lang-nursery/bitflags/issues/109
+    //
+    // Input:
+    //
+    //     ? #[cfg(feature = "advanced")]
+    //     ? #[deprecated(note = "Use somthing else.")]
+    //     ? #[doc = r"High quality documentation."]
+    //     fn f() -> i32 { /* ... */ }
+    //
+    // Output:
+    //
+    //     #[cfg(feature = "advanced")]
+    //     fn f() -> i32 { /* ... */ }
+    (
+        $(#[$filtered:meta])*
+        ? #[cfg $($cfgargs:tt)*]
+        $(? #[$rest:ident $($restargs:tt)*])*
+        fn $($item:tt)*
+    ) => {
+        __impl_bitflags! {
+            $(#[$filtered])*
+            #[cfg $($cfgargs)*]
+            $(? #[$rest $($restargs)*])*
+            fn $($item)*
+        }
+    };
+    (
+        $(#[$filtered:meta])*
+        // $next != `cfg`
+        ? #[$next:ident $($nextargs:tt)*]
+        $(? #[$rest:ident $($restargs:tt)*])*
+        fn $($item:tt)*
+    ) => {
+        __impl_bitflags! {
+            $(#[$filtered])*
+            // $next filtered out
+            $(? #[$rest $($restargs)*])*
+            fn $($item)*
+        }
+    };
+    (
+        $(#[$filtered:meta])*
+        fn $($item:tt)*
+    ) => {
+        $(#[$filtered])*
+        fn $($item)*
+    };
 }
 
 #[cfg(feature = "example_generated")]
 pub mod example_generated;
 
 #[cfg(test)]
-#[allow(non_upper_case_globals, dead_code)]
 mod tests {
     use std::hash::{Hash, Hasher};
     use std::collections::hash_map::DefaultHasher;
 
     bitflags! {
         #[doc = "> The first principle is that you must not fool yourself — and"]
         #[doc = "> you are the easiest person to fool."]
         #[doc = "> "]
         #[doc = "> - Richard Feynman"]
         struct Flags: u32 {
-            const FlagA       = 0b00000001;
+            const FLAG_A       = 0b00000001;
             #[doc = "<pcwalton> macros are way better at generating code than trans is"]
-            const FlagB       = 0b00000010;
-            const FlagC       = 0b00000100;
+            const FLAG_B       = 0b00000010;
+            const FLAG_C       = 0b00000100;
             #[doc = "* cmr bed"]
             #[doc = "* strcat table"]
             #[doc = "<strcat> wait what?"]
-            const FlagABC     = FlagA.bits
-                               | FlagB.bits
-                               | FlagC.bits;
+            const FLAG_ABC     = Self::FLAG_A.bits
+                               | Self::FLAG_B.bits
+                               | Self::FLAG_C.bits;
         }
     }
 
     bitflags! {
         struct _CfgFlags: u32 {
             #[cfg(windows)]
-            const _CfgA = 0b01;
+            const _CFG_A = 0b01;
             #[cfg(unix)]
-            const _CfgB = 0b01;
+            const _CFG_B = 0b01;
             #[cfg(windows)]
-            const _CfgC = _CfgA.bits | 0b10;
+            const _CFG_C = _CFG_A.bits | 0b10;
         }
     }
 
     bitflags! {
         struct AnotherSetOfFlags: i8 {
-            const AnotherFlag = -1_i8;
+            const ANOTHER_FLAG = -1_i8;
         }
     }
 
     bitflags! {
         struct LongFlags: u32 {
-            const LongFlagA = 0b1111111111111111;
+            const LONG_FLAG_A = 0b1111111111111111;
         }
     }
 
     #[test]
     fn test_bits(){
         assert_eq!(Flags::empty().bits(), 0b00000000);
-        assert_eq!(FlagA.bits(), 0b00000001);
-        assert_eq!(FlagABC.bits(), 0b00000111);
+        assert_eq!(Flags::FLAG_A.bits(), 0b00000001);
+        assert_eq!(Flags::FLAG_ABC.bits(), 0b00000111);
 
         assert_eq!(AnotherSetOfFlags::empty().bits(), 0b00);
-        assert_eq!(AnotherFlag.bits(), !0_i8);
+        assert_eq!(AnotherSetOfFlags::ANOTHER_FLAG.bits(), !0_i8);
     }
 
     #[test]
     fn test_from_bits() {
         assert_eq!(Flags::from_bits(0), Some(Flags::empty()));
-        assert_eq!(Flags::from_bits(0b1), Some(FlagA));
-        assert_eq!(Flags::from_bits(0b10), Some(FlagB));
-        assert_eq!(Flags::from_bits(0b11), Some(FlagA | FlagB));
+        assert_eq!(Flags::from_bits(0b1), Some(Flags::FLAG_A));
+        assert_eq!(Flags::from_bits(0b10), Some(Flags::FLAG_B));
+        assert_eq!(Flags::from_bits(0b11), Some(Flags::FLAG_A | Flags::FLAG_B));
         assert_eq!(Flags::from_bits(0b1000), None);
 
-        assert_eq!(AnotherSetOfFlags::from_bits(!0_i8), Some(AnotherFlag));
+        assert_eq!(AnotherSetOfFlags::from_bits(!0_i8), Some(AnotherSetOfFlags::ANOTHER_FLAG));
     }
 
     #[test]
     fn test_from_bits_truncate() {
         assert_eq!(Flags::from_bits_truncate(0), Flags::empty());
-        assert_eq!(Flags::from_bits_truncate(0b1), FlagA);
-        assert_eq!(Flags::from_bits_truncate(0b10), FlagB);
-        assert_eq!(Flags::from_bits_truncate(0b11), (FlagA | FlagB));
+        assert_eq!(Flags::from_bits_truncate(0b1), Flags::FLAG_A);
+        assert_eq!(Flags::from_bits_truncate(0b10), Flags::FLAG_B);
+        assert_eq!(Flags::from_bits_truncate(0b11), (Flags::FLAG_A | Flags::FLAG_B));
         assert_eq!(Flags::from_bits_truncate(0b1000), Flags::empty());
-        assert_eq!(Flags::from_bits_truncate(0b1001), FlagA);
+        assert_eq!(Flags::from_bits_truncate(0b1001), Flags::FLAG_A);
 
         assert_eq!(AnotherSetOfFlags::from_bits_truncate(0_i8), AnotherSetOfFlags::empty());
     }
 
     #[test]
     fn test_is_empty(){
         assert!(Flags::empty().is_empty());
-        assert!(!FlagA.is_empty());
-        assert!(!FlagABC.is_empty());
+        assert!(!Flags::FLAG_A.is_empty());
+        assert!(!Flags::FLAG_ABC.is_empty());
 
-        assert!(!AnotherFlag.is_empty());
+        assert!(!AnotherSetOfFlags::ANOTHER_FLAG.is_empty());
     }
 
     #[test]
     fn test_is_all() {
         assert!(Flags::all().is_all());
-        assert!(!FlagA.is_all());
-        assert!(FlagABC.is_all());
+        assert!(!Flags::FLAG_A.is_all());
+        assert!(Flags::FLAG_ABC.is_all());
 
-        assert!(AnotherFlag.is_all());
+        assert!(AnotherSetOfFlags::ANOTHER_FLAG.is_all());
     }
 
     #[test]
     fn test_two_empties_do_not_intersect() {
         let e1 = Flags::empty();
         let e2 = Flags::empty();
         assert!(!e1.intersects(e2));
 
-        assert!(AnotherFlag.intersects(AnotherFlag));
+        assert!(AnotherSetOfFlags::ANOTHER_FLAG.intersects(AnotherSetOfFlags::ANOTHER_FLAG));
     }
 
     #[test]
     fn test_empty_does_not_intersect_with_full() {
         let e1 = Flags::empty();
-        let e2 = FlagABC;
+        let e2 = Flags::FLAG_ABC;
         assert!(!e1.intersects(e2));
     }
 
     #[test]
     fn test_disjoint_intersects() {
-        let e1 = FlagA;
-        let e2 = FlagB;
+        let e1 = Flags::FLAG_A;
+        let e2 = Flags::FLAG_B;
         assert!(!e1.intersects(e2));
     }
 
     #[test]
     fn test_overlapping_intersects() {
-        let e1 = FlagA;
-        let e2 = FlagA | FlagB;
+        let e1 = Flags::FLAG_A;
+        let e2 = Flags::FLAG_A | Flags::FLAG_B;
         assert!(e1.intersects(e2));
     }
 
     #[test]
     fn test_contains() {
-        let e1 = FlagA;
-        let e2 = FlagA | FlagB;
+        let e1 = Flags::FLAG_A;
+        let e2 = Flags::FLAG_A | Flags::FLAG_B;
         assert!(!e1.contains(e2));
         assert!(e2.contains(e1));
-        assert!(FlagABC.contains(e2));
+        assert!(Flags::FLAG_ABC.contains(e2));
 
-        assert!(AnotherFlag.contains(AnotherFlag));
+        assert!(AnotherSetOfFlags::ANOTHER_FLAG.contains(AnotherSetOfFlags::ANOTHER_FLAG));
     }
 
     #[test]
     fn test_insert(){
-        let mut e1 = FlagA;
-        let e2 = FlagA | FlagB;
+        let mut e1 = Flags::FLAG_A;
+        let e2 = Flags::FLAG_A | Flags::FLAG_B;
         e1.insert(e2);
         assert_eq!(e1, e2);
 
         let mut e3 = AnotherSetOfFlags::empty();
-        e3.insert(AnotherFlag);
-        assert_eq!(e3, AnotherFlag);
+        e3.insert(AnotherSetOfFlags::ANOTHER_FLAG);
+        assert_eq!(e3, AnotherSetOfFlags::ANOTHER_FLAG);
     }
 
     #[test]
     fn test_remove(){
-        let mut e1 = FlagA | FlagB;
-        let e2 = FlagA | FlagC;
+        let mut e1 = Flags::FLAG_A | Flags::FLAG_B;
+        let e2 = Flags::FLAG_A | Flags::FLAG_C;
         e1.remove(e2);
-        assert_eq!(e1, FlagB);
+        assert_eq!(e1, Flags::FLAG_B);
 
-        let mut e3 = AnotherFlag;
-        e3.remove(AnotherFlag);
+        let mut e3 = AnotherSetOfFlags::ANOTHER_FLAG;
+        e3.remove(AnotherSetOfFlags::ANOTHER_FLAG);
         assert_eq!(e3, AnotherSetOfFlags::empty());
     }
 
     #[test]
     fn test_operators() {
-        let e1 = FlagA | FlagC;
-        let e2 = FlagB | FlagC;
-        assert_eq!((e1 | e2), FlagABC);     // union
-        assert_eq!((e1 & e2), FlagC);       // intersection
-        assert_eq!((e1 - e2), FlagA);       // set difference
-        assert_eq!(!e2, FlagA);             // set complement
-        assert_eq!(e1 ^ e2, FlagA | FlagB); // toggle
+        let e1 = Flags::FLAG_A | Flags::FLAG_C;
+        let e2 = Flags::FLAG_B | Flags::FLAG_C;
+        assert_eq!((e1 | e2), Flags::FLAG_ABC);     // union
+        assert_eq!((e1 & e2), Flags::FLAG_C);       // intersection
+        assert_eq!((e1 - e2), Flags::FLAG_A);       // set difference
+        assert_eq!(!e2, Flags::FLAG_A);             // set complement
+        assert_eq!(e1 ^ e2, Flags::FLAG_A | Flags::FLAG_B); // toggle
         let mut e3 = e1;
         e3.toggle(e2);
-        assert_eq!(e3, FlagA | FlagB);
+        assert_eq!(e3, Flags::FLAG_A | Flags::FLAG_B);
 
         let mut m4 = AnotherSetOfFlags::empty();
         m4.toggle(AnotherSetOfFlags::empty());
         assert_eq!(m4, AnotherSetOfFlags::empty());
     }
 
     #[test]
     fn test_set() {
-        let mut e1 = FlagA | FlagC;
-        e1.set(FlagB, true);
-        e1.set(FlagC, false);
+        let mut e1 = Flags::FLAG_A | Flags::FLAG_C;
+        e1.set(Flags::FLAG_B, true);
+        e1.set(Flags::FLAG_C, false);
 
-        assert_eq!(e1, FlagA | FlagB);
+        assert_eq!(e1, Flags::FLAG_A | Flags::FLAG_B);
     }
 
     #[test]
     fn test_assignment_operators() {
         let mut m1 = Flags::empty();
-        let e1 = FlagA | FlagC;
+        let e1 = Flags::FLAG_A | Flags::FLAG_C;
         // union
-        m1 |= FlagA;
-        assert_eq!(m1, FlagA);
+        m1 |= Flags::FLAG_A;
+        assert_eq!(m1, Flags::FLAG_A);
         // intersection
         m1 &= e1;
-        assert_eq!(m1, FlagA);
+        assert_eq!(m1, Flags::FLAG_A);
         // set difference
         m1 -= m1;
         assert_eq!(m1, Flags::empty());
         // toggle
         m1 ^= e1;
         assert_eq!(m1, e1);
     }
 
@@ -836,131 +918,134 @@ mod tests {
     fn test_extend() {
         let mut flags;
 
         flags = Flags::empty();
         flags.extend([].iter().cloned());
         assert_eq!(flags, Flags::empty());
 
         flags = Flags::empty();
-        flags.extend([FlagA, FlagB].iter().cloned());
-        assert_eq!(flags, FlagA | FlagB);
+        flags.extend([Flags::FLAG_A, Flags::FLAG_B].iter().cloned());
+        assert_eq!(flags, Flags::FLAG_A | Flags::FLAG_B);
 
-        flags = FlagA;
-        flags.extend([FlagA, FlagB].iter().cloned());
-        assert_eq!(flags, FlagA | FlagB);
+        flags = Flags::FLAG_A;
+        flags.extend([Flags::FLAG_A, Flags::FLAG_B].iter().cloned());
+        assert_eq!(flags, Flags::FLAG_A | Flags::FLAG_B);
 
-        flags = FlagB;
-        flags.extend([FlagA, FlagABC].iter().cloned());
-        assert_eq!(flags, FlagABC);
+        flags = Flags::FLAG_B;
+        flags.extend([Flags::FLAG_A, Flags::FLAG_ABC].iter().cloned());
+        assert_eq!(flags, Flags::FLAG_ABC);
     }
 
     #[test]
     fn test_from_iterator() {
         assert_eq!([].iter().cloned().collect::<Flags>(), Flags::empty());
-        assert_eq!([FlagA, FlagB].iter().cloned().collect::<Flags>(), FlagA | FlagB);
-        assert_eq!([FlagA, FlagABC].iter().cloned().collect::<Flags>(), FlagABC);
+        assert_eq!([Flags::FLAG_A, Flags::FLAG_B].iter().cloned().collect::<Flags>(),
+                   Flags::FLAG_A | Flags::FLAG_B);
+        assert_eq!([Flags::FLAG_A, Flags::FLAG_ABC].iter().cloned().collect::<Flags>(),
+                   Flags::FLAG_ABC);
     }
 
     #[test]
     fn test_lt() {
         let mut a = Flags::empty();
         let mut b = Flags::empty();
 
         assert!(!(a < b) && !(b < a));
-        b = FlagB;
+        b = Flags::FLAG_B;
         assert!(a < b);
-        a = FlagC;
+        a = Flags::FLAG_C;
         assert!(!(a < b) && b < a);
-        b = FlagC | FlagB;
+        b = Flags::FLAG_C | Flags::FLAG_B;
         assert!(a < b);
     }
 
     #[test]
     fn test_ord() {
         let mut a = Flags::empty();
         let mut b = Flags::empty();
 
         assert!(a <= b && a >= b);
-        a = FlagA;
+        a = Flags::FLAG_A;
         assert!(a > b && a >= b);
         assert!(b < a && b <= a);
-        b = FlagB;
+        b = Flags::FLAG_B;
         assert!(b > a && b >= a);
         assert!(a < b && a <= b);
     }
 
     fn hash<T: Hash>(t: &T) -> u64 {
         let mut s = DefaultHasher::new();
         t.hash(&mut s);
         s.finish()
     }
 
     #[test]
     fn test_hash() {
         let mut x = Flags::empty();
         let mut y = Flags::empty();
         assert_eq!(hash(&x), hash(&y));
         x = Flags::all();
-        y = FlagABC;
+        y = Flags::FLAG_ABC;
         assert_eq!(hash(&x), hash(&y));
     }
 
     #[test]
     fn test_debug() {
-        assert_eq!(format!("{:?}", FlagA | FlagB), "FlagA | FlagB");
+        assert_eq!(format!("{:?}", Flags::FLAG_A | Flags::FLAG_B), "FLAG_A | FLAG_B");
         assert_eq!(format!("{:?}", Flags::empty()), "(empty)");
-        assert_eq!(format!("{:?}", FlagABC), "FlagA | FlagB | FlagC | FlagABC");
+        assert_eq!(format!("{:?}", Flags::FLAG_ABC), "FLAG_A | FLAG_B | FLAG_C | FLAG_ABC");
     }
 
     #[test]
     fn test_binary() {
-        assert_eq!(format!("{:b}", FlagABC), "111");
-        assert_eq!(format!("{:#b}", FlagABC), "0b111");
+        assert_eq!(format!("{:b}", Flags::FLAG_ABC), "111");
+        assert_eq!(format!("{:#b}", Flags::FLAG_ABC), "0b111");
     }
 
     #[test]
     fn test_octal() {
-        assert_eq!(format!("{:o}", LongFlagA), "177777");
-        assert_eq!(format!("{:#o}", LongFlagA), "0o177777");
+        assert_eq!(format!("{:o}", LongFlags::LONG_FLAG_A), "177777");
+        assert_eq!(format!("{:#o}", LongFlags::LONG_FLAG_A), "0o177777");
     }
 
     #[test]
     fn test_lowerhex() {
-        assert_eq!(format!("{:x}", LongFlagA), "ffff");
-        assert_eq!(format!("{:#x}", LongFlagA), "0xffff");
+        assert_eq!(format!("{:x}", LongFlags::LONG_FLAG_A), "ffff");
+        assert_eq!(format!("{:#x}", LongFlags::LONG_FLAG_A), "0xffff");
     }
 
     #[test]
     fn test_upperhex() {
-        assert_eq!(format!("{:X}", LongFlagA), "FFFF");
-        assert_eq!(format!("{:#X}", LongFlagA), "0xFFFF");
+        assert_eq!(format!("{:X}", LongFlags::LONG_FLAG_A), "FFFF");
+        assert_eq!(format!("{:#X}", LongFlags::LONG_FLAG_A), "0xFFFF");
     }
 
     mod submodule {
         bitflags! {
             pub struct PublicFlags: i8 {
-                const FlagX = 0;
+                const FLAG_X = 0;
             }
         }
         bitflags! {
             struct PrivateFlags: i8 {
-                const FlagY = 0;
+                const FLAG_Y = 0;
             }
         }
 
         #[test]
         fn test_private() {
-            let _ = FlagY;
+
+            let _ = PrivateFlags::FLAG_Y;
         }
     }
 
     #[test]
     fn test_public() {
-        let _ = submodule::FlagX;
+        let _ = submodule::PublicFlags::FLAG_X;
     }
 
     mod t1 {
         mod foo {
             pub type Bar = i32;
         }
 
         bitflags! {
@@ -979,12 +1064,22 @@ mod tests {
     fn test_in_function() {
         bitflags! {
            struct Flags: u8 {
                 const A = 1;
                 #[cfg(any())] // false
                 const B = 2;
             }
         }
-        assert_eq!(Flags::all(), A);
-        assert_eq!(format!("{:?}", A), "A");
+        assert_eq!(Flags::all(), Flags::A);
+        assert_eq!(format!("{:?}", Flags::A), "A");
+    }
+
+    #[test]
+    fn test_deprecated() {
+        bitflags! {
+            pub struct TestFlags: u32 {
+                #[deprecated(note = "Use something else.")]
+                const FLAG_ONE = 1;
+            }
+        }
     }
 }
--- a/third_party/rust/bitflags/tests/conflicting_trait_impls.rs
+++ b/third_party/rust/bitflags/tests/conflicting_trait_impls.rs
@@ -1,9 +1,8 @@
-#![allow(dead_code)]
 #![no_std]
 
 #[macro_use]
 extern crate bitflags;
 
 #[allow(unused_imports)]
 use core::fmt::Display;
 
--- a/third_party/rust/bitflags/tests/external.rs
+++ b/third_party/rust/bitflags/tests/external.rs
@@ -1,21 +1,19 @@
-#![allow(dead_code)]
-
 #[macro_use]
 extern crate bitflags;
 
 bitflags! {
     /// baz
     struct Flags: u32 {
         const A       = 0b00000001;
         #[doc = "bar"]
         const B       = 0b00000010;
         const C       = 0b00000100;
         #[doc = "foo"]
-        const ABC     = A.bits | B.bits | C.bits;
+        const ABC     = Flags::A.bits | Flags::B.bits | Flags::C.bits;
     }
 }
 
 #[test]
 fn smoke() {
-    assert_eq!(ABC, A | B | C);
+    assert_eq!(Flags::ABC, Flags::A | Flags::B | Flags::C);
 }
--- a/third_party/rust/bitflags/tests/external_no_std.rs
+++ b/third_party/rust/bitflags/tests/external_no_std.rs
@@ -1,22 +1,21 @@
-#![allow(dead_code)]
 #![no_std]
 
 #[macro_use]
 extern crate bitflags;
 
 bitflags! {
     /// baz
     struct Flags: u32 {
         const A       = 0b00000001;
         #[doc = "bar"]
         const B       = 0b00000010;
         const C       = 0b00000100;
         #[doc = "foo"]
-        const ABC     = A.bits | B.bits | C.bits;
+        const ABC     = Flags::A.bits | Flags::B.bits | Flags::C.bits;
     }
 }
 
 #[test]
 fn smoke() {
-    assert_eq!(ABC, A | B | C);
+    assert_eq!(Flags::ABC, Flags::A | Flags::B | Flags::C);
 }
--- a/third_party/rust/bitflags/tests/i128_bitflags.rs
+++ b/third_party/rust/bitflags/tests/i128_bitflags.rs
@@ -1,30 +1,29 @@
 #![cfg(feature = "unstable_testing")]
 
-#![allow(dead_code, unused_imports)]
 #![feature(i128_type)]
 
 #[macro_use]
 extern crate bitflags;
 
 bitflags! {
     /// baz
     struct Flags128: u128 {
         const A       = 0x0000_0000_0000_0000_0000_0000_0000_0001;
         const B       = 0x0000_0000_0000_1000_0000_0000_0000_0000;
         const C       = 0x8000_0000_0000_0000_0000_0000_0000_0000;
-        const ABC     = A.bits | B.bits | C.bits;
+        const ABC     = Self::A.bits | Self::B.bits | Self::C.bits;
     }
 }
 
 #[test]
 fn test_i128_bitflags() {
-    assert_eq!(ABC, A | B | C);
-    assert_eq!(A.bits, 0x0000_0000_0000_0000_0000_0000_0000_0001);
-    assert_eq!(B.bits, 0x0000_0000_0000_1000_0000_0000_0000_0000);
-    assert_eq!(C.bits, 0x8000_0000_0000_0000_0000_0000_0000_0000);
-    assert_eq!(ABC.bits, 0x8000_0000_0000_1000_0000_0000_0000_0001);
-    assert_eq!(format!("{:?}", A), "A");
-    assert_eq!(format!("{:?}", B), "B");
-    assert_eq!(format!("{:?}", C), "C");
-    assert_eq!(format!("{:?}", ABC), "A | B | C | ABC");
+    assert_eq!(Flags128::ABC, Flags128::A | Flags128::B | Flags128::C);
+    assert_eq!(Flags128::A.bits, 0x0000_0000_0000_0000_0000_0000_0000_0001);
+    assert_eq!(Flags128::B.bits, 0x0000_0000_0000_1000_0000_0000_0000_0000);
+    assert_eq!(Flags128::C.bits, 0x8000_0000_0000_0000_0000_0000_0000_0000);
+    assert_eq!(Flags128::ABC.bits, 0x8000_0000_0000_1000_0000_0000_0000_0001);
+    assert_eq!(format!("{:?}", Flags128::A), "A");
+    assert_eq!(format!("{:?}", Flags128::B), "B");
+    assert_eq!(format!("{:?}", Flags128::C), "C");
+    assert_eq!(format!("{:?}", Flags128::ABC), "A | B | C | ABC");
 }
--- a/toolkit/library/gtest/rust/Cargo.lock
+++ b/toolkit/library/gtest/rust/Cargo.lock
@@ -186,16 +186,21 @@ version = "0.8.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "bitflags"
 version = "0.9.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
+name = "bitflags"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
 name = "bitreader"
 version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "boxfnonce"
 version = "0.0.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1587,17 +1592,17 @@ dependencies = [
 ]
 
 [[package]]
 name = "webrender"
 version = "0.52.1"
 dependencies = [
  "app_units 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "bincode 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-text 7.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1614,17 +1619,17 @@ dependencies = [
 ]
 
 [[package]]
 name = "webrender_api"
 version = "0.52.1"
 dependencies = [
  "app_units 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "bincode 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1683,16 +1688,17 @@ dependencies = [
 "checksum backtrace-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d192fd129132fbc97497c1f2ec2c2c5174e376b95f535199ef4fe0a293d33842"
 "checksum binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88ceb0d16c4fd0e42876e298d7d3ce3780dd9ebdcbe4199816a32c77e08597ff"
 "checksum bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e103c8b299b28a9c6990458b7013dc4a8356a9b854c51b9883241f5866fac36e"
 "checksum bincode 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d3fb369af639822830328794eba2501b3479652fcd021b2aeb1ed4984202afd"
 "checksum bindgen 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ba610cba0c1727ed837316540068b51349b8268c073906067b7c3948598929bd"
 "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
 "checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"
 "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
+"checksum bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5cde24d1b2e2216a726368b2363a273739c91f4e3eb4e0dd12d672d396ad989"
 "checksum bitreader 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "80b13e2ab064ff3aa0bdbf1eff533f9822dc37899821f5f98c67f263eab51707"
 "checksum boxfnonce 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8380105befe91099e6f69206164072c05bc92427ff6aa8a5171388317346dd75"
 "checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8"
 "checksum bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d828f97b58cc5de3e40c421d0cf2132d6b2da4ee0e11b8632fa838f0f9333ad6"
 "checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d"
 "checksum cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c47d456a36ebf0536a6705c83c1cbbcb9255fbc1d905a6ded104f479268a29"
 "checksum clang-sys 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5955eab05fa8e6ff2b353753dc73a0608daa36e472a21c69f2eb51f43f593544"
 "checksum clap 2.25.0 (registry+https://github.com/rust-lang/crates.io-index)" = "867a885995b4184be051b70a592d4d70e32d7a188db6e8dff626af286a962771"
--- a/toolkit/library/rust/Cargo.lock
+++ b/toolkit/library/rust/Cargo.lock
@@ -185,16 +185,21 @@ version = "0.8.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "bitflags"
 version = "0.9.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
+name = "bitflags"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
 name = "bitreader"
 version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "boxfnonce"
 version = "0.0.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1599,17 +1604,17 @@ dependencies = [
 ]
 
 [[package]]
 name = "webrender"
 version = "0.52.1"
 dependencies = [
  "app_units 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "bincode 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-text 7.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1626,17 +1631,17 @@ dependencies = [
 ]
 
 [[package]]
 name = "webrender_api"
 version = "0.52.1"
 dependencies = [
  "app_units 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "bincode 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1695,16 +1700,17 @@ dependencies = [
 "checksum backtrace-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d192fd129132fbc97497c1f2ec2c2c5174e376b95f535199ef4fe0a293d33842"
 "checksum binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88ceb0d16c4fd0e42876e298d7d3ce3780dd9ebdcbe4199816a32c77e08597ff"
 "checksum bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e103c8b299b28a9c6990458b7013dc4a8356a9b854c51b9883241f5866fac36e"
 "checksum bincode 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d3fb369af639822830328794eba2501b3479652fcd021b2aeb1ed4984202afd"
 "checksum bindgen 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ba610cba0c1727ed837316540068b51349b8268c073906067b7c3948598929bd"
 "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
 "checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"
 "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
+"checksum bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5cde24d1b2e2216a726368b2363a273739c91f4e3eb4e0dd12d672d396ad989"
 "checksum bitreader 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "80b13e2ab064ff3aa0bdbf1eff533f9822dc37899821f5f98c67f263eab51707"
 "checksum boxfnonce 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8380105befe91099e6f69206164072c05bc92427ff6aa8a5171388317346dd75"
 "checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8"
 "checksum bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d828f97b58cc5de3e40c421d0cf2132d6b2da4ee0e11b8632fa838f0f9333ad6"
 "checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d"
 "checksum cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c47d456a36ebf0536a6705c83c1cbbcb9255fbc1d905a6ded104f479268a29"
 "checksum clang-sys 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5955eab05fa8e6ff2b353753dc73a0608daa36e472a21c69f2eb51f43f593544"
 "checksum clap 2.25.0 (registry+https://github.com/rust-lang/crates.io-index)" = "867a885995b4184be051b70a592d4d70e32d7a188db6e8dff626af286a962771"