[rust] Add tempfile 3.0.4

tempdir has been deprecated, and instead it recommends
use the tempfile crate to create temporary directories:

https: //github.com/rust-lang-deprecated/tempdir#deprecation-note
Change-Id: Ie51a93fc6df8ec7256d285bd8e223dac18e04750
diff --git a/rustc_deps/Cargo.lock b/rustc_deps/Cargo.lock
index 51401d8..223e81d 100644
--- a/rustc_deps/Cargo.lock
+++ b/rustc_deps/Cargo.lock
@@ -212,6 +212,14 @@
 ]
 
 [[package]]
+name = "cloudabi"
+version = "0.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
 name = "crc"
 version = "1.8.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -413,6 +421,7 @@
  "slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "structopt 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
  "timebomb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -938,6 +947,31 @@
 ]
 
 [[package]]
+name = "rand"
+version = "0.5.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "fuchsia-zircon 0.3.3",
+ "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
 name = "redox_syscall"
 version = "0.1.37"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1187,6 +1221,19 @@
 ]
 
 [[package]]
+name = "tempfile"
+version = "3.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
+ "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
 name = "term"
 version = "0.2.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1516,6 +1563,7 @@
 "checksum chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1cce36c92cb605414e9b824f866f5babe0a0368e39ea07393b9b63cf3844c0e6"
 "checksum chunked_transfer 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "498d20a7aaf62625b9bf26e637cf7736417cde1d0c99f1d04d1170229a85cf87"
 "checksum clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536"
+"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
 "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb"
 "checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19"
 "checksum deflate 0.7.18 (registry+https://github.com/rust-lang/crates.io-index)" = "32c8120d981901a9970a3a1c97cf8b630e0fa8c3ca31e75b6fd6fd5f9f427b31"
@@ -1595,6 +1643,9 @@
 "checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8"
 "checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1"
 "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5"
+"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
+"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372"
+"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db"
 "checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd"
 "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
 "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
@@ -1624,6 +1675,7 @@
 "checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd"
 "checksum syntect 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eceb461f684c9e8e00f7a50055698af62c76d5b86e4ad50b4311acd5f655d606"
 "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
+"checksum tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "55c1195ef8513f3273d55ff59fe5da6940287a0d7a98331254397f464833675b"
 "checksum term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "f2077e54d38055cf1ca0fd7933a2e00cd3ec8f6fed352b2a377f06dcdaaf3281"
 "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
 "checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693"
diff --git a/rustc_deps/Cargo.toml b/rustc_deps/Cargo.toml
index 44e7c52..eb6ec42 100644
--- a/rustc_deps/Cargo.toml
+++ b/rustc_deps/Cargo.toml
@@ -44,6 +44,7 @@
 slab = "0.4"
 structopt = "0.2.4"
 tempdir = "0.3"
+tempfile = "3"
 time = "0.1"
 timebomb = "0.1.2"
 toml = "0.4"
diff --git a/rustc_deps/vendor/cloudabi/.cargo-checksum.json b/rustc_deps/vendor/cloudabi/.cargo-checksum.json
new file mode 100644
index 0000000..f79ba65
--- /dev/null
+++ b/rustc_deps/vendor/cloudabi/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"Cargo.toml":"16ef935056e2aaf48b28c1340a63cc75febaabc901c752da9a3a2edbe081b429","bitflags.rs":"4621173dcf1307094cf240d26955b6f25c2f770dfd4e975ec2728771209006b5","cloudabi.rs":"93e139ba72a04db4934b04a6f21b054757a218a687e0bd2f6ba32514ec8c5f38"},"package":"ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"}
\ No newline at end of file
diff --git a/rustc_deps/vendor/cloudabi/Cargo.toml b/rustc_deps/vendor/cloudabi/Cargo.toml
new file mode 100644
index 0000000..ed0daf9
--- /dev/null
+++ b/rustc_deps/vendor/cloudabi/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 = "cloudabi"
+version = "0.0.3"
+authors = ["Nuxi (https://nuxi.nl/) and contributors"]
+description = "Low level interface to CloudABI. Contains all syscalls and related types."
+homepage = "https://nuxi.nl/cloudabi/"
+documentation = "https://docs.rs/cloudabi/"
+keywords = ["cloudabi"]
+license = "BSD-2-Clause"
+repository = "https://github.com/nuxinl/cloudabi"
+
+[lib]
+path = "cloudabi.rs"
+[dependencies.bitflags]
+version = "1.0"
+optional = true
+
+[features]
+default = ["bitflags"]
diff --git a/rustc_deps/vendor/cloudabi/LICENSE b/rustc_deps/vendor/cloudabi/LICENSE
new file mode 100644
index 0000000..5f97bf7
--- /dev/null
+++ b/rustc_deps/vendor/cloudabi/LICENSE
@@ -0,0 +1,26 @@
+https://raw.githubusercontent.com/nuxinl/cloudabi/master/LICENSE:
+
+All files in this directory are distributed under the following license:
+
+  Copyright (c) 2016-2017 Nuxi (https://nuxi.nl/) and contributors.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in the
+     documentation and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  SUCH DAMAGE.
diff --git a/rustc_deps/vendor/cloudabi/bitflags.rs b/rustc_deps/vendor/cloudabi/bitflags.rs
new file mode 100644
index 0000000..f764cc1
--- /dev/null
+++ b/rustc_deps/vendor/cloudabi/bitflags.rs
@@ -0,0 +1,51 @@
+// Copyright (c) 2018 Nuxi (https://nuxi.nl/) and contributors.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE.
+
+// Appease Rust's tidy.
+// ignore-license
+
+#[cfg(feature = "bitflags")]
+#[macro_use]
+extern crate bitflags;
+
+// Minimal implementation of bitflags! in case we can't depend on the bitflags
+// crate. Only implements `bits()` and a `from_bits_truncate()` that doesn't
+// actually truncate.
+#[cfg(not(feature = "bitflags"))]
+macro_rules! bitflags {
+  (
+    $(#[$attr:meta])*
+    pub struct $name:ident: $type:ty {
+      $($(#[$const_attr:meta])* const $const:ident = $val:expr;)*
+    }
+  ) => {
+    $(#[$attr])*
+    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+    pub struct $name { bits: $type }
+    impl $name {
+      $($(#[$const_attr])* pub const $const: $name = $name{ bits: $val };)*
+      pub fn bits(&self) -> $type { self.bits }
+      pub fn from_bits_truncate(bits: $type) -> Self { $name{ bits } }
+    }
+  }
+}
diff --git a/rustc_deps/vendor/cloudabi/cloudabi.rs b/rustc_deps/vendor/cloudabi/cloudabi.rs
new file mode 100644
index 0000000..2909db5
--- /dev/null
+++ b/rustc_deps/vendor/cloudabi/cloudabi.rs
@@ -0,0 +1,2847 @@
+// Copyright (c) 2016-2017 Nuxi (https://nuxi.nl/) and contributors.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE.
+//
+// This file is automatically generated. Do not edit.
+//
+// Source: https://github.com/NuxiNL/cloudabi
+
+// Appease Rust's tidy.
+// ignore-license
+// ignore-tidy-linelength
+
+//! **PLEASE NOTE: This entire crate including this
+//! documentation is automatically generated from
+//! [`cloudabi.txt`](https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt)**
+//!
+//! # Nuxi CloudABI
+//!
+//! CloudABI is what you get if you take POSIX, add capability-based
+//! security, and remove everything that's incompatible with that. The
+//! result is a minimal ABI consisting of only 49 syscalls.
+//!
+//! CloudABI doesn't have its own kernel, but instead is implemented in existing
+//! kernels: FreeBSD has CloudABI support for x86-64 and arm64, and [a patch-set
+//! for NetBSD](https://github.com/NuxiNL/netbsd) and [a patch-set for
+//! Linux](https://github.com/NuxiNL/linux) are available as well. This means that
+//! CloudABI binaries can be executed on different operating systems, without any
+//! modification.
+//!
+//! ## Capability-Based Security
+//!
+//! Capability-based security means that processes can only perform
+//! actions that have no global impact. Processes cannot open files by
+//! their absolute path, cannot open network connections, and cannot
+//! observe global system state such as the process table.
+//!
+//! The capabilities of a process are fully determined by its set of open
+//! file descriptors (fds). For example, files can only be opened if the
+//! process already has a file descriptor to a directory the file is in.
+//!
+//! Unlike in POSIX, where processes are normally started with file
+//! descriptors 0, 1, and 2 reserved for standard input, output, and
+//! error, CloudABI does not reserve any file descriptor numbers for
+//! specific purposes.
+//!
+//! In CloudABI, a process depends on its parent process to launch it with
+//! the right set of resources, since the process will not be able to open
+//! any new resources. For example, a simple static web server would need
+//! to be started with a file descriptor to a [TCP
+//! listener](https://github.com/NuxiNL/flower), and a file descriptor to
+//! the directory for which to serve files. The web server will then be
+//! unable to do anything other than reading files in that directory, and
+//! process incoming network connections.
+//!
+//! So, unknown CloudABI binaries can safely be executed without the need
+//! for containers, virtual machines, or other sandboxing technologies.
+//!
+//! Watch [Ed Schouten's Talk at
+//! 32C3](https://www.youtube.com/watch?v=3N29vrPoDv8) for more
+//! information about what capability-based security for UNIX means.
+//!
+//! ## Cloudlibc
+//!
+//! [Cloudlibc](https://github.com/NuxiNL/cloudlibc) is an implementation
+//! of the C standard library, without all CloudABI-incompatible
+//! functions. For example, Cloudlibc does not have `printf`, but does
+//! have `fprintf`. It does not have `open`, but does have `openat`.
+//!
+//! ## CloudABI-Ports
+//!
+//! [CloudABI-Ports](https://github.com/NuxiNL/cloudabi-ports) is a
+//! collection of ports of commonly used libraries and applications to
+//! CloudABI. It contains software such as `zlib`, `libpng`, `boost`,
+//! `memcached`, and much more. The software is patched to not depend on
+//! any global state, such as files in `/etc` or `/dev`, using `open()`,
+//! etc.
+//!
+//! ## Using CloudABI
+//!
+//! Instructions for using CloudABI (including kernel modules/patches,
+//! toolchain, and ports) are available for several operating systems:
+//!
+//! - [Arch Linux](https://nuxi.nl/cloudabi/archlinux/)
+//! - [Debian, Ubuntu, and other Debian derivatives](https://nuxi.nl/cloudabi/debian/)
+//! - [FreeBSD, PC-BSD and DragonFly BSD](https://nuxi.nl/cloudabi/freebsd/)
+//! - [Mac OS X](https://nuxi.nl/cloudabi/mac/)
+//! - [NetBSD](https://nuxi.nl/cloudabi/netbsd/)
+//!
+//! ## Specification of the ABI
+//!
+//! The entire ABI is specified in a a file called
+//! [`cloudabi.txt`](https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt),
+//! from which all
+//! [headers](https://github.com/NuxiNL/cloudabi/tree/master/headers)
+//! and documentation (including the one you're reading now) is generated.
+
+#![no_std]
+#![allow(non_camel_case_types)]
+
+include!("bitflags.rs");
+
+/// File or memory access pattern advisory information.
+#[repr(u8)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum advice {
+  /// The application expects that it will not access the
+  /// specified data in the near future.
+  DONTNEED   = 1,
+  /// The application expects to access the specified data
+  /// once and then not reuse it thereafter.
+  NOREUSE    = 2,
+  /// The application has no advice to give on its behavior
+  /// with respect to the specified data.
+  NORMAL     = 3,
+  /// The application expects to access the specified data
+  /// in a random order.
+  RANDOM     = 4,
+  /// The application expects to access the specified data
+  /// sequentially from lower offsets to higher offsets.
+  SEQUENTIAL = 5,
+  /// The application expects to access the specified data
+  /// in the near future.
+  WILLNEED   = 6,
+  #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
+}
+
+/// Enumeration describing the kind of value stored in [`auxv`](struct.auxv.html).
+#[repr(u32)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum auxtype {
+  /// Base address of the binary argument data provided to
+  /// [`proc_exec()`](fn.proc_exec.html).
+  ARGDATA      = 256,
+  /// Length of the binary argument data provided to
+  /// [`proc_exec()`](fn.proc_exec.html).
+  ARGDATALEN   = 257,
+  /// Base address at which the executable is placed in
+  /// memory.
+  BASE         =   7,
+  /// Base address of a buffer of random data that may be
+  /// used for non-cryptographic purposes, for example as a
+  /// canary for stack smashing protection.
+  CANARY       = 258,
+  /// Length of a buffer of random data that may be used
+  /// for non-cryptographic purposes, for example as a
+  /// canary for stack smashing protection.
+  CANARYLEN    = 259,
+  /// Number of CPUs that the system this process is running
+  /// on has.
+  NCPUS        = 260,
+  /// Terminator of the auxiliary vector.
+  NULL         =   0,
+  /// Smallest memory object size for which individual
+  /// memory protection controls can be configured.
+  PAGESZ       =   6,
+  /// Address of the first ELF program header of the
+  /// executable.
+  PHDR         =   3,
+  /// Number of ELF program headers of the executable.
+  PHNUM        =   4,
+  /// Identifier of the process.
+  ///
+  /// This environment does not provide any simple numerical
+  /// process identifiers, for the reason that these are not
+  /// useful in distributed contexts. Instead, processes are
+  /// identified by a UUID.
+  ///
+  /// This record should point to sixteen bytes of binary
+  /// data, containing a version 4 UUID (fully random).
+  PID          = 263,
+  /// Address of the ELF header of the vDSO.
+  ///
+  /// The vDSO is a shared library that is mapped in the
+  /// address space of the process. It provides entry points
+  /// for every system call supported by the environment,
+  /// all having a corresponding symbol that is prefixed
+  /// with `cloudabi_sys_`. System calls should be invoked
+  /// through these entry points.
+  ///
+  /// The first advantage of letting processes call into a
+  /// vDSO to perform system calls instead of raising
+  /// hardware traps is that it allows for easy emulation of
+  /// executables on top of existing operating systems. The
+  /// second advantage is that in cases where an operating
+  /// system provides native support for CloudABI executables,
+  /// it may still implement partial userspace
+  /// implementations of these system calls to improve
+  /// performance (e.g., [`clock_time_get()`](fn.clock_time_get.html)). It also provides
+  /// a more dynamic way of adding, removing or replacing
+  /// system calls.
+  SYSINFO_EHDR = 262,
+  /// Thread ID of the initial thread of the process.
+  TID          = 261,
+  #[doc(hidden)] _NonExhaustive = -1 as isize as u32,
+}
+
+/// Identifiers for clocks.
+#[repr(u32)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum clockid {
+  /// The system-wide monotonic clock, which is defined as a
+  /// clock measuring real time, whose value cannot be
+  /// adjusted and which cannot have negative clock jumps.
+  ///
+  /// The epoch of this clock is undefined. The absolute
+  /// time value of this clock therefore has no meaning.
+  MONOTONIC          = 1,
+  /// The CPU-time clock associated with the current
+  /// process.
+  PROCESS_CPUTIME_ID = 2,
+  /// The system-wide clock measuring real time. Time value
+  /// zero corresponds with 1970-01-01T00:00:00Z.
+  REALTIME           = 3,
+  /// The CPU-time clock associated with the current thread.
+  THREAD_CPUTIME_ID  = 4,
+  #[doc(hidden)] _NonExhaustive = -1 as isize as u32,
+}
+
+/// A userspace condition variable.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct condvar(pub u32);
+/// The condition variable is in its initial state. There
+/// are no threads waiting to be woken up. If the
+/// condition variable has any other value, the kernel
+/// must be called to wake up any sleeping threads.
+pub const CONDVAR_HAS_NO_WAITERS: condvar = condvar(0);
+
+/// Identifier for a device containing a file system. Can be used
+/// in combination with [`inode`](struct.inode.html) to uniquely identify a file on the
+/// local system.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct device(pub u64);
+
+/// A reference to the offset of a directory entry.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct dircookie(pub u64);
+/// Permanent reference to the first directory entry
+/// within a directory.
+pub const DIRCOOKIE_START: dircookie = dircookie(0);
+
+/// Error codes returned by system calls.
+///
+/// Not all of these error codes are returned by the system calls
+/// provided by this environment, but are either used in userspace
+/// exclusively or merely provided for alignment with POSIX.
+#[repr(u16)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum errno {
+  /// No error occurred. System call completed successfully.
+  SUCCESS        =  0,
+  /// Argument list too long.
+  TOOBIG         =  1,
+  /// Permission denied.
+  ACCES          =  2,
+  /// Address in use.
+  ADDRINUSE      =  3,
+  /// Address not available.
+  ADDRNOTAVAIL   =  4,
+  /// Address family not supported.
+  AFNOSUPPORT    =  5,
+  /// Resource unavailable, or operation would block.
+  AGAIN          =  6,
+  /// Connection already in progress.
+  ALREADY        =  7,
+  /// Bad file descriptor.
+  BADF           =  8,
+  /// Bad message.
+  BADMSG         =  9,
+  /// Device or resource busy.
+  BUSY           = 10,
+  /// Operation canceled.
+  CANCELED       = 11,
+  /// No child processes.
+  CHILD          = 12,
+  /// Connection aborted.
+  CONNABORTED    = 13,
+  /// Connection refused.
+  CONNREFUSED    = 14,
+  /// Connection reset.
+  CONNRESET      = 15,
+  /// Resource deadlock would occur.
+  DEADLK         = 16,
+  /// Destination address required.
+  DESTADDRREQ    = 17,
+  /// Mathematics argument out of domain of function.
+  DOM            = 18,
+  /// Reserved.
+  DQUOT          = 19,
+  /// File exists.
+  EXIST          = 20,
+  /// Bad address.
+  FAULT          = 21,
+  /// File too large.
+  FBIG           = 22,
+  /// Host is unreachable.
+  HOSTUNREACH    = 23,
+  /// Identifier removed.
+  IDRM           = 24,
+  /// Illegal byte sequence.
+  ILSEQ          = 25,
+  /// Operation in progress.
+  INPROGRESS     = 26,
+  /// Interrupted function.
+  INTR           = 27,
+  /// Invalid argument.
+  INVAL          = 28,
+  /// I/O error.
+  IO             = 29,
+  /// Socket is connected.
+  ISCONN         = 30,
+  /// Is a directory.
+  ISDIR          = 31,
+  /// Too many levels of symbolic links.
+  LOOP           = 32,
+  /// File descriptor value too large.
+  MFILE          = 33,
+  /// Too many links.
+  MLINK          = 34,
+  /// Message too large.
+  MSGSIZE        = 35,
+  /// Reserved.
+  MULTIHOP       = 36,
+  /// Filename too long.
+  NAMETOOLONG    = 37,
+  /// Network is down.
+  NETDOWN        = 38,
+  /// Connection aborted by network.
+  NETRESET       = 39,
+  /// Network unreachable.
+  NETUNREACH     = 40,
+  /// Too many files open in system.
+  NFILE          = 41,
+  /// No buffer space available.
+  NOBUFS         = 42,
+  /// No such device.
+  NODEV          = 43,
+  /// No such file or directory.
+  NOENT          = 44,
+  /// Executable file format error.
+  NOEXEC         = 45,
+  /// No locks available.
+  NOLCK          = 46,
+  /// Reserved.
+  NOLINK         = 47,
+  /// Not enough space.
+  NOMEM          = 48,
+  /// No message of the desired type.
+  NOMSG          = 49,
+  /// Protocol not available.
+  NOPROTOOPT     = 50,
+  /// No space left on device.
+  NOSPC          = 51,
+  /// Function not supported.
+  NOSYS          = 52,
+  /// The socket is not connected.
+  NOTCONN        = 53,
+  /// Not a directory or a symbolic link to a directory.
+  NOTDIR         = 54,
+  /// Directory not empty.
+  NOTEMPTY       = 55,
+  /// State not recoverable.
+  NOTRECOVERABLE = 56,
+  /// Not a socket.
+  NOTSOCK        = 57,
+  /// Not supported, or operation not supported on socket.
+  NOTSUP         = 58,
+  /// Inappropriate I/O control operation.
+  NOTTY          = 59,
+  /// No such device or address.
+  NXIO           = 60,
+  /// Value too large to be stored in data type.
+  OVERFLOW       = 61,
+  /// Previous owner died.
+  OWNERDEAD      = 62,
+  /// Operation not permitted.
+  PERM           = 63,
+  /// Broken pipe.
+  PIPE           = 64,
+  /// Protocol error.
+  PROTO          = 65,
+  /// Protocol not supported.
+  PROTONOSUPPORT = 66,
+  /// Protocol wrong type for socket.
+  PROTOTYPE      = 67,
+  /// Result too large.
+  RANGE          = 68,
+  /// Read-only file system.
+  ROFS           = 69,
+  /// Invalid seek.
+  SPIPE          = 70,
+  /// No such process.
+  SRCH           = 71,
+  /// Reserved.
+  STALE          = 72,
+  /// Connection timed out.
+  TIMEDOUT       = 73,
+  /// Text file busy.
+  TXTBSY         = 74,
+  /// Cross-device link.
+  XDEV           = 75,
+  /// Extension: Capabilities insufficient.
+  NOTCAPABLE     = 76,
+  #[doc(hidden)] _NonExhaustive = -1 as isize as u16,
+}
+
+bitflags! {
+  /// The state of the file descriptor subscribed to with
+  /// [`FD_READ`](enum.eventtype.html#variant.FD_READ) or [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE).
+  #[repr(C)]
+  pub struct eventrwflags: u16 {
+    /// The peer of this socket has closed or disconnected.
+    const HANGUP = 0x0001;
+  }
+}
+
+/// Type of a subscription to an event or its occurrence.
+#[repr(u8)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum eventtype {
+  /// The time value of clock [`subscription.union.clock.clock_id`](struct.subscription_clock.html#structfield.clock_id)
+  /// has reached timestamp [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout).
+  CLOCK          = 1,
+  /// Condition variable [`subscription.union.condvar.condvar`](struct.subscription_condvar.html#structfield.condvar) has
+  /// been woken up and [`subscription.union.condvar.lock`](struct.subscription_condvar.html#structfield.lock) has been
+  /// acquired for writing.
+  CONDVAR        = 2,
+  /// File descriptor [`subscription.union.fd_readwrite.fd`](struct.subscription_fd_readwrite.html#structfield.fd) has
+  /// data available for reading. This event always triggers
+  /// for regular files.
+  FD_READ        = 3,
+  /// File descriptor [`subscription.union.fd_readwrite.fd`](struct.subscription_fd_readwrite.html#structfield.fd) has
+  /// capacity available for writing. This event always
+  /// triggers for regular files.
+  FD_WRITE       = 4,
+  /// Lock [`subscription.union.lock.lock`](struct.subscription_lock.html#structfield.lock) has been acquired for
+  /// reading.
+  LOCK_RDLOCK    = 5,
+  /// Lock [`subscription.union.lock.lock`](struct.subscription_lock.html#structfield.lock) has been acquired for
+  /// writing.
+  LOCK_WRLOCK    = 6,
+  /// The process associated with process descriptor
+  /// [`subscription.union.proc_terminate.fd`](struct.subscription_proc_terminate.html#structfield.fd) has terminated.
+  PROC_TERMINATE = 7,
+  #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
+}
+
+/// Exit code generated by a process when exiting.
+pub type exitcode = u32;
+
+/// A file descriptor number.
+///
+/// Unlike on POSIX-compliant systems, none of the file descriptor
+/// numbers are reserved for a purpose (e.g., stdin, stdout,
+/// stderr). Operating systems are not required to allocate new
+/// file descriptors in ascending order.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct fd(pub u32);
+/// Returned to the child process by [`proc_fork()`](fn.proc_fork.html).
+pub const PROCESS_CHILD: fd = fd(0xffffffff);
+/// Passed to [`mem_map()`](fn.mem_map.html) when creating a mapping to
+/// anonymous memory.
+pub const MAP_ANON_FD  : fd = fd(0xffffffff);
+
+bitflags! {
+  /// File descriptor flags.
+  #[repr(C)]
+  pub struct fdflags: u16 {
+    /// Append mode: Data written to the file is always
+    /// appended to the file's end.
+    const APPEND   = 0x0001;
+    /// Write according to synchronized I/O data integrity
+    /// completion. Only the data stored in the file is
+    /// synchronized.
+    const DSYNC    = 0x0002;
+    /// Non-blocking mode.
+    const NONBLOCK = 0x0004;
+    /// Synchronized read I/O operations.
+    const RSYNC    = 0x0008;
+    /// Write according to synchronized I/O file integrity
+    /// completion. In addition to synchronizing the data
+    /// stored in the file, the system may also synchronously
+    /// update the file's metadata.
+    const SYNC     = 0x0010;
+  }
+}
+
+bitflags! {
+  /// Which file descriptor attributes to adjust.
+  #[repr(C)]
+  pub struct fdsflags: u16 {
+    /// Adjust the file descriptor flags stored in
+    /// [`fdstat.fs_flags`](struct.fdstat.html#structfield.fs_flags).
+    const FLAGS  = 0x0001;
+    /// Restrict the rights of the file descriptor to the
+    /// rights stored in [`fdstat.fs_rights_base`](struct.fdstat.html#structfield.fs_rights_base) and
+    /// [`fdstat.fs_rights_inheriting`](struct.fdstat.html#structfield.fs_rights_inheriting).
+    const RIGHTS = 0x0002;
+  }
+}
+
+/// Relative offset within a file.
+pub type filedelta = i64;
+
+/// Non-negative file size or length of a region within a file.
+pub type filesize = u64;
+
+/// The type of a file descriptor or file.
+#[repr(u8)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum filetype {
+  /// The type of the file descriptor or file is unknown or
+  /// is different from any of the other types specified.
+  UNKNOWN          =   0,
+  /// The file descriptor or file refers to a block device
+  /// inode.
+  BLOCK_DEVICE     =  16,
+  /// The file descriptor or file refers to a character
+  /// device inode.
+  CHARACTER_DEVICE =  17,
+  /// The file descriptor or file refers to a directory
+  /// inode.
+  DIRECTORY        =  32,
+  /// The file descriptor refers to a process handle.
+  PROCESS          =  80,
+  /// The file descriptor or file refers to a regular file
+  /// inode.
+  REGULAR_FILE     =  96,
+  /// The file descriptor refers to a shared memory object.
+  SHARED_MEMORY    = 112,
+  /// The file descriptor or file refers to a datagram
+  /// socket.
+  SOCKET_DGRAM     = 128,
+  /// The file descriptor or file refers to a byte-stream
+  /// socket.
+  SOCKET_STREAM    = 130,
+  /// The file refers to a symbolic link inode.
+  SYMBOLIC_LINK    = 144,
+  #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
+}
+
+bitflags! {
+  /// Which file attributes to adjust.
+  #[repr(C)]
+  pub struct fsflags: u16 {
+    /// Adjust the last data access timestamp to the value
+    /// stored in [`filestat.st_atim`](struct.filestat.html#structfield.st_atim).
+    const ATIM     = 0x0001;
+    /// Adjust the last data access timestamp to the time
+    /// of clock [`REALTIME`](enum.clockid.html#variant.REALTIME).
+    const ATIM_NOW = 0x0002;
+    /// Adjust the last data modification timestamp to the
+    /// value stored in [`filestat.st_mtim`](struct.filestat.html#structfield.st_mtim).
+    const MTIM     = 0x0004;
+    /// Adjust the last data modification timestamp to the
+    /// time of clock [`REALTIME`](enum.clockid.html#variant.REALTIME).
+    const MTIM_NOW = 0x0008;
+    /// Truncate or extend the file to the size stored in
+    /// [`filestat.st_size`](struct.filestat.html#structfield.st_size).
+    const SIZE     = 0x0010;
+  }
+}
+
+/// File serial number that is unique within its file system.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct inode(pub u64);
+
+/// Number of hard links to an inode.
+pub type linkcount = u32;
+
+/// A userspace read-recursive readers-writer lock, similar to a
+/// Linux futex or a FreeBSD umtx.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct lock(pub u32);
+/// Value indicating that the lock is in its initial
+/// unlocked state.
+pub const LOCK_UNLOCKED      : lock = lock(0x00000000);
+/// Bitmask indicating that the lock is write-locked. If
+/// set, the lower 30 bits of the lock contain the
+/// identifier of the thread that owns the write lock.
+/// Otherwise, the lower 30 bits of the lock contain the
+/// number of acquired read locks.
+pub const LOCK_WRLOCKED      : lock = lock(0x40000000);
+/// Bitmask indicating that the lock is either read locked
+/// or write locked, and that one or more threads have
+/// their execution suspended, waiting to acquire the
+/// lock. The last owner of the lock must call the
+/// kernel to unlock.
+///
+/// When the lock is acquired for reading and this bit is
+/// set, it means that one or more threads are attempting
+/// to acquire this lock for writing. In that case, other
+/// threads should only acquire additional read locks if
+/// suspending execution would cause a deadlock. It is
+/// preferred to suspend execution, as this prevents
+/// starvation of writers.
+pub const LOCK_KERNEL_MANAGED: lock = lock(0x80000000);
+/// Value indicating that the lock is in an incorrect
+/// state. A lock cannot be in its initial unlocked state,
+/// while also managed by the kernel.
+pub const LOCK_BOGUS         : lock = lock(0x80000000);
+
+bitflags! {
+  /// Flags determining the method of how paths are resolved.
+  #[repr(C)]
+  pub struct lookupflags: u32 {
+    /// As long as the resolved path corresponds to a symbolic
+    /// link, it is expanded.
+    const SYMLINK_FOLLOW = 0x00000001;
+  }
+}
+
+bitflags! {
+  /// Memory mapping flags.
+  #[repr(C)]
+  pub struct mflags: u8 {
+    /// Instead of mapping the contents of the file provided,
+    /// create a mapping to anonymous memory. The file
+    /// descriptor argument must be set to [`MAP_ANON_FD`](constant.MAP_ANON_FD.html),
+    /// and the offset must be set to zero.
+    const ANON    = 0x01;
+    /// Require that the mapping is performed at the base
+    /// address provided.
+    const FIXED   = 0x02;
+    /// Changes are private.
+    const PRIVATE = 0x04;
+    /// Changes are shared.
+    const SHARED  = 0x08;
+  }
+}
+
+bitflags! {
+  /// Memory page protection options.
+  ///
+  /// This implementation enforces the `W^X` property: Pages cannot be
+  /// mapped for execution while also mapped for writing.
+  #[repr(C)]
+  pub struct mprot: u8 {
+    /// Page can be executed.
+    const EXEC  = 0x01;
+    /// Page can be written.
+    const WRITE = 0x02;
+    /// Page can be read.
+    const READ  = 0x04;
+  }
+}
+
+bitflags! {
+  /// Methods of synchronizing memory with physical storage.
+  #[repr(C)]
+  pub struct msflags: u8 {
+    /// Perform asynchronous writes.
+    const ASYNC      = 0x01;
+    /// Invalidate cached data.
+    const INVALIDATE = 0x02;
+    /// Perform synchronous writes.
+    const SYNC       = 0x04;
+  }
+}
+
+/// Specifies the number of threads sleeping on a condition
+/// variable that should be woken up.
+pub type nthreads = u32;
+
+bitflags! {
+  /// Open flags used by [`file_open()`](fn.file_open.html).
+  #[repr(C)]
+  pub struct oflags: u16 {
+    /// Create file if it does not exist.
+    const CREAT     = 0x0001;
+    /// Fail if not a directory.
+    const DIRECTORY = 0x0002;
+    /// Fail if file already exists.
+    const EXCL      = 0x0004;
+    /// Truncate file to size 0.
+    const TRUNC     = 0x0008;
+  }
+}
+
+bitflags! {
+  /// Flags provided to [`sock_recv()`](fn.sock_recv.html).
+  #[repr(C)]
+  pub struct riflags: u16 {
+    /// Returns the message without removing it from the
+    /// socket's receive queue.
+    const PEEK    = 0x0004;
+    /// On byte-stream sockets, block until the full amount
+    /// of data can be returned.
+    const WAITALL = 0x0010;
+  }
+}
+
+bitflags! {
+  /// File descriptor rights, determining which actions may be
+  /// performed.
+  #[repr(C)]
+  pub struct rights: u64 {
+    /// The right to invoke [`fd_datasync()`](fn.fd_datasync.html).
+    ///
+    /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, includes the right to
+    /// invoke [`file_open()`](fn.file_open.html) with [`DSYNC`](struct.fdflags.html#associatedconstant.DSYNC).
+    const FD_DATASYNC           = 0x0000000000000001;
+    /// The right to invoke [`fd_read()`](fn.fd_read.html) and [`sock_recv()`](fn.sock_recv.html).
+    ///
+    /// If [`MEM_MAP`](struct.rights.html#associatedconstant.MEM_MAP) is set, includes the right to
+    /// invoke [`mem_map()`](fn.mem_map.html) with memory protection option
+    /// [`READ`](struct.mprot.html#associatedconstant.READ).
+    ///
+    /// If [`FD_SEEK`](struct.rights.html#associatedconstant.FD_SEEK) is set, includes the right to invoke
+    /// [`fd_pread()`](fn.fd_pread.html).
+    const FD_READ               = 0x0000000000000002;
+    /// The right to invoke [`fd_seek()`](fn.fd_seek.html). This flag implies
+    /// [`FD_TELL`](struct.rights.html#associatedconstant.FD_TELL).
+    const FD_SEEK               = 0x0000000000000004;
+    /// The right to invoke [`fd_stat_put()`](fn.fd_stat_put.html) with
+    /// [`FLAGS`](struct.fdsflags.html#associatedconstant.FLAGS).
+    const FD_STAT_PUT_FLAGS     = 0x0000000000000008;
+    /// The right to invoke [`fd_sync()`](fn.fd_sync.html).
+    ///
+    /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, includes the right to
+    /// invoke [`file_open()`](fn.file_open.html) with [`RSYNC`](struct.fdflags.html#associatedconstant.RSYNC) and
+    /// [`DSYNC`](struct.fdflags.html#associatedconstant.DSYNC).
+    const FD_SYNC               = 0x0000000000000010;
+    /// The right to invoke [`fd_seek()`](fn.fd_seek.html) in such a way that the
+    /// file offset remains unaltered (i.e., [`CUR`](enum.whence.html#variant.CUR) with
+    /// offset zero).
+    const FD_TELL               = 0x0000000000000020;
+    /// The right to invoke [`fd_write()`](fn.fd_write.html) and [`sock_send()`](fn.sock_send.html).
+    ///
+    /// If [`MEM_MAP`](struct.rights.html#associatedconstant.MEM_MAP) is set, includes the right to
+    /// invoke [`mem_map()`](fn.mem_map.html) with memory protection option
+    /// [`WRITE`](struct.mprot.html#associatedconstant.WRITE).
+    ///
+    /// If [`FD_SEEK`](struct.rights.html#associatedconstant.FD_SEEK) is set, includes the right to
+    /// invoke [`fd_pwrite()`](fn.fd_pwrite.html).
+    const FD_WRITE              = 0x0000000000000040;
+    /// The right to invoke [`file_advise()`](fn.file_advise.html).
+    const FILE_ADVISE           = 0x0000000000000080;
+    /// The right to invoke [`file_allocate()`](fn.file_allocate.html).
+    const FILE_ALLOCATE         = 0x0000000000000100;
+    /// The right to invoke [`file_create()`](fn.file_create.html) with
+    /// [`DIRECTORY`](enum.filetype.html#variant.DIRECTORY).
+    const FILE_CREATE_DIRECTORY = 0x0000000000000200;
+    /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, the right to invoke
+    /// [`file_open()`](fn.file_open.html) with [`CREAT`](struct.oflags.html#associatedconstant.CREAT).
+    const FILE_CREATE_FILE      = 0x0000000000000400;
+    /// The right to invoke [`file_link()`](fn.file_link.html) with the file
+    /// descriptor as the source directory.
+    const FILE_LINK_SOURCE      = 0x0000000000001000;
+    /// The right to invoke [`file_link()`](fn.file_link.html) with the file
+    /// descriptor as the target directory.
+    const FILE_LINK_TARGET      = 0x0000000000002000;
+    /// The right to invoke [`file_open()`](fn.file_open.html).
+    const FILE_OPEN             = 0x0000000000004000;
+    /// The right to invoke [`file_readdir()`](fn.file_readdir.html).
+    const FILE_READDIR          = 0x0000000000008000;
+    /// The right to invoke [`file_readlink()`](fn.file_readlink.html).
+    const FILE_READLINK         = 0x0000000000010000;
+    /// The right to invoke [`file_rename()`](fn.file_rename.html) with the file
+    /// descriptor as the source directory.
+    const FILE_RENAME_SOURCE    = 0x0000000000020000;
+    /// The right to invoke [`file_rename()`](fn.file_rename.html) with the file
+    /// descriptor as the target directory.
+    const FILE_RENAME_TARGET    = 0x0000000000040000;
+    /// The right to invoke [`file_stat_fget()`](fn.file_stat_fget.html).
+    const FILE_STAT_FGET        = 0x0000000000080000;
+    /// The right to invoke [`file_stat_fput()`](fn.file_stat_fput.html) with
+    /// [`SIZE`](struct.fsflags.html#associatedconstant.SIZE).
+    ///
+    /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, includes the right to
+    /// invoke [`file_open()`](fn.file_open.html) with [`TRUNC`](struct.oflags.html#associatedconstant.TRUNC).
+    const FILE_STAT_FPUT_SIZE   = 0x0000000000100000;
+    /// The right to invoke [`file_stat_fput()`](fn.file_stat_fput.html) with
+    /// [`ATIM`](struct.fsflags.html#associatedconstant.ATIM), [`ATIM_NOW`](struct.fsflags.html#associatedconstant.ATIM_NOW), [`MTIM`](struct.fsflags.html#associatedconstant.MTIM),
+    /// and [`MTIM_NOW`](struct.fsflags.html#associatedconstant.MTIM_NOW).
+    const FILE_STAT_FPUT_TIMES  = 0x0000000000200000;
+    /// The right to invoke [`file_stat_get()`](fn.file_stat_get.html).
+    const FILE_STAT_GET         = 0x0000000000400000;
+    /// The right to invoke [`file_stat_put()`](fn.file_stat_put.html) with
+    /// [`ATIM`](struct.fsflags.html#associatedconstant.ATIM), [`ATIM_NOW`](struct.fsflags.html#associatedconstant.ATIM_NOW), [`MTIM`](struct.fsflags.html#associatedconstant.MTIM),
+    /// and [`MTIM_NOW`](struct.fsflags.html#associatedconstant.MTIM_NOW).
+    const FILE_STAT_PUT_TIMES   = 0x0000000000800000;
+    /// The right to invoke [`file_symlink()`](fn.file_symlink.html).
+    const FILE_SYMLINK          = 0x0000000001000000;
+    /// The right to invoke [`file_unlink()`](fn.file_unlink.html).
+    const FILE_UNLINK           = 0x0000000002000000;
+    /// The right to invoke [`mem_map()`](fn.mem_map.html) with [`mprot`](struct.mprot.html) set to
+    /// zero.
+    const MEM_MAP               = 0x0000000004000000;
+    /// If [`MEM_MAP`](struct.rights.html#associatedconstant.MEM_MAP) is set, the right to invoke
+    /// [`mem_map()`](fn.mem_map.html) with [`EXEC`](struct.mprot.html#associatedconstant.EXEC).
+    const MEM_MAP_EXEC          = 0x0000000008000000;
+    /// If [`FD_READ`](struct.rights.html#associatedconstant.FD_READ) is set, includes the right to
+    /// invoke [`poll()`](fn.poll.html) to subscribe to [`FD_READ`](enum.eventtype.html#variant.FD_READ).
+    ///
+    /// If [`FD_WRITE`](struct.rights.html#associatedconstant.FD_WRITE) is set, includes the right to
+    /// invoke [`poll()`](fn.poll.html) to subscribe to [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE).
+    const POLL_FD_READWRITE     = 0x0000000010000000;
+    /// The right to invoke [`poll()`](fn.poll.html) to subscribe to
+    /// [`PROC_TERMINATE`](enum.eventtype.html#variant.PROC_TERMINATE).
+    const POLL_PROC_TERMINATE   = 0x0000000040000000;
+    /// The right to invoke [`proc_exec()`](fn.proc_exec.html).
+    const PROC_EXEC             = 0x0000000100000000;
+    /// The right to invoke [`sock_shutdown()`](fn.sock_shutdown.html).
+    const SOCK_SHUTDOWN         = 0x0000008000000000;
+  }
+}
+
+bitflags! {
+  /// Flags returned by [`sock_recv()`](fn.sock_recv.html).
+  #[repr(C)]
+  pub struct roflags: u16 {
+    /// Returned by [`sock_recv()`](fn.sock_recv.html): List of file descriptors
+    /// has been truncated.
+    const FDS_TRUNCATED  = 0x0001;
+    /// Returned by [`sock_recv()`](fn.sock_recv.html): Message data has been
+    /// truncated.
+    const DATA_TRUNCATED = 0x0008;
+  }
+}
+
+/// Indicates whether an object is stored in private or shared
+/// memory.
+#[repr(u8)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum scope {
+  /// The object is stored in private memory.
+  PRIVATE = 4,
+  /// The object is stored in shared memory.
+  SHARED  = 8,
+  #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
+}
+
+bitflags! {
+  /// Which channels on a socket need to be shut down.
+  #[repr(C)]
+  pub struct sdflags: u8 {
+    /// Disables further receive operations.
+    const RD = 0x01;
+    /// Disables further send operations.
+    const WR = 0x02;
+  }
+}
+
+bitflags! {
+  /// Flags provided to [`sock_send()`](fn.sock_send.html). As there are currently no flags
+  /// defined, it must be set to zero.
+  #[repr(C)]
+  pub struct siflags: u16 {
+    const DEFAULT = 0;
+  }
+}
+
+/// Signal condition.
+#[repr(u8)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum signal {
+  /// Process abort signal.
+  ///
+  /// Action: Terminates the process.
+  ABRT   =  1,
+  /// Alarm clock.
+  ///
+  /// Action: Terminates the process.
+  ALRM   =  2,
+  /// Access to an undefined portion of a memory object.
+  ///
+  /// Action: Terminates the process.
+  BUS    =  3,
+  /// Child process terminated, stopped, or continued.
+  ///
+  /// Action: Ignored.
+  CHLD   =  4,
+  /// Continue executing, if stopped.
+  ///
+  /// Action: Continues executing, if stopped.
+  CONT   =  5,
+  /// Erroneous arithmetic operation.
+  ///
+  /// Action: Terminates the process.
+  FPE    =  6,
+  /// Hangup.
+  ///
+  /// Action: Terminates the process.
+  HUP    =  7,
+  /// Illegal instruction.
+  ///
+  /// Action: Terminates the process.
+  ILL    =  8,
+  /// Terminate interrupt signal.
+  ///
+  /// Action: Terminates the process.
+  INT    =  9,
+  /// Kill.
+  ///
+  /// Action: Terminates the process.
+  KILL   = 10,
+  /// Write on a pipe with no one to read it.
+  ///
+  /// Action: Ignored.
+  PIPE   = 11,
+  /// Terminal quit signal.
+  ///
+  /// Action: Terminates the process.
+  QUIT   = 12,
+  /// Invalid memory reference.
+  ///
+  /// Action: Terminates the process.
+  SEGV   = 13,
+  /// Stop executing.
+  ///
+  /// Action: Stops executing.
+  STOP   = 14,
+  /// Bad system call.
+  ///
+  /// Action: Terminates the process.
+  SYS    = 15,
+  /// Termination signal.
+  ///
+  /// Action: Terminates the process.
+  TERM   = 16,
+  /// Trace/breakpoint trap.
+  ///
+  /// Action: Terminates the process.
+  TRAP   = 17,
+  /// Terminal stop signal.
+  ///
+  /// Action: Stops executing.
+  TSTP   = 18,
+  /// Background process attempting read.
+  ///
+  /// Action: Stops executing.
+  TTIN   = 19,
+  /// Background process attempting write.
+  ///
+  /// Action: Stops executing.
+  TTOU   = 20,
+  /// High bandwidth data is available at a socket.
+  ///
+  /// Action: Ignored.
+  URG    = 21,
+  /// User-defined signal 1.
+  ///
+  /// Action: Terminates the process.
+  USR1   = 22,
+  /// User-defined signal 2.
+  ///
+  /// Action: Terminates the process.
+  USR2   = 23,
+  /// Virtual timer expired.
+  ///
+  /// Action: Terminates the process.
+  VTALRM = 24,
+  /// CPU time limit exceeded.
+  ///
+  /// Action: Terminates the process.
+  XCPU   = 25,
+  /// File size limit exceeded.
+  ///
+  /// Action: Terminates the process.
+  XFSZ   = 26,
+  #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
+}
+
+bitflags! {
+  /// Flags determining how the timestamp provided in
+  /// [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout) should be interpreted.
+  #[repr(C)]
+  pub struct subclockflags: u16 {
+    /// If set, treat the timestamp provided in
+    /// [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout) as an absolute timestamp
+    /// of clock [`subscription.union.clock.clock_id`](struct.subscription_clock.html#structfield.clock_id).
+    ///
+    /// If clear, treat the timestamp provided in
+    /// [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout) relative to the current
+    /// time value of clock [`subscription.union.clock.clock_id`](struct.subscription_clock.html#structfield.clock_id).
+    const ABSTIME = 0x0001;
+  }
+}
+
+bitflags! {
+  /// Flags influencing the method of polling for read or writing on
+  /// a file descriptor.
+  #[repr(C)]
+  pub struct subrwflags: u16 {
+    /// Deprecated. Must be set by callers and ignored by
+    /// implementations.
+    const POLL = 0x0001;
+  }
+}
+
+/// Unique system-local identifier of a thread. This identifier is
+/// only valid during the lifetime of the thread.
+///
+/// Threads must be aware of their thread identifier, as it is
+/// written it into locks when acquiring them for writing. It is
+/// not advised to use these identifiers for any other purpose.
+///
+/// As the thread identifier is also stored in [`lock`](struct.lock.html) when
+/// [`LOCK_WRLOCKED`](constant.LOCK_WRLOCKED.html) is set, the top two bits of the thread
+/// must always be set to zero.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct tid(pub u32);
+
+/// Timestamp in nanoseconds.
+pub type timestamp = u64;
+
+bitflags! {
+  /// Specifies whether files are unlinked or directories are
+  /// removed.
+  #[repr(C)]
+  pub struct ulflags: u8 {
+    /// If set, removes a directory. Otherwise, unlinks any
+    /// non-directory file.
+    const REMOVEDIR = 0x01;
+  }
+}
+
+/// User-provided value that can be attached to objects that is
+/// retained when extracted from the kernel.
+pub type userdata = u64;
+
+/// Relative to which position the offset of the file descriptor
+/// should be set.
+#[repr(u8)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum whence {
+  /// Seek relative to current position.
+  CUR = 1,
+  /// Seek relative to end-of-file.
+  END = 2,
+  /// Seek relative to start-of-file.
+  SET = 3,
+  #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
+}
+
+/// Auxiliary vector entry.
+///
+/// The auxiliary vector is a list of key-value pairs that is
+/// provided to the process on startup. Unlike structures, it is
+/// extensible, as it is possible to add new records later on.
+/// The auxiliary vector is always terminated by an entry having
+/// type [`NULL`](enum.auxtype.html#variant.NULL).
+///
+/// The auxiliary vector is part of the x86-64 ABI, but is used by
+/// this environment on all architectures.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct auxv {
+  /// The type of the auxiliary vector entry.
+  pub a_type: auxtype,
+  pub union: auxv_union
+}
+/// A union inside `auxv`.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union auxv_union {
+  /// Used when `a_type` is [`ARGDATALEN`](enum.auxtype.html#variant.ARGDATALEN), [`CANARYLEN`](enum.auxtype.html#variant.CANARYLEN), [`NCPUS`](enum.auxtype.html#variant.NCPUS), [`PAGESZ`](enum.auxtype.html#variant.PAGESZ), [`PHNUM`](enum.auxtype.html#variant.PHNUM), or [`TID`](enum.auxtype.html#variant.TID).
+/// A numerical value.
+  pub a_val: usize,
+  /// Used when `a_type` is [`ARGDATA`](enum.auxtype.html#variant.ARGDATA), [`BASE`](enum.auxtype.html#variant.BASE), [`CANARY`](enum.auxtype.html#variant.CANARY), [`PHDR`](enum.auxtype.html#variant.PHDR), [`PID`](enum.auxtype.html#variant.PID), or [`SYSINFO_EHDR`](enum.auxtype.html#variant.SYSINFO_EHDR).
+/// A pointer value.
+  pub a_ptr: *mut (),
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn auxv_layout_test_32() {
+  assert_eq!(::core::mem::size_of::<auxv>(), 8);
+  assert_eq!(::core::mem::align_of::<auxv>(), 4);
+  unsafe {
+    let obj: auxv = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.a_type as *const _ as usize - base, 0);
+    assert_eq!(&obj.union.a_val as *const _ as usize - base, 4);
+    assert_eq!(&obj.union.a_ptr as *const _ as usize - base, 4);
+  }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn auxv_layout_test_64() {
+  assert_eq!(::core::mem::size_of::<auxv>(), 16);
+  assert_eq!(::core::mem::align_of::<auxv>(), 8);
+  unsafe {
+    let obj: auxv = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.a_type as *const _ as usize - base, 0);
+    assert_eq!(&obj.union.a_val as *const _ as usize - base, 8);
+    assert_eq!(&obj.union.a_ptr as *const _ as usize - base, 8);
+  }
+}
+
+/// A region of memory for scatter/gather writes.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct ciovec {
+  /// The address and length of the buffer to be written.
+  pub buf: (*const (), usize),
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn ciovec_layout_test_32() {
+  assert_eq!(::core::mem::size_of::<ciovec>(), 8);
+  assert_eq!(::core::mem::align_of::<ciovec>(), 4);
+  unsafe {
+    let obj: ciovec = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.buf.0 as *const _ as usize - base, 0);
+    assert_eq!(&obj.buf.1 as *const _ as usize - base, 4);
+  }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn ciovec_layout_test_64() {
+  assert_eq!(::core::mem::size_of::<ciovec>(), 16);
+  assert_eq!(::core::mem::align_of::<ciovec>(), 8);
+  unsafe {
+    let obj: ciovec = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.buf.0 as *const _ as usize - base, 0);
+    assert_eq!(&obj.buf.1 as *const _ as usize - base, 8);
+  }
+}
+
+/// A directory entry.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct dirent {
+  /// The offset of the next directory entry stored in this
+  /// directory.
+  pub d_next: dircookie,
+  /// The serial number of the file referred to by this
+  /// directory entry.
+  pub d_ino: inode,
+  /// The length of the name of the directory entry.
+  pub d_namlen: u32,
+  /// The type of the file referred to by this directory
+  /// entry.
+  pub d_type: filetype,
+}
+#[test]
+fn dirent_layout_test() {
+  assert_eq!(::core::mem::size_of::<dirent>(), 24);
+  assert_eq!(::core::mem::align_of::<dirent>(), 8);
+  unsafe {
+    let obj: dirent = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.d_next as *const _ as usize - base, 0);
+    assert_eq!(&obj.d_ino as *const _ as usize - base, 8);
+    assert_eq!(&obj.d_namlen as *const _ as usize - base, 16);
+    assert_eq!(&obj.d_type as *const _ as usize - base, 20);
+  }
+}
+
+/// An event that occurred.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct event {
+  /// User-provided value that got attached to
+  /// [`subscription.userdata`](struct.subscription.html#structfield.userdata).
+  pub userdata: userdata,
+  /// If non-zero, an error that occurred while processing
+  /// the subscription request.
+  pub error: errno,
+  /// The type of the event that occurred.
+  pub type_: eventtype,
+  pub union: event_union
+}
+/// A union inside `event`.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union event_union {
+  /// Used when `type_` is [`FD_READ`](enum.eventtype.html#variant.FD_READ) or [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE).
+  pub fd_readwrite: event_fd_readwrite,
+  /// Used when `type_` is [`PROC_TERMINATE`](enum.eventtype.html#variant.PROC_TERMINATE).
+  pub proc_terminate: event_proc_terminate,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct event_fd_readwrite {
+  /// The number of bytes available
+  /// for reading or writing.
+  pub nbytes: filesize,
+  /// Obsolete.
+  pub unused: [u8; 4],
+  /// The state of the file
+  /// descriptor.
+  pub flags: eventrwflags,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct event_proc_terminate {
+  /// Obsolete.
+  pub unused: [u8; 4],
+  /// If zero, the process has
+  /// exited.
+  /// Otherwise, the signal
+  /// condition causing it to
+  /// terminated.
+  pub signal: signal,
+  /// If exited, the exit code of
+  /// the process.
+  pub exitcode: exitcode,
+}
+#[test]
+fn event_layout_test() {
+  assert_eq!(::core::mem::size_of::<event>(), 32);
+  assert_eq!(::core::mem::align_of::<event>(), 8);
+  unsafe {
+    let obj: event = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.userdata as *const _ as usize - base, 0);
+    assert_eq!(&obj.error as *const _ as usize - base, 8);
+    assert_eq!(&obj.type_ as *const _ as usize - base, 10);
+    assert_eq!(&obj.union.fd_readwrite.nbytes as *const _ as usize - base, 16);
+    assert_eq!(&obj.union.fd_readwrite.unused as *const _ as usize - base, 24);
+    assert_eq!(&obj.union.fd_readwrite.flags as *const _ as usize - base, 28);
+    assert_eq!(&obj.union.proc_terminate.unused as *const _ as usize - base, 16);
+    assert_eq!(&obj.union.proc_terminate.signal as *const _ as usize - base, 20);
+    assert_eq!(&obj.union.proc_terminate.exitcode as *const _ as usize - base, 24);
+  }
+}
+
+/// File descriptor attributes.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct fdstat {
+  /// File type.
+  pub fs_filetype: filetype,
+  /// File descriptor flags.
+  pub fs_flags: fdflags,
+  /// Rights that apply to this file descriptor.
+  pub fs_rights_base: rights,
+  /// Maximum set of rights that can be installed on new
+  /// file descriptors that are created through this file
+  /// descriptor, e.g., through [`file_open()`](fn.file_open.html).
+  pub fs_rights_inheriting: rights,
+}
+#[test]
+fn fdstat_layout_test() {
+  assert_eq!(::core::mem::size_of::<fdstat>(), 24);
+  assert_eq!(::core::mem::align_of::<fdstat>(), 8);
+  unsafe {
+    let obj: fdstat = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.fs_filetype as *const _ as usize - base, 0);
+    assert_eq!(&obj.fs_flags as *const _ as usize - base, 2);
+    assert_eq!(&obj.fs_rights_base as *const _ as usize - base, 8);
+    assert_eq!(&obj.fs_rights_inheriting as *const _ as usize - base, 16);
+  }
+}
+
+/// File attributes.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct filestat {
+  /// Device ID of device containing the file.
+  pub st_dev: device,
+  /// File serial number.
+  pub st_ino: inode,
+  /// File type.
+  pub st_filetype: filetype,
+  /// Number of hard links to the file.
+  pub st_nlink: linkcount,
+  /// For regular files, the file size in bytes. For
+  /// symbolic links, the length in bytes of the pathname
+  /// contained in the symbolic link.
+  pub st_size: filesize,
+  /// Last data access timestamp.
+  pub st_atim: timestamp,
+  /// Last data modification timestamp.
+  pub st_mtim: timestamp,
+  /// Last file status change timestamp.
+  pub st_ctim: timestamp,
+}
+#[test]
+fn filestat_layout_test() {
+  assert_eq!(::core::mem::size_of::<filestat>(), 56);
+  assert_eq!(::core::mem::align_of::<filestat>(), 8);
+  unsafe {
+    let obj: filestat = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.st_dev as *const _ as usize - base, 0);
+    assert_eq!(&obj.st_ino as *const _ as usize - base, 8);
+    assert_eq!(&obj.st_filetype as *const _ as usize - base, 16);
+    assert_eq!(&obj.st_nlink as *const _ as usize - base, 20);
+    assert_eq!(&obj.st_size as *const _ as usize - base, 24);
+    assert_eq!(&obj.st_atim as *const _ as usize - base, 32);
+    assert_eq!(&obj.st_mtim as *const _ as usize - base, 40);
+    assert_eq!(&obj.st_ctim as *const _ as usize - base, 48);
+  }
+}
+
+/// A region of memory for scatter/gather reads.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct iovec {
+  /// The address and length of the buffer to be filled.
+  pub buf: (*mut (), usize),
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn iovec_layout_test_32() {
+  assert_eq!(::core::mem::size_of::<iovec>(), 8);
+  assert_eq!(::core::mem::align_of::<iovec>(), 4);
+  unsafe {
+    let obj: iovec = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.buf.0 as *const _ as usize - base, 0);
+    assert_eq!(&obj.buf.1 as *const _ as usize - base, 4);
+  }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn iovec_layout_test_64() {
+  assert_eq!(::core::mem::size_of::<iovec>(), 16);
+  assert_eq!(::core::mem::align_of::<iovec>(), 8);
+  unsafe {
+    let obj: iovec = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.buf.0 as *const _ as usize - base, 0);
+    assert_eq!(&obj.buf.1 as *const _ as usize - base, 8);
+  }
+}
+
+/// Path lookup properties.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct lookup {
+  /// The working directory at which the resolution of the
+  /// path starts.
+  pub fd: fd,
+  /// Flags determining the method of how the path is
+  /// resolved.
+  pub flags: lookupflags,
+}
+#[test]
+fn lookup_layout_test() {
+  assert_eq!(::core::mem::size_of::<lookup>(), 8);
+  assert_eq!(::core::mem::align_of::<lookup>(), 4);
+  unsafe {
+    let obj: lookup = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.fd as *const _ as usize - base, 0);
+    assert_eq!(&obj.flags as *const _ as usize - base, 4);
+  }
+}
+
+/// Entry point for a process (`_start`).
+///
+/// **auxv**:
+/// The auxiliary vector. See [`auxv`](struct.auxv.html).
+pub type processentry = unsafe extern "C" fn(
+  auxv: *const auxv,
+) -> ();
+
+/// Arguments of [`sock_recv()`](fn.sock_recv.html).
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct recv_in {
+  /// List of scatter/gather vectors where message data
+  /// should be stored.
+  pub ri_data: (*const iovec, usize),
+  /// Buffer where numbers of incoming file descriptors
+  /// should be stored.
+  pub ri_fds: (*mut fd, usize),
+  /// Message flags.
+  pub ri_flags: riflags,
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn recv_in_layout_test_32() {
+  assert_eq!(::core::mem::size_of::<recv_in>(), 20);
+  assert_eq!(::core::mem::align_of::<recv_in>(), 4);
+  unsafe {
+    let obj: recv_in = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.ri_data.0 as *const _ as usize - base, 0);
+    assert_eq!(&obj.ri_data.1 as *const _ as usize - base, 4);
+    assert_eq!(&obj.ri_fds.0 as *const _ as usize - base, 8);
+    assert_eq!(&obj.ri_fds.1 as *const _ as usize - base, 12);
+    assert_eq!(&obj.ri_flags as *const _ as usize - base, 16);
+  }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn recv_in_layout_test_64() {
+  assert_eq!(::core::mem::size_of::<recv_in>(), 40);
+  assert_eq!(::core::mem::align_of::<recv_in>(), 8);
+  unsafe {
+    let obj: recv_in = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.ri_data.0 as *const _ as usize - base, 0);
+    assert_eq!(&obj.ri_data.1 as *const _ as usize - base, 8);
+    assert_eq!(&obj.ri_fds.0 as *const _ as usize - base, 16);
+    assert_eq!(&obj.ri_fds.1 as *const _ as usize - base, 24);
+    assert_eq!(&obj.ri_flags as *const _ as usize - base, 32);
+  }
+}
+
+/// Results of [`sock_recv()`](fn.sock_recv.html).
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct recv_out {
+  /// Number of bytes stored in [`recv_in.ri_data`](struct.recv_in.html#structfield.ri_data).
+  pub ro_datalen: usize,
+  /// Number of file descriptors stored in [`recv_in.ri_fds`](struct.recv_in.html#structfield.ri_fds).
+  pub ro_fdslen: usize,
+  /// Fields that were used by previous implementations.
+  pub ro_unused: [u8; 40],
+  /// Message flags.
+  pub ro_flags: roflags,
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn recv_out_layout_test_32() {
+  assert_eq!(::core::mem::size_of::<recv_out>(), 52);
+  assert_eq!(::core::mem::align_of::<recv_out>(), 4);
+  unsafe {
+    let obj: recv_out = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.ro_datalen as *const _ as usize - base, 0);
+    assert_eq!(&obj.ro_fdslen as *const _ as usize - base, 4);
+    assert_eq!(&obj.ro_unused as *const _ as usize - base, 8);
+    assert_eq!(&obj.ro_flags as *const _ as usize - base, 48);
+  }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn recv_out_layout_test_64() {
+  assert_eq!(::core::mem::size_of::<recv_out>(), 64);
+  assert_eq!(::core::mem::align_of::<recv_out>(), 8);
+  unsafe {
+    let obj: recv_out = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.ro_datalen as *const _ as usize - base, 0);
+    assert_eq!(&obj.ro_fdslen as *const _ as usize - base, 8);
+    assert_eq!(&obj.ro_unused as *const _ as usize - base, 16);
+    assert_eq!(&obj.ro_flags as *const _ as usize - base, 56);
+  }
+}
+
+/// Arguments of [`sock_send()`](fn.sock_send.html).
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct send_in {
+  /// List of scatter/gather vectors where message data
+  /// should be retrieved.
+  pub si_data: (*const ciovec, usize),
+  /// File descriptors that need to be attached to the
+  /// message.
+  pub si_fds: (*const fd, usize),
+  /// Message flags.
+  pub si_flags: siflags,
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn send_in_layout_test_32() {
+  assert_eq!(::core::mem::size_of::<send_in>(), 20);
+  assert_eq!(::core::mem::align_of::<send_in>(), 4);
+  unsafe {
+    let obj: send_in = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.si_data.0 as *const _ as usize - base, 0);
+    assert_eq!(&obj.si_data.1 as *const _ as usize - base, 4);
+    assert_eq!(&obj.si_fds.0 as *const _ as usize - base, 8);
+    assert_eq!(&obj.si_fds.1 as *const _ as usize - base, 12);
+    assert_eq!(&obj.si_flags as *const _ as usize - base, 16);
+  }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn send_in_layout_test_64() {
+  assert_eq!(::core::mem::size_of::<send_in>(), 40);
+  assert_eq!(::core::mem::align_of::<send_in>(), 8);
+  unsafe {
+    let obj: send_in = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.si_data.0 as *const _ as usize - base, 0);
+    assert_eq!(&obj.si_data.1 as *const _ as usize - base, 8);
+    assert_eq!(&obj.si_fds.0 as *const _ as usize - base, 16);
+    assert_eq!(&obj.si_fds.1 as *const _ as usize - base, 24);
+    assert_eq!(&obj.si_flags as *const _ as usize - base, 32);
+  }
+}
+
+/// Results of [`sock_send()`](fn.sock_send.html).
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct send_out {
+  /// Number of bytes transmitted.
+  pub so_datalen: usize,
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn send_out_layout_test_32() {
+  assert_eq!(::core::mem::size_of::<send_out>(), 4);
+  assert_eq!(::core::mem::align_of::<send_out>(), 4);
+  unsafe {
+    let obj: send_out = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.so_datalen as *const _ as usize - base, 0);
+  }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn send_out_layout_test_64() {
+  assert_eq!(::core::mem::size_of::<send_out>(), 8);
+  assert_eq!(::core::mem::align_of::<send_out>(), 8);
+  unsafe {
+    let obj: send_out = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.so_datalen as *const _ as usize - base, 0);
+  }
+}
+
+/// Subscription to an event.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct subscription {
+  /// User-provided value that is attached to the
+  /// subscription in the kernel and returned through
+  /// [`event.userdata`](struct.event.html#structfield.userdata).
+  pub userdata: userdata,
+  /// Used by previous implementations. Ignored.
+  pub unused: u16,
+  /// The type of the event to which to subscribe.
+  ///
+  /// Currently, [`CONDVAR`](enum.eventtype.html#variant.CONDVAR),
+  /// [`LOCK_RDLOCK`](enum.eventtype.html#variant.LOCK_RDLOCK), and [`LOCK_WRLOCK`](enum.eventtype.html#variant.LOCK_WRLOCK)
+  /// must be provided as the first subscription and may
+  /// only be followed by up to one other subscription,
+  /// having type [`CLOCK`](enum.eventtype.html#variant.CLOCK).
+  pub type_: eventtype,
+  pub union: subscription_union
+}
+/// A union inside `subscription`.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union subscription_union {
+  /// Used when `type_` is [`CLOCK`](enum.eventtype.html#variant.CLOCK).
+  pub clock: subscription_clock,
+  /// Used when `type_` is [`CONDVAR`](enum.eventtype.html#variant.CONDVAR).
+  pub condvar: subscription_condvar,
+  /// Used when `type_` is [`FD_READ`](enum.eventtype.html#variant.FD_READ) or [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE).
+  pub fd_readwrite: subscription_fd_readwrite,
+  /// Used when `type_` is [`LOCK_RDLOCK`](enum.eventtype.html#variant.LOCK_RDLOCK) or [`LOCK_WRLOCK`](enum.eventtype.html#variant.LOCK_WRLOCK).
+  pub lock: subscription_lock,
+  /// Used when `type_` is [`PROC_TERMINATE`](enum.eventtype.html#variant.PROC_TERMINATE).
+  pub proc_terminate: subscription_proc_terminate,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct subscription_clock {
+  /// The user-defined unique
+  /// identifier of the clock.
+  pub identifier: userdata,
+  /// The clock against which the
+  /// timestamp should be compared.
+  pub clock_id: clockid,
+  /// The absolute or relative
+  /// timestamp.
+  pub timeout: timestamp,
+  /// The amount of time that the
+  /// kernel may wait additionally
+  /// to coalesce with other events.
+  pub precision: timestamp,
+  /// Flags specifying whether the
+  /// timeout is absolute or
+  /// relative.
+  pub flags: subclockflags,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct subscription_condvar {
+  /// The condition variable on
+  /// which to wait to be woken up.
+  pub condvar: *mut condvar,
+  /// The lock that will be
+  /// released while waiting.
+  ///
+  /// The lock will be reacquired
+  /// for writing when the condition
+  /// variable triggers.
+  pub lock: *mut lock,
+  /// Whether the condition variable
+  /// is stored in private or shared
+  /// memory.
+  pub condvar_scope: scope,
+  /// Whether the lock is stored in
+  /// private or shared memory.
+  pub lock_scope: scope,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct subscription_fd_readwrite {
+  /// The file descriptor on which
+  /// to wait for it to become ready
+  /// for reading or writing.
+  pub fd: fd,
+  /// Under which conditions to
+  /// trigger.
+  pub flags: subrwflags,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct subscription_lock {
+  /// The lock that will be acquired
+  /// for reading or writing.
+  pub lock: *mut lock,
+  /// Whether the lock is stored in
+  /// private or shared memory.
+  pub lock_scope: scope,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct subscription_proc_terminate {
+  /// The process descriptor on
+  /// which to wait for process
+  /// termination.
+  pub fd: fd,
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn subscription_layout_test_32() {
+  assert_eq!(::core::mem::size_of::<subscription>(), 56);
+  assert_eq!(::core::mem::align_of::<subscription>(), 8);
+  unsafe {
+    let obj: subscription = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.userdata as *const _ as usize - base, 0);
+    assert_eq!(&obj.unused as *const _ as usize - base, 8);
+    assert_eq!(&obj.type_ as *const _ as usize - base, 10);
+    assert_eq!(&obj.union.clock.identifier as *const _ as usize - base, 16);
+    assert_eq!(&obj.union.clock.clock_id as *const _ as usize - base, 24);
+    assert_eq!(&obj.union.clock.timeout as *const _ as usize - base, 32);
+    assert_eq!(&obj.union.clock.precision as *const _ as usize - base, 40);
+    assert_eq!(&obj.union.clock.flags as *const _ as usize - base, 48);
+    assert_eq!(&obj.union.condvar.condvar as *const _ as usize - base, 16);
+    assert_eq!(&obj.union.condvar.lock as *const _ as usize - base, 20);
+    assert_eq!(&obj.union.condvar.condvar_scope as *const _ as usize - base, 24);
+    assert_eq!(&obj.union.condvar.lock_scope as *const _ as usize - base, 25);
+    assert_eq!(&obj.union.fd_readwrite.fd as *const _ as usize - base, 16);
+    assert_eq!(&obj.union.fd_readwrite.flags as *const _ as usize - base, 20);
+    assert_eq!(&obj.union.lock.lock as *const _ as usize - base, 16);
+    assert_eq!(&obj.union.lock.lock_scope as *const _ as usize - base, 20);
+    assert_eq!(&obj.union.proc_terminate.fd as *const _ as usize - base, 16);
+  }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn subscription_layout_test_64() {
+  assert_eq!(::core::mem::size_of::<subscription>(), 56);
+  assert_eq!(::core::mem::align_of::<subscription>(), 8);
+  unsafe {
+    let obj: subscription = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.userdata as *const _ as usize - base, 0);
+    assert_eq!(&obj.unused as *const _ as usize - base, 8);
+    assert_eq!(&obj.type_ as *const _ as usize - base, 10);
+    assert_eq!(&obj.union.clock.identifier as *const _ as usize - base, 16);
+    assert_eq!(&obj.union.clock.clock_id as *const _ as usize - base, 24);
+    assert_eq!(&obj.union.clock.timeout as *const _ as usize - base, 32);
+    assert_eq!(&obj.union.clock.precision as *const _ as usize - base, 40);
+    assert_eq!(&obj.union.clock.flags as *const _ as usize - base, 48);
+    assert_eq!(&obj.union.condvar.condvar as *const _ as usize - base, 16);
+    assert_eq!(&obj.union.condvar.lock as *const _ as usize - base, 24);
+    assert_eq!(&obj.union.condvar.condvar_scope as *const _ as usize - base, 32);
+    assert_eq!(&obj.union.condvar.lock_scope as *const _ as usize - base, 33);
+    assert_eq!(&obj.union.fd_readwrite.fd as *const _ as usize - base, 16);
+    assert_eq!(&obj.union.fd_readwrite.flags as *const _ as usize - base, 20);
+    assert_eq!(&obj.union.lock.lock as *const _ as usize - base, 16);
+    assert_eq!(&obj.union.lock.lock_scope as *const _ as usize - base, 24);
+    assert_eq!(&obj.union.proc_terminate.fd as *const _ as usize - base, 16);
+  }
+}
+
+/// The Thread Control Block (TCB).
+///
+/// After a thread begins execution (at program startup or when
+/// created through [`thread_create()`](fn.thread_create.html)), the CPU's registers
+/// controlling Thread-Local Storage (TLS) will already be
+/// initialized. They will point to an area only containing the
+/// TCB.
+///
+/// If the thread needs space for storing thread-specific
+/// variables, the thread may allocate a larger area and adjust
+/// the CPU's registers to point to that area instead. However, it
+/// does need to make sure that the TCB is copied over to the new
+/// TLS area.
+///
+/// The purpose of the TCB is that it allows light-weight
+/// emulators to store information related to individual threads.
+/// For example, it may be used to store a copy of the CPU
+/// registers prior emulation, so that TLS for the host system
+/// can be restored if needed.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct tcb {
+  /// Pointer that may be freely assigned by the system. Its
+  /// value cannot be interpreted by the application.
+  pub parent: *mut (),
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn tcb_layout_test_32() {
+  assert_eq!(::core::mem::size_of::<tcb>(), 4);
+  assert_eq!(::core::mem::align_of::<tcb>(), 4);
+  unsafe {
+    let obj: tcb = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.parent as *const _ as usize - base, 0);
+  }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn tcb_layout_test_64() {
+  assert_eq!(::core::mem::size_of::<tcb>(), 8);
+  assert_eq!(::core::mem::align_of::<tcb>(), 8);
+  unsafe {
+    let obj: tcb = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.parent as *const _ as usize - base, 0);
+  }
+}
+
+/// Entry point for additionally created threads.
+///
+/// **tid**:
+/// Thread ID of the current thread.
+///
+/// **aux**:
+/// Copy of the value stored in
+/// [`threadattr.argument`](struct.threadattr.html#structfield.argument).
+pub type threadentry = unsafe extern "C" fn(
+  tid: tid,
+  aux: *mut (),
+) -> ();
+
+/// Attributes for thread creation.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct threadattr {
+  /// Initial program counter value.
+  pub entry_point: threadentry,
+  /// Region allocated to serve as stack space.
+  pub stack: (*mut (), usize),
+  /// Argument to be forwarded to the entry point function.
+  pub argument: *mut (),
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn threadattr_layout_test_32() {
+  assert_eq!(::core::mem::size_of::<threadattr>(), 16);
+  assert_eq!(::core::mem::align_of::<threadattr>(), 4);
+  unsafe {
+    let obj: threadattr = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.entry_point as *const _ as usize - base, 0);
+    assert_eq!(&obj.stack.0 as *const _ as usize - base, 4);
+    assert_eq!(&obj.stack.1 as *const _ as usize - base, 8);
+    assert_eq!(&obj.argument as *const _ as usize - base, 12);
+  }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn threadattr_layout_test_64() {
+  assert_eq!(::core::mem::size_of::<threadattr>(), 32);
+  assert_eq!(::core::mem::align_of::<threadattr>(), 8);
+  unsafe {
+    let obj: threadattr = ::core::mem::uninitialized();
+    let base = &obj as *const _ as usize;
+    assert_eq!(&obj.entry_point as *const _ as usize - base, 0);
+    assert_eq!(&obj.stack.0 as *const _ as usize - base, 8);
+    assert_eq!(&obj.stack.1 as *const _ as usize - base, 16);
+    assert_eq!(&obj.argument as *const _ as usize - base, 24);
+  }
+}
+
+/// The table with pointers to all syscall implementations.
+#[allow(improper_ctypes)]
+extern "C" {
+  fn cloudabi_sys_clock_res_get(_: clockid, _: *mut timestamp) -> errno;
+  fn cloudabi_sys_clock_time_get(_: clockid, _: timestamp, _: *mut timestamp) -> errno;
+  fn cloudabi_sys_condvar_signal(_: *mut condvar, _: scope, _: nthreads) -> errno;
+  fn cloudabi_sys_fd_close(_: fd) -> errno;
+  fn cloudabi_sys_fd_create1(_: filetype, _: *mut fd) -> errno;
+  fn cloudabi_sys_fd_create2(_: filetype, _: *mut fd, _: *mut fd) -> errno;
+  fn cloudabi_sys_fd_datasync(_: fd) -> errno;
+  fn cloudabi_sys_fd_dup(_: fd, _: *mut fd) -> errno;
+  fn cloudabi_sys_fd_pread(_: fd, _: *const iovec, _: usize, _: filesize, _: *mut usize) -> errno;
+  fn cloudabi_sys_fd_pwrite(_: fd, _: *const ciovec, _: usize, _: filesize, _: *mut usize) -> errno;
+  fn cloudabi_sys_fd_read(_: fd, _: *const iovec, _: usize, _: *mut usize) -> errno;
+  fn cloudabi_sys_fd_replace(_: fd, _: fd) -> errno;
+  fn cloudabi_sys_fd_seek(_: fd, _: filedelta, _: whence, _: *mut filesize) -> errno;
+  fn cloudabi_sys_fd_stat_get(_: fd, _: *mut fdstat) -> errno;
+  fn cloudabi_sys_fd_stat_put(_: fd, _: *const fdstat, _: fdsflags) -> errno;
+  fn cloudabi_sys_fd_sync(_: fd) -> errno;
+  fn cloudabi_sys_fd_write(_: fd, _: *const ciovec, _: usize, _: *mut usize) -> errno;
+  fn cloudabi_sys_file_advise(_: fd, _: filesize, _: filesize, _: advice) -> errno;
+  fn cloudabi_sys_file_allocate(_: fd, _: filesize, _: filesize) -> errno;
+  fn cloudabi_sys_file_create(_: fd, _: *const u8, _: usize, _: filetype) -> errno;
+  fn cloudabi_sys_file_link(_: lookup, _: *const u8, _: usize, _: fd, _: *const u8, _: usize) -> errno;
+  fn cloudabi_sys_file_open(_: lookup, _: *const u8, _: usize, _: oflags, _: *const fdstat, _: *mut fd) -> errno;
+  fn cloudabi_sys_file_readdir(_: fd, _: *mut (), _: usize, _: dircookie, _: *mut usize) -> errno;
+  fn cloudabi_sys_file_readlink(_: fd, _: *const u8, _: usize, _: *mut u8, _: usize, _: *mut usize) -> errno;
+  fn cloudabi_sys_file_rename(_: fd, _: *const u8, _: usize, _: fd, _: *const u8, _: usize) -> errno;
+  fn cloudabi_sys_file_stat_fget(_: fd, _: *mut filestat) -> errno;
+  fn cloudabi_sys_file_stat_fput(_: fd, _: *const filestat, _: fsflags) -> errno;
+  fn cloudabi_sys_file_stat_get(_: lookup, _: *const u8, _: usize, _: *mut filestat) -> errno;
+  fn cloudabi_sys_file_stat_put(_: lookup, _: *const u8, _: usize, _: *const filestat, _: fsflags) -> errno;
+  fn cloudabi_sys_file_symlink(_: *const u8, _: usize, _: fd, _: *const u8, _: usize) -> errno;
+  fn cloudabi_sys_file_unlink(_: fd, _: *const u8, _: usize, _: ulflags) -> errno;
+  fn cloudabi_sys_lock_unlock(_: *mut lock, _: scope) -> errno;
+  fn cloudabi_sys_mem_advise(_: *mut (), _: usize, _: advice) -> errno;
+  fn cloudabi_sys_mem_map(_: *mut (), _: usize, _: mprot, _: mflags, _: fd, _: filesize, _: *mut *mut ()) -> errno;
+  fn cloudabi_sys_mem_protect(_: *mut (), _: usize, _: mprot) -> errno;
+  fn cloudabi_sys_mem_sync(_: *mut (), _: usize, _: msflags) -> errno;
+  fn cloudabi_sys_mem_unmap(_: *mut (), _: usize) -> errno;
+  fn cloudabi_sys_poll(_: *const subscription, _: *mut event, _: usize, _: *mut usize) -> errno;
+  fn cloudabi_sys_proc_exec(_: fd, _: *const (), _: usize, _: *const fd, _: usize) -> errno;
+  fn cloudabi_sys_proc_exit(_: exitcode) -> !;
+  fn cloudabi_sys_proc_fork(_: *mut fd, _: *mut tid) -> errno;
+  fn cloudabi_sys_proc_raise(_: signal) -> errno;
+  fn cloudabi_sys_random_get(_: *mut (), _: usize) -> errno;
+  fn cloudabi_sys_sock_recv(_: fd, _: *const recv_in, _: *mut recv_out) -> errno;
+  fn cloudabi_sys_sock_send(_: fd, _: *const send_in, _: *mut send_out) -> errno;
+  fn cloudabi_sys_sock_shutdown(_: fd, _: sdflags) -> errno;
+  fn cloudabi_sys_thread_create(_: *mut threadattr, _: *mut tid) -> errno;
+  fn cloudabi_sys_thread_exit(_: *mut lock, _: scope) -> !;
+  fn cloudabi_sys_thread_yield() -> errno;
+}
+
+/// Obtains the resolution of a clock.
+///
+/// ## Parameters
+///
+/// **clock_id**:
+/// The clock for which the resolution needs to be
+/// returned.
+///
+/// **resolution**:
+/// The resolution of the clock.
+#[inline]
+pub unsafe fn clock_res_get(clock_id_: clockid, resolution_: &mut timestamp) -> errno {
+  cloudabi_sys_clock_res_get(clock_id_, resolution_)
+}
+
+/// Obtains the time value of a clock.
+///
+/// ## Parameters
+///
+/// **clock_id**:
+/// The clock for which the time needs to be
+/// returned.
+///
+/// **precision**:
+/// The maximum lag (exclusive) that the returned
+/// time value may have, compared to its actual
+/// value.
+///
+/// **time**:
+/// The time value of the clock.
+#[inline]
+pub unsafe fn clock_time_get(clock_id_: clockid, precision_: timestamp, time_: &mut timestamp) -> errno {
+  cloudabi_sys_clock_time_get(clock_id_, precision_, time_)
+}
+
+/// Wakes up threads waiting on a userspace condition variable.
+///
+/// If an invocation of this system call causes all waiting
+/// threads to be woken up, the value of the condition variable
+/// is set to [`CONDVAR_HAS_NO_WAITERS`](constant.CONDVAR_HAS_NO_WAITERS.html). As long as the condition
+/// variable is set to this value, it is not needed to invoke this
+/// system call.
+///
+/// ## Parameters
+///
+/// **condvar**:
+/// The userspace condition variable that has
+/// waiting threads.
+///
+/// **scope**:
+/// Whether the condition variable is stored in
+/// private or shared memory.
+///
+/// **nwaiters**:
+/// The number of threads that need to be woken
+/// up. If it exceeds the number of waiting
+/// threads, all threads are woken up.
+#[inline]
+pub unsafe fn condvar_signal(condvar_: *mut condvar, scope_: scope, nwaiters_: nthreads) -> errno {
+  cloudabi_sys_condvar_signal(condvar_, scope_, nwaiters_)
+}
+
+/// Closes a file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor that needs to be closed.
+#[inline]
+pub unsafe fn fd_close(fd_: fd) -> errno {
+  cloudabi_sys_fd_close(fd_)
+}
+
+/// Creates a file descriptor.
+///
+/// ## Parameters
+///
+/// **type**:
+/// Possible values:
+///
+///   - [`SHARED_MEMORY`](enum.filetype.html#variant.SHARED_MEMORY):
+///     Creates an anonymous shared memory
+///     object.
+///
+/// **fd**:
+/// The file descriptor that has been created.
+#[inline]
+pub unsafe fn fd_create1(type_: filetype, fd_: &mut fd) -> errno {
+  cloudabi_sys_fd_create1(type_, fd_)
+}
+
+/// Creates a pair of file descriptors.
+///
+/// ## Parameters
+///
+/// **type**:
+/// Possible values:
+///
+///   - [`SOCKET_DGRAM`](enum.filetype.html#variant.SOCKET_DGRAM):
+///     Creates a UNIX datagram socket pair.
+///   - [`SOCKET_STREAM`](enum.filetype.html#variant.SOCKET_STREAM):
+///     Creates a UNIX byte-stream socket
+///     pair.
+///
+/// **fd1**:
+/// The first file descriptor of the pair.
+///
+/// **fd2**:
+/// The second file descriptor of the pair.
+#[inline]
+pub unsafe fn fd_create2(type_: filetype, fd1_: &mut fd, fd2_: &mut fd) -> errno {
+  cloudabi_sys_fd_create2(type_, fd1_, fd2_)
+}
+
+/// Synchronizes the data of a file to disk.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor of the file whose data
+/// needs to be synchronized to disk.
+#[inline]
+pub unsafe fn fd_datasync(fd_: fd) -> errno {
+  cloudabi_sys_fd_datasync(fd_)
+}
+
+/// Duplicates a file descriptor.
+///
+/// ## Parameters
+///
+/// **from**:
+/// The file descriptor that needs to be
+/// duplicated.
+///
+/// **fd**:
+/// The new file descriptor.
+#[inline]
+pub unsafe fn fd_dup(from_: fd, fd_: &mut fd) -> errno {
+  cloudabi_sys_fd_dup(from_, fd_)
+}
+
+/// Reads from a file descriptor, without using and updating the
+/// file descriptor's offset.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor from which data should be
+/// read.
+///
+/// **iovs**:
+/// List of scatter/gather vectors where data
+/// should be stored.
+///
+/// **offset**:
+/// The offset within the file at which reading
+/// should start.
+///
+/// **nread**:
+/// The number of bytes read.
+#[inline]
+pub unsafe fn fd_pread(fd_: fd, iovs_: &[iovec], offset_: filesize, nread_: &mut usize) -> errno {
+  cloudabi_sys_fd_pread(fd_, iovs_.as_ptr(), iovs_.len(), offset_, nread_)
+}
+
+/// Writes to a file descriptor, without using and updating the
+/// file descriptor's offset.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor to which data should be
+/// written.
+///
+/// **iovs**:
+/// List of scatter/gather vectors where data
+/// should be retrieved.
+///
+/// **offset**:
+/// The offset within the file at which writing
+/// should start.
+///
+/// **nwritten**:
+/// The number of bytes written.
+#[inline]
+pub unsafe fn fd_pwrite(fd_: fd, iovs_: &[ciovec], offset_: filesize, nwritten_: &mut usize) -> errno {
+  cloudabi_sys_fd_pwrite(fd_, iovs_.as_ptr(), iovs_.len(), offset_, nwritten_)
+}
+
+/// Reads from a file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor from which data should be
+/// read.
+///
+/// **iovs**:
+/// List of scatter/gather vectors where data
+/// should be stored.
+///
+/// **nread**:
+/// The number of bytes read.
+#[inline]
+pub unsafe fn fd_read(fd_: fd, iovs_: &[iovec], nread_: &mut usize) -> errno {
+  cloudabi_sys_fd_read(fd_, iovs_.as_ptr(), iovs_.len(), nread_)
+}
+
+/// Atomically replaces a file descriptor by a copy of another
+/// file descriptor.
+///
+/// Due to the strong focus on thread safety, this environment
+/// does not provide a mechanism to duplicate a file descriptor to
+/// an arbitrary number, like dup2(). This would be prone to race
+/// conditions, as an actual file descriptor with the same number
+/// could be allocated by a different thread at the same time.
+///
+/// This system call provides a way to atomically replace file
+/// descriptors, which would disappear if dup2() were to be
+/// removed entirely.
+///
+/// ## Parameters
+///
+/// **from**:
+/// The file descriptor that needs to be copied.
+///
+/// **to**:
+/// The file descriptor that needs to be
+/// overwritten.
+#[inline]
+pub unsafe fn fd_replace(from_: fd, to_: fd) -> errno {
+  cloudabi_sys_fd_replace(from_, to_)
+}
+
+/// Moves the offset of the file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor whose offset has to be
+/// moved.
+///
+/// **offset**:
+/// The number of bytes to move.
+///
+/// **whence**:
+/// Relative to which position the move should
+/// take place.
+///
+/// **newoffset**:
+/// The new offset of the file descriptor,
+/// relative to the start of the file.
+#[inline]
+pub unsafe fn fd_seek(fd_: fd, offset_: filedelta, whence_: whence, newoffset_: &mut filesize) -> errno {
+  cloudabi_sys_fd_seek(fd_, offset_, whence_, newoffset_)
+}
+
+/// Gets attributes of a file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor whose attributes have to
+/// be obtained.
+///
+/// **buf**:
+/// The buffer where the file descriptor's
+/// attributes are stored.
+#[inline]
+pub unsafe fn fd_stat_get(fd_: fd, buf_: *mut fdstat) -> errno {
+  cloudabi_sys_fd_stat_get(fd_, buf_)
+}
+
+/// Adjusts attributes of a file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor whose attributes have to
+/// be adjusted.
+///
+/// **buf**:
+/// The desired values of the file descriptor
+/// attributes that are adjusted.
+///
+/// **flags**:
+/// A bitmask indicating which attributes have to
+/// be adjusted.
+#[inline]
+pub unsafe fn fd_stat_put(fd_: fd, buf_: *const fdstat, flags_: fdsflags) -> errno {
+  cloudabi_sys_fd_stat_put(fd_, buf_, flags_)
+}
+
+/// Synchronizes the data and metadata of a file to disk.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor of the file whose data
+/// and metadata needs to be synchronized to disk.
+#[inline]
+pub unsafe fn fd_sync(fd_: fd) -> errno {
+  cloudabi_sys_fd_sync(fd_)
+}
+
+/// Writes to a file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor to which data should be
+/// written.
+///
+/// **iovs**:
+/// List of scatter/gather vectors where data
+/// should be retrieved.
+///
+/// **nwritten**:
+/// The number of bytes written.
+#[inline]
+pub unsafe fn fd_write(fd_: fd, iovs_: &[ciovec], nwritten_: &mut usize) -> errno {
+  cloudabi_sys_fd_write(fd_, iovs_.as_ptr(), iovs_.len(), nwritten_)
+}
+
+/// Provides file advisory information on a file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor for which to provide file
+/// advisory information.
+///
+/// **offset**:
+/// The offset within the file to which the
+/// advisory applies.
+///
+/// **len**:
+/// The length of the region to which the advisory
+/// applies.
+///
+/// **advice**:
+/// The advice.
+#[inline]
+pub unsafe fn file_advise(fd_: fd, offset_: filesize, len_: filesize, advice_: advice) -> errno {
+  cloudabi_sys_file_advise(fd_, offset_, len_, advice_)
+}
+
+/// Forces the allocation of space in a file.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file in which the space should be
+/// allocated.
+///
+/// **offset**:
+/// The offset at which the allocation should
+/// start.
+///
+/// **len**:
+/// The length of the area that is allocated.
+#[inline]
+pub unsafe fn file_allocate(fd_: fd, offset_: filesize, len_: filesize) -> errno {
+  cloudabi_sys_file_allocate(fd_, offset_, len_)
+}
+
+/// Creates a file of a specified type.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The working directory at which the resolution
+/// of the file to be created starts.
+///
+/// **path**:
+/// The path at which the file should be created.
+///
+/// **type**:
+/// Possible values:
+///
+///   - [`DIRECTORY`](enum.filetype.html#variant.DIRECTORY):
+///     Creates a directory.
+#[inline]
+pub unsafe fn file_create(fd_: fd, path_: &[u8], type_: filetype) -> errno {
+  cloudabi_sys_file_create(fd_, path_.as_ptr(), path_.len(), type_)
+}
+
+/// Creates a hard link.
+///
+/// ## Parameters
+///
+/// **fd1**:
+/// The working directory at which the resolution
+/// of the source path starts.
+///
+/// **path1**:
+/// The source path of the file that should be
+/// hard linked.
+///
+/// **fd2**:
+/// The working directory at which the resolution
+/// of the destination path starts.
+///
+/// **path2**:
+/// The destination path at which the hard link
+/// should be created.
+#[inline]
+pub unsafe fn file_link(fd1_: lookup, path1_: &[u8], fd2_: fd, path2_: &[u8]) -> errno {
+  cloudabi_sys_file_link(fd1_, path1_.as_ptr(), path1_.len(), fd2_, path2_.as_ptr(), path2_.len())
+}
+
+/// Opens a file.
+///
+/// ## Parameters
+///
+/// **dirfd**:
+/// The working directory at which the resolution
+/// of the file to be opened starts.
+///
+/// **path**:
+/// The path of the file that should be opened.
+///
+/// **oflags**:
+/// The method at which the file should be opened.
+///
+/// **fds**:
+/// [`fdstat.fs_rights_base`](struct.fdstat.html#structfield.fs_rights_base) and
+/// [`fdstat.fs_rights_inheriting`](struct.fdstat.html#structfield.fs_rights_inheriting) specify the
+/// initial rights of the newly created file
+/// descriptor. The operating system is allowed to
+/// return a file descriptor with fewer rights
+/// than specified, if and only if those rights do
+/// not apply to the type of file being opened.
+///
+/// [`fdstat.fs_flags`](struct.fdstat.html#structfield.fs_flags) specifies the initial flags
+/// of the file descriptor.
+///
+/// [`fdstat.fs_filetype`](struct.fdstat.html#structfield.fs_filetype) is ignored.
+///
+/// **fd**:
+/// The file descriptor of the file that has been
+/// opened.
+#[inline]
+pub unsafe fn file_open(dirfd_: lookup, path_: &[u8], oflags_: oflags, fds_: *const fdstat, fd_: &mut fd) -> errno {
+  cloudabi_sys_file_open(dirfd_, path_.as_ptr(), path_.len(), oflags_, fds_, fd_)
+}
+
+/// Reads directory entries from a directory.
+///
+/// When successful, the contents of the output buffer consist of
+/// a sequence of directory entries. Each directory entry consists
+/// of a [`dirent`](struct.dirent.html) object, followed by [`dirent.d_namlen`](struct.dirent.html#structfield.d_namlen) bytes
+/// holding the name of the directory entry.
+///
+/// This system call fills the output buffer as much as possible,
+/// potentially truncating the last directory entry. This allows
+/// the caller to grow its read buffer size in case it's too small
+/// to fit a single large directory entry, or skip the oversized
+/// directory entry.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The directory from which to read the directory
+/// entries.
+///
+/// **buf**:
+/// The buffer where directory entries are stored.
+///
+/// **cookie**:
+/// The location within the directory to start
+/// reading.
+///
+/// **bufused**:
+/// The number of bytes stored in the read buffer.
+/// If less than the size of the read buffer, the
+/// end of the directory has been reached.
+#[inline]
+pub unsafe fn file_readdir(fd_: fd, buf_: &mut [u8], cookie_: dircookie, bufused_: &mut usize) -> errno {
+  cloudabi_sys_file_readdir(fd_, buf_.as_mut_ptr() as *mut (), buf_.len(), cookie_, bufused_)
+}
+
+/// Reads the contents of a symbolic link.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The working directory at which the resolution
+/// of the path of the symbolic starts.
+///
+/// **path**:
+/// The path of the symbolic link whose contents
+/// should be read.
+///
+/// **buf**:
+/// The buffer where the contents of the symbolic
+/// link should be stored.
+///
+/// **bufused**:
+/// The number of bytes placed in the buffer.
+#[inline]
+pub unsafe fn file_readlink(fd_: fd, path_: &[u8], buf_: &mut [u8], bufused_: &mut usize) -> errno {
+  cloudabi_sys_file_readlink(fd_, path_.as_ptr(), path_.len(), buf_.as_mut_ptr(), buf_.len(), bufused_)
+}
+
+/// Renames a file.
+///
+/// ## Parameters
+///
+/// **fd1**:
+/// The working directory at which the resolution
+/// of the source path starts.
+///
+/// **path1**:
+/// The source path of the file that should be
+/// renamed.
+///
+/// **fd2**:
+/// The working directory at which the resolution
+/// of the destination path starts.
+///
+/// **path2**:
+/// The destination path to which the file should
+/// be renamed.
+#[inline]
+pub unsafe fn file_rename(fd1_: fd, path1_: &[u8], fd2_: fd, path2_: &[u8]) -> errno {
+  cloudabi_sys_file_rename(fd1_, path1_.as_ptr(), path1_.len(), fd2_, path2_.as_ptr(), path2_.len())
+}
+
+/// Gets attributes of a file by file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor whose attributes have to
+/// be obtained.
+///
+/// **buf**:
+/// The buffer where the file's attributes are
+/// stored.
+#[inline]
+pub unsafe fn file_stat_fget(fd_: fd, buf_: *mut filestat) -> errno {
+  cloudabi_sys_file_stat_fget(fd_, buf_)
+}
+
+/// Adjusts attributes of a file by file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor whose attributes have to
+/// be adjusted.
+///
+/// **buf**:
+/// The desired values of the file attributes that
+/// are adjusted.
+///
+/// **flags**:
+/// A bitmask indicating which attributes have to
+/// be adjusted.
+#[inline]
+pub unsafe fn file_stat_fput(fd_: fd, buf_: *const filestat, flags_: fsflags) -> errno {
+  cloudabi_sys_file_stat_fput(fd_, buf_, flags_)
+}
+
+/// Gets attributes of a file by path.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The working directory at which the resolution
+/// of the path whose attributes have to be
+/// obtained starts.
+///
+/// **path**:
+/// The path of the file whose attributes have to
+/// be obtained.
+///
+/// **buf**:
+/// The buffer where the file's attributes are
+/// stored.
+#[inline]
+pub unsafe fn file_stat_get(fd_: lookup, path_: &[u8], buf_: *mut filestat) -> errno {
+  cloudabi_sys_file_stat_get(fd_, path_.as_ptr(), path_.len(), buf_)
+}
+
+/// Adjusts attributes of a file by path.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The working directory at which the resolution
+/// of the path whose attributes have to be
+/// adjusted starts.
+///
+/// **path**:
+/// The path of the file whose attributes have to
+/// be adjusted.
+///
+/// **buf**:
+/// The desired values of the file attributes that
+/// are adjusted.
+///
+/// **flags**:
+/// A bitmask indicating which attributes have to
+/// be adjusted.
+#[inline]
+pub unsafe fn file_stat_put(fd_: lookup, path_: &[u8], buf_: *const filestat, flags_: fsflags) -> errno {
+  cloudabi_sys_file_stat_put(fd_, path_.as_ptr(), path_.len(), buf_, flags_)
+}
+
+/// Creates a symbolic link.
+///
+/// ## Parameters
+///
+/// **path1**:
+/// The contents of the symbolic link.
+///
+/// **fd**:
+/// The working directory at which the resolution
+/// of the destination path starts.
+///
+/// **path2**:
+/// The destination path at which the symbolic
+/// link should be created.
+#[inline]
+pub unsafe fn file_symlink(path1_: &[u8], fd_: fd, path2_: &[u8]) -> errno {
+  cloudabi_sys_file_symlink(path1_.as_ptr(), path1_.len(), fd_, path2_.as_ptr(), path2_.len())
+}
+
+/// Unlinks a file, or removes a directory.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The working directory at which the resolution
+/// of the path starts.
+///
+/// **path**:
+/// The path that needs to be unlinked or removed.
+///
+/// **flags**:
+/// Possible values:
+///
+///   - [`REMOVEDIR`](struct.ulflags.html#associatedconstant.REMOVEDIR):
+///     If set, attempt to remove a directory.
+///     Otherwise, unlink a file.
+#[inline]
+pub unsafe fn file_unlink(fd_: fd, path_: &[u8], flags_: ulflags) -> errno {
+  cloudabi_sys_file_unlink(fd_, path_.as_ptr(), path_.len(), flags_)
+}
+
+/// Unlocks a write-locked userspace lock.
+///
+/// If a userspace lock is unlocked while having its
+/// [`LOCK_KERNEL_MANAGED`](constant.LOCK_KERNEL_MANAGED.html) flag set, the lock cannot be unlocked in
+/// userspace directly. This system call needs to be performed
+/// instead, so that any waiting threads can be woken up.
+///
+/// To prevent spurious invocations of this system call, the lock
+/// must be locked for writing. This prevents other threads from
+/// acquiring additional read locks while the system call is in
+/// progress. If the lock is acquired for reading, it must first
+/// be upgraded to a write lock.
+///
+/// ## Parameters
+///
+/// **lock**:
+/// The userspace lock that is locked for writing
+/// by the calling thread.
+///
+/// **scope**:
+/// Whether the lock is stored in private or
+/// shared memory.
+#[inline]
+pub unsafe fn lock_unlock(lock_: *mut lock, scope_: scope) -> errno {
+  cloudabi_sys_lock_unlock(lock_, scope_)
+}
+
+/// Provides memory advisory information on a region of memory.
+///
+/// ## Parameters
+///
+/// **mapping**:
+/// The pages for which to provide memory advisory
+/// information.
+///
+/// **advice**:
+/// The advice.
+#[inline]
+pub unsafe fn mem_advise(mapping_: &mut [u8], advice_: advice) -> errno {
+  cloudabi_sys_mem_advise(mapping_.as_mut_ptr() as *mut (), mapping_.len(), advice_)
+}
+
+/// Creates a memory mapping, making the contents of a file
+/// accessible through memory.
+///
+/// ## Parameters
+///
+/// **addr**:
+/// If [`FIXED`](struct.mflags.html#associatedconstant.FIXED) is set, specifies to which
+/// address the file region is mapped. Otherwise,
+/// the mapping is performed at an unused
+/// location.
+///
+/// **len**:
+/// The length of the memory mapping to be
+/// created.
+///
+/// **prot**:
+/// Initial memory protection options for the
+/// memory mapping.
+///
+/// **flags**:
+/// Memory mapping flags.
+///
+/// **fd**:
+/// If [`ANON`](struct.mflags.html#associatedconstant.ANON) is set, this argument must be
+/// [`MAP_ANON_FD`](constant.MAP_ANON_FD.html). Otherwise, this argument
+/// specifies the file whose contents need to be
+/// mapped.
+///
+/// **off**:
+/// If [`ANON`](struct.mflags.html#associatedconstant.ANON) is set, this argument must be
+/// zero. Otherwise, this argument specifies the
+/// offset within the file at which the mapping
+/// starts.
+///
+/// **mem**:
+/// The starting address of the memory mapping.
+#[inline]
+pub unsafe fn mem_map(addr_: *mut (), len_: usize, prot_: mprot, flags_: mflags, fd_: fd, off_: filesize, mem_: &mut *mut ()) -> errno {
+  cloudabi_sys_mem_map(addr_, len_, prot_, flags_, fd_, off_, mem_)
+}
+
+/// Change the protection of a memory mapping.
+///
+/// ## Parameters
+///
+/// **mapping**:
+/// The pages that need their protection changed.
+///
+/// **prot**:
+/// New protection options.
+#[inline]
+pub unsafe fn mem_protect(mapping_: &mut [u8], prot_: mprot) -> errno {
+  cloudabi_sys_mem_protect(mapping_.as_mut_ptr() as *mut (), mapping_.len(), prot_)
+}
+
+/// Synchronize a region of memory with its physical storage.
+///
+/// ## Parameters
+///
+/// **mapping**:
+/// The pages that need to be synchronized.
+///
+/// **flags**:
+/// The method of synchronization.
+#[inline]
+pub unsafe fn mem_sync(mapping_: &mut [u8], flags_: msflags) -> errno {
+  cloudabi_sys_mem_sync(mapping_.as_mut_ptr() as *mut (), mapping_.len(), flags_)
+}
+
+/// Unmaps a region of memory.
+///
+/// ## Parameters
+///
+/// **mapping**:
+/// The pages that needs to be unmapped.
+#[inline]
+pub unsafe fn mem_unmap(mapping_: &mut [u8]) -> errno {
+  cloudabi_sys_mem_unmap(mapping_.as_mut_ptr() as *mut (), mapping_.len())
+}
+
+/// Concurrently polls for the occurrence of a set of events.
+///
+/// ## Parameters
+///
+/// **in**:
+/// The events to which to subscribe.
+///
+/// **out**:
+/// The events that have occurred.
+///
+/// **nsubscriptions**:
+/// Both the number of subscriptions and events.
+///
+/// **nevents**:
+/// The number of events stored.
+#[inline]
+pub unsafe fn poll(in_: *const subscription, out_: *mut event, nsubscriptions_: usize, nevents_: &mut usize) -> errno {
+  cloudabi_sys_poll(in_, out_, nsubscriptions_, nevents_)
+}
+
+/// Replaces the process by a new executable.
+///
+/// Process execution in CloudABI differs from POSIX in two ways:
+/// handling of arguments and inheritance of file descriptors.
+///
+/// CloudABI does not use string command line arguments. Instead,
+/// a buffer with binary data is copied into the address space of
+/// the new executable. The kernel does not enforce any specific
+/// structure to this data, although CloudABI's C library uses it
+/// to store a tree structure that is semantically identical to
+/// YAML.
+///
+/// Due to the strong focus on thread safety, file descriptors
+/// aren't inherited through close-on-exec flags. An explicit
+/// list of file descriptors that need to be retained needs to be
+/// provided. After execution, file descriptors are placed in the
+/// order in which they are stored in the array. This not only
+/// makes the execution process deterministic. It also prevents
+/// potential information disclosures about the layout of the
+/// original process.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// A file descriptor of the new executable.
+///
+/// **data**:
+/// Binary argument data that is passed on to the
+/// new executable.
+///
+/// **fds**:
+/// The layout of the file descriptor table after
+/// execution.
+#[inline]
+pub unsafe fn proc_exec(fd_: fd, data_: &[u8], fds_: &[fd]) -> errno {
+  cloudabi_sys_proc_exec(fd_, data_.as_ptr() as *const (), data_.len(), fds_.as_ptr(), fds_.len())
+}
+
+/// Terminates the process normally.
+///
+/// ## Parameters
+///
+/// **rval**:
+/// The exit code returned by the process. The
+/// exit code can be obtained by other processes
+/// through [`event.union.proc_terminate.exitcode`](struct.event_proc_terminate.html#structfield.exitcode).
+#[inline]
+pub unsafe fn proc_exit(rval_: exitcode) -> ! {
+  cloudabi_sys_proc_exit(rval_)
+}
+
+/// Forks the process of the calling thread.
+///
+/// After forking, a new process shall be created, having only a
+/// copy of the calling thread. The parent process will obtain a
+/// process descriptor. When closed, the child process is
+/// automatically signaled with [`KILL`](enum.signal.html#variant.KILL).
+///
+/// ## Parameters
+///
+/// **fd**:
+/// In the parent process: the file descriptor
+/// number of the process descriptor.
+///
+/// In the child process: [`PROCESS_CHILD`](constant.PROCESS_CHILD.html).
+///
+/// **tid**:
+/// In the parent process: undefined.
+///
+/// In the child process: the thread ID of the
+/// initial thread of the child process.
+#[inline]
+pub unsafe fn proc_fork(fd_: &mut fd, tid_: &mut tid) -> errno {
+  cloudabi_sys_proc_fork(fd_, tid_)
+}
+
+/// Sends a signal to the process of the calling thread.
+///
+/// ## Parameters
+///
+/// **sig**:
+/// The signal condition that should be triggered.
+/// If the signal causes the process to terminate,
+/// its condition can be obtained by other
+/// processes through
+/// [`event.union.proc_terminate.signal`](struct.event_proc_terminate.html#structfield.signal).
+#[inline]
+pub unsafe fn proc_raise(sig_: signal) -> errno {
+  cloudabi_sys_proc_raise(sig_)
+}
+
+/// Obtains random data from the kernel random number generator.
+///
+/// As this interface is not guaranteed to be fast, it is advised
+/// that the random data obtained through this system call is used
+/// as the seed for a userspace pseudo-random number generator.
+///
+/// ## Parameters
+///
+/// **buf**:
+/// The buffer that needs to be filled with random
+/// data.
+#[inline]
+pub unsafe fn random_get(buf_: &mut [u8]) -> errno {
+  cloudabi_sys_random_get(buf_.as_mut_ptr() as *mut (), buf_.len())
+}
+
+/// Receives a message on a socket.
+///
+/// ## Parameters
+///
+/// **sock**:
+/// The socket on which a message should be
+/// received.
+///
+/// **in**:
+/// Input parameters.
+///
+/// **out**:
+/// Output parameters.
+#[inline]
+pub unsafe fn sock_recv(sock_: fd, in_: *const recv_in, out_: *mut recv_out) -> errno {
+  cloudabi_sys_sock_recv(sock_, in_, out_)
+}
+
+/// Sends a message on a socket.
+///
+/// ## Parameters
+///
+/// **sock**:
+/// The socket on which a message should be sent.
+///
+/// **in**:
+/// Input parameters.
+///
+/// **out**:
+/// Output parameters.
+#[inline]
+pub unsafe fn sock_send(sock_: fd, in_: *const send_in, out_: *mut send_out) -> errno {
+  cloudabi_sys_sock_send(sock_, in_, out_)
+}
+
+/// Shuts down socket send and receive channels.
+///
+/// ## Parameters
+///
+/// **sock**:
+/// The socket that needs its channels shut down.
+///
+/// **how**:
+/// Which channels on the socket need to be shut
+/// down.
+#[inline]
+pub unsafe fn sock_shutdown(sock_: fd, how_: sdflags) -> errno {
+  cloudabi_sys_sock_shutdown(sock_, how_)
+}
+
+/// Creates a new thread within the current process.
+///
+/// ## Parameters
+///
+/// **attr**:
+/// The desired attributes of the new thread.
+///
+/// **tid**:
+/// The thread ID of the new thread.
+#[inline]
+pub unsafe fn thread_create(attr_: *mut threadattr, tid_: &mut tid) -> errno {
+  cloudabi_sys_thread_create(attr_, tid_)
+}
+
+/// Terminates the calling thread.
+///
+/// This system call can also unlock a single userspace lock
+/// after termination, which can be used to implement thread
+/// joining.
+///
+/// ## Parameters
+///
+/// **lock**:
+/// Userspace lock that is locked for writing by
+/// the calling thread.
+///
+/// **scope**:
+/// Whether the lock is stored in private or
+/// shared memory.
+#[inline]
+pub unsafe fn thread_exit(lock_: *mut lock, scope_: scope) -> ! {
+  cloudabi_sys_thread_exit(lock_, scope_)
+}
+
+/// Temporarily yields execution of the calling thread.
+#[inline]
+pub unsafe fn thread_yield() -> errno {
+  cloudabi_sys_thread_yield()
+}
diff --git a/rustc_deps/vendor/rand-0.4.2/.cargo-checksum.json b/rustc_deps/vendor/rand-0.4.2/.cargo-checksum.json
new file mode 100644
index 0000000..9c1f055
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{".travis.yml":"12868a81c3590d8f2c08d53ca51e6b4b9be39d854f81bd4a57f82466cbe8d79a","CHANGELOG.md":"03974fa236c7ac7a29931ef548d05ba1d8e00b1202961310f6d837aca9bc377a","Cargo.toml":"09b6978ce09c8df87e5fe605d1ff5ea920747da588523df8f2f5d1ca3292db80","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"f15d6584b8f417cc743ebcad6b69776874a6ac30807d0ce0ed28f3779be1f151","appveyor.yml":"8796156caf7041ef2a43f7a313df21ea639de3f2563b6181bba1096b1c489f1b","benches/bench.rs":"35c4ab609f2a5f5aab6c52c257415258dc0780621b492b5a82bb12d048cab6db","benches/distributions/exponential.rs":"99cb59c013a0b6bb390d34c5649b341fc3b88ea7df0caf2470bdda8798f9fe3d","benches/distributions/gamma.rs":"3533f311e4b55d743c5b01a7eb6529c94fd97726ef6702a6372f914f5f33666b","benches/distributions/mod.rs":"0028f1cb96f61152ed5b49a4fe91227d809ef6d19035592c36032a538af7f95e","benches/distributions/normal.rs":"4e10c18cb583ccb96301ea953c8e0aa9ee3b6662060271d1b8d19ca23364dc6b","benches/generators.rs":"aaa2f1dbfb399df8323d8a5796b92add6210cd5f0f1d916895ffdd81d60f812b","benches/misc.rs":"bd2f7c5a16f0fcb59022d5aeef66ed3c94e89ebf6c06667851dd23d0b1595504","src/distributions/exponential.rs":"103c8412c8a581b71835f1c00e40f6370e7702adf9d499243933a793d132d4e7","src/distributions/gamma.rs":"7a3f85c8daad4e56e334586ddb9fc9d83df3b0699738ed681a6c41e4ed455be9","src/distributions/mod.rs":"7943c4f83721bac816f831cca3b1574b6136932f7b4927aa6101130080ba62c5","src/distributions/normal.rs":"1562b43f80e4d5f83a8deb5af18de5a18dfeeeeda11fefc577da26672b14c949","src/distributions/range.rs":"a72a538d3ec4ed23f8d632aa55fd4793c464f24a5872d04ce8095ddd5db92115","src/distributions/ziggurat_tables.rs":"4eacf94fc352c91c455a6623de6a721e53842e1690f13a5662b6a79c7fbb73de","src/jitter.rs":"befd4b84bf753c107370b5b9498ad49611c220bdae2e4be9ee4398e9fa497042","src/lib.rs":"c86b28064c2c5abd02694e8bf97c84513b21fefe04e4305f9a78d5e864ef3e3f","src/os.rs":"38c2f26c2784c61ae9a17a7a9c59fcf449dada826a66f66b7f46b0992ef001de","src/prng/chacha.rs":"558007276f9c22933d39e5b8e853f4dd9533e823ed66df8dc1f23ad6925b1d51","src/prng/isaac.rs":"a8a2ee8b38d312663308e3bdf03376e342fd91330655f39144e5bba7392b2a8e","src/prng/isaac64.rs":"f28f7596ccab910db265b42671116abb9d2039fa8a421cbc75312bd0e7715d3a","src/prng/mod.rs":"c1a73450f49e819a20942a5b591f84a08ebb5ac33aa0f65b18ac1dc9a19a3084","src/prng/xorshift.rs":"606c308747293652c868b46dc3cad847d0c3717629c04ba75681c887c7634114","src/rand_impls.rs":"e1f27077fc13d5855bb66235f8ccfb216e116337eb38424d9c30c090e112215c","src/read.rs":"bd0eb508a6b659dc578d546fc2f231484aed80c73cfe8c475e0d65c8d699a769","src/reseeding.rs":"a97b86387b87ea1adc5262ddea480fe735c9c2a86762abaace29119022ac9f6e","src/seq.rs":"76dd58af0f580aed2721c393a5c036322186dc7cb3b4abed33436620c7c49288","utils/ziggurat_tables.py":"a9fc0a2fdae9b5c798c238788f94b720c156e13fd96f2356c409aa533191eb94"},"package":"eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5"}
\ No newline at end of file
diff --git a/rustc_deps/vendor/rand-0.4.2/.travis.yml b/rustc_deps/vendor/rand-0.4.2/.travis.yml
new file mode 100644
index 0000000..f3d7688
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/.travis.yml
@@ -0,0 +1,33 @@
+language: rust
+sudo: false
+
+matrix:
+  include:
+    - rust: 1.15.0
+    - rust: stable
+    - rust: stable
+      os: osx
+    - rust: beta
+    - rust: nightly
+
+    - rust: nightly
+      before_script:
+        - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
+      script:
+        - cargo doc --no-deps --all-features
+        - cargo test --benches
+        - cargo test --features nightly
+      after_success:
+        - travis-cargo --only nightly doc-upload
+
+script:
+  - cargo test
+  - cargo test --manifest-path rand-derive/Cargo.toml
+
+env:
+  global:
+    secure: "BdDntVHSompN+Qxz5Rz45VI4ZqhD72r6aPl166FADlnkIwS6N6FLWdqs51O7G5CpoMXEDvyYrjmRMZe/GYLIG9cmqmn/wUrWPO+PauGiIuG/D2dmfuUNvSTRcIe7UQLXrfP3yyfZPgqsH6pSnNEVopquQKy3KjzqepgriOJtbyY="
+
+notifications:
+  email:
+    on_success: never
diff --git a/rustc_deps/vendor/rand-0.4.2/CHANGELOG.md b/rustc_deps/vendor/rand-0.4.2/CHANGELOG.md
new file mode 100644
index 0000000..4898fc5
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/CHANGELOG.md
@@ -0,0 +1,265 @@
+# Changelog
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
+and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+
+## [0.4.2] - 2018-01-05
+### Changed
+- Use winapi on Windows
+- Update for Fuchsia OS
+- Remove dev-dependency on `log`
+
+## [0.4.1] - 2017-12-17
+### Added
+- `no_std` support
+
+## [0.4.0-pre.0] - 2017-12-11
+### Added
+- `JitterRng` added as a high-quality alternative entropy source using the
+  system timer
+- new `seq` module with `sample_iter`, `sample_slice`, etc.
+- WASM support via dummy implementations (fail at run-time)
+- Additional benchmarks, covering generators and new seq code
+
+### Changed
+- `thread_rng` uses `JitterRng` if seeding from system time fails
+  (slower but more secure than previous method)
+
+### Deprecated
+  - `sample` function deprecated (replaced by `sample_iter`)
+
+## [0.3.18] - 2017-11-06
+### Changed
+- `thread_rng` is seeded from the system time if `OsRng` fails
+- `weak_rng` now uses `thread_rng` internally
+
+
+## [0.3.17] - 2017-10-07
+### Changed
+ - Fuchsia: Magenta was renamed Zircon
+
+## [0.3.16] - 2017-07-27
+### Added
+- Implement Debug for mote non-public types
+- implement `Rand` for (i|u)i128
+- Support for Fuchsia
+
+### Changed
+- Add inline attribute to SampleRange::construct_range.
+  This improves the benchmark for sample in 11% and for shuffle in 16%.
+- Use `RtlGenRandom` instead of `CryptGenRandom`
+
+
+## [0.3.15] - 2016-11-26
+### Added
+- Add `Rng` trait method `choose_mut`
+- Redox support
+
+### Changed
+- Use `arc4rand` for `OsRng` on FreeBSD.
+- Use `arc4random(3)` for `OsRng` on OpenBSD.
+
+### Fixed
+- Fix filling buffers 4 GiB or larger with `OsRng::fill_bytes` on Windows
+
+
+## [0.3.14] - 2016-02-13
+### Fixed
+- Inline definitions from winapi/advapi32, wich decreases build times
+
+
+## [0.3.13] - 2016-01-09
+### Fixed
+- Compatible with Rust 1.7.0-nightly (needed some extra type annotations)
+
+
+## [0.3.12] - 2015-11-09
+### Changed
+- Replaced the methods in `next_f32` and `next_f64` with the technique described
+  Saito & Matsumoto at MCQMC'08. The new method should exhibit a slightly more
+  uniform distribution.
+- Depend on libc 0.2
+
+### Fixed
+- Fix iterator protocol issue in `rand::sample`
+
+
+## [0.3.11] - 2015-08-31
+### Added
+- Implement `Rand` for arrays with n <= 32
+
+
+## [0.3.10] - 2015-08-17
+### Added
+- Support for NaCl platforms
+
+### Changed
+- Allow `Rng` to be `?Sized`, impl for `&mut R` and `Box<R>` where `R: ?Sized + Rng`
+
+
+## [0.3.9] - 2015-06-18
+### Changed
+- Use `winapi` for Windows API things
+
+### Fixed
+- Fixed test on stable/nightly
+- Fix `getrandom` syscall number for aarch64-unknown-linux-gnu
+
+
+## [0.3.8] - 2015-04-23
+### Changed
+- `log` is a dev dependency
+
+### Fixed
+- Fix race condition of atomics in `is_getrandom_available`
+
+
+## [0.3.7] - 2015-04-03
+### Fixed
+- Derive Copy/Clone changes
+
+
+## [0.3.6] - 2015-04-02
+### Changed
+- Move to stable Rust!
+
+
+## [0.3.5] - 2015-04-01
+### Fixed
+- Compatible with Rust master
+
+
+## [0.3.4] - 2015-03-31
+### Added
+- Implement Clone for `Weighted`
+
+### Fixed
+- Compatible with Rust master
+
+
+## [0.3.3] - 2015-03-26
+### Fixed
+- Fix compile on Windows
+
+
+## [0.3.2] - 2015-03-26
+
+
+## [0.3.1] - 2015-03-26
+### Fixed
+- Fix compile on Windows
+
+
+## [0.3.0] - 2015-03-25
+### Changed
+- Update to use log version 0.3.x
+
+
+## [0.2.1] - 2015-03-22
+### Fixed
+- Compatible with Rust master
+- Fixed iOS compilation
+
+
+## [0.2.0] - 2015-03-06
+### Fixed
+- Compatible with Rust master (move from `old_io` to `std::io`)
+
+
+## [0.1.4] - 2015-03-04
+### Fixed
+- Compatible with Rust master (use wrapping ops)
+
+
+## [0.1.3] - 2015-02-20
+### Fixed
+- Compatible with Rust master
+
+### Removed
+- Removed Copy inplementaions from RNGs
+
+
+## [0.1.2] - 2015-02-03
+### Added
+- Imported functionality from `std::rand`, including:
+  - `StdRng`, `SeedableRng`, `TreadRng`, `weak_rng()`
+  - `ReaderRng`: A wrapper around any Reader to treat it as an RNG.
+- Imported documentation from `std::rand`
+- Imported tests from `std::rand`
+
+
+## [0.1.1] - 2015-02-03
+### Added
+- Migrate to a cargo-compatible directory structure.
+
+### Fixed
+- Do not use entropy during `gen_weighted_bool(1)`
+
+
+## [Rust 0.12.0] - 2014-10-09
+### Added
+- Impl Rand for tuples of arity 11 and 12
+- Include ChaCha pseudorandom generator
+- Add `next_f64` and `next_f32` to Rng
+- Implement Clone for PRNGs
+
+### Changed
+- Rename `TaskRng` to `ThreadRng` and `task_rng` to `thread_rng` (since a
+  runtime is removed from Rust).
+
+### Fixed
+- Improved performance of ISAAC and ISAAC64 by 30% and 12 % respectively, by
+  informing the optimiser that indexing is never out-of-bounds.
+
+### Removed
+- Removed the Deprecated `choose_option`
+
+
+## [Rust 0.11.0] - 2014-07-02
+### Added
+- document when to use `OSRng` in cryptographic context, and explain why we use `/dev/urandom` instead of `/dev/random`
+- `Rng::gen_iter()` which will return an infinite stream of random values
+- `Rng::gen_ascii_chars()` which will return an infinite stream of random ascii characters
+
+### Changed
+- Now only depends on libcore!   2adf5363f88ffe06f6d2ea5c338d1b186d47f4a1
+- Remove `Rng.choose()`, rename `Rng.choose_option()` to `.choose()`
+- Rename OSRng to OsRng
+- The WeightedChoice structure is no longer built with a `Vec<Weighted<T>>`,
+  but rather a `&mut [Weighted<T>]`. This means that the WeightedChoice
+  structure now has a lifetime associated with it.
+- The `sample` method on `Rng` has been moved to a top-level function in the
+  `rand` module due to its dependence on `Vec`.
+
+### Removed
+- `Rng::gen_vec()` was removed. Previous behavior can be regained with
+  `rng.gen_iter().take(n).collect()`
+- `Rng::gen_ascii_str()` was removed. Previous behavior can be regained with
+  `rng.gen_ascii_chars().take(n).collect()`
+- {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all
+  relied on being able to use an OSRng for seeding, but this is no longer
+  available in librand (where these types are defined). To retain the same
+  functionality, these types now implement the `Rand` trait so they can be
+  generated with a random seed from another random number generator. This allows
+  the stdlib to use an OSRng to create seeded instances of these RNGs.
+- Rand implementations for `Box<T>` and `@T` were removed. These seemed to be
+  pretty rare in the codebase, and it allows for librand to not depend on
+  liballoc.  Additionally, other pointer types like Rc<T> and Arc<T> were not
+  supported.
+- Remove a slew of old deprecated functions
+
+
+## [Rust 0.10] - 2014-04-03
+### Changed
+- replace `Rng.shuffle's` functionality with `.shuffle_mut`
+- bubble up IO errors when creating an OSRng
+
+### Fixed
+- Use `fill()` instead of `read()`
+- Rewrite OsRng in Rust for windows
+
+## [0.10-pre] - 2014-03-02
+### Added
+- Seperate `rand` out of the standard library
+
diff --git a/rustc_deps/vendor/rand-0.4.2/Cargo.toml b/rustc_deps/vendor/rand-0.4.2/Cargo.toml
new file mode 100644
index 0000000..d20e99f
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/Cargo.toml
@@ -0,0 +1,39 @@
+# 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 = "rand"
+version = "0.4.2"
+authors = ["The Rust Project Developers"]
+description = "Random number generators and other randomness functionality.\n"
+homepage = "https://github.com/rust-lang-nursery/rand"
+documentation = "https://docs.rs/rand"
+readme = "README.md"
+keywords = ["random", "rng"]
+categories = ["algorithms"]
+license = "MIT/Apache-2.0"
+repository = "https://github.com/rust-lang-nursery/rand"
+
+[features]
+alloc = []
+default = ["std"]
+i128_support = []
+nightly = ["i128_support"]
+std = ["libc"]
+[target."cfg(target_os = \"fuchsia\")".dependencies.fuchsia-zircon]
+version = "0.3.2"
+[target."cfg(unix)".dependencies.libc]
+version = "0.2"
+optional = true
+[target."cfg(windows)".dependencies.winapi]
+version = "0.3"
+features = ["minwindef", "ntsecapi", "profileapi", "winnt"]
diff --git a/rustc_deps/vendor/rand-0.4.2/LICENSE-APACHE b/rustc_deps/vendor/rand-0.4.2/LICENSE-APACHE
new file mode 100644
index 0000000..16fe87b
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/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.
diff --git a/rustc_deps/vendor/rand-0.4.2/LICENSE-MIT b/rustc_deps/vendor/rand-0.4.2/LICENSE-MIT
new file mode 100644
index 0000000..39d4bdb
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/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.
diff --git a/rustc_deps/vendor/rand-0.4.2/README.md b/rustc_deps/vendor/rand-0.4.2/README.md
new file mode 100644
index 0000000..ffe3980
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/README.md
@@ -0,0 +1,142 @@
+rand
+====
+
+A Rust library for random number generators and other randomness functionality.
+
+[![Build Status](https://travis-ci.org/rust-lang-nursery/rand.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/rand)
+[![Build status](https://ci.appveyor.com/api/projects/status/rm5c9o33k3jhchbw?svg=true)](https://ci.appveyor.com/project/alexcrichton/rand)
+
+[Documentation](https://docs.rs/rand)
+
+## Usage
+
+Add this to your `Cargo.toml`:
+
+```toml
+[dependencies]
+rand = "0.4"
+```
+
+and this to your crate root:
+
+```rust
+extern crate rand;
+```
+
+### Versions
+
+The `rand` crate has been at version `0.3` since March 2015. If you wish to
+avoid all breaking changes you may wish to stick with this version.
+
+Version `0.4`was released in December 2017. It contains almost no breaking
+changes since the `0.3` series, but nevertheless contains some significant
+new code, including a new "external" entropy source (`JitterRng`) and `no_std`
+support.
+
+Version `0.5` is in development and contains significant performance
+improvements for the ISAAC random number generators.
+
+## Examples
+
+There is built-in support for a random number generator (RNG) associated with each thread stored in thread-local storage. This RNG can be accessed via thread_rng, or used implicitly via random. This RNG is normally randomly seeded from an operating-system source of randomness, e.g. /dev/urandom on Unix systems, and will automatically reseed itself from this source after generating 32 KiB of random data.
+
+```rust
+let tuple = rand::random::<(f64, char)>();
+println!("{:?}", tuple)
+```
+
+```rust
+use rand::Rng;
+
+let mut rng = rand::thread_rng();
+if rng.gen() { // random bool
+    println!("i32: {}, u32: {}", rng.gen::<i32>(), rng.gen::<u32>())
+}
+```
+
+It is also possible to use other RNG types, which have a similar interface. The following uses the "ChaCha" algorithm instead of the default.
+
+```rust
+use rand::{Rng, ChaChaRng};
+
+let mut rng = rand::ChaChaRng::new_unseeded();
+println!("i32: {}, u32: {}", rng.gen::<i32>(), rng.gen::<u32>())
+```
+
+## Features
+
+By default, `rand` is built with all stable features available. The following
+optional features are available:
+
+-   `i128_support` enables support for generating `u128` and `i128` values
+-   `nightly` enables all unstable features (`i128_support`)
+-   `std` enabled by default; by setting "default-features = false" `no_std`
+    mode is activated; this removes features depending on `std` functionality:
+    
+        -   `OsRng` is entirely unavailable
+        -   `JitterRng` code is still present, but a nanosecond timer must be
+            provided via `JitterRng::new_with_timer`
+        -   Since no external entropy is available, it is not possible to create
+            generators with fresh seeds (user must provide entropy)
+        -   `thread_rng`, `weak_rng` and `random` are all disabled
+        -   exponential, normal and gamma type distributions are unavailable
+            since `exp` and `log` functions are not provided in `core`
+        -   any code requiring `Vec` or `Box`
+-   `alloc` can be used instead of `std` to provide `Vec` and `Box`
+
+## Testing
+
+Unfortunately, `cargo test` does not test everything. The following tests are
+recommended:
+
+```
+# Basic tests for rand and sub-crates
+cargo test --all
+
+# Test no_std support (build only since nearly all tests require std)
+cargo build --all --no-default-features
+
+# Test 128-bit support (requires nightly)
+cargo test --all --features nightly
+
+# Benchmarks (requires nightly)
+cargo bench
+# or just to test the benchmark code:
+cargo test --benches
+```
+
+# `derive(Rand)`
+
+You can derive the `Rand` trait for your custom type via the `#[derive(Rand)]`
+directive. To use this first add this to your Cargo.toml:
+
+```toml
+rand = "0.4"
+rand_derive = "0.3"
+```
+
+Next in your crate:
+
+```rust
+extern crate rand;
+#[macro_use]
+extern crate rand_derive;
+
+#[derive(Rand, Debug)]
+struct MyStruct {
+    a: i32,
+    b: u32,
+}
+
+fn main() {
+    println!("{:?}", rand::random::<MyStruct>());
+}
+```
+
+
+# License
+
+`rand` is primarily distributed under the terms of both the MIT
+license and the Apache License (Version 2.0).
+
+See LICENSE-APACHE, and LICENSE-MIT for details.
diff --git a/rustc_deps/vendor/rand-0.4.2/appveyor.yml b/rustc_deps/vendor/rand-0.4.2/appveyor.yml
new file mode 100644
index 0000000..02e217f
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/appveyor.yml
@@ -0,0 +1,38 @@
+environment:
+
+  # At the time this was added AppVeyor was having troubles with checking
+  # revocation of SSL certificates of sites like static.rust-lang.org and what
+  # we think is crates.io. The libcurl HTTP client by default checks for
+  # revocation on Windows and according to a mailing list [1] this can be
+  # disabled.
+  #
+  # The `CARGO_HTTP_CHECK_REVOKE` env var here tells cargo to disable SSL
+  # revocation checking on Windows in libcurl. Note, though, that rustup, which
+  # we're using to download Rust here, also uses libcurl as the default backend.
+  # Unlike Cargo, however, rustup doesn't have a mechanism to disable revocation
+  # checking. To get rustup working we set `RUSTUP_USE_HYPER` which forces it to
+  # use the Hyper instead of libcurl backend. Both Hyper and libcurl use
+  # schannel on Windows but it appears that Hyper configures it slightly
+  # differently such that revocation checking isn't turned on by default.
+  #
+  # [1]: https://curl.haxx.se/mail/lib-2016-03/0202.html
+  RUSTUP_USE_HYPER: 1
+  CARGO_HTTP_CHECK_REVOKE: false
+
+  matrix:
+  - TARGET: x86_64-pc-windows-msvc
+  - TARGET: i686-pc-windows-msvc
+install:
+  - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
+  - rustup-init.exe -y --default-host %TARGET% --default-toolchain nightly
+  - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
+  - rustc -V
+  - cargo -V
+
+build: false
+
+test_script:
+  - cargo test --benches
+  - cargo test
+  - cargo test --features nightly
+  - cargo test --manifest-path rand-derive/Cargo.toml
diff --git a/rustc_deps/vendor/rand/benches/bench.rs b/rustc_deps/vendor/rand-0.4.2/benches/bench.rs
similarity index 100%
rename from rustc_deps/vendor/rand/benches/bench.rs
rename to rustc_deps/vendor/rand-0.4.2/benches/bench.rs
diff --git a/rustc_deps/vendor/rand/benches/distributions/exponential.rs b/rustc_deps/vendor/rand-0.4.2/benches/distributions/exponential.rs
similarity index 100%
rename from rustc_deps/vendor/rand/benches/distributions/exponential.rs
rename to rustc_deps/vendor/rand-0.4.2/benches/distributions/exponential.rs
diff --git a/rustc_deps/vendor/rand/benches/distributions/gamma.rs b/rustc_deps/vendor/rand-0.4.2/benches/distributions/gamma.rs
similarity index 100%
rename from rustc_deps/vendor/rand/benches/distributions/gamma.rs
rename to rustc_deps/vendor/rand-0.4.2/benches/distributions/gamma.rs
diff --git a/rustc_deps/vendor/rand/benches/distributions/mod.rs b/rustc_deps/vendor/rand-0.4.2/benches/distributions/mod.rs
similarity index 100%
rename from rustc_deps/vendor/rand/benches/distributions/mod.rs
rename to rustc_deps/vendor/rand-0.4.2/benches/distributions/mod.rs
diff --git a/rustc_deps/vendor/rand/benches/distributions/normal.rs b/rustc_deps/vendor/rand-0.4.2/benches/distributions/normal.rs
similarity index 100%
rename from rustc_deps/vendor/rand/benches/distributions/normal.rs
rename to rustc_deps/vendor/rand-0.4.2/benches/distributions/normal.rs
diff --git a/rustc_deps/vendor/rand-0.4.2/benches/generators.rs b/rustc_deps/vendor/rand-0.4.2/benches/generators.rs
new file mode 100644
index 0000000..daee7c5
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/benches/generators.rs
@@ -0,0 +1,133 @@
+#![feature(test)]
+
+extern crate test;
+extern crate rand;
+
+const RAND_BENCH_N: u64 = 1000;
+const BYTES_LEN: usize = 1024;
+
+use std::mem::size_of;
+use test::{black_box, Bencher};
+
+use rand::{Rng, StdRng, OsRng, JitterRng};
+use rand::{XorShiftRng, IsaacRng, Isaac64Rng, ChaChaRng};
+
+macro_rules! gen_bytes {
+    ($fnn:ident, $gen:ident) => {
+        #[bench]
+        fn $fnn(b: &mut Bencher) {
+            let mut rng: $gen = OsRng::new().unwrap().gen();
+            let mut buf = [0u8; BYTES_LEN];
+            b.iter(|| {
+                for _ in 0..RAND_BENCH_N {
+                    rng.fill_bytes(&mut buf);
+                    black_box(buf);
+                }
+            });
+            b.bytes = BYTES_LEN as u64 * RAND_BENCH_N;
+        }
+    }
+}
+
+macro_rules! gen_bytes_new {
+    ($fnn:ident, $gen:ident) => {
+        #[bench]
+        fn $fnn(b: &mut Bencher) {
+            let mut rng = $gen::new().unwrap();
+            let mut buf = [0u8; BYTES_LEN];
+            b.iter(|| {
+                for _ in 0..RAND_BENCH_N {
+                    rng.fill_bytes(&mut buf);
+                    black_box(buf);
+                }
+            });
+            b.bytes = BYTES_LEN as u64 * RAND_BENCH_N;
+        }
+    }
+}
+
+gen_bytes!(gen_bytes_xorshift, XorShiftRng);
+gen_bytes!(gen_bytes_isaac, IsaacRng);
+gen_bytes!(gen_bytes_isaac64, Isaac64Rng);
+gen_bytes!(gen_bytes_chacha, ChaChaRng);
+gen_bytes_new!(gen_bytes_std, StdRng);
+gen_bytes_new!(gen_bytes_os, OsRng);
+
+
+macro_rules! gen_uint {
+    ($fnn:ident, $ty:ty, $gen:ident) => {
+        #[bench]
+        fn $fnn(b: &mut Bencher) {
+            let mut rng: $gen = OsRng::new().unwrap().gen();
+            b.iter(|| {
+                for _ in 0..RAND_BENCH_N {
+                    black_box(rng.gen::<$ty>());
+                }
+            });
+            b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N;
+        }
+    }
+}
+
+macro_rules! gen_uint_new {
+    ($fnn:ident, $ty:ty, $gen:ident) => {
+        #[bench]
+        fn $fnn(b: &mut Bencher) {
+            let mut rng = $gen::new().unwrap();
+            b.iter(|| {
+                for _ in 0..RAND_BENCH_N {
+                    black_box(rng.gen::<$ty>());
+                }
+            });
+            b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N;
+        }
+    }
+}
+
+gen_uint!(gen_u32_xorshift, u32, XorShiftRng);
+gen_uint!(gen_u32_isaac, u32, IsaacRng);
+gen_uint!(gen_u32_isaac64, u32, Isaac64Rng);
+gen_uint!(gen_u32_chacha, u32, ChaChaRng);
+gen_uint_new!(gen_u32_std, u32, StdRng);
+gen_uint_new!(gen_u32_os, u32, OsRng);
+
+gen_uint!(gen_u64_xorshift, u64, XorShiftRng);
+gen_uint!(gen_u64_isaac, u64, IsaacRng);
+gen_uint!(gen_u64_isaac64, u64, Isaac64Rng);
+gen_uint!(gen_u64_chacha, u64, ChaChaRng);
+gen_uint_new!(gen_u64_std, u64, StdRng);
+gen_uint_new!(gen_u64_os, u64, OsRng);
+
+#[bench]
+fn gen_u64_jitter(b: &mut Bencher) {
+    let mut rng = JitterRng::new().unwrap();
+    b.iter(|| {
+        black_box(rng.gen::<u64>());
+    });
+    b.bytes = size_of::<u64>() as u64;
+}
+
+macro_rules! init_gen {
+    ($fnn:ident, $gen:ident) => {
+        #[bench]
+        fn $fnn(b: &mut Bencher) {
+            let mut rng: XorShiftRng = OsRng::new().unwrap().gen();
+            b.iter(|| {
+                let r2: $gen = rng.gen();
+                black_box(r2);
+            });
+        }
+    }
+}
+
+init_gen!(init_xorshift, XorShiftRng);
+init_gen!(init_isaac, IsaacRng);
+init_gen!(init_isaac64, Isaac64Rng);
+init_gen!(init_chacha, ChaChaRng);
+
+#[bench]
+fn init_jitter(b: &mut Bencher) {
+    b.iter(|| {
+        black_box(JitterRng::new().unwrap());
+    });
+}
diff --git a/rustc_deps/vendor/rand-0.4.2/benches/misc.rs b/rustc_deps/vendor/rand-0.4.2/benches/misc.rs
new file mode 100644
index 0000000..4251761
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/benches/misc.rs
@@ -0,0 +1,62 @@
+#![feature(test)]
+
+extern crate test;
+extern crate rand;
+
+use test::{black_box, Bencher};
+
+use rand::{Rng, weak_rng};
+use rand::seq::*;
+
+#[bench]
+fn misc_shuffle_100(b: &mut Bencher) {
+    let mut rng = weak_rng();
+    let x : &mut [usize] = &mut [1; 100];
+    b.iter(|| {
+        rng.shuffle(x);
+        black_box(&x);
+    })
+}
+
+#[bench]
+fn misc_sample_iter_10_of_100(b: &mut Bencher) {
+    let mut rng = weak_rng();
+    let x : &[usize] = &[1; 100];
+    b.iter(|| {
+        black_box(sample_iter(&mut rng, x, 10).unwrap_or_else(|e| e));
+    })
+}
+
+#[bench]
+fn misc_sample_slice_10_of_100(b: &mut Bencher) {
+    let mut rng = weak_rng();
+    let x : &[usize] = &[1; 100];
+    b.iter(|| {
+        black_box(sample_slice(&mut rng, x, 10));
+    })
+}
+
+#[bench]
+fn misc_sample_slice_ref_10_of_100(b: &mut Bencher) {
+    let mut rng = weak_rng();
+    let x : &[usize] = &[1; 100];
+    b.iter(|| {
+        black_box(sample_slice_ref(&mut rng, x, 10));
+    })
+}
+
+macro_rules! sample_indices {
+    ($name:ident, $amount:expr, $length:expr) => {
+        #[bench]
+        fn $name(b: &mut Bencher) {
+            let mut rng = weak_rng();
+            b.iter(|| {
+                black_box(sample_indices(&mut rng, $length, $amount));
+            })
+        }
+    }
+}
+
+sample_indices!(misc_sample_indices_10_of_1k, 10, 1000);
+sample_indices!(misc_sample_indices_50_of_1k, 50, 1000);
+sample_indices!(misc_sample_indices_100_of_1k, 100, 1000);
diff --git a/rustc_deps/vendor/rand-0.4.2/src/distributions/exponential.rs b/rustc_deps/vendor/rand-0.4.2/src/distributions/exponential.rs
new file mode 100644
index 0000000..c3c924c
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/src/distributions/exponential.rs
@@ -0,0 +1,124 @@
+// Copyright 2013 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.
+
+//! The exponential distribution.
+
+use {Rng, Rand};
+use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
+
+/// A wrapper around an `f64` to generate Exp(1) random numbers.
+///
+/// See `Exp` for the general exponential distribution.
+///
+/// Implemented via the ZIGNOR variant[1] of the Ziggurat method. The
+/// exact description in the paper was adjusted to use tables for the
+/// exponential distribution rather than normal.
+///
+/// [1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to
+/// Generate Normal Random
+/// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield
+/// College, Oxford
+///
+/// # Example
+///
+/// ```rust
+/// use rand::distributions::exponential::Exp1;
+///
+/// let Exp1(x) = rand::random();
+/// println!("{}", x);
+/// ```
+#[derive(Clone, Copy, Debug)]
+pub struct Exp1(pub f64);
+
+// This could be done via `-rng.gen::<f64>().ln()` but that is slower.
+impl Rand for Exp1 {
+    #[inline]
+    fn rand<R:Rng>(rng: &mut R) -> Exp1 {
+        #[inline]
+        fn pdf(x: f64) -> f64 {
+            (-x).exp()
+        }
+        #[inline]
+        fn zero_case<R:Rng>(rng: &mut R, _u: f64) -> f64 {
+            ziggurat_tables::ZIG_EXP_R - rng.gen::<f64>().ln()
+        }
+
+        Exp1(ziggurat(rng, false,
+                      &ziggurat_tables::ZIG_EXP_X,
+                      &ziggurat_tables::ZIG_EXP_F,
+                      pdf, zero_case))
+    }
+}
+
+/// The exponential distribution `Exp(lambda)`.
+///
+/// This distribution has density function: `f(x) = lambda *
+/// exp(-lambda * x)` for `x > 0`.
+///
+/// # Example
+///
+/// ```rust
+/// use rand::distributions::{Exp, IndependentSample};
+///
+/// let exp = Exp::new(2.0);
+/// let v = exp.ind_sample(&mut rand::thread_rng());
+/// println!("{} is from a Exp(2) distribution", v);
+/// ```
+#[derive(Clone, Copy, Debug)]
+pub struct Exp {
+    /// `lambda` stored as `1/lambda`, since this is what we scale by.
+    lambda_inverse: f64
+}
+
+impl Exp {
+    /// Construct a new `Exp` with the given shape parameter
+    /// `lambda`. Panics if `lambda <= 0`.
+    #[inline]
+    pub fn new(lambda: f64) -> Exp {
+        assert!(lambda > 0.0, "Exp::new called with `lambda` <= 0");
+        Exp { lambda_inverse: 1.0 / lambda }
+    }
+}
+
+impl Sample<f64> for Exp {
+    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
+}
+impl IndependentSample<f64> for Exp {
+    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
+        let Exp1(n) = rng.gen::<Exp1>();
+        n * self.lambda_inverse
+    }
+}
+
+#[cfg(test)]
+mod test {
+    use distributions::{Sample, IndependentSample};
+    use super::Exp;
+
+    #[test]
+    fn test_exp() {
+        let mut exp = Exp::new(10.0);
+        let mut rng = ::test::rng();
+        for _ in 0..1000 {
+            assert!(exp.sample(&mut rng) >= 0.0);
+            assert!(exp.ind_sample(&mut rng) >= 0.0);
+        }
+    }
+    #[test]
+    #[should_panic]
+    fn test_exp_invalid_lambda_zero() {
+        Exp::new(0.0);
+    }
+    #[test]
+    #[should_panic]
+    fn test_exp_invalid_lambda_neg() {
+        Exp::new(-10.0);
+    }
+}
diff --git a/rustc_deps/vendor/rand-0.4.2/src/distributions/gamma.rs b/rustc_deps/vendor/rand-0.4.2/src/distributions/gamma.rs
new file mode 100644
index 0000000..2806495
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/src/distributions/gamma.rs
@@ -0,0 +1,386 @@
+// Copyright 2013 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.
+//
+// ignore-lexer-test FIXME #15679
+
+//! The Gamma and derived distributions.
+
+use self::GammaRepr::*;
+use self::ChiSquaredRepr::*;
+
+use {Rng, Open01};
+use super::normal::StandardNormal;
+use super::{IndependentSample, Sample, Exp};
+
+/// The Gamma distribution `Gamma(shape, scale)` distribution.
+///
+/// The density function of this distribution is
+///
+/// ```text
+/// f(x) =  x^(k - 1) * exp(-x / θ) / (Γ(k) * θ^k)
+/// ```
+///
+/// where `Γ` is the Gamma function, `k` is the shape and `θ` is the
+/// scale and both `k` and `θ` are strictly positive.
+///
+/// The algorithm used is that described by Marsaglia & Tsang 2000[1],
+/// falling back to directly sampling from an Exponential for `shape
+/// == 1`, and using the boosting technique described in [1] for
+/// `shape < 1`.
+///
+/// # Example
+///
+/// ```rust
+/// use rand::distributions::{IndependentSample, Gamma};
+///
+/// let gamma = Gamma::new(2.0, 5.0);
+/// let v = gamma.ind_sample(&mut rand::thread_rng());
+/// println!("{} is from a Gamma(2, 5) distribution", v);
+/// ```
+///
+/// [1]: George Marsaglia and Wai Wan Tsang. 2000. "A Simple Method
+/// for Generating Gamma Variables" *ACM Trans. Math. Softw.* 26, 3
+/// (September 2000),
+/// 363-372. DOI:[10.1145/358407.358414](http://doi.acm.org/10.1145/358407.358414)
+#[derive(Clone, Copy, Debug)]
+pub struct Gamma {
+    repr: GammaRepr,
+}
+
+#[derive(Clone, Copy, Debug)]
+enum GammaRepr {
+    Large(GammaLargeShape),
+    One(Exp),
+    Small(GammaSmallShape)
+}
+
+// These two helpers could be made public, but saving the
+// match-on-Gamma-enum branch from using them directly (e.g. if one
+// knows that the shape is always > 1) doesn't appear to be much
+// faster.
+
+/// Gamma distribution where the shape parameter is less than 1.
+///
+/// Note, samples from this require a compulsory floating-point `pow`
+/// call, which makes it significantly slower than sampling from a
+/// gamma distribution where the shape parameter is greater than or
+/// equal to 1.
+///
+/// See `Gamma` for sampling from a Gamma distribution with general
+/// shape parameters.
+#[derive(Clone, Copy, Debug)]
+struct GammaSmallShape {
+    inv_shape: f64,
+    large_shape: GammaLargeShape
+}
+
+/// Gamma distribution where the shape parameter is larger than 1.
+///
+/// See `Gamma` for sampling from a Gamma distribution with general
+/// shape parameters.
+#[derive(Clone, Copy, Debug)]
+struct GammaLargeShape {
+    scale: f64,
+    c: f64,
+    d: f64
+}
+
+impl Gamma {
+    /// Construct an object representing the `Gamma(shape, scale)`
+    /// distribution.
+    ///
+    /// Panics if `shape <= 0` or `scale <= 0`.
+    #[inline]
+    pub fn new(shape: f64, scale: f64) -> Gamma {
+        assert!(shape > 0.0, "Gamma::new called with shape <= 0");
+        assert!(scale > 0.0, "Gamma::new called with scale <= 0");
+
+        let repr = if shape == 1.0 {
+            One(Exp::new(1.0 / scale))
+        } else if shape < 1.0 {
+            Small(GammaSmallShape::new_raw(shape, scale))
+        } else {
+            Large(GammaLargeShape::new_raw(shape, scale))
+        };
+        Gamma { repr: repr }
+    }
+}
+
+impl GammaSmallShape {
+    fn new_raw(shape: f64, scale: f64) -> GammaSmallShape {
+        GammaSmallShape {
+            inv_shape: 1. / shape,
+            large_shape: GammaLargeShape::new_raw(shape + 1.0, scale)
+        }
+    }
+}
+
+impl GammaLargeShape {
+    fn new_raw(shape: f64, scale: f64) -> GammaLargeShape {
+        let d = shape - 1. / 3.;
+        GammaLargeShape {
+            scale: scale,
+            c: 1. / (9. * d).sqrt(),
+            d: d
+        }
+    }
+}
+
+impl Sample<f64> for Gamma {
+    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
+}
+impl Sample<f64> for GammaSmallShape {
+    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
+}
+impl Sample<f64> for GammaLargeShape {
+    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
+}
+
+impl IndependentSample<f64> for Gamma {
+    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
+        match self.repr {
+            Small(ref g) => g.ind_sample(rng),
+            One(ref g) => g.ind_sample(rng),
+            Large(ref g) => g.ind_sample(rng),
+        }
+    }
+}
+impl IndependentSample<f64> for GammaSmallShape {
+    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
+        let Open01(u) = rng.gen::<Open01<f64>>();
+
+        self.large_shape.ind_sample(rng) * u.powf(self.inv_shape)
+    }
+}
+impl IndependentSample<f64> for GammaLargeShape {
+    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
+        loop {
+            let StandardNormal(x) = rng.gen::<StandardNormal>();
+            let v_cbrt = 1.0 + self.c * x;
+            if v_cbrt <= 0.0 { // a^3 <= 0 iff a <= 0
+                continue
+            }
+
+            let v = v_cbrt * v_cbrt * v_cbrt;
+            let Open01(u) = rng.gen::<Open01<f64>>();
+
+            let x_sqr = x * x;
+            if u < 1.0 - 0.0331 * x_sqr * x_sqr ||
+                u.ln() < 0.5 * x_sqr + self.d * (1.0 - v + v.ln()) {
+                return self.d * v * self.scale
+            }
+        }
+    }
+}
+
+/// The chi-squared distribution `χ²(k)`, where `k` is the degrees of
+/// freedom.
+///
+/// For `k > 0` integral, this distribution is the sum of the squares
+/// of `k` independent standard normal random variables. For other
+/// `k`, this uses the equivalent characterisation
+/// `χ²(k) = Gamma(k/2, 2)`.
+///
+/// # Example
+///
+/// ```rust
+/// use rand::distributions::{ChiSquared, IndependentSample};
+///
+/// let chi = ChiSquared::new(11.0);
+/// let v = chi.ind_sample(&mut rand::thread_rng());
+/// println!("{} is from a χ²(11) distribution", v)
+/// ```
+#[derive(Clone, Copy, Debug)]
+pub struct ChiSquared {
+    repr: ChiSquaredRepr,
+}
+
+#[derive(Clone, Copy, Debug)]
+enum ChiSquaredRepr {
+    // k == 1, Gamma(alpha, ..) is particularly slow for alpha < 1,
+    // e.g. when alpha = 1/2 as it would be for this case, so special-
+    // casing and using the definition of N(0,1)^2 is faster.
+    DoFExactlyOne,
+    DoFAnythingElse(Gamma),
+}
+
+impl ChiSquared {
+    /// Create a new chi-squared distribution with degrees-of-freedom
+    /// `k`. Panics if `k < 0`.
+    pub fn new(k: f64) -> ChiSquared {
+        let repr = if k == 1.0 {
+            DoFExactlyOne
+        } else {
+            assert!(k > 0.0, "ChiSquared::new called with `k` < 0");
+            DoFAnythingElse(Gamma::new(0.5 * k, 2.0))
+        };
+        ChiSquared { repr: repr }
+    }
+}
+impl Sample<f64> for ChiSquared {
+    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
+}
+impl IndependentSample<f64> for ChiSquared {
+    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
+        match self.repr {
+            DoFExactlyOne => {
+                // k == 1 => N(0,1)^2
+                let StandardNormal(norm) = rng.gen::<StandardNormal>();
+                norm * norm
+            }
+            DoFAnythingElse(ref g) => g.ind_sample(rng)
+        }
+    }
+}
+
+/// The Fisher F distribution `F(m, n)`.
+///
+/// This distribution is equivalent to the ratio of two normalised
+/// chi-squared distributions, that is, `F(m,n) = (χ²(m)/m) /
+/// (χ²(n)/n)`.
+///
+/// # Example
+///
+/// ```rust
+/// use rand::distributions::{FisherF, IndependentSample};
+///
+/// let f = FisherF::new(2.0, 32.0);
+/// let v = f.ind_sample(&mut rand::thread_rng());
+/// println!("{} is from an F(2, 32) distribution", v)
+/// ```
+#[derive(Clone, Copy, Debug)]
+pub struct FisherF {
+    numer: ChiSquared,
+    denom: ChiSquared,
+    // denom_dof / numer_dof so that this can just be a straight
+    // multiplication, rather than a division.
+    dof_ratio: f64,
+}
+
+impl FisherF {
+    /// Create a new `FisherF` distribution, with the given
+    /// parameter. Panics if either `m` or `n` are not positive.
+    pub fn new(m: f64, n: f64) -> FisherF {
+        assert!(m > 0.0, "FisherF::new called with `m < 0`");
+        assert!(n > 0.0, "FisherF::new called with `n < 0`");
+
+        FisherF {
+            numer: ChiSquared::new(m),
+            denom: ChiSquared::new(n),
+            dof_ratio: n / m
+        }
+    }
+}
+impl Sample<f64> for FisherF {
+    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
+}
+impl IndependentSample<f64> for FisherF {
+    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
+        self.numer.ind_sample(rng) / self.denom.ind_sample(rng) * self.dof_ratio
+    }
+}
+
+/// The Student t distribution, `t(nu)`, where `nu` is the degrees of
+/// freedom.
+///
+/// # Example
+///
+/// ```rust
+/// use rand::distributions::{StudentT, IndependentSample};
+///
+/// let t = StudentT::new(11.0);
+/// let v = t.ind_sample(&mut rand::thread_rng());
+/// println!("{} is from a t(11) distribution", v)
+/// ```
+#[derive(Clone, Copy, Debug)]
+pub struct StudentT {
+    chi: ChiSquared,
+    dof: f64
+}
+
+impl StudentT {
+    /// Create a new Student t distribution with `n` degrees of
+    /// freedom. Panics if `n <= 0`.
+    pub fn new(n: f64) -> StudentT {
+        assert!(n > 0.0, "StudentT::new called with `n <= 0`");
+        StudentT {
+            chi: ChiSquared::new(n),
+            dof: n
+        }
+    }
+}
+impl Sample<f64> for StudentT {
+    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
+}
+impl IndependentSample<f64> for StudentT {
+    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
+        let StandardNormal(norm) = rng.gen::<StandardNormal>();
+        norm * (self.dof / self.chi.ind_sample(rng)).sqrt()
+    }
+}
+
+#[cfg(test)]
+mod test {
+    use distributions::{Sample, IndependentSample};
+    use super::{ChiSquared, StudentT, FisherF};
+
+    #[test]
+    fn test_chi_squared_one() {
+        let mut chi = ChiSquared::new(1.0);
+        let mut rng = ::test::rng();
+        for _ in 0..1000 {
+            chi.sample(&mut rng);
+            chi.ind_sample(&mut rng);
+        }
+    }
+    #[test]
+    fn test_chi_squared_small() {
+        let mut chi = ChiSquared::new(0.5);
+        let mut rng = ::test::rng();
+        for _ in 0..1000 {
+            chi.sample(&mut rng);
+            chi.ind_sample(&mut rng);
+        }
+    }
+    #[test]
+    fn test_chi_squared_large() {
+        let mut chi = ChiSquared::new(30.0);
+        let mut rng = ::test::rng();
+        for _ in 0..1000 {
+            chi.sample(&mut rng);
+            chi.ind_sample(&mut rng);
+        }
+    }
+    #[test]
+    #[should_panic]
+    fn test_chi_squared_invalid_dof() {
+        ChiSquared::new(-1.0);
+    }
+
+    #[test]
+    fn test_f() {
+        let mut f = FisherF::new(2.0, 32.0);
+        let mut rng = ::test::rng();
+        for _ in 0..1000 {
+            f.sample(&mut rng);
+            f.ind_sample(&mut rng);
+        }
+    }
+
+    #[test]
+    fn test_t() {
+        let mut t = StudentT::new(11.0);
+        let mut rng = ::test::rng();
+        for _ in 0..1000 {
+            t.sample(&mut rng);
+            t.ind_sample(&mut rng);
+        }
+    }
+}
diff --git a/rustc_deps/vendor/rand-0.4.2/src/distributions/mod.rs b/rustc_deps/vendor/rand-0.4.2/src/distributions/mod.rs
new file mode 100644
index 0000000..5de8efb
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/src/distributions/mod.rs
@@ -0,0 +1,409 @@
+// Copyright 2013 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.
+
+//! Sampling from random distributions.
+//!
+//! This is a generalization of `Rand` to allow parameters to control the
+//! exact properties of the generated values, e.g. the mean and standard
+//! deviation of a normal distribution. The `Sample` trait is the most
+//! general, and allows for generating values that change some state
+//! internally. The `IndependentSample` trait is for generating values
+//! that do not need to record state.
+
+use core::marker;
+
+use {Rng, Rand};
+
+pub use self::range::Range;
+#[cfg(feature="std")]
+pub use self::gamma::{Gamma, ChiSquared, FisherF, StudentT};
+#[cfg(feature="std")]
+pub use self::normal::{Normal, LogNormal};
+#[cfg(feature="std")]
+pub use self::exponential::Exp;
+
+pub mod range;
+#[cfg(feature="std")]
+pub mod gamma;
+#[cfg(feature="std")]
+pub mod normal;
+#[cfg(feature="std")]
+pub mod exponential;
+
+#[cfg(feature="std")]
+mod ziggurat_tables;
+
+/// Types that can be used to create a random instance of `Support`.
+pub trait Sample<Support> {
+    /// Generate a random value of `Support`, using `rng` as the
+    /// source of randomness.
+    fn sample<R: Rng>(&mut self, rng: &mut R) -> Support;
+}
+
+/// `Sample`s that do not require keeping track of state.
+///
+/// Since no state is recorded, each sample is (statistically)
+/// independent of all others, assuming the `Rng` used has this
+/// property.
+// FIXME maybe having this separate is overkill (the only reason is to
+// take &self rather than &mut self)? or maybe this should be the
+// trait called `Sample` and the other should be `DependentSample`.
+pub trait IndependentSample<Support>: Sample<Support> {
+    /// Generate a random value.
+    fn ind_sample<R: Rng>(&self, &mut R) -> Support;
+}
+
+/// A wrapper for generating types that implement `Rand` via the
+/// `Sample` & `IndependentSample` traits.
+#[derive(Debug)]
+pub struct RandSample<Sup> {
+    _marker: marker::PhantomData<fn() -> Sup>,
+}
+
+impl<Sup> Copy for RandSample<Sup> {}
+impl<Sup> Clone for RandSample<Sup> {
+    fn clone(&self) -> Self { *self }
+}
+
+impl<Sup: Rand> Sample<Sup> for RandSample<Sup> {
+    fn sample<R: Rng>(&mut self, rng: &mut R) -> Sup { self.ind_sample(rng) }
+}
+
+impl<Sup: Rand> IndependentSample<Sup> for RandSample<Sup> {
+    fn ind_sample<R: Rng>(&self, rng: &mut R) -> Sup {
+        rng.gen()
+    }
+}
+
+impl<Sup> RandSample<Sup> {
+    pub fn new() -> RandSample<Sup> {
+        RandSample { _marker: marker::PhantomData }
+    }
+}
+
+/// A value with a particular weight for use with `WeightedChoice`.
+#[derive(Copy, Clone, Debug)]
+pub struct Weighted<T> {
+    /// The numerical weight of this item
+    pub weight: u32,
+    /// The actual item which is being weighted
+    pub item: T,
+}
+
+/// A distribution that selects from a finite collection of weighted items.
+///
+/// Each item has an associated weight that influences how likely it
+/// is to be chosen: higher weight is more likely.
+///
+/// The `Clone` restriction is a limitation of the `Sample` and
+/// `IndependentSample` traits. Note that `&T` is (cheaply) `Clone` for
+/// all `T`, as is `u32`, so one can store references or indices into
+/// another vector.
+///
+/// # Example
+///
+/// ```rust
+/// use rand::distributions::{Weighted, WeightedChoice, IndependentSample};
+///
+/// let mut items = vec!(Weighted { weight: 2, item: 'a' },
+///                      Weighted { weight: 4, item: 'b' },
+///                      Weighted { weight: 1, item: 'c' });
+/// let wc = WeightedChoice::new(&mut items);
+/// let mut rng = rand::thread_rng();
+/// for _ in 0..16 {
+///      // on average prints 'a' 4 times, 'b' 8 and 'c' twice.
+///      println!("{}", wc.ind_sample(&mut rng));
+/// }
+/// ```
+#[derive(Debug)]
+pub struct WeightedChoice<'a, T:'a> {
+    items: &'a mut [Weighted<T>],
+    weight_range: Range<u32>
+}
+
+impl<'a, T: Clone> WeightedChoice<'a, T> {
+    /// Create a new `WeightedChoice`.
+    ///
+    /// Panics if:
+    ///
+    /// - `items` is empty
+    /// - the total weight is 0
+    /// - the total weight is larger than a `u32` can contain.
+    pub fn new(items: &'a mut [Weighted<T>]) -> WeightedChoice<'a, T> {
+        // strictly speaking, this is subsumed by the total weight == 0 case
+        assert!(!items.is_empty(), "WeightedChoice::new called with no items");
+
+        let mut running_total: u32 = 0;
+
+        // we convert the list from individual weights to cumulative
+        // weights so we can binary search. This *could* drop elements
+        // with weight == 0 as an optimisation.
+        for item in items.iter_mut() {
+            running_total = match running_total.checked_add(item.weight) {
+                Some(n) => n,
+                None => panic!("WeightedChoice::new called with a total weight \
+                               larger than a u32 can contain")
+            };
+
+            item.weight = running_total;
+        }
+        assert!(running_total != 0, "WeightedChoice::new called with a total weight of 0");
+
+        WeightedChoice {
+            items: items,
+            // we're likely to be generating numbers in this range
+            // relatively often, so might as well cache it
+            weight_range: Range::new(0, running_total)
+        }
+    }
+}
+
+impl<'a, T: Clone> Sample<T> for WeightedChoice<'a, T> {
+    fn sample<R: Rng>(&mut self, rng: &mut R) -> T { self.ind_sample(rng) }
+}
+
+impl<'a, T: Clone> IndependentSample<T> for WeightedChoice<'a, T> {
+    fn ind_sample<R: Rng>(&self, rng: &mut R) -> T {
+        // we want to find the first element that has cumulative
+        // weight > sample_weight, which we do by binary since the
+        // cumulative weights of self.items are sorted.
+
+        // choose a weight in [0, total_weight)
+        let sample_weight = self.weight_range.ind_sample(rng);
+
+        // short circuit when it's the first item
+        if sample_weight < self.items[0].weight {
+            return self.items[0].item.clone();
+        }
+
+        let mut idx = 0;
+        let mut modifier = self.items.len();
+
+        // now we know that every possibility has an element to the
+        // left, so we can just search for the last element that has
+        // cumulative weight <= sample_weight, then the next one will
+        // be "it". (Note that this greatest element will never be the
+        // last element of the vector, since sample_weight is chosen
+        // in [0, total_weight) and the cumulative weight of the last
+        // one is exactly the total weight.)
+        while modifier > 1 {
+            let i = idx + modifier / 2;
+            if self.items[i].weight <= sample_weight {
+                // we're small, so look to the right, but allow this
+                // exact element still.
+                idx = i;
+                // we need the `/ 2` to round up otherwise we'll drop
+                // the trailing elements when `modifier` is odd.
+                modifier += 1;
+            } else {
+                // otherwise we're too big, so go left. (i.e. do
+                // nothing)
+            }
+            modifier /= 2;
+        }
+        return self.items[idx + 1].item.clone();
+    }
+}
+
+/// Sample a random number using the Ziggurat method (specifically the
+/// ZIGNOR variant from Doornik 2005). Most of the arguments are
+/// directly from the paper:
+///
+/// * `rng`: source of randomness
+/// * `symmetric`: whether this is a symmetric distribution, or one-sided with P(x < 0) = 0.
+/// * `X`: the $x_i$ abscissae.
+/// * `F`: precomputed values of the PDF at the $x_i$, (i.e. $f(x_i)$)
+/// * `F_DIFF`: precomputed values of $f(x_i) - f(x_{i+1})$
+/// * `pdf`: the probability density function
+/// * `zero_case`: manual sampling from the tail when we chose the
+///    bottom box (i.e. i == 0)
+
+// the perf improvement (25-50%) is definitely worth the extra code
+// size from force-inlining.
+#[cfg(feature="std")]
+#[inline(always)]
+fn ziggurat<R: Rng, P, Z>(
+            rng: &mut R,
+            symmetric: bool,
+            x_tab: ziggurat_tables::ZigTable,
+            f_tab: ziggurat_tables::ZigTable,
+            mut pdf: P,
+            mut zero_case: Z)
+            -> f64 where P: FnMut(f64) -> f64, Z: FnMut(&mut R, f64) -> f64 {
+    const SCALE: f64 = (1u64 << 53) as f64;
+    loop {
+        // reimplement the f64 generation as an optimisation suggested
+        // by the Doornik paper: we have a lot of precision-space
+        // (i.e. there are 11 bits of the 64 of a u64 to use after
+        // creating a f64), so we might as well reuse some to save
+        // generating a whole extra random number. (Seems to be 15%
+        // faster.)
+        //
+        // This unfortunately misses out on the benefits of direct
+        // floating point generation if an RNG like dSMFT is
+        // used. (That is, such RNGs create floats directly, highly
+        // efficiently and overload next_f32/f64, so by not calling it
+        // this may be slower than it would be otherwise.)
+        // FIXME: investigate/optimise for the above.
+        let bits: u64 = rng.gen();
+        let i = (bits & 0xff) as usize;
+        let f = (bits >> 11) as f64 / SCALE;
+
+        // u is either U(-1, 1) or U(0, 1) depending on if this is a
+        // symmetric distribution or not.
+        let u = if symmetric {2.0 * f - 1.0} else {f};
+        let x = u * x_tab[i];
+
+        let test_x = if symmetric { x.abs() } else {x};
+
+        // algebraically equivalent to |u| < x_tab[i+1]/x_tab[i] (or u < x_tab[i+1]/x_tab[i])
+        if test_x < x_tab[i + 1] {
+            return x;
+        }
+        if i == 0 {
+            return zero_case(rng, u);
+        }
+        // algebraically equivalent to f1 + DRanU()*(f0 - f1) < 1
+        if f_tab[i + 1] + (f_tab[i] - f_tab[i + 1]) * rng.gen::<f64>() < pdf(x) {
+            return x;
+        }
+    }
+}
+
+#[cfg(test)]
+mod tests {
+
+    use {Rng, Rand};
+    use super::{RandSample, WeightedChoice, Weighted, Sample, IndependentSample};
+
+    #[derive(PartialEq, Debug)]
+    struct ConstRand(usize);
+    impl Rand for ConstRand {
+        fn rand<R: Rng>(_: &mut R) -> ConstRand {
+            ConstRand(0)
+        }
+    }
+
+    // 0, 1, 2, 3, ...
+    struct CountingRng { i: u32 }
+    impl Rng for CountingRng {
+        fn next_u32(&mut self) -> u32 {
+            self.i += 1;
+            self.i - 1
+        }
+        fn next_u64(&mut self) -> u64 {
+            self.next_u32() as u64
+        }
+    }
+
+    #[test]
+    fn test_rand_sample() {
+        let mut rand_sample = RandSample::<ConstRand>::new();
+
+        assert_eq!(rand_sample.sample(&mut ::test::rng()), ConstRand(0));
+        assert_eq!(rand_sample.ind_sample(&mut ::test::rng()), ConstRand(0));
+    }
+    #[test]
+    fn test_weighted_choice() {
+        // this makes assumptions about the internal implementation of
+        // WeightedChoice, specifically: it doesn't reorder the items,
+        // it doesn't do weird things to the RNG (so 0 maps to 0, 1 to
+        // 1, internally; modulo a modulo operation).
+
+        macro_rules! t {
+            ($items:expr, $expected:expr) => {{
+                let mut items = $items;
+                let wc = WeightedChoice::new(&mut items);
+                let expected = $expected;
+
+                let mut rng = CountingRng { i: 0 };
+
+                for &val in expected.iter() {
+                    assert_eq!(wc.ind_sample(&mut rng), val)
+                }
+            }}
+        }
+
+        t!(vec!(Weighted { weight: 1, item: 10}), [10]);
+
+        // skip some
+        t!(vec!(Weighted { weight: 0, item: 20},
+                Weighted { weight: 2, item: 21},
+                Weighted { weight: 0, item: 22},
+                Weighted { weight: 1, item: 23}),
+           [21,21, 23]);
+
+        // different weights
+        t!(vec!(Weighted { weight: 4, item: 30},
+                Weighted { weight: 3, item: 31}),
+           [30,30,30,30, 31,31,31]);
+
+        // check that we're binary searching
+        // correctly with some vectors of odd
+        // length.
+        t!(vec!(Weighted { weight: 1, item: 40},
+                Weighted { weight: 1, item: 41},
+                Weighted { weight: 1, item: 42},
+                Weighted { weight: 1, item: 43},
+                Weighted { weight: 1, item: 44}),
+           [40, 41, 42, 43, 44]);
+        t!(vec!(Weighted { weight: 1, item: 50},
+                Weighted { weight: 1, item: 51},
+                Weighted { weight: 1, item: 52},
+                Weighted { weight: 1, item: 53},
+                Weighted { weight: 1, item: 54},
+                Weighted { weight: 1, item: 55},
+                Weighted { weight: 1, item: 56}),
+           [50, 51, 52, 53, 54, 55, 56]);
+    }
+
+    #[test]
+    fn test_weighted_clone_initialization() {
+        let initial : Weighted<u32> = Weighted {weight: 1, item: 1};
+        let clone = initial.clone();
+        assert_eq!(initial.weight, clone.weight);
+        assert_eq!(initial.item, clone.item);
+    }
+
+    #[test] #[should_panic]
+    fn test_weighted_clone_change_weight() {
+        let initial : Weighted<u32> = Weighted {weight: 1, item: 1};
+        let mut clone = initial.clone();
+        clone.weight = 5;
+        assert_eq!(initial.weight, clone.weight);
+    }
+
+    #[test] #[should_panic]
+    fn test_weighted_clone_change_item() {
+        let initial : Weighted<u32> = Weighted {weight: 1, item: 1};
+        let mut clone = initial.clone();
+        clone.item = 5;
+        assert_eq!(initial.item, clone.item);
+
+    }
+
+    #[test] #[should_panic]
+    fn test_weighted_choice_no_items() {
+        WeightedChoice::<isize>::new(&mut []);
+    }
+    #[test] #[should_panic]
+    fn test_weighted_choice_zero_weight() {
+        WeightedChoice::new(&mut [Weighted { weight: 0, item: 0},
+                                  Weighted { weight: 0, item: 1}]);
+    }
+    #[test] #[should_panic]
+    fn test_weighted_choice_weight_overflows() {
+        let x = ::std::u32::MAX / 2; // x + x + 2 is the overflow
+        WeightedChoice::new(&mut [Weighted { weight: x, item: 0 },
+                                  Weighted { weight: 1, item: 1 },
+                                  Weighted { weight: x, item: 2 },
+                                  Weighted { weight: 1, item: 3 }]);
+    }
+}
diff --git a/rustc_deps/vendor/rand-0.4.2/src/distributions/normal.rs b/rustc_deps/vendor/rand-0.4.2/src/distributions/normal.rs
new file mode 100644
index 0000000..280613d
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/src/distributions/normal.rs
@@ -0,0 +1,201 @@
+// Copyright 2013 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.
+
+//! The normal and derived distributions.
+
+use {Rng, Rand, Open01};
+use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
+
+/// A wrapper around an `f64` to generate N(0, 1) random numbers
+/// (a.k.a.  a standard normal, or Gaussian).
+///
+/// See `Normal` for the general normal distribution.
+///
+/// Implemented via the ZIGNOR variant[1] of the Ziggurat method.
+///
+/// [1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to
+/// Generate Normal Random
+/// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield
+/// College, Oxford
+///
+/// # Example
+///
+/// ```rust
+/// use rand::distributions::normal::StandardNormal;
+///
+/// let StandardNormal(x) = rand::random();
+/// println!("{}", x);
+/// ```
+#[derive(Clone, Copy, Debug)]
+pub struct StandardNormal(pub f64);
+
+impl Rand for StandardNormal {
+    fn rand<R:Rng>(rng: &mut R) -> StandardNormal {
+        #[inline]
+        fn pdf(x: f64) -> f64 {
+            (-x*x/2.0).exp()
+        }
+        #[inline]
+        fn zero_case<R:Rng>(rng: &mut R, u: f64) -> f64 {
+            // compute a random number in the tail by hand
+
+            // strange initial conditions, because the loop is not
+            // do-while, so the condition should be true on the first
+            // run, they get overwritten anyway (0 < 1, so these are
+            // good).
+            let mut x = 1.0f64;
+            let mut y = 0.0f64;
+
+            while -2.0 * y < x * x {
+                let Open01(x_) = rng.gen::<Open01<f64>>();
+                let Open01(y_) = rng.gen::<Open01<f64>>();
+
+                x = x_.ln() / ziggurat_tables::ZIG_NORM_R;
+                y = y_.ln();
+            }
+
+            if u < 0.0 { x - ziggurat_tables::ZIG_NORM_R } else { ziggurat_tables::ZIG_NORM_R - x }
+        }
+
+        StandardNormal(ziggurat(
+            rng,
+            true, // this is symmetric
+            &ziggurat_tables::ZIG_NORM_X,
+            &ziggurat_tables::ZIG_NORM_F,
+            pdf, zero_case))
+    }
+}
+
+/// The normal distribution `N(mean, std_dev**2)`.
+///
+/// This uses the ZIGNOR variant of the Ziggurat method, see
+/// `StandardNormal` for more details.
+///
+/// # Example
+///
+/// ```rust
+/// use rand::distributions::{Normal, IndependentSample};
+///
+/// // mean 2, standard deviation 3
+/// let normal = Normal::new(2.0, 3.0);
+/// let v = normal.ind_sample(&mut rand::thread_rng());
+/// println!("{} is from a N(2, 9) distribution", v)
+/// ```
+#[derive(Clone, Copy, Debug)]
+pub struct Normal {
+    mean: f64,
+    std_dev: f64,
+}
+
+impl Normal {
+    /// Construct a new `Normal` distribution with the given mean and
+    /// standard deviation.
+    ///
+    /// # Panics
+    ///
+    /// Panics if `std_dev < 0`.
+    #[inline]
+    pub fn new(mean: f64, std_dev: f64) -> Normal {
+        assert!(std_dev >= 0.0, "Normal::new called with `std_dev` < 0");
+        Normal {
+            mean: mean,
+            std_dev: std_dev
+        }
+    }
+}
+impl Sample<f64> for Normal {
+    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
+}
+impl IndependentSample<f64> for Normal {
+    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
+        let StandardNormal(n) = rng.gen::<StandardNormal>();
+        self.mean + self.std_dev * n
+    }
+}
+
+
+/// The log-normal distribution `ln N(mean, std_dev**2)`.
+///
+/// If `X` is log-normal distributed, then `ln(X)` is `N(mean,
+/// std_dev**2)` distributed.
+///
+/// # Example
+///
+/// ```rust
+/// use rand::distributions::{LogNormal, IndependentSample};
+///
+/// // mean 2, standard deviation 3
+/// let log_normal = LogNormal::new(2.0, 3.0);
+/// let v = log_normal.ind_sample(&mut rand::thread_rng());
+/// println!("{} is from an ln N(2, 9) distribution", v)
+/// ```
+#[derive(Clone, Copy, Debug)]
+pub struct LogNormal {
+    norm: Normal
+}
+
+impl LogNormal {
+    /// Construct a new `LogNormal` distribution with the given mean
+    /// and standard deviation.
+    ///
+    /// # Panics
+    ///
+    /// Panics if `std_dev < 0`.
+    #[inline]
+    pub fn new(mean: f64, std_dev: f64) -> LogNormal {
+        assert!(std_dev >= 0.0, "LogNormal::new called with `std_dev` < 0");
+        LogNormal { norm: Normal::new(mean, std_dev) }
+    }
+}
+impl Sample<f64> for LogNormal {
+    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
+}
+impl IndependentSample<f64> for LogNormal {
+    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
+        self.norm.ind_sample(rng).exp()
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use distributions::{Sample, IndependentSample};
+    use super::{Normal, LogNormal};
+
+    #[test]
+    fn test_normal() {
+        let mut norm = Normal::new(10.0, 10.0);
+        let mut rng = ::test::rng();
+        for _ in 0..1000 {
+            norm.sample(&mut rng);
+            norm.ind_sample(&mut rng);
+        }
+    }
+    #[test]
+    #[should_panic]
+    fn test_normal_invalid_sd() {
+        Normal::new(10.0, -1.0);
+    }
+
+
+    #[test]
+    fn test_log_normal() {
+        let mut lnorm = LogNormal::new(10.0, 10.0);
+        let mut rng = ::test::rng();
+        for _ in 0..1000 {
+            lnorm.sample(&mut rng);
+            lnorm.ind_sample(&mut rng);
+        }
+    }
+    #[test]
+    #[should_panic]
+    fn test_log_normal_invalid_sd() {
+        LogNormal::new(10.0, -1.0);
+    }
+}
diff --git a/rustc_deps/vendor/rand/src/distributions/range.rs b/rustc_deps/vendor/rand-0.4.2/src/distributions/range.rs
similarity index 100%
rename from rustc_deps/vendor/rand/src/distributions/range.rs
rename to rustc_deps/vendor/rand-0.4.2/src/distributions/range.rs
diff --git a/rustc_deps/vendor/rand-0.4.2/src/distributions/ziggurat_tables.rs b/rustc_deps/vendor/rand-0.4.2/src/distributions/ziggurat_tables.rs
new file mode 100644
index 0000000..b6de4bf
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/src/distributions/ziggurat_tables.rs
@@ -0,0 +1,280 @@
+// Copyright 2013 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.
+
+// Tables for distributions which are sampled using the ziggurat
+// algorithm. Autogenerated by `ziggurat_tables.py`.
+
+pub type ZigTable = &'static [f64; 257];
+pub const ZIG_NORM_R: f64 = 3.654152885361008796;
+pub static ZIG_NORM_X: [f64; 257] =
+    [3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074,
+     3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434,
+     2.978603279880844834, 2.934366867207854224, 2.894121053612348060, 2.857138730872132548,
+     2.822877396825325125, 2.790921174000785765, 2.760944005278822555, 2.732685359042827056,
+     2.705933656121858100, 2.680514643284522158, 2.656283037575502437, 2.633116393630324570,
+     2.610910518487548515, 2.589575986706995181, 2.569035452680536569, 2.549221550323460761,
+     2.530075232158516929, 2.511544441625342294, 2.493583041269680667, 2.476149939669143318,
+     2.459208374333311298, 2.442725318198956774, 2.426670984935725972, 2.411018413899685520,
+     2.395743119780480601, 2.380822795170626005, 2.366237056715818632, 2.351967227377659952,
+     2.337996148795031370, 2.324308018869623016, 2.310888250599850036, 2.297723348901329565,
+     2.284800802722946056, 2.272108990226823888, 2.259637095172217780, 2.247375032945807760,
+     2.235313384928327984, 2.223443340090905718, 2.211756642882544366, 2.200245546609647995,
+     2.188902771624720689, 2.177721467738641614, 2.166695180352645966, 2.155817819875063268,
+     2.145083634046203613, 2.134487182844320152, 2.124023315687815661, 2.113687150684933957,
+     2.103474055713146829, 2.093379631137050279, 2.083399693996551783, 2.073530263516978778,
+     2.063767547809956415, 2.054107931648864849, 2.044547965215732788, 2.035084353727808715,
+     2.025713947862032960, 2.016433734904371722, 2.007240830558684852, 1.998132471356564244,
+     1.989106007615571325, 1.980158896898598364, 1.971288697931769640, 1.962493064942461896,
+     1.953769742382734043, 1.945116560006753925, 1.936531428273758904, 1.928012334050718257,
+     1.919557336591228847, 1.911164563769282232, 1.902832208548446369, 1.894558525668710081,
+     1.886341828534776388, 1.878180486290977669, 1.870072921069236838, 1.862017605397632281,
+     1.854013059758148119, 1.846057850283119750, 1.838150586580728607, 1.830289919680666566,
+     1.822474540091783224, 1.814703175964167636, 1.806974591348693426, 1.799287584547580199,
+     1.791640986550010028, 1.784033659547276329, 1.776464495522344977, 1.768932414909077933,
+     1.761436365316706665, 1.753975320315455111, 1.746548278279492994, 1.739154261283669012,
+     1.731792314050707216, 1.724461502945775715, 1.717160915015540690, 1.709889657069006086,
+     1.702646854797613907, 1.695431651932238548, 1.688243209434858727, 1.681080704722823338,
+     1.673943330923760353, 1.666830296159286684, 1.659740822855789499, 1.652674147080648526,
+     1.645629517902360339, 1.638606196773111146, 1.631603456932422036, 1.624620582830568427,
+     1.617656869570534228, 1.610711622367333673, 1.603784156023583041, 1.596873794420261339,
+     1.589979870021648534, 1.583101723393471438, 1.576238702733332886, 1.569390163412534456,
+     1.562555467528439657, 1.555733983466554893, 1.548925085471535512, 1.542128153226347553,
+     1.535342571438843118, 1.528567729435024614, 1.521803020758293101, 1.515047842773992404,
+     1.508301596278571965, 1.501563685112706548, 1.494833515777718391, 1.488110497054654369,
+     1.481394039625375747, 1.474683555695025516, 1.467978458615230908, 1.461278162507407830,
+     1.454582081885523293, 1.447889631277669675, 1.441200224845798017, 1.434513276002946425,
+     1.427828197027290358, 1.421144398672323117, 1.414461289772464658, 1.407778276843371534,
+     1.401094763676202559, 1.394410150925071257, 1.387723835686884621, 1.381035211072741964,
+     1.374343665770030531, 1.367648583594317957, 1.360949343030101844, 1.354245316759430606,
+     1.347535871177359290, 1.340820365893152122, 1.334098153216083604, 1.327368577624624679,
+     1.320630975217730096, 1.313884673146868964, 1.307128989027353860, 1.300363230327433728,
+     1.293586693733517645, 1.286798664489786415, 1.279998415710333237, 1.273185207661843732,
+     1.266358287014688333, 1.259516886060144225, 1.252660221891297887, 1.245787495544997903,
+     1.238897891102027415, 1.231990574742445110, 1.225064693752808020, 1.218119375481726552,
+     1.211153726239911244, 1.204166830140560140, 1.197157747875585931, 1.190125515422801650,
+     1.183069142678760732, 1.175987612011489825, 1.168879876726833800, 1.161744859441574240,
+     1.154581450355851802, 1.147388505416733873, 1.140164844363995789, 1.132909248648336975,
+     1.125620459211294389, 1.118297174115062909, 1.110938046009249502, 1.103541679420268151,
+     1.096106627847603487, 1.088631390649514197, 1.081114409698889389, 1.073554065787871714,
+     1.065948674757506653, 1.058296483326006454, 1.050595664586207123, 1.042844313139370538,
+     1.035040439828605274, 1.027181966030751292, 1.019266717460529215, 1.011292417434978441,
+     1.003256679539591412, 0.995156999629943084, 0.986990747093846266, 0.978755155288937750,
+     0.970447311058864615, 0.962064143217605250, 0.953602409875572654, 0.945058684462571130,
+     0.936429340280896860, 0.927710533396234771, 0.918898183643734989, 0.909987953490768997,
+     0.900975224455174528, 0.891855070726792376, 0.882622229578910122, 0.873271068082494550,
+     0.863795545546826915, 0.854189171001560554, 0.844444954902423661, 0.834555354079518752,
+     0.824512208745288633, 0.814306670128064347, 0.803929116982664893, 0.793369058833152785,
+     0.782615023299588763, 0.771654424216739354, 0.760473406422083165, 0.749056662009581653,
+     0.737387211425838629, 0.725446140901303549, 0.713212285182022732, 0.700661841097584448,
+     0.687767892786257717, 0.674499822827436479, 0.660822574234205984, 0.646695714884388928,
+     0.632072236375024632, 0.616896989996235545, 0.601104617743940417, 0.584616766093722262,
+     0.567338257040473026, 0.549151702313026790, 0.529909720646495108, 0.509423329585933393,
+     0.487443966121754335, 0.463634336771763245, 0.437518402186662658, 0.408389134588000746,
+     0.375121332850465727, 0.335737519180459465, 0.286174591747260509, 0.215241895913273806,
+     0.000000000000000000];
+pub static ZIG_NORM_F: [f64; 257] =
+    [0.000477467764586655, 0.001260285930498598, 0.002609072746106363, 0.004037972593371872,
+     0.005522403299264754, 0.007050875471392110, 0.008616582769422917, 0.010214971439731100,
+     0.011842757857943104, 0.013497450601780807, 0.015177088307982072, 0.016880083152595839,
+     0.018605121275783350, 0.020351096230109354, 0.022117062707379922, 0.023902203305873237,
+     0.025705804008632656, 0.027527235669693315, 0.029365939758230111, 0.031221417192023690,
+     0.033093219458688698, 0.034980941461833073, 0.036884215688691151, 0.038802707404656918,
+     0.040736110656078753, 0.042684144916619378, 0.044646552251446536, 0.046623094902089664,
+     0.048613553216035145, 0.050617723861121788, 0.052635418276973649, 0.054666461325077916,
+     0.056710690106399467, 0.058767952921137984, 0.060838108349751806, 0.062921024437977854,
+     0.065016577971470438, 0.067124653828023989, 0.069245144397250269, 0.071377949059141965,
+     0.073522973714240991, 0.075680130359194964, 0.077849336702372207, 0.080030515814947509,
+     0.082223595813495684, 0.084428509570654661, 0.086645194450867782, 0.088873592068594229,
+     0.091113648066700734, 0.093365311913026619, 0.095628536713353335, 0.097903279039215627,
+     0.100189498769172020, 0.102487158942306270, 0.104796225622867056, 0.107116667775072880,
+     0.109448457147210021, 0.111791568164245583, 0.114145977828255210, 0.116511665626037014,
+     0.118888613443345698, 0.121276805485235437, 0.123676228202051403, 0.126086870220650349,
+     0.128508722280473636, 0.130941777174128166, 0.133386029692162844, 0.135841476571757352,
+     0.138308116449064322, 0.140785949814968309, 0.143274978974047118, 0.145775208006537926,
+     0.148286642733128721, 0.150809290682410169, 0.153343161060837674, 0.155888264725064563,
+     0.158444614156520225, 0.161012223438117663, 0.163591108232982951, 0.166181285765110071,
+     0.168782774801850333, 0.171395595638155623, 0.174019770082499359, 0.176655321444406654,
+     0.179302274523530397, 0.181960655600216487, 0.184630492427504539, 0.187311814224516926,
+     0.190004651671193070, 0.192709036904328807, 0.195425003514885592, 0.198152586546538112,
+     0.200891822495431333, 0.203642749311121501, 0.206405406398679298, 0.209179834621935651,
+     0.211966076307852941, 0.214764175252008499, 0.217574176725178370, 0.220396127481011589,
+     0.223230075764789593, 0.226076071323264877, 0.228934165415577484, 0.231804410825248525,
+     0.234686861873252689, 0.237581574432173676, 0.240488605941449107, 0.243408015423711988,
+     0.246339863502238771, 0.249284212419516704, 0.252241126056943765, 0.255210669955677150,
+     0.258192911338648023, 0.261187919133763713, 0.264195763998317568, 0.267216518344631837,
+     0.270250256366959984, 0.273297054069675804, 0.276356989296781264, 0.279430141762765316,
+     0.282516593084849388, 0.285616426816658109, 0.288729728483353931, 0.291856585618280984,
+     0.294997087801162572, 0.298151326697901342, 0.301319396102034120, 0.304501391977896274,
+     0.307697412505553769, 0.310907558127563710, 0.314131931597630143, 0.317370638031222396,
+     0.320623784958230129, 0.323891482377732021, 0.327173842814958593, 0.330470981380537099,
+     0.333783015832108509, 0.337110066638412809, 0.340452257045945450, 0.343809713148291340,
+     0.347182563958251478, 0.350570941482881204, 0.353974980801569250, 0.357394820147290515,
+     0.360830600991175754, 0.364282468130549597, 0.367750569780596226, 0.371235057669821344,
+     0.374736087139491414, 0.378253817247238111, 0.381788410875031348, 0.385340034841733958,
+     0.388908860020464597, 0.392495061461010764, 0.396098818517547080, 0.399720314981931668,
+     0.403359739222868885, 0.407017284331247953, 0.410693148271983222, 0.414387534042706784,
+     0.418100649839684591, 0.421832709231353298, 0.425583931339900579, 0.429354541031341519,
+     0.433144769114574058, 0.436954852549929273, 0.440785034667769915, 0.444635565397727750,
+     0.448506701509214067, 0.452398706863882505, 0.456311852680773566, 0.460246417814923481,
+     0.464202689050278838, 0.468180961407822172, 0.472181538469883255, 0.476204732721683788,
+     0.480250865911249714, 0.484320269428911598, 0.488413284707712059, 0.492530263646148658,
+     0.496671569054796314, 0.500837575128482149, 0.505028667945828791, 0.509245245998136142,
+     0.513487720749743026, 0.517756517232200619, 0.522052074674794864, 0.526374847174186700,
+     0.530725304406193921, 0.535103932383019565, 0.539511234259544614, 0.543947731192649941,
+     0.548413963257921133, 0.552910490428519918, 0.557437893621486324, 0.561996775817277916,
+     0.566587763258951771, 0.571211506738074970, 0.575868682975210544, 0.580559996103683473,
+     0.585286179266300333, 0.590047996335791969, 0.594846243770991268, 0.599681752622167719,
+     0.604555390700549533, 0.609468064928895381, 0.614420723892076803, 0.619414360609039205,
+     0.624450015550274240, 0.629528779928128279, 0.634651799290960050, 0.639820277456438991,
+     0.645035480824251883, 0.650298743114294586, 0.655611470583224665, 0.660975147780241357,
+     0.666391343912380640, 0.671861719900766374, 0.677388036222513090, 0.682972161648791376,
+     0.688616083008527058, 0.694321916130032579, 0.700091918140490099, 0.705928501336797409,
+     0.711834248882358467, 0.717811932634901395, 0.723864533472881599, 0.729995264565802437,
+     0.736207598131266683, 0.742505296344636245, 0.748892447223726720, 0.755373506511754500,
+     0.761953346841546475, 0.768637315803334831, 0.775431304986138326, 0.782341832659861902,
+     0.789376143571198563, 0.796542330428254619, 0.803849483176389490, 0.811307874318219935,
+     0.818929191609414797, 0.826726833952094231, 0.834716292992930375, 0.842915653118441077,
+     0.851346258465123684, 0.860033621203008636, 0.869008688043793165, 0.878309655816146839,
+     0.887984660763399880, 0.898095921906304051, 0.908726440060562912, 0.919991505048360247,
+     0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328,
+     1.000000000000000000];
+pub const ZIG_EXP_R: f64 = 7.697117470131050077;
+pub static ZIG_EXP_X: [f64; 257] =
+    [8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696,
+     6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488,
+     5.323090505754398016, 5.181487281301500047, 5.054288489981304089, 4.938777085901250530,
+     4.832939741025112035, 4.735242996601741083, 4.644491885420085175, 4.559737061707351380,
+     4.480211746528421912, 4.405287693473573185, 4.334443680317273007, 4.267242480277365857,
+     4.203313713735184365, 4.142340865664051464, 4.084051310408297830, 4.028208544647936762,
+     3.974606066673788796, 3.923062500135489739, 3.873417670399509127, 3.825529418522336744,
+     3.779270992411667862, 3.734528894039797375, 3.691201090237418825, 3.649195515760853770,
+     3.608428813128909507, 3.568825265648337020, 3.530315889129343354, 3.492837654774059608,
+     3.456332821132760191, 3.420748357251119920, 3.386035442460300970, 3.352149030900109405,
+     3.319047470970748037, 3.286692171599068679, 3.255047308570449882, 3.224079565286264160,
+     3.193757903212240290, 3.164053358025972873, 3.134938858084440394, 3.106389062339824481,
+     3.078380215254090224, 3.050890016615455114, 3.023897504455676621, 2.997382949516130601,
+     2.971327759921089662, 2.945714394895045718, 2.920526286512740821, 2.895747768600141825,
+     2.871364012015536371, 2.847360965635188812, 2.823725302450035279, 2.800444370250737780,
+     2.777506146439756574, 2.754899196562344610, 2.732612636194700073, 2.710636095867928752,
+     2.688959688741803689, 2.667573980773266573, 2.646469963151809157, 2.625639026797788489,
+     2.605072938740835564, 2.584763820214140750, 2.564704126316905253, 2.544886627111869970,
+     2.525304390037828028, 2.505950763528594027, 2.486819361740209455, 2.467904050297364815,
+     2.449198932978249754, 2.430698339264419694, 2.412396812688870629, 2.394289099921457886,
+     2.376370140536140596, 2.358635057409337321, 2.341079147703034380, 2.323697874390196372,
+     2.306486858283579799, 2.289441870532269441, 2.272558825553154804, 2.255833774367219213,
+     2.239262898312909034, 2.222842503111036816, 2.206569013257663858, 2.190438966723220027,
+     2.174449009937774679, 2.158595893043885994, 2.142876465399842001, 2.127287671317368289,
+     2.111826546019042183, 2.096490211801715020, 2.081275874393225145, 2.066180819490575526,
+     2.051202409468584786, 2.036338080248769611, 2.021585338318926173, 2.006941757894518563,
+     1.992404978213576650, 1.977972700957360441, 1.963642687789548313, 1.949412758007184943,
+     1.935280786297051359, 1.921244700591528076, 1.907302480018387536, 1.893452152939308242,
+     1.879691795072211180, 1.866019527692827973, 1.852433515911175554, 1.838931967018879954,
+     1.825513128903519799, 1.812175288526390649, 1.798916770460290859, 1.785735935484126014,
+     1.772631179231305643, 1.759600930889074766, 1.746643651946074405, 1.733757834985571566,
+     1.720942002521935299, 1.708194705878057773, 1.695514524101537912, 1.682900062917553896,
+     1.670349953716452118, 1.657862852574172763, 1.645437439303723659, 1.633072416535991334,
+     1.620766508828257901, 1.608518461798858379, 1.596327041286483395, 1.584191032532688892,
+     1.572109239386229707, 1.560080483527888084, 1.548103603714513499, 1.536177455041032092,
+     1.524300908219226258, 1.512472848872117082, 1.500692176842816750, 1.488957805516746058,
+     1.477268661156133867, 1.465623682245745352, 1.454021818848793446, 1.442462031972012504,
+     1.430943292938879674, 1.419464582769983219, 1.408024891569535697, 1.396623217917042137,
+     1.385258568263121992, 1.373929956328490576, 1.362636402505086775, 1.351376933258335189,
+     1.340150580529504643, 1.328956381137116560, 1.317793376176324749, 1.306660610415174117,
+     1.295557131686601027, 1.284481990275012642, 1.273434238296241139, 1.262412929069615330,
+     1.251417116480852521, 1.240445854334406572, 1.229498195693849105, 1.218573192208790124,
+     1.207669893426761121, 1.196787346088403092, 1.185924593404202199, 1.175080674310911677,
+     1.164254622705678921, 1.153445466655774743, 1.142652227581672841, 1.131873919411078511,
+     1.121109547701330200, 1.110358108727411031, 1.099618588532597308, 1.088889961938546813,
+     1.078171191511372307, 1.067461226479967662, 1.056759001602551429, 1.046063435977044209,
+     1.035373431790528542, 1.024687873002617211, 1.014005623957096480, 1.003325527915696735,
+     0.992646405507275897, 0.981967053085062602, 0.971286240983903260, 0.960602711668666509,
+     0.949915177764075969, 0.939222319955262286, 0.928522784747210395, 0.917815182070044311,
+     0.907098082715690257, 0.896370015589889935, 0.885629464761751528, 0.874874866291025066,
+     0.864104604811004484, 0.853317009842373353, 0.842510351810368485, 0.831682837734273206,
+     0.820832606554411814, 0.809957724057418282, 0.799056177355487174, 0.788125868869492430,
+     0.777164609759129710, 0.766170112735434672, 0.755139984181982249, 0.744071715500508102,
+     0.732962673584365398, 0.721810090308756203, 0.710611050909655040, 0.699362481103231959,
+     0.688061132773747808, 0.676703568029522584, 0.665286141392677943, 0.653804979847664947,
+     0.642255960424536365, 0.630634684933490286, 0.618936451394876075, 0.607156221620300030,
+     0.595288584291502887, 0.583327712748769489, 0.571267316532588332, 0.559100585511540626,
+     0.546820125163310577, 0.534417881237165604, 0.521885051592135052, 0.509211982443654398,
+     0.496388045518671162, 0.483401491653461857, 0.470239275082169006, 0.456886840931420235,
+     0.443327866073552401, 0.429543940225410703, 0.415514169600356364, 0.401214678896277765,
+     0.386617977941119573, 0.371692145329917234, 0.356399760258393816, 0.340696481064849122,
+     0.324529117016909452, 0.307832954674932158, 0.290527955491230394, 0.272513185478464703,
+     0.253658363385912022, 0.233790483059674731, 0.212671510630966620, 0.189958689622431842,
+     0.165127622564187282, 0.137304980940012589, 0.104838507565818778, 0.063852163815001570,
+     0.000000000000000000];
+pub static ZIG_EXP_F: [f64; 257] =
+    [0.000167066692307963, 0.000454134353841497, 0.000967269282327174, 0.001536299780301573,
+     0.002145967743718907, 0.002788798793574076, 0.003460264777836904, 0.004157295120833797,
+     0.004877655983542396, 0.005619642207205489, 0.006381905937319183, 0.007163353183634991,
+     0.007963077438017043, 0.008780314985808977, 0.009614413642502212, 0.010464810181029981,
+     0.011331013597834600, 0.012212592426255378, 0.013109164931254991, 0.014020391403181943,
+     0.014945968011691148, 0.015885621839973156, 0.016839106826039941, 0.017806200410911355,
+     0.018786700744696024, 0.019780424338009740, 0.020787204072578114, 0.021806887504283581,
+     0.022839335406385240, 0.023884420511558174, 0.024942026419731787, 0.026012046645134221,
+     0.027094383780955803, 0.028188948763978646, 0.029295660224637411, 0.030414443910466622,
+     0.031545232172893622, 0.032687963508959555, 0.033842582150874358, 0.035009037697397431,
+     0.036187284781931443, 0.037377282772959382, 0.038578995503074871, 0.039792391023374139,
+     0.041017441380414840, 0.042254122413316254, 0.043502413568888197, 0.044762297732943289,
+     0.046033761076175184, 0.047316792913181561, 0.048611385573379504, 0.049917534282706379,
+     0.051235237055126281, 0.052564494593071685, 0.053905310196046080, 0.055257689676697030,
+     0.056621641283742870, 0.057997175631200659, 0.059384305633420280, 0.060783046445479660,
+     0.062193415408541036, 0.063615431999807376, 0.065049117786753805, 0.066494496385339816,
+     0.067951593421936643, 0.069420436498728783, 0.070901055162371843, 0.072393480875708752,
+     0.073897746992364746, 0.075413888734058410, 0.076941943170480517, 0.078481949201606435,
+     0.080033947542319905, 0.081597980709237419, 0.083174093009632397, 0.084762330532368146,
+     0.086362741140756927, 0.087975374467270231, 0.089600281910032886, 0.091237516631040197,
+     0.092887133556043569, 0.094549189376055873, 0.096223742550432825, 0.097910853311492213,
+     0.099610583670637132, 0.101322997425953631, 0.103048160171257702, 0.104786139306570145,
+     0.106537004050001632, 0.108300825451033755, 0.110077676405185357, 0.111867631670056283,
+     0.113670767882744286, 0.115487163578633506, 0.117316899211555525, 0.119160057175327641,
+     0.121016721826674792, 0.122886979509545108, 0.124770918580830933, 0.126668629437510671,
+     0.128580204545228199, 0.130505738468330773, 0.132445327901387494, 0.134399071702213602,
+     0.136367070926428829, 0.138349428863580176, 0.140346251074862399, 0.142357645432472146,
+     0.144383722160634720, 0.146424593878344889, 0.148480375643866735, 0.150551185001039839,
+     0.152637142027442801, 0.154738369384468027, 0.156854992369365148, 0.158987138969314129,
+     0.161134939917591952, 0.163298528751901734, 0.165478041874935922, 0.167673618617250081,
+     0.169885401302527550, 0.172113535315319977, 0.174358169171353411, 0.176619454590494829,
+     0.178897546572478278, 0.181192603475496261, 0.183504787097767436, 0.185834262762197083,
+     0.188181199404254262, 0.190545769663195363, 0.192928149976771296, 0.195328520679563189,
+     0.197747066105098818, 0.200183974691911210, 0.202639439093708962, 0.205113656293837654,
+     0.207606827724221982, 0.210119159388988230, 0.212650861992978224, 0.215202151075378628,
+     0.217773247148700472, 0.220364375843359439, 0.222975768058120111, 0.225607660116683956,
+     0.228260293930716618, 0.230933917169627356, 0.233628783437433291, 0.236345152457059560,
+     0.239083290262449094, 0.241843469398877131, 0.244625969131892024, 0.247431075665327543,
+     0.250259082368862240, 0.253110290015629402, 0.255985007030415324, 0.258883549749016173,
+     0.261806242689362922, 0.264753418835062149, 0.267725419932044739, 0.270722596799059967,
+     0.273745309652802915, 0.276793928448517301, 0.279868833236972869, 0.282970414538780746,
+     0.286099073737076826, 0.289255223489677693, 0.292439288161892630, 0.295651704281261252,
+     0.298892921015581847, 0.302163400675693528, 0.305463619244590256, 0.308794066934560185,
+     0.312155248774179606, 0.315547685227128949, 0.318971912844957239, 0.322428484956089223,
+     0.325917972393556354, 0.329440964264136438, 0.332998068761809096, 0.336589914028677717,
+     0.340217149066780189, 0.343880444704502575, 0.347580494621637148, 0.351318016437483449,
+     0.355093752866787626, 0.358908472948750001, 0.362762973354817997, 0.366658079781514379,
+     0.370594648435146223, 0.374573567615902381, 0.378595759409581067, 0.382662181496010056,
+     0.386773829084137932, 0.390931736984797384, 0.395136981833290435, 0.399390684475231350,
+     0.403694012530530555, 0.408048183152032673, 0.412454465997161457, 0.416914186433003209,
+     0.421428728997616908, 0.425999541143034677, 0.430628137288459167, 0.435316103215636907,
+     0.440065100842354173, 0.444876873414548846, 0.449753251162755330, 0.454696157474615836,
+     0.459707615642138023, 0.464789756250426511, 0.469944825283960310, 0.475175193037377708,
+     0.480483363930454543, 0.485871987341885248, 0.491343869594032867, 0.496901987241549881,
+     0.502549501841348056, 0.508289776410643213, 0.514126393814748894, 0.520063177368233931,
+     0.526104213983620062, 0.532253880263043655, 0.538516872002862246, 0.544898237672440056,
+     0.551403416540641733, 0.558038282262587892, 0.564809192912400615, 0.571723048664826150,
+     0.578787358602845359, 0.586010318477268366, 0.593400901691733762, 0.600968966365232560,
+     0.608725382079622346, 0.616682180915207878, 0.624852738703666200, 0.633251994214366398,
+     0.641896716427266423, 0.650805833414571433, 0.660000841079000145, 0.669506316731925177,
+     0.679350572264765806, 0.689566496117078431, 0.700192655082788606, 0.711274760805076456,
+     0.722867659593572465, 0.735038092431424039, 0.747868621985195658, 0.761463388849896838,
+     0.775956852040116218, 0.791527636972496285, 0.808421651523009044, 0.826993296643051101,
+     0.847785500623990496, 0.871704332381204705, 0.900469929925747703, 0.938143680862176477,
+     1.000000000000000000];
diff --git a/rustc_deps/vendor/rand/src/jitter.rs b/rustc_deps/vendor/rand-0.4.2/src/jitter.rs
similarity index 100%
rename from rustc_deps/vendor/rand/src/jitter.rs
rename to rustc_deps/vendor/rand-0.4.2/src/jitter.rs
diff --git a/rustc_deps/vendor/rand-0.4.2/src/lib.rs b/rustc_deps/vendor/rand-0.4.2/src/lib.rs
new file mode 100644
index 0000000..960a567
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/src/lib.rs
@@ -0,0 +1,1214 @@
+// Copyright 2013-2017 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.
+
+//! Utilities for random number generation
+//!
+//! The key functions are `random()` and `Rng::gen()`. These are polymorphic and
+//! so can be used to generate any type that implements `Rand`. Type inference
+//! means that often a simple call to `rand::random()` or `rng.gen()` will
+//! suffice, but sometimes an annotation is required, e.g.
+//! `rand::random::<f64>()`.
+//!
+//! See the `distributions` submodule for sampling random numbers from
+//! distributions like normal and exponential.
+//!
+//! # Usage
+//!
+//! This crate is [on crates.io](https://crates.io/crates/rand) and can be
+//! used by adding `rand` to the dependencies in your project's `Cargo.toml`.
+//!
+//! ```toml
+//! [dependencies]
+//! rand = "0.4"
+//! ```
+//!
+//! and this to your crate root:
+//!
+//! ```rust
+//! extern crate rand;
+//! ```
+//!
+//! # Thread-local RNG
+//!
+//! There is built-in support for a RNG associated with each thread stored
+//! in thread-local storage. This RNG can be accessed via `thread_rng`, or
+//! used implicitly via `random`. This RNG is normally randomly seeded
+//! from an operating-system source of randomness, e.g. `/dev/urandom` on
+//! Unix systems, and will automatically reseed itself from this source
+//! after generating 32 KiB of random data.
+//!
+//! # Cryptographic security
+//!
+//! An application that requires an entropy source for cryptographic purposes
+//! must use `OsRng`, which reads randomness from the source that the operating
+//! system provides (e.g. `/dev/urandom` on Unixes or `CryptGenRandom()` on
+//! Windows).
+//! The other random number generators provided by this module are not suitable
+//! for such purposes.
+//!
+//! *Note*: many Unix systems provide `/dev/random` as well as `/dev/urandom`.
+//! This module uses `/dev/urandom` for the following reasons:
+//!
+//! -   On Linux, `/dev/random` may block if entropy pool is empty;
+//!     `/dev/urandom` will not block.  This does not mean that `/dev/random`
+//!     provides better output than `/dev/urandom`; the kernel internally runs a
+//!     cryptographically secure pseudorandom number generator (CSPRNG) based on
+//!     entropy pool for random number generation, so the "quality" of
+//!     `/dev/random` is not better than `/dev/urandom` in most cases.  However,
+//!     this means that `/dev/urandom` can yield somewhat predictable randomness
+//!     if the entropy pool is very small, such as immediately after first
+//!     booting.  Linux 3.17 added the `getrandom(2)` system call which solves
+//!     the issue: it blocks if entropy pool is not initialized yet, but it does
+//!     not block once initialized.  `OsRng` tries to use `getrandom(2)` if
+//!     available, and use `/dev/urandom` fallback if not.  If an application
+//!     does not have `getrandom` and likely to be run soon after first booting,
+//!     or on a system with very few entropy sources, one should consider using
+//!     `/dev/random` via `ReadRng`.
+//! -   On some systems (e.g. FreeBSD, OpenBSD and Mac OS X) there is no
+//!     difference between the two sources. (Also note that, on some systems
+//!     e.g.  FreeBSD, both `/dev/random` and `/dev/urandom` may block once if
+//!     the CSPRNG has not seeded yet.)
+//!
+//! # Examples
+//!
+//! ```rust
+//! use rand::Rng;
+//!
+//! let mut rng = rand::thread_rng();
+//! if rng.gen() { // random bool
+//!     println!("i32: {}, u32: {}", rng.gen::<i32>(), rng.gen::<u32>())
+//! }
+//! ```
+//!
+//! ```rust
+//! let tuple = rand::random::<(f64, char)>();
+//! println!("{:?}", tuple)
+//! ```
+//!
+//! ## Monte Carlo estimation of π
+//!
+//! For this example, imagine we have a square with sides of length 2 and a unit
+//! circle, both centered at the origin. Since the area of a unit circle is π,
+//! we have:
+//!
+//! ```text
+//!     (area of unit circle) / (area of square) = π / 4
+//! ```
+//!
+//! So if we sample many points randomly from the square, roughly π / 4 of them
+//! should be inside the circle.
+//!
+//! We can use the above fact to estimate the value of π: pick many points in
+//! the square at random, calculate the fraction that fall within the circle,
+//! and multiply this fraction by 4.
+//!
+//! ```
+//! use rand::distributions::{IndependentSample, Range};
+//!
+//! fn main() {
+//!    let between = Range::new(-1f64, 1.);
+//!    let mut rng = rand::thread_rng();
+//!
+//!    let total = 1_000_000;
+//!    let mut in_circle = 0;
+//!
+//!    for _ in 0..total {
+//!        let a = between.ind_sample(&mut rng);
+//!        let b = between.ind_sample(&mut rng);
+//!        if a*a + b*b <= 1. {
+//!            in_circle += 1;
+//!        }
+//!    }
+//!
+//!    // prints something close to 3.14159...
+//!    println!("{}", 4. * (in_circle as f64) / (total as f64));
+//! }
+//! ```
+//!
+//! ## Monty Hall Problem
+//!
+//! This is a simulation of the [Monty Hall Problem][]:
+//!
+//! > Suppose you're on a game show, and you're given the choice of three doors:
+//! > Behind one door is a car; behind the others, goats. You pick a door, say
+//! > No. 1, and the host, who knows what's behind the doors, opens another
+//! > door, say No. 3, which has a goat. He then says to you, "Do you want to
+//! > pick door No. 2?" Is it to your advantage to switch your choice?
+//!
+//! The rather unintuitive answer is that you will have a 2/3 chance of winning
+//! if you switch and a 1/3 chance of winning if you don't, so it's better to
+//! switch.
+//!
+//! This program will simulate the game show and with large enough simulation
+//! steps it will indeed confirm that it is better to switch.
+//!
+//! [Monty Hall Problem]: http://en.wikipedia.org/wiki/Monty_Hall_problem
+//!
+//! ```
+//! use rand::Rng;
+//! use rand::distributions::{IndependentSample, Range};
+//!
+//! struct SimulationResult {
+//!     win: bool,
+//!     switch: bool,
+//! }
+//!
+//! // Run a single simulation of the Monty Hall problem.
+//! fn simulate<R: Rng>(random_door: &Range<u32>, rng: &mut R)
+//!                     -> SimulationResult {
+//!     let car = random_door.ind_sample(rng);
+//!
+//!     // This is our initial choice
+//!     let mut choice = random_door.ind_sample(rng);
+//!
+//!     // The game host opens a door
+//!     let open = game_host_open(car, choice, rng);
+//!
+//!     // Shall we switch?
+//!     let switch = rng.gen();
+//!     if switch {
+//!         choice = switch_door(choice, open);
+//!     }
+//!
+//!     SimulationResult { win: choice == car, switch: switch }
+//! }
+//!
+//! // Returns the door the game host opens given our choice and knowledge of
+//! // where the car is. The game host will never open the door with the car.
+//! fn game_host_open<R: Rng>(car: u32, choice: u32, rng: &mut R) -> u32 {
+//!     let choices = free_doors(&[car, choice]);
+//!     rand::seq::sample_slice(rng, &choices, 1)[0]
+//! }
+//!
+//! // Returns the door we switch to, given our current choice and
+//! // the open door. There will only be one valid door.
+//! fn switch_door(choice: u32, open: u32) -> u32 {
+//!     free_doors(&[choice, open])[0]
+//! }
+//!
+//! fn free_doors(blocked: &[u32]) -> Vec<u32> {
+//!     (0..3).filter(|x| !blocked.contains(x)).collect()
+//! }
+//!
+//! fn main() {
+//!     // The estimation will be more accurate with more simulations
+//!     let num_simulations = 10000;
+//!
+//!     let mut rng = rand::thread_rng();
+//!     let random_door = Range::new(0, 3);
+//!
+//!     let (mut switch_wins, mut switch_losses) = (0, 0);
+//!     let (mut keep_wins, mut keep_losses) = (0, 0);
+//!
+//!     println!("Running {} simulations...", num_simulations);
+//!     for _ in 0..num_simulations {
+//!         let result = simulate(&random_door, &mut rng);
+//!
+//!         match (result.win, result.switch) {
+//!             (true, true) => switch_wins += 1,
+//!             (true, false) => keep_wins += 1,
+//!             (false, true) => switch_losses += 1,
+//!             (false, false) => keep_losses += 1,
+//!         }
+//!     }
+//!
+//!     let total_switches = switch_wins + switch_losses;
+//!     let total_keeps = keep_wins + keep_losses;
+//!
+//!     println!("Switched door {} times with {} wins and {} losses",
+//!              total_switches, switch_wins, switch_losses);
+//!
+//!     println!("Kept our choice {} times with {} wins and {} losses",
+//!              total_keeps, keep_wins, keep_losses);
+//!
+//!     // With a large number of simulations, the values should converge to
+//!     // 0.667 and 0.333 respectively.
+//!     println!("Estimated chance to win if we switch: {}",
+//!              switch_wins as f32 / total_switches as f32);
+//!     println!("Estimated chance to win if we don't: {}",
+//!              keep_wins as f32 / total_keeps as f32);
+//! }
+//! ```
+
+#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
+       html_favicon_url = "https://www.rust-lang.org/favicon.ico",
+       html_root_url = "https://docs.rs/rand/0.3")]
+
+#![deny(missing_debug_implementations)]
+
+#![cfg_attr(not(feature="std"), no_std)]
+#![cfg_attr(all(feature="alloc", not(feature="std")), feature(alloc))]
+#![cfg_attr(feature = "i128_support", feature(i128_type, i128))]
+
+#[cfg(feature="std")] extern crate std as core;
+#[cfg(all(feature = "alloc", not(feature="std")))] extern crate alloc;
+
+use core::marker;
+use core::mem;
+#[cfg(feature="std")] use std::cell::RefCell;
+#[cfg(feature="std")] use std::io;
+#[cfg(feature="std")] use std::rc::Rc;
+
+// external rngs
+pub use jitter::JitterRng;
+#[cfg(feature="std")] pub use os::OsRng;
+
+// pseudo rngs
+pub use isaac::{IsaacRng, Isaac64Rng};
+pub use chacha::ChaChaRng;
+pub use prng::XorShiftRng;
+
+// local use declarations
+#[cfg(target_pointer_width = "32")]
+use prng::IsaacRng as IsaacWordRng;
+#[cfg(target_pointer_width = "64")]
+use prng::Isaac64Rng as IsaacWordRng;
+
+use distributions::{Range, IndependentSample};
+use distributions::range::SampleRange;
+
+// public modules
+pub mod distributions;
+pub mod jitter;
+#[cfg(feature="std")] pub mod os;
+#[cfg(feature="std")] pub mod read;
+pub mod reseeding;
+#[cfg(any(feature="std", feature = "alloc"))] pub mod seq;
+
+// These tiny modules are here to avoid API breakage, probably only temporarily
+pub mod chacha {
+    //! The ChaCha random number generator.
+    pub use prng::ChaChaRng;
+}
+pub mod isaac {
+    //! The ISAAC random number generator.
+    pub use prng::{IsaacRng, Isaac64Rng};
+}
+
+// private modules
+mod rand_impls;
+mod prng;
+
+
+/// A type that can be randomly generated using an `Rng`.
+///
+/// ## Built-in Implementations
+///
+/// This crate implements `Rand` for various primitive types.  Assuming the
+/// provided `Rng` is well-behaved, these implementations generate values with
+/// the following ranges and distributions:
+///
+/// * Integers (`i32`, `u32`, `isize`, `usize`, etc.): Uniformly distributed
+///   over all values of the type.
+/// * `char`: Uniformly distributed over all Unicode scalar values, i.e. all
+///   code points in the range `0...0x10_FFFF`, except for the range
+///   `0xD800...0xDFFF` (the surrogate code points).  This includes
+///   unassigned/reserved code points.
+/// * `bool`: Generates `false` or `true`, each with probability 0.5.
+/// * Floating point types (`f32` and `f64`): Uniformly distributed in the
+///   half-open range `[0, 1)`.  (The [`Open01`], [`Closed01`], [`Exp1`], and
+///   [`StandardNormal`] wrapper types produce floating point numbers with
+///   alternative ranges or distributions.)
+///
+/// [`Open01`]: struct.Open01.html
+/// [`Closed01`]: struct.Closed01.html
+/// [`Exp1`]: distributions/exponential/struct.Exp1.html
+/// [`StandardNormal`]: distributions/normal/struct.StandardNormal.html
+///
+/// The following aggregate types also implement `Rand` as long as their
+/// component types implement it:
+///
+/// * Tuples and arrays: Each element of the tuple or array is generated
+///   independently, using its own `Rand` implementation.
+/// * `Option<T>`: Returns `None` with probability 0.5; otherwise generates a
+///   random `T` and returns `Some(T)`.
+pub trait Rand : Sized {
+    /// Generates a random instance of this type using the specified source of
+    /// randomness.
+    fn rand<R: Rng>(rng: &mut R) -> Self;
+}
+
+/// A random number generator.
+pub trait Rng {
+    /// Return the next random u32.
+    ///
+    /// This rarely needs to be called directly, prefer `r.gen()` to
+    /// `r.next_u32()`.
+    // FIXME #rust-lang/rfcs#628: Should be implemented in terms of next_u64
+    fn next_u32(&mut self) -> u32;
+
+    /// Return the next random u64.
+    ///
+    /// By default this is implemented in terms of `next_u32`. An
+    /// implementation of this trait must provide at least one of
+    /// these two methods. Similarly to `next_u32`, this rarely needs
+    /// to be called directly, prefer `r.gen()` to `r.next_u64()`.
+    fn next_u64(&mut self) -> u64 {
+        ((self.next_u32() as u64) << 32) | (self.next_u32() as u64)
+    }
+
+    /// Return the next random f32 selected from the half-open
+    /// interval `[0, 1)`.
+    ///
+    /// This uses a technique described by Saito and Matsumoto at
+    /// MCQMC'08. Given that the IEEE floating point numbers are
+    /// uniformly distributed over [1,2), we generate a number in
+    /// this range and then offset it onto the range [0,1). Our
+    /// choice of bits (masking v. shifting) is arbitrary and
+    /// should be immaterial for high quality generators. For low
+    /// quality generators (ex. LCG), prefer bitshifting due to
+    /// correlation between sequential low order bits.
+    ///
+    /// See:
+    /// A PRNG specialized in double precision floating point numbers using
+    /// an affine transition
+    ///
+    /// * <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/ARTICLES/dSFMT.pdf>
+    /// * <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/dSFMT-slide-e.pdf>
+    ///
+    /// By default this is implemented in terms of `next_u32`, but a
+    /// random number generator which can generate numbers satisfying
+    /// the requirements directly can overload this for performance.
+    /// It is required that the return value lies in `[0, 1)`.
+    ///
+    /// See `Closed01` for the closed interval `[0,1]`, and
+    /// `Open01` for the open interval `(0,1)`.
+    fn next_f32(&mut self) -> f32 {
+        const UPPER_MASK: u32 = 0x3F800000;
+        const LOWER_MASK: u32 = 0x7FFFFF;
+        let tmp = UPPER_MASK | (self.next_u32() & LOWER_MASK);
+        let result: f32 = unsafe { mem::transmute(tmp) };
+        result - 1.0
+    }
+
+    /// Return the next random f64 selected from the half-open
+    /// interval `[0, 1)`.
+    ///
+    /// By default this is implemented in terms of `next_u64`, but a
+    /// random number generator which can generate numbers satisfying
+    /// the requirements directly can overload this for performance.
+    /// It is required that the return value lies in `[0, 1)`.
+    ///
+    /// See `Closed01` for the closed interval `[0,1]`, and
+    /// `Open01` for the open interval `(0,1)`.
+    fn next_f64(&mut self) -> f64 {
+        const UPPER_MASK: u64 = 0x3FF0000000000000;
+        const LOWER_MASK: u64 = 0xFFFFFFFFFFFFF;
+        let tmp = UPPER_MASK | (self.next_u64() & LOWER_MASK);
+        let result: f64 = unsafe { mem::transmute(tmp) };
+        result - 1.0
+    }
+
+    /// Fill `dest` with random data.
+    ///
+    /// This has a default implementation in terms of `next_u64` and
+    /// `next_u32`, but should be overridden by implementations that
+    /// offer a more efficient solution than just calling those
+    /// methods repeatedly.
+    ///
+    /// This method does *not* have a requirement to bear any fixed
+    /// relationship to the other methods, for example, it does *not*
+    /// have to result in the same output as progressively filling
+    /// `dest` with `self.gen::<u8>()`, and any such behaviour should
+    /// not be relied upon.
+    ///
+    /// This method should guarantee that `dest` is entirely filled
+    /// with new data, and may panic if this is impossible
+    /// (e.g. reading past the end of a file that is being used as the
+    /// source of randomness).
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// use rand::{thread_rng, Rng};
+    ///
+    /// let mut v = [0u8; 13579];
+    /// thread_rng().fill_bytes(&mut v);
+    /// println!("{:?}", &v[..]);
+    /// ```
+    fn fill_bytes(&mut self, dest: &mut [u8]) {
+        // this could, in theory, be done by transmuting dest to a
+        // [u64], but this is (1) likely to be undefined behaviour for
+        // LLVM, (2) has to be very careful about alignment concerns,
+        // (3) adds more `unsafe` that needs to be checked, (4)
+        // probably doesn't give much performance gain if
+        // optimisations are on.
+        let mut count = 0;
+        let mut num = 0;
+        for byte in dest.iter_mut() {
+            if count == 0 {
+                // we could micro-optimise here by generating a u32 if
+                // we only need a few more bytes to fill the vector
+                // (i.e. at most 4).
+                num = self.next_u64();
+                count = 8;
+            }
+
+            *byte = (num & 0xff) as u8;
+            num >>= 8;
+            count -= 1;
+        }
+    }
+
+    /// Return a random value of a `Rand` type.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// use rand::{thread_rng, Rng};
+    ///
+    /// let mut rng = thread_rng();
+    /// let x: u32 = rng.gen();
+    /// println!("{}", x);
+    /// println!("{:?}", rng.gen::<(f64, bool)>());
+    /// ```
+    #[inline(always)]
+    fn gen<T: Rand>(&mut self) -> T where Self: Sized {
+        Rand::rand(self)
+    }
+
+    /// Return an iterator that will yield an infinite number of randomly
+    /// generated items.
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// use rand::{thread_rng, Rng};
+    ///
+    /// let mut rng = thread_rng();
+    /// let x = rng.gen_iter::<u32>().take(10).collect::<Vec<u32>>();
+    /// println!("{:?}", x);
+    /// println!("{:?}", rng.gen_iter::<(f64, bool)>().take(5)
+    ///                     .collect::<Vec<(f64, bool)>>());
+    /// ```
+    fn gen_iter<'a, T: Rand>(&'a mut self) -> Generator<'a, T, Self> where Self: Sized {
+        Generator { rng: self, _marker: marker::PhantomData }
+    }
+
+    /// Generate a random value in the range [`low`, `high`).
+    ///
+    /// This is a convenience wrapper around
+    /// `distributions::Range`. If this function will be called
+    /// repeatedly with the same arguments, one should use `Range`, as
+    /// that will amortize the computations that allow for perfect
+    /// uniformity, as they only happen on initialization.
+    ///
+    /// # Panics
+    ///
+    /// Panics if `low >= high`.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// use rand::{thread_rng, Rng};
+    ///
+    /// let mut rng = thread_rng();
+    /// let n: u32 = rng.gen_range(0, 10);
+    /// println!("{}", n);
+    /// let m: f64 = rng.gen_range(-40.0f64, 1.3e5f64);
+    /// println!("{}", m);
+    /// ```
+    fn gen_range<T: PartialOrd + SampleRange>(&mut self, low: T, high: T) -> T where Self: Sized {
+        assert!(low < high, "Rng.gen_range called with low >= high");
+        Range::new(low, high).ind_sample(self)
+    }
+
+    /// Return a bool with a 1 in n chance of true
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// use rand::{thread_rng, Rng};
+    ///
+    /// let mut rng = thread_rng();
+    /// println!("{}", rng.gen_weighted_bool(3));
+    /// ```
+    fn gen_weighted_bool(&mut self, n: u32) -> bool where Self: Sized {
+        n <= 1 || self.gen_range(0, n) == 0
+    }
+
+    /// Return an iterator of random characters from the set A-Z,a-z,0-9.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// use rand::{thread_rng, Rng};
+    ///
+    /// let s: String = thread_rng().gen_ascii_chars().take(10).collect();
+    /// println!("{}", s);
+    /// ```
+    fn gen_ascii_chars<'a>(&'a mut self) -> AsciiGenerator<'a, Self> where Self: Sized {
+        AsciiGenerator { rng: self }
+    }
+
+    /// Return a random element from `values`.
+    ///
+    /// Return `None` if `values` is empty.
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// use rand::{thread_rng, Rng};
+    ///
+    /// let choices = [1, 2, 4, 8, 16, 32];
+    /// let mut rng = thread_rng();
+    /// println!("{:?}", rng.choose(&choices));
+    /// assert_eq!(rng.choose(&choices[..0]), None);
+    /// ```
+    fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> where Self: Sized {
+        if values.is_empty() {
+            None
+        } else {
+            Some(&values[self.gen_range(0, values.len())])
+        }
+    }
+
+    /// Return a mutable pointer to a random element from `values`.
+    ///
+    /// Return `None` if `values` is empty.
+    fn choose_mut<'a, T>(&mut self, values: &'a mut [T]) -> Option<&'a mut T> where Self: Sized {
+        if values.is_empty() {
+            None
+        } else {
+            let len = values.len();
+            Some(&mut values[self.gen_range(0, len)])
+        }
+    }
+
+    /// Shuffle a mutable slice in place.
+    ///
+    /// This applies Durstenfeld's algorithm for the [Fisher–Yates shuffle](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm)
+    /// which produces an unbiased permutation.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// use rand::{thread_rng, Rng};
+    ///
+    /// let mut rng = thread_rng();
+    /// let mut y = [1, 2, 3];
+    /// rng.shuffle(&mut y);
+    /// println!("{:?}", y);
+    /// rng.shuffle(&mut y);
+    /// println!("{:?}", y);
+    /// ```
+    fn shuffle<T>(&mut self, values: &mut [T]) where Self: Sized {
+        let mut i = values.len();
+        while i >= 2 {
+            // invariant: elements with index >= i have been locked in place.
+            i -= 1;
+            // lock element i in place.
+            values.swap(i, self.gen_range(0, i + 1));
+        }
+    }
+}
+
+impl<'a, R: ?Sized> Rng for &'a mut R where R: Rng {
+    fn next_u32(&mut self) -> u32 {
+        (**self).next_u32()
+    }
+
+    fn next_u64(&mut self) -> u64 {
+        (**self).next_u64()
+    }
+
+    fn next_f32(&mut self) -> f32 {
+        (**self).next_f32()
+    }
+
+    fn next_f64(&mut self) -> f64 {
+        (**self).next_f64()
+    }
+
+    fn fill_bytes(&mut self, dest: &mut [u8]) {
+        (**self).fill_bytes(dest)
+    }
+}
+
+#[cfg(feature="std")]
+impl<R: ?Sized> Rng for Box<R> where R: Rng {
+    fn next_u32(&mut self) -> u32 {
+        (**self).next_u32()
+    }
+
+    fn next_u64(&mut self) -> u64 {
+        (**self).next_u64()
+    }
+
+    fn next_f32(&mut self) -> f32 {
+        (**self).next_f32()
+    }
+
+    fn next_f64(&mut self) -> f64 {
+        (**self).next_f64()
+    }
+
+    fn fill_bytes(&mut self, dest: &mut [u8]) {
+        (**self).fill_bytes(dest)
+    }
+}
+
+/// Iterator which will generate a stream of random items.
+///
+/// This iterator is created via the [`gen_iter`] method on [`Rng`].
+///
+/// [`gen_iter`]: trait.Rng.html#method.gen_iter
+/// [`Rng`]: trait.Rng.html
+#[derive(Debug)]
+pub struct Generator<'a, T, R:'a> {
+    rng: &'a mut R,
+    _marker: marker::PhantomData<fn() -> T>,
+}
+
+impl<'a, T: Rand, R: Rng> Iterator for Generator<'a, T, R> {
+    type Item = T;
+
+    fn next(&mut self) -> Option<T> {
+        Some(self.rng.gen())
+    }
+}
+
+/// Iterator which will continuously generate random ascii characters.
+///
+/// This iterator is created via the [`gen_ascii_chars`] method on [`Rng`].
+///
+/// [`gen_ascii_chars`]: trait.Rng.html#method.gen_ascii_chars
+/// [`Rng`]: trait.Rng.html
+#[derive(Debug)]
+pub struct AsciiGenerator<'a, R:'a> {
+    rng: &'a mut R,
+}
+
+impl<'a, R: Rng> Iterator for AsciiGenerator<'a, R> {
+    type Item = char;
+
+    fn next(&mut self) -> Option<char> {
+        const GEN_ASCII_STR_CHARSET: &'static [u8] =
+            b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
+              abcdefghijklmnopqrstuvwxyz\
+              0123456789";
+        Some(*self.rng.choose(GEN_ASCII_STR_CHARSET).unwrap() as char)
+    }
+}
+
+/// A random number generator that can be explicitly seeded to produce
+/// the same stream of randomness multiple times.
+pub trait SeedableRng<Seed>: Rng {
+    /// Reseed an RNG with the given seed.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// use rand::{Rng, SeedableRng, StdRng};
+    ///
+    /// let seed: &[_] = &[1, 2, 3, 4];
+    /// let mut rng: StdRng = SeedableRng::from_seed(seed);
+    /// println!("{}", rng.gen::<f64>());
+    /// rng.reseed(&[5, 6, 7, 8]);
+    /// println!("{}", rng.gen::<f64>());
+    /// ```
+    fn reseed(&mut self, Seed);
+
+    /// Create a new RNG with the given seed.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// use rand::{Rng, SeedableRng, StdRng};
+    ///
+    /// let seed: &[_] = &[1, 2, 3, 4];
+    /// let mut rng: StdRng = SeedableRng::from_seed(seed);
+    /// println!("{}", rng.gen::<f64>());
+    /// ```
+    fn from_seed(seed: Seed) -> Self;
+}
+
+/// A wrapper for generating floating point numbers uniformly in the
+/// open interval `(0,1)` (not including either endpoint).
+///
+/// Use `Closed01` for the closed interval `[0,1]`, and the default
+/// `Rand` implementation for `f32` and `f64` for the half-open
+/// `[0,1)`.
+///
+/// # Example
+/// ```rust
+/// use rand::{random, Open01};
+///
+/// let Open01(val) = random::<Open01<f32>>();
+/// println!("f32 from (0,1): {}", val);
+/// ```
+#[derive(Debug)]
+pub struct Open01<F>(pub F);
+
+/// A wrapper for generating floating point numbers uniformly in the
+/// closed interval `[0,1]` (including both endpoints).
+///
+/// Use `Open01` for the closed interval `(0,1)`, and the default
+/// `Rand` implementation of `f32` and `f64` for the half-open
+/// `[0,1)`.
+///
+/// # Example
+///
+/// ```rust
+/// use rand::{random, Closed01};
+///
+/// let Closed01(val) = random::<Closed01<f32>>();
+/// println!("f32 from [0,1]: {}", val);
+/// ```
+#[derive(Debug)]
+pub struct Closed01<F>(pub F);
+
+/// The standard RNG. This is designed to be efficient on the current
+/// platform.
+#[derive(Copy, Clone, Debug)]
+pub struct StdRng {
+    rng: IsaacWordRng,
+}
+
+impl StdRng {
+    /// Create a randomly seeded instance of `StdRng`.
+    ///
+    /// This is a very expensive operation as it has to read
+    /// randomness from the operating system and use this in an
+    /// expensive seeding operation. If one is only generating a small
+    /// number of random numbers, or doesn't need the utmost speed for
+    /// generating each number, `thread_rng` and/or `random` may be more
+    /// appropriate.
+    ///
+    /// Reading the randomness from the OS may fail, and any error is
+    /// propagated via the `io::Result` return value.
+    #[cfg(feature="std")]
+    pub fn new() -> io::Result<StdRng> {
+        match OsRng::new() {
+            Ok(mut r) => Ok(StdRng { rng: r.gen() }),
+            Err(e1) => {
+                match JitterRng::new() {
+                    Ok(mut r) => Ok(StdRng { rng: r.gen() }),
+                    Err(_) => {
+                        Err(e1)
+                    }
+                }
+            }
+        }
+    }
+}
+
+impl Rng for StdRng {
+    #[inline]
+    fn next_u32(&mut self) -> u32 {
+        self.rng.next_u32()
+    }
+
+    #[inline]
+    fn next_u64(&mut self) -> u64 {
+        self.rng.next_u64()
+    }
+}
+
+impl<'a> SeedableRng<&'a [usize]> for StdRng {
+    fn reseed(&mut self, seed: &'a [usize]) {
+        // the internal RNG can just be seeded from the above
+        // randomness.
+        self.rng.reseed(unsafe {mem::transmute(seed)})
+    }
+
+    fn from_seed(seed: &'a [usize]) -> StdRng {
+        StdRng { rng: SeedableRng::from_seed(unsafe {mem::transmute(seed)}) }
+    }
+}
+
+/// Create a weak random number generator with a default algorithm and seed.
+///
+/// It returns the fastest `Rng` algorithm currently available in Rust without
+/// consideration for cryptography or security. If you require a specifically
+/// seeded `Rng` for consistency over time you should pick one algorithm and
+/// create the `Rng` yourself.
+///
+/// This will seed the generator with randomness from thread_rng.
+#[cfg(feature="std")]
+pub fn weak_rng() -> XorShiftRng {
+    thread_rng().gen()
+}
+
+/// Controls how the thread-local RNG is reseeded.
+#[cfg(feature="std")]
+#[derive(Debug)]
+struct ThreadRngReseeder;
+
+#[cfg(feature="std")]
+impl reseeding::Reseeder<StdRng> for ThreadRngReseeder {
+    fn reseed(&mut self, rng: &mut StdRng) {
+        match StdRng::new() {
+            Ok(r) => *rng = r,
+            Err(e) => panic!("No entropy available: {}", e),
+        }
+    }
+}
+#[cfg(feature="std")]
+const THREAD_RNG_RESEED_THRESHOLD: u64 = 32_768;
+#[cfg(feature="std")]
+type ThreadRngInner = reseeding::ReseedingRng<StdRng, ThreadRngReseeder>;
+
+/// The thread-local RNG.
+#[cfg(feature="std")]
+#[derive(Clone, Debug)]
+pub struct ThreadRng {
+    rng: Rc<RefCell<ThreadRngInner>>,
+}
+
+/// Retrieve the lazily-initialized thread-local random number
+/// generator, seeded by the system. Intended to be used in method
+/// chaining style, e.g. `thread_rng().gen::<i32>()`.
+///
+/// After generating a certain amount of randomness, the RNG will reseed itself
+/// from the operating system or, if the operating system RNG returns an error,
+/// a seed based on the current system time.
+///
+/// The internal RNG used is platform and architecture dependent, even
+/// if the operating system random number generator is rigged to give
+/// the same sequence always. If absolute consistency is required,
+/// explicitly select an RNG, e.g. `IsaacRng` or `Isaac64Rng`.
+#[cfg(feature="std")]
+pub fn thread_rng() -> ThreadRng {
+    // used to make space in TLS for a random number generator
+    thread_local!(static THREAD_RNG_KEY: Rc<RefCell<ThreadRngInner>> = {
+        let r = match StdRng::new() {
+            Ok(r) => r,
+            Err(e) => panic!("No entropy available: {}", e),
+        };
+        let rng = reseeding::ReseedingRng::new(r,
+                                               THREAD_RNG_RESEED_THRESHOLD,
+                                               ThreadRngReseeder);
+        Rc::new(RefCell::new(rng))
+    });
+
+    ThreadRng { rng: THREAD_RNG_KEY.with(|t| t.clone()) }
+}
+
+#[cfg(feature="std")]
+impl Rng for ThreadRng {
+    fn next_u32(&mut self) -> u32 {
+        self.rng.borrow_mut().next_u32()
+    }
+
+    fn next_u64(&mut self) -> u64 {
+        self.rng.borrow_mut().next_u64()
+    }
+
+    #[inline]
+    fn fill_bytes(&mut self, bytes: &mut [u8]) {
+        self.rng.borrow_mut().fill_bytes(bytes)
+    }
+}
+
+/// Generates a random value using the thread-local random number generator.
+///
+/// `random()` can generate various types of random things, and so may require
+/// type hinting to generate the specific type you want.
+///
+/// This function uses the thread local random number generator. This means
+/// that if you're calling `random()` in a loop, caching the generator can
+/// increase performance. An example is shown below.
+///
+/// # Examples
+///
+/// ```
+/// let x = rand::random::<u8>();
+/// println!("{}", x);
+///
+/// let y = rand::random::<f64>();
+/// println!("{}", y);
+///
+/// if rand::random() { // generates a boolean
+///     println!("Better lucky than good!");
+/// }
+/// ```
+///
+/// Caching the thread local random number generator:
+///
+/// ```
+/// use rand::Rng;
+///
+/// let mut v = vec![1, 2, 3];
+///
+/// for x in v.iter_mut() {
+///     *x = rand::random()
+/// }
+///
+/// // can be made faster by caching thread_rng
+///
+/// let mut rng = rand::thread_rng();
+///
+/// for x in v.iter_mut() {
+///     *x = rng.gen();
+/// }
+/// ```
+#[cfg(feature="std")]
+#[inline]
+pub fn random<T: Rand>() -> T {
+    thread_rng().gen()
+}
+
+/// DEPRECATED: use `seq::sample_iter` instead.
+///
+/// Randomly sample up to `amount` elements from a finite iterator.
+/// The order of elements in the sample is not random.
+///
+/// # Example
+///
+/// ```rust
+/// use rand::{thread_rng, sample};
+///
+/// let mut rng = thread_rng();
+/// let sample = sample(&mut rng, 1..100, 5);
+/// println!("{:?}", sample);
+/// ```
+#[cfg(feature="std")]
+#[inline(always)]
+#[deprecated(since="0.4.0", note="renamed to seq::sample_iter")]
+pub fn sample<T, I, R>(rng: &mut R, iterable: I, amount: usize) -> Vec<T>
+    where I: IntoIterator<Item=T>,
+          R: Rng,
+{
+    // the legacy sample didn't care whether amount was met
+    seq::sample_iter(rng, iterable, amount)
+        .unwrap_or_else(|e| e)
+}
+
+#[cfg(test)]
+mod test {
+    use super::{Rng, thread_rng, random, SeedableRng, StdRng, weak_rng};
+    use std::iter::repeat;
+
+    pub struct MyRng<R> { inner: R }
+
+    impl<R: Rng> Rng for MyRng<R> {
+        fn next_u32(&mut self) -> u32 {
+            fn next<T: Rng>(t: &mut T) -> u32 {
+                t.next_u32()
+            }
+            next(&mut self.inner)
+        }
+    }
+
+    pub fn rng() -> MyRng<::ThreadRng> {
+        MyRng { inner: ::thread_rng() }
+    }
+
+    struct ConstRng { i: u64 }
+    impl Rng for ConstRng {
+        fn next_u32(&mut self) -> u32 { self.i as u32 }
+        fn next_u64(&mut self) -> u64 { self.i }
+
+        // no fill_bytes on purpose
+    }
+
+    pub fn iter_eq<I, J>(i: I, j: J) -> bool
+        where I: IntoIterator,
+              J: IntoIterator<Item=I::Item>,
+              I::Item: Eq
+    {
+        // make sure the iterators have equal length
+        let mut i = i.into_iter();
+        let mut j = j.into_iter();
+        loop {
+            match (i.next(), j.next()) {
+                (Some(ref ei), Some(ref ej)) if ei == ej => { }
+                (None, None) => return true,
+                _ => return false,
+            }
+        }
+    }
+
+    #[test]
+    fn test_fill_bytes_default() {
+        let mut r = ConstRng { i: 0x11_22_33_44_55_66_77_88 };
+
+        // check every remainder mod 8, both in small and big vectors.
+        let lengths = [0, 1, 2, 3, 4, 5, 6, 7,
+                       80, 81, 82, 83, 84, 85, 86, 87];
+        for &n in lengths.iter() {
+            let mut v = repeat(0u8).take(n).collect::<Vec<_>>();
+            r.fill_bytes(&mut v);
+
+            // use this to get nicer error messages.
+            for (i, &byte) in v.iter().enumerate() {
+                if byte == 0 {
+                    panic!("byte {} of {} is zero", i, n)
+                }
+            }
+        }
+    }
+
+    #[test]
+    fn test_gen_range() {
+        let mut r = thread_rng();
+        for _ in 0..1000 {
+            let a = r.gen_range(-3, 42);
+            assert!(a >= -3 && a < 42);
+            assert_eq!(r.gen_range(0, 1), 0);
+            assert_eq!(r.gen_range(-12, -11), -12);
+        }
+
+        for _ in 0..1000 {
+            let a = r.gen_range(10, 42);
+            assert!(a >= 10 && a < 42);
+            assert_eq!(r.gen_range(0, 1), 0);
+            assert_eq!(r.gen_range(3_000_000, 3_000_001), 3_000_000);
+        }
+
+    }
+
+    #[test]
+    #[should_panic]
+    fn test_gen_range_panic_int() {
+        let mut r = thread_rng();
+        r.gen_range(5, -2);
+    }
+
+    #[test]
+    #[should_panic]
+    fn test_gen_range_panic_usize() {
+        let mut r = thread_rng();
+        r.gen_range(5, 2);
+    }
+
+    #[test]
+    fn test_gen_weighted_bool() {
+        let mut r = thread_rng();
+        assert_eq!(r.gen_weighted_bool(0), true);
+        assert_eq!(r.gen_weighted_bool(1), true);
+    }
+
+    #[test]
+    fn test_gen_ascii_str() {
+        let mut r = thread_rng();
+        assert_eq!(r.gen_ascii_chars().take(0).count(), 0);
+        assert_eq!(r.gen_ascii_chars().take(10).count(), 10);
+        assert_eq!(r.gen_ascii_chars().take(16).count(), 16);
+    }
+
+    #[test]
+    fn test_gen_vec() {
+        let mut r = thread_rng();
+        assert_eq!(r.gen_iter::<u8>().take(0).count(), 0);
+        assert_eq!(r.gen_iter::<u8>().take(10).count(), 10);
+        assert_eq!(r.gen_iter::<f64>().take(16).count(), 16);
+    }
+
+    #[test]
+    fn test_choose() {
+        let mut r = thread_rng();
+        assert_eq!(r.choose(&[1, 1, 1]).map(|&x|x), Some(1));
+
+        let v: &[isize] = &[];
+        assert_eq!(r.choose(v), None);
+    }
+
+    #[test]
+    fn test_shuffle() {
+        let mut r = thread_rng();
+        let empty: &mut [isize] = &mut [];
+        r.shuffle(empty);
+        let mut one = [1];
+        r.shuffle(&mut one);
+        let b: &[_] = &[1];
+        assert_eq!(one, b);
+
+        let mut two = [1, 2];
+        r.shuffle(&mut two);
+        assert!(two == [1, 2] || two == [2, 1]);
+
+        let mut x = [1, 1, 1];
+        r.shuffle(&mut x);
+        let b: &[_] = &[1, 1, 1];
+        assert_eq!(x, b);
+    }
+
+    #[test]
+    fn test_thread_rng() {
+        let mut r = thread_rng();
+        r.gen::<i32>();
+        let mut v = [1, 1, 1];
+        r.shuffle(&mut v);
+        let b: &[_] = &[1, 1, 1];
+        assert_eq!(v, b);
+        assert_eq!(r.gen_range(0, 1), 0);
+    }
+
+    #[test]
+    fn test_rng_trait_object() {
+        let mut rng = thread_rng();
+        {
+            let mut r = &mut rng as &mut Rng;
+            r.next_u32();
+            (&mut r).gen::<i32>();
+            let mut v = [1, 1, 1];
+            (&mut r).shuffle(&mut v);
+            let b: &[_] = &[1, 1, 1];
+            assert_eq!(v, b);
+            assert_eq!((&mut r).gen_range(0, 1), 0);
+        }
+        {
+            let mut r = Box::new(rng) as Box<Rng>;
+            r.next_u32();
+            r.gen::<i32>();
+            let mut v = [1, 1, 1];
+            r.shuffle(&mut v);
+            let b: &[_] = &[1, 1, 1];
+            assert_eq!(v, b);
+            assert_eq!(r.gen_range(0, 1), 0);
+        }
+    }
+
+    #[test]
+    fn test_random() {
+        // not sure how to test this aside from just getting some values
+        let _n : usize = random();
+        let _f : f32 = random();
+        let _o : Option<Option<i8>> = random();
+        let _many : ((),
+                     (usize,
+                      isize,
+                      Option<(u32, (bool,))>),
+                     (u8, i8, u16, i16, u32, i32, u64, i64),
+                     (f32, (f64, (f64,)))) = random();
+    }
+
+    #[test]
+    fn test_std_rng_seeded() {
+        let s = thread_rng().gen_iter::<usize>().take(256).collect::<Vec<usize>>();
+        let mut ra: StdRng = SeedableRng::from_seed(&s[..]);
+        let mut rb: StdRng = SeedableRng::from_seed(&s[..]);
+        assert!(iter_eq(ra.gen_ascii_chars().take(100),
+                        rb.gen_ascii_chars().take(100)));
+    }
+
+    #[test]
+    fn test_std_rng_reseed() {
+        let s = thread_rng().gen_iter::<usize>().take(256).collect::<Vec<usize>>();
+        let mut r: StdRng = SeedableRng::from_seed(&s[..]);
+        let string1 = r.gen_ascii_chars().take(100).collect::<String>();
+
+        r.reseed(&s);
+
+        let string2 = r.gen_ascii_chars().take(100).collect::<String>();
+        assert_eq!(string1, string2);
+    }
+
+    #[test]
+    fn test_weak_rng() {
+        let s = weak_rng().gen_iter::<usize>().take(256).collect::<Vec<usize>>();
+        let mut ra: StdRng = SeedableRng::from_seed(&s[..]);
+        let mut rb: StdRng = SeedableRng::from_seed(&s[..]);
+        assert!(iter_eq(ra.gen_ascii_chars().take(100),
+                        rb.gen_ascii_chars().take(100)));
+    }
+}
diff --git a/rustc_deps/vendor/rand/src/os.rs b/rustc_deps/vendor/rand-0.4.2/src/os.rs
similarity index 100%
rename from rustc_deps/vendor/rand/src/os.rs
rename to rustc_deps/vendor/rand-0.4.2/src/os.rs
diff --git a/rustc_deps/vendor/rand-0.4.2/src/prng/chacha.rs b/rustc_deps/vendor/rand-0.4.2/src/prng/chacha.rs
new file mode 100644
index 0000000..a73e8e7
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/src/prng/chacha.rs
@@ -0,0 +1,321 @@
+// 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.
+
+//! The ChaCha random number generator.
+
+use core::num::Wrapping as w;
+use {Rng, SeedableRng, Rand};
+
+#[allow(bad_style)]
+type w32 = w<u32>;
+
+const KEY_WORDS    : usize =  8; // 8 words for the 256-bit key
+const STATE_WORDS  : usize = 16;
+const CHACHA_ROUNDS: u32 = 20; // Cryptographically secure from 8 upwards as of this writing
+
+/// A random number generator that uses the ChaCha20 algorithm [1].
+///
+/// The ChaCha algorithm is widely accepted as suitable for
+/// cryptographic purposes, but this implementation has not been
+/// verified as such. Prefer a generator like `OsRng` that defers to
+/// the operating system for cases that need high security.
+///
+/// [1]: D. J. Bernstein, [*ChaCha, a variant of
+/// Salsa20*](http://cr.yp.to/chacha.html)
+#[derive(Copy, Clone, Debug)]
+pub struct ChaChaRng {
+    buffer:  [w32; STATE_WORDS], // Internal buffer of output
+    state:   [w32; STATE_WORDS], // Initial state
+    index:   usize,                 // Index into state
+}
+
+static EMPTY: ChaChaRng = ChaChaRng {
+    buffer:  [w(0); STATE_WORDS],
+    state:   [w(0); STATE_WORDS],
+    index:   STATE_WORDS
+};
+
+
+macro_rules! quarter_round{
+    ($a: expr, $b: expr, $c: expr, $d: expr) => {{
+        $a = $a + $b; $d = $d ^ $a; $d = w($d.0.rotate_left(16));
+        $c = $c + $d; $b = $b ^ $c; $b = w($b.0.rotate_left(12));
+        $a = $a + $b; $d = $d ^ $a; $d = w($d.0.rotate_left( 8));
+        $c = $c + $d; $b = $b ^ $c; $b = w($b.0.rotate_left( 7));
+    }}
+}
+
+macro_rules! double_round{
+    ($x: expr) => {{
+        // Column round
+        quarter_round!($x[ 0], $x[ 4], $x[ 8], $x[12]);
+        quarter_round!($x[ 1], $x[ 5], $x[ 9], $x[13]);
+        quarter_round!($x[ 2], $x[ 6], $x[10], $x[14]);
+        quarter_round!($x[ 3], $x[ 7], $x[11], $x[15]);
+        // Diagonal round
+        quarter_round!($x[ 0], $x[ 5], $x[10], $x[15]);
+        quarter_round!($x[ 1], $x[ 6], $x[11], $x[12]);
+        quarter_round!($x[ 2], $x[ 7], $x[ 8], $x[13]);
+        quarter_round!($x[ 3], $x[ 4], $x[ 9], $x[14]);
+    }}
+}
+
+#[inline]
+fn core(output: &mut [w32; STATE_WORDS], input: &[w32; STATE_WORDS]) {
+    *output = *input;
+
+    for _ in 0..CHACHA_ROUNDS / 2 {
+        double_round!(output);
+    }
+
+    for i in 0..STATE_WORDS {
+        output[i] = output[i] + input[i];
+    }
+}
+
+impl ChaChaRng {
+
+    /// Create an ChaCha random number generator using the default
+    /// fixed key of 8 zero words.
+    ///
+    /// # Examples
+    ///
+    /// ```rust
+    /// use rand::{Rng, ChaChaRng};
+    ///
+    /// let mut ra = ChaChaRng::new_unseeded();
+    /// println!("{:?}", ra.next_u32());
+    /// println!("{:?}", ra.next_u32());
+    /// ```
+    ///
+    /// Since this equivalent to a RNG with a fixed seed, repeated executions
+    /// of an unseeded RNG will produce the same result. This code sample will
+    /// consistently produce:
+    ///
+    /// - 2917185654
+    /// - 2419978656
+    pub fn new_unseeded() -> ChaChaRng {
+        let mut rng = EMPTY;
+        rng.init(&[0; KEY_WORDS]);
+        rng
+    }
+
+    /// Sets the internal 128-bit ChaCha counter to
+    /// a user-provided value. This permits jumping
+    /// arbitrarily ahead (or backwards) in the pseudorandom stream.
+    ///
+    /// Since the nonce words are used to extend the counter to 128 bits,
+    /// users wishing to obtain the conventional ChaCha pseudorandom stream
+    /// associated with a particular nonce can call this function with
+    /// arguments `0, desired_nonce`.
+    ///
+    /// # Examples
+    ///
+    /// ```rust
+    /// use rand::{Rng, ChaChaRng};
+    ///
+    /// let mut ra = ChaChaRng::new_unseeded();
+    /// ra.set_counter(0u64, 1234567890u64);
+    /// println!("{:?}", ra.next_u32());
+    /// println!("{:?}", ra.next_u32());
+    /// ```
+    pub fn set_counter(&mut self, counter_low: u64, counter_high: u64) {
+        self.state[12] = w((counter_low >>  0) as u32);
+        self.state[13] = w((counter_low >> 32) as u32);
+        self.state[14] = w((counter_high >>  0) as u32);
+        self.state[15] = w((counter_high >> 32) as u32);
+        self.index = STATE_WORDS; // force recomputation
+    }
+
+    /// Initializes `self.state` with the appropriate key and constants
+    ///
+    /// We deviate slightly from the ChaCha specification regarding
+    /// the nonce, which is used to extend the counter to 128 bits.
+    /// This is provably as strong as the original cipher, though,
+    /// since any distinguishing attack on our variant also works
+    /// against ChaCha with a chosen-nonce. See the XSalsa20 [1]
+    /// security proof for a more involved example of this.
+    ///
+    /// The modified word layout is:
+    /// ```text
+    /// constant constant constant constant
+    /// key      key      key      key
+    /// key      key      key      key
+    /// counter  counter  counter  counter
+    /// ```
+    /// [1]: Daniel J. Bernstein. [*Extending the Salsa20
+    /// nonce.*](http://cr.yp.to/papers.html#xsalsa)
+    fn init(&mut self, key: &[u32; KEY_WORDS]) {
+        self.state[0] = w(0x61707865);
+        self.state[1] = w(0x3320646E);
+        self.state[2] = w(0x79622D32);
+        self.state[3] = w(0x6B206574);
+
+        for i in 0..KEY_WORDS {
+            self.state[4+i] = w(key[i]);
+        }
+
+        self.state[12] = w(0);
+        self.state[13] = w(0);
+        self.state[14] = w(0);
+        self.state[15] = w(0);
+
+        self.index = STATE_WORDS;
+    }
+
+    /// Refill the internal output buffer (`self.buffer`)
+    fn update(&mut self) {
+        core(&mut self.buffer, &self.state);
+        self.index = 0;
+        // update 128-bit counter
+        self.state[12] = self.state[12] + w(1);
+        if self.state[12] != w(0) { return };
+        self.state[13] = self.state[13] + w(1);
+        if self.state[13] != w(0) { return };
+        self.state[14] = self.state[14] + w(1);
+        if self.state[14] != w(0) { return };
+        self.state[15] = self.state[15] + w(1);
+    }
+}
+
+impl Rng for ChaChaRng {
+    #[inline]
+    fn next_u32(&mut self) -> u32 {
+        if self.index == STATE_WORDS {
+            self.update();
+        }
+
+        let value = self.buffer[self.index % STATE_WORDS];
+        self.index += 1;
+        value.0
+    }
+}
+
+impl<'a> SeedableRng<&'a [u32]> for ChaChaRng {
+
+    fn reseed(&mut self, seed: &'a [u32]) {
+        // reset state
+        self.init(&[0u32; KEY_WORDS]);
+        // set key in place
+        let key = &mut self.state[4 .. 4+KEY_WORDS];
+        for (k, s) in key.iter_mut().zip(seed.iter()) {
+            *k = w(*s);
+        }
+    }
+
+    /// Create a ChaCha generator from a seed,
+    /// obtained from a variable-length u32 array.
+    /// Only up to 8 words are used; if less than 8
+    /// words are used, the remaining are set to zero.
+    fn from_seed(seed: &'a [u32]) -> ChaChaRng {
+        let mut rng = EMPTY;
+        rng.reseed(seed);
+        rng
+    }
+}
+
+impl Rand for ChaChaRng {
+    fn rand<R: Rng>(other: &mut R) -> ChaChaRng {
+        let mut key : [u32; KEY_WORDS] = [0; KEY_WORDS];
+        for word in key.iter_mut() {
+            *word = other.gen();
+        }
+        SeedableRng::from_seed(&key[..])
+    }
+}
+
+
+#[cfg(test)]
+mod test {
+    use {Rng, SeedableRng};
+    use super::ChaChaRng;
+
+    #[test]
+    fn test_rng_rand_seeded() {
+        let s = ::test::rng().gen_iter::<u32>().take(8).collect::<Vec<u32>>();
+        let mut ra: ChaChaRng = SeedableRng::from_seed(&s[..]);
+        let mut rb: ChaChaRng = SeedableRng::from_seed(&s[..]);
+        assert!(::test::iter_eq(ra.gen_ascii_chars().take(100),
+                                rb.gen_ascii_chars().take(100)));
+    }
+
+    #[test]
+    fn test_rng_seeded() {
+        let seed : &[_] = &[0,1,2,3,4,5,6,7];
+        let mut ra: ChaChaRng = SeedableRng::from_seed(seed);
+        let mut rb: ChaChaRng = SeedableRng::from_seed(seed);
+        assert!(::test::iter_eq(ra.gen_ascii_chars().take(100),
+                                rb.gen_ascii_chars().take(100)));
+    }
+
+    #[test]
+    fn test_rng_reseed() {
+        let s = ::test::rng().gen_iter::<u32>().take(8).collect::<Vec<u32>>();
+        let mut r: ChaChaRng = SeedableRng::from_seed(&s[..]);
+        let string1: String = r.gen_ascii_chars().take(100).collect();
+
+        r.reseed(&s);
+
+        let string2: String = r.gen_ascii_chars().take(100).collect();
+        assert_eq!(string1, string2);
+    }
+
+    #[test]
+    fn test_rng_true_values() {
+        // Test vectors 1 and 2 from
+        // http://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04
+        let seed : &[_] = &[0u32; 8];
+        let mut ra: ChaChaRng = SeedableRng::from_seed(seed);
+
+        let v = (0..16).map(|_| ra.next_u32()).collect::<Vec<_>>();
+        assert_eq!(v,
+                   vec!(0xade0b876, 0x903df1a0, 0xe56a5d40, 0x28bd8653,
+                        0xb819d2bd, 0x1aed8da0, 0xccef36a8, 0xc70d778b,
+                        0x7c5941da, 0x8d485751, 0x3fe02477, 0x374ad8b8,
+                        0xf4b8436a, 0x1ca11815, 0x69b687c3, 0x8665eeb2));
+
+        let v = (0..16).map(|_| ra.next_u32()).collect::<Vec<_>>();
+        assert_eq!(v,
+                   vec!(0xbee7079f, 0x7a385155, 0x7c97ba98, 0x0d082d73,
+                        0xa0290fcb, 0x6965e348, 0x3e53c612, 0xed7aee32,
+                        0x7621b729, 0x434ee69c, 0xb03371d5, 0xd539d874,
+                        0x281fed31, 0x45fb0a51, 0x1f0ae1ac, 0x6f4d794b));
+
+
+        let seed : &[_] = &[0,1,2,3,4,5,6,7];
+        let mut ra: ChaChaRng = SeedableRng::from_seed(seed);
+
+        // Store the 17*i-th 32-bit word,
+        // i.e., the i-th word of the i-th 16-word block
+        let mut v : Vec<u32> = Vec::new();
+        for _ in 0..16 {
+            v.push(ra.next_u32());
+            for _ in 0..16 {
+                ra.next_u32();
+            }
+        }
+
+        assert_eq!(v,
+                   vec!(0xf225c81a, 0x6ab1be57, 0x04d42951, 0x70858036,
+                        0x49884684, 0x64efec72, 0x4be2d186, 0x3615b384,
+                        0x11cfa18e, 0xd3c50049, 0x75c775f6, 0x434c6530,
+                        0x2c5bad8f, 0x898881dc, 0x5f1c86d9, 0xc1f8e7f4));
+    }
+
+    #[test]
+    fn test_rng_clone() {
+        let seed : &[_] = &[0u32; 8];
+        let mut rng: ChaChaRng = SeedableRng::from_seed(seed);
+        let mut clone = rng.clone();
+        for _ in 0..16 {
+            assert_eq!(rng.next_u64(), clone.next_u64());
+        }
+    }
+}
diff --git a/rustc_deps/vendor/rand-0.4.2/src/prng/isaac.rs b/rustc_deps/vendor/rand-0.4.2/src/prng/isaac.rs
new file mode 100644
index 0000000..cf5eb67
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/src/prng/isaac.rs
@@ -0,0 +1,328 @@
+// Copyright 2013 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.
+
+//! The ISAAC random number generator.
+
+#![allow(non_camel_case_types)]
+
+use core::slice;
+use core::iter::repeat;
+use core::num::Wrapping as w;
+use core::fmt;
+
+use {Rng, SeedableRng, Rand};
+
+#[allow(bad_style)]
+type w32 = w<u32>;
+
+const RAND_SIZE_LEN: usize = 8;
+const RAND_SIZE: u32 = 1 << RAND_SIZE_LEN;
+const RAND_SIZE_USIZE: usize = 1 << RAND_SIZE_LEN;
+
+/// A random number generator that uses the ISAAC algorithm[1].
+///
+/// The ISAAC algorithm is generally accepted as suitable for
+/// cryptographic purposes, but this implementation has not be
+/// verified as such. Prefer a generator like `OsRng` that defers to
+/// the operating system for cases that need high security.
+///
+/// [1]: Bob Jenkins, [*ISAAC: A fast cryptographic random number
+/// generator*](http://www.burtleburtle.net/bob/rand/isaacafa.html)
+#[derive(Copy)]
+pub struct IsaacRng {
+    cnt: u32,
+    rsl: [w32; RAND_SIZE_USIZE],
+    mem: [w32; RAND_SIZE_USIZE],
+    a: w32,
+    b: w32,
+    c: w32,
+}
+
+static EMPTY: IsaacRng = IsaacRng {
+    cnt: 0,
+    rsl: [w(0); RAND_SIZE_USIZE],
+    mem: [w(0); RAND_SIZE_USIZE],
+    a: w(0), b: w(0), c: w(0),
+};
+
+impl IsaacRng {
+
+    /// Create an ISAAC random number generator using the default
+    /// fixed seed.
+    pub fn new_unseeded() -> IsaacRng {
+        let mut rng = EMPTY;
+        rng.init(false);
+        rng
+    }
+
+    /// Initialises `self`. If `use_rsl` is true, then use the current value
+    /// of `rsl` as a seed, otherwise construct one algorithmically (not
+    /// randomly).
+    fn init(&mut self, use_rsl: bool) {
+        let mut a = w(0x9e3779b9);
+        let mut b = a;
+        let mut c = a;
+        let mut d = a;
+        let mut e = a;
+        let mut f = a;
+        let mut g = a;
+        let mut h = a;
+
+        macro_rules! mix {
+            () => {{
+                a=a^(b<<11); d=d+a; b=b+c;
+                b=b^(c>>2);  e=e+b; c=c+d;
+                c=c^(d<<8);  f=f+c; d=d+e;
+                d=d^(e>>16); g=g+d; e=e+f;
+                e=e^(f<<10); h=h+e; f=f+g;
+                f=f^(g>>4);  a=a+f; g=g+h;
+                g=g^(h<<8);  b=b+g; h=h+a;
+                h=h^(a>>9);  c=c+h; a=a+b;
+            }}
+        }
+
+        for _ in 0..4 {
+            mix!();
+        }
+
+        if use_rsl {
+            macro_rules! memloop {
+                ($arr:expr) => {{
+                    for i in (0..RAND_SIZE_USIZE/8).map(|i| i * 8) {
+                        a=a+$arr[i  ]; b=b+$arr[i+1];
+                        c=c+$arr[i+2]; d=d+$arr[i+3];
+                        e=e+$arr[i+4]; f=f+$arr[i+5];
+                        g=g+$arr[i+6]; h=h+$arr[i+7];
+                        mix!();
+                        self.mem[i  ]=a; self.mem[i+1]=b;
+                        self.mem[i+2]=c; self.mem[i+3]=d;
+                        self.mem[i+4]=e; self.mem[i+5]=f;
+                        self.mem[i+6]=g; self.mem[i+7]=h;
+                    }
+                }}
+            }
+
+            memloop!(self.rsl);
+            memloop!(self.mem);
+        } else {
+            for i in (0..RAND_SIZE_USIZE/8).map(|i| i * 8) {
+                mix!();
+                self.mem[i  ]=a; self.mem[i+1]=b;
+                self.mem[i+2]=c; self.mem[i+3]=d;
+                self.mem[i+4]=e; self.mem[i+5]=f;
+                self.mem[i+6]=g; self.mem[i+7]=h;
+            }
+        }
+
+        self.isaac();
+    }
+
+    /// Refills the output buffer (`self.rsl`)
+    #[inline]
+    fn isaac(&mut self) {
+        self.c = self.c + w(1);
+        // abbreviations
+        let mut a = self.a;
+        let mut b = self.b + self.c;
+
+        const MIDPOINT: usize = RAND_SIZE_USIZE / 2;
+
+        macro_rules! ind {
+            ($x:expr) => ( self.mem[($x >> 2usize).0 as usize & (RAND_SIZE_USIZE - 1)] )
+        }
+
+        let r = [(0, MIDPOINT), (MIDPOINT, 0)];
+        for &(mr_offset, m2_offset) in r.iter() {
+
+            macro_rules! rngstepp {
+                ($j:expr, $shift:expr) => {{
+                    let base = $j;
+                    let mix = a << $shift;
+
+                    let x = self.mem[base  + mr_offset];
+                    a = (a ^ mix) + self.mem[base + m2_offset];
+                    let y = ind!(x) + a + b;
+                    self.mem[base + mr_offset] = y;
+
+                    b = ind!(y >> RAND_SIZE_LEN) + x;
+                    self.rsl[base + mr_offset] = b;
+                }}
+            }
+
+            macro_rules! rngstepn {
+                ($j:expr, $shift:expr) => {{
+                    let base = $j;
+                    let mix = a >> $shift;
+
+                    let x = self.mem[base  + mr_offset];
+                    a = (a ^ mix) + self.mem[base + m2_offset];
+                    let y = ind!(x) + a + b;
+                    self.mem[base + mr_offset] = y;
+
+                    b = ind!(y >> RAND_SIZE_LEN) + x;
+                    self.rsl[base + mr_offset] = b;
+                }}
+            }
+
+            for i in (0..MIDPOINT/4).map(|i| i * 4) {
+                rngstepp!(i + 0, 13);
+                rngstepn!(i + 1, 6);
+                rngstepp!(i + 2, 2);
+                rngstepn!(i + 3, 16);
+            }
+        }
+
+        self.a = a;
+        self.b = b;
+        self.cnt = RAND_SIZE;
+    }
+}
+
+// Cannot be derived because [u32; 256] does not implement Clone
+impl Clone for IsaacRng {
+    fn clone(&self) -> IsaacRng {
+        *self
+    }
+}
+
+impl Rng for IsaacRng {
+    #[inline]
+    fn next_u32(&mut self) -> u32 {
+        if self.cnt == 0 {
+            // make some more numbers
+            self.isaac();
+        }
+        self.cnt -= 1;
+
+        // self.cnt is at most RAND_SIZE, but that is before the
+        // subtraction above. We want to index without bounds
+        // checking, but this could lead to incorrect code if someone
+        // misrefactors, so we check, sometimes.
+        //
+        // (Changes here should be reflected in Isaac64Rng.next_u64.)
+        debug_assert!(self.cnt < RAND_SIZE);
+
+        // (the % is cheaply telling the optimiser that we're always
+        // in bounds, without unsafe. NB. this is a power of two, so
+        // it optimises to a bitwise mask).
+        self.rsl[(self.cnt % RAND_SIZE) as usize].0
+    }
+}
+
+impl<'a> SeedableRng<&'a [u32]> for IsaacRng {
+    fn reseed(&mut self, seed: &'a [u32]) {
+        // make the seed into [seed[0], seed[1], ..., seed[seed.len()
+        // - 1], 0, 0, ...], to fill rng.rsl.
+        let seed_iter = seed.iter().map(|&x| x).chain(repeat(0u32));
+
+        for (rsl_elem, seed_elem) in self.rsl.iter_mut().zip(seed_iter) {
+            *rsl_elem = w(seed_elem);
+        }
+        self.cnt = 0;
+        self.a = w(0);
+        self.b = w(0);
+        self.c = w(0);
+
+        self.init(true);
+    }
+
+    /// Create an ISAAC random number generator with a seed. This can
+    /// be any length, although the maximum number of elements used is
+    /// 256 and any more will be silently ignored. A generator
+    /// constructed with a given seed will generate the same sequence
+    /// of values as all other generators constructed with that seed.
+    fn from_seed(seed: &'a [u32]) -> IsaacRng {
+        let mut rng = EMPTY;
+        rng.reseed(seed);
+        rng
+    }
+}
+
+impl Rand for IsaacRng {
+    fn rand<R: Rng>(other: &mut R) -> IsaacRng {
+        let mut ret = EMPTY;
+        unsafe {
+            let ptr = ret.rsl.as_mut_ptr() as *mut u8;
+
+            let slice = slice::from_raw_parts_mut(ptr, RAND_SIZE_USIZE * 4);
+            other.fill_bytes(slice);
+        }
+        ret.cnt = 0;
+        ret.a = w(0);
+        ret.b = w(0);
+        ret.c = w(0);
+
+        ret.init(true);
+        return ret;
+    }
+}
+
+impl fmt::Debug for IsaacRng {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "IsaacRng {{}}")
+    }
+}
+
+#[cfg(test)]
+mod test {
+    use {Rng, SeedableRng};
+    use super::IsaacRng;
+
+    #[test]
+    fn test_rng_32_rand_seeded() {
+        let s = ::test::rng().gen_iter::<u32>().take(256).collect::<Vec<u32>>();
+        let mut ra: IsaacRng = SeedableRng::from_seed(&s[..]);
+        let mut rb: IsaacRng = SeedableRng::from_seed(&s[..]);
+        assert!(::test::iter_eq(ra.gen_ascii_chars().take(100),
+                                rb.gen_ascii_chars().take(100)));
+    }
+
+    #[test]
+    fn test_rng_32_seeded() {
+        let seed: &[_] = &[1, 23, 456, 7890, 12345];
+        let mut ra: IsaacRng = SeedableRng::from_seed(seed);
+        let mut rb: IsaacRng = SeedableRng::from_seed(seed);
+        assert!(::test::iter_eq(ra.gen_ascii_chars().take(100),
+                                rb.gen_ascii_chars().take(100)));
+    }
+
+    #[test]
+    fn test_rng_32_reseed() {
+        let s = ::test::rng().gen_iter::<u32>().take(256).collect::<Vec<u32>>();
+        let mut r: IsaacRng = SeedableRng::from_seed(&s[..]);
+        let string1: String = r.gen_ascii_chars().take(100).collect();
+
+        r.reseed(&s[..]);
+
+        let string2: String = r.gen_ascii_chars().take(100).collect();
+        assert_eq!(string1, string2);
+    }
+
+    #[test]
+    fn test_rng_32_true_values() {
+        let seed: &[_] = &[1, 23, 456, 7890, 12345];
+        let mut ra: IsaacRng = SeedableRng::from_seed(seed);
+        // Regression test that isaac is actually using the above vector
+        let v = (0..10).map(|_| ra.next_u32()).collect::<Vec<_>>();
+        assert_eq!(v,
+                   vec!(2558573138, 873787463, 263499565, 2103644246, 3595684709,
+                        4203127393, 264982119, 2765226902, 2737944514, 3900253796));
+
+        let seed: &[_] = &[12345, 67890, 54321, 9876];
+        let mut rb: IsaacRng = SeedableRng::from_seed(seed);
+        // skip forward to the 10000th number
+        for _ in 0..10000 { rb.next_u32(); }
+
+        let v = (0..10).map(|_| rb.next_u32()).collect::<Vec<_>>();
+        assert_eq!(v,
+                   vec!(3676831399, 3183332890, 2834741178, 3854698763, 2717568474,
+                        1576568959, 3507990155, 179069555, 141456972, 2478885421));
+    }
+}
diff --git a/rustc_deps/vendor/rand-0.4.2/src/prng/isaac64.rs b/rustc_deps/vendor/rand-0.4.2/src/prng/isaac64.rs
new file mode 100644
index 0000000..b98e3fe
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/src/prng/isaac64.rs
@@ -0,0 +1,340 @@
+// Copyright 2013 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.
+
+//! The ISAAC-64 random number generator.
+
+use core::slice;
+use core::iter::repeat;
+use core::num::Wrapping as w;
+use core::fmt;
+
+use {Rng, SeedableRng, Rand};
+
+#[allow(bad_style)]
+type w64 = w<u64>;
+
+const RAND_SIZE_64_LEN: usize = 8;
+const RAND_SIZE_64: usize = 1 << RAND_SIZE_64_LEN;
+
+/// A random number generator that uses ISAAC-64[1], the 64-bit
+/// variant of the ISAAC algorithm.
+///
+/// The ISAAC algorithm is generally accepted as suitable for
+/// cryptographic purposes, but this implementation has not be
+/// verified as such. Prefer a generator like `OsRng` that defers to
+/// the operating system for cases that need high security.
+///
+/// [1]: Bob Jenkins, [*ISAAC: A fast cryptographic random number
+/// generator*](http://www.burtleburtle.net/bob/rand/isaacafa.html)
+#[derive(Copy)]
+pub struct Isaac64Rng {
+    cnt: usize,
+    rsl: [w64; RAND_SIZE_64],
+    mem: [w64; RAND_SIZE_64],
+    a: w64,
+    b: w64,
+    c: w64,
+}
+
+static EMPTY_64: Isaac64Rng = Isaac64Rng {
+    cnt: 0,
+    rsl: [w(0); RAND_SIZE_64],
+    mem: [w(0); RAND_SIZE_64],
+    a: w(0), b: w(0), c: w(0),
+};
+
+impl Isaac64Rng {
+    /// Create a 64-bit ISAAC random number generator using the
+    /// default fixed seed.
+    pub fn new_unseeded() -> Isaac64Rng {
+        let mut rng = EMPTY_64;
+        rng.init(false);
+        rng
+    }
+
+    /// Initialises `self`. If `use_rsl` is true, then use the current value
+    /// of `rsl` as a seed, otherwise construct one algorithmically (not
+    /// randomly).
+    fn init(&mut self, use_rsl: bool) {
+        macro_rules! init {
+            ($var:ident) => (
+                let mut $var = w(0x9e3779b97f4a7c13);
+            )
+        }
+        init!(a); init!(b); init!(c); init!(d);
+        init!(e); init!(f); init!(g); init!(h);
+
+        macro_rules! mix {
+            () => {{
+                a=a-e; f=f^(h>>9);  h=h+a;
+                b=b-f; g=g^(a<<9);  a=a+b;
+                c=c-g; h=h^(b>>23); b=b+c;
+                d=d-h; a=a^(c<<15); c=c+d;
+                e=e-a; b=b^(d>>14); d=d+e;
+                f=f-b; c=c^(e<<20); e=e+f;
+                g=g-c; d=d^(f>>17); f=f+g;
+                h=h-d; e=e^(g<<14); g=g+h;
+            }}
+        }
+
+        for _ in 0..4 {
+            mix!();
+        }
+
+        if use_rsl {
+            macro_rules! memloop {
+                ($arr:expr) => {{
+                    for i in (0..RAND_SIZE_64 / 8).map(|i| i * 8) {
+                        a=a+$arr[i  ]; b=b+$arr[i+1];
+                        c=c+$arr[i+2]; d=d+$arr[i+3];
+                        e=e+$arr[i+4]; f=f+$arr[i+5];
+                        g=g+$arr[i+6]; h=h+$arr[i+7];
+                        mix!();
+                        self.mem[i  ]=a; self.mem[i+1]=b;
+                        self.mem[i+2]=c; self.mem[i+3]=d;
+                        self.mem[i+4]=e; self.mem[i+5]=f;
+                        self.mem[i+6]=g; self.mem[i+7]=h;
+                    }
+                }}
+            }
+
+            memloop!(self.rsl);
+            memloop!(self.mem);
+        } else {
+            for i in (0..RAND_SIZE_64 / 8).map(|i| i * 8) {
+                mix!();
+                self.mem[i  ]=a; self.mem[i+1]=b;
+                self.mem[i+2]=c; self.mem[i+3]=d;
+                self.mem[i+4]=e; self.mem[i+5]=f;
+                self.mem[i+6]=g; self.mem[i+7]=h;
+            }
+        }
+
+        self.isaac64();
+    }
+
+    /// Refills the output buffer (`self.rsl`)
+    fn isaac64(&mut self) {
+        self.c = self.c + w(1);
+        // abbreviations
+        let mut a = self.a;
+        let mut b = self.b + self.c;
+        const MIDPOINT: usize =  RAND_SIZE_64 / 2;
+        const MP_VEC: [(usize, usize); 2] = [(0,MIDPOINT), (MIDPOINT, 0)];
+        macro_rules! ind {
+            ($x:expr) => {
+                *self.mem.get_unchecked((($x >> 3usize).0 as usize) & (RAND_SIZE_64 - 1))
+            }
+        }
+
+        for &(mr_offset, m2_offset) in MP_VEC.iter() {
+            for base in (0..MIDPOINT / 4).map(|i| i * 4) {
+
+                macro_rules! rngstepp {
+                    ($j:expr, $shift:expr) => {{
+                        let base = base + $j;
+                        let mix = a ^ (a << $shift);
+                        let mix = if $j == 0 {!mix} else {mix};
+
+                        unsafe {
+                            let x = *self.mem.get_unchecked(base + mr_offset);
+                            a = mix + *self.mem.get_unchecked(base + m2_offset);
+                            let y = ind!(x) + a + b;
+                            *self.mem.get_unchecked_mut(base + mr_offset) = y;
+
+                            b = ind!(y >> RAND_SIZE_64_LEN) + x;
+                            *self.rsl.get_unchecked_mut(base + mr_offset) = b;
+                        }
+                    }}
+                }
+
+                macro_rules! rngstepn {
+                    ($j:expr, $shift:expr) => {{
+                        let base = base + $j;
+                        let mix = a ^ (a >> $shift);
+                        let mix = if $j == 0 {!mix} else {mix};
+
+                        unsafe {
+                            let x = *self.mem.get_unchecked(base + mr_offset);
+                            a = mix + *self.mem.get_unchecked(base + m2_offset);
+                            let y = ind!(x) + a + b;
+                            *self.mem.get_unchecked_mut(base + mr_offset) = y;
+
+                            b = ind!(y >> RAND_SIZE_64_LEN) + x;
+                            *self.rsl.get_unchecked_mut(base + mr_offset) = b;
+                        }
+                    }}
+                }
+
+                rngstepp!(0, 21);
+                rngstepn!(1, 5);
+                rngstepp!(2, 12);
+                rngstepn!(3, 33);
+            }
+        }
+
+        self.a = a;
+        self.b = b;
+        self.cnt = RAND_SIZE_64;
+    }
+}
+
+// Cannot be derived because [u32; 256] does not implement Clone
+impl Clone for Isaac64Rng {
+    fn clone(&self) -> Isaac64Rng {
+        *self
+    }
+}
+
+impl Rng for Isaac64Rng {
+    #[inline]
+    fn next_u32(&mut self) -> u32 {
+        self.next_u64() as u32
+    }
+
+    #[inline]
+    fn next_u64(&mut self) -> u64 {
+        if self.cnt == 0 {
+            // make some more numbers
+            self.isaac64();
+        }
+        self.cnt -= 1;
+
+        // See corresponding location in IsaacRng.next_u32 for
+        // explanation.
+        debug_assert!(self.cnt < RAND_SIZE_64);
+        self.rsl[(self.cnt % RAND_SIZE_64) as usize].0
+    }
+}
+
+impl<'a> SeedableRng<&'a [u64]> for Isaac64Rng {
+    fn reseed(&mut self, seed: &'a [u64]) {
+        // make the seed into [seed[0], seed[1], ..., seed[seed.len()
+        // - 1], 0, 0, ...], to fill rng.rsl.
+        let seed_iter = seed.iter().map(|&x| x).chain(repeat(0u64));
+
+        for (rsl_elem, seed_elem) in self.rsl.iter_mut().zip(seed_iter) {
+            *rsl_elem = w(seed_elem);
+        }
+        self.cnt = 0;
+        self.a = w(0);
+        self.b = w(0);
+        self.c = w(0);
+
+        self.init(true);
+    }
+
+    /// Create an ISAAC random number generator with a seed. This can
+    /// be any length, although the maximum number of elements used is
+    /// 256 and any more will be silently ignored. A generator
+    /// constructed with a given seed will generate the same sequence
+    /// of values as all other generators constructed with that seed.
+    fn from_seed(seed: &'a [u64]) -> Isaac64Rng {
+        let mut rng = EMPTY_64;
+        rng.reseed(seed);
+        rng
+    }
+}
+
+impl Rand for Isaac64Rng {
+    fn rand<R: Rng>(other: &mut R) -> Isaac64Rng {
+        let mut ret = EMPTY_64;
+        unsafe {
+            let ptr = ret.rsl.as_mut_ptr() as *mut u8;
+
+            let slice = slice::from_raw_parts_mut(ptr, RAND_SIZE_64 * 8);
+            other.fill_bytes(slice);
+        }
+        ret.cnt = 0;
+        ret.a = w(0);
+        ret.b = w(0);
+        ret.c = w(0);
+
+        ret.init(true);
+        return ret;
+    }
+}
+
+impl fmt::Debug for Isaac64Rng {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "Isaac64Rng {{}}")
+    }
+}
+
+#[cfg(test)]
+mod test {
+    use {Rng, SeedableRng};
+    use super::Isaac64Rng;
+
+    #[test]
+    fn test_rng_64_rand_seeded() {
+        let s = ::test::rng().gen_iter::<u64>().take(256).collect::<Vec<u64>>();
+        let mut ra: Isaac64Rng = SeedableRng::from_seed(&s[..]);
+        let mut rb: Isaac64Rng = SeedableRng::from_seed(&s[..]);
+        assert!(::test::iter_eq(ra.gen_ascii_chars().take(100),
+                                rb.gen_ascii_chars().take(100)));
+    }
+
+    #[test]
+    fn test_rng_64_seeded() {
+        let seed: &[_] = &[1, 23, 456, 7890, 12345];
+        let mut ra: Isaac64Rng = SeedableRng::from_seed(seed);
+        let mut rb: Isaac64Rng = SeedableRng::from_seed(seed);
+        assert!(::test::iter_eq(ra.gen_ascii_chars().take(100),
+                                rb.gen_ascii_chars().take(100)));
+    }
+
+    #[test]
+    fn test_rng_64_reseed() {
+        let s = ::test::rng().gen_iter::<u64>().take(256).collect::<Vec<u64>>();
+        let mut r: Isaac64Rng = SeedableRng::from_seed(&s[..]);
+        let string1: String = r.gen_ascii_chars().take(100).collect();
+
+        r.reseed(&s[..]);
+
+        let string2: String = r.gen_ascii_chars().take(100).collect();
+        assert_eq!(string1, string2);
+    }
+
+    #[test]
+    fn test_rng_64_true_values() {
+        let seed: &[_] = &[1, 23, 456, 7890, 12345];
+        let mut ra: Isaac64Rng = SeedableRng::from_seed(seed);
+        // Regression test that isaac is actually using the above vector
+        let v = (0..10).map(|_| ra.next_u64()).collect::<Vec<_>>();
+        assert_eq!(v,
+                   vec!(547121783600835980, 14377643087320773276, 17351601304698403469,
+                        1238879483818134882, 11952566807690396487, 13970131091560099343,
+                        4469761996653280935, 15552757044682284409, 6860251611068737823,
+                        13722198873481261842));
+
+        let seed: &[_] = &[12345, 67890, 54321, 9876];
+        let mut rb: Isaac64Rng = SeedableRng::from_seed(seed);
+        // skip forward to the 10000th number
+        for _ in 0..10000 { rb.next_u64(); }
+
+        let v = (0..10).map(|_| rb.next_u64()).collect::<Vec<_>>();
+        assert_eq!(v,
+                   vec!(18143823860592706164, 8491801882678285927, 2699425367717515619,
+                        17196852593171130876, 2606123525235546165, 15790932315217671084,
+                        596345674630742204, 9947027391921273664, 11788097613744130851,
+                        10391409374914919106));
+    }
+
+    #[test]
+    fn test_rng_clone() {
+        let seed: &[_] = &[1, 23, 456, 7890, 12345];
+        let mut rng: Isaac64Rng = SeedableRng::from_seed(seed);
+        let mut clone = rng.clone();
+        for _ in 0..16 {
+            assert_eq!(rng.next_u64(), clone.next_u64());
+        }
+    }
+}
diff --git a/rustc_deps/vendor/rand-0.4.2/src/prng/mod.rs b/rustc_deps/vendor/rand-0.4.2/src/prng/mod.rs
new file mode 100644
index 0000000..ed3e018
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/src/prng/mod.rs
@@ -0,0 +1,51 @@
+// Copyright 2017 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.
+
+//! Pseudo random number generators are algorithms to produce *apparently
+//! random* numbers deterministically, and usually fairly quickly.
+//! 
+//! So long as the algorithm is computationally secure, is initialised with
+//! sufficient entropy (i.e. unknown by an attacker), and its internal state is
+//! also protected (unknown to an attacker), the output will also be
+//! *computationally secure*. Computationally Secure Pseudo Random Number
+//! Generators (CSPRNGs) are thus suitable sources of random numbers for
+//! cryptography. There are a couple of gotchas here, however. First, the seed
+//! used for initialisation must be unknown. Usually this should be provided by
+//! the operating system and should usually be secure, however this may not
+//! always be the case (especially soon after startup). Second, user-space
+//! memory may be vulnerable, for example when written to swap space, and after
+//! forking a child process should reinitialise any user-space PRNGs. For this
+//! reason it may be preferable to source random numbers directly from the OS
+//! for cryptographic applications.
+//! 
+//! PRNGs are also widely used for non-cryptographic uses: randomised
+//! algorithms, simulations, games. In these applications it is usually not
+//! important for numbers to be cryptographically *unguessable*, but even
+//! distribution and independence from other samples (from the point of view
+//! of someone unaware of the algorithm used, at least) may still be important.
+//! Good PRNGs should satisfy these properties, but do not take them for
+//! granted; Wikipedia's article on 
+//! [Pseudorandom number generators](https://en.wikipedia.org/wiki/Pseudorandom_number_generator)
+//! provides some background on this topic.
+//! 
+//! Care should be taken when seeding (initialising) PRNGs. Some PRNGs have
+//! short periods for some seeds. If one PRNG is seeded from another using the
+//! same algorithm, it is possible that both will yield the same sequence of
+//! values (with some lag).
+
+mod chacha;
+mod isaac;
+mod isaac64;
+mod xorshift;
+
+pub use self::chacha::ChaChaRng;
+pub use self::isaac::IsaacRng;
+pub use self::isaac64::Isaac64Rng;
+pub use self::xorshift::XorShiftRng;
diff --git a/rustc_deps/vendor/rand-0.4.2/src/prng/xorshift.rs b/rustc_deps/vendor/rand-0.4.2/src/prng/xorshift.rs
new file mode 100644
index 0000000..dd367e9
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/src/prng/xorshift.rs
@@ -0,0 +1,101 @@
+// Copyright 2017 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.
+
+//! Xorshift generators
+
+use core::num::Wrapping as w;
+use {Rng, SeedableRng, Rand};
+
+/// An Xorshift[1] random number
+/// generator.
+///
+/// The Xorshift algorithm is not suitable for cryptographic purposes
+/// but is very fast. If you do not know for sure that it fits your
+/// requirements, use a more secure one such as `IsaacRng` or `OsRng`.
+///
+/// [1]: Marsaglia, George (July 2003). ["Xorshift
+/// RNGs"](http://www.jstatsoft.org/v08/i14/paper). *Journal of
+/// Statistical Software*. Vol. 8 (Issue 14).
+#[allow(missing_copy_implementations)]
+#[derive(Clone, Debug)]
+pub struct XorShiftRng {
+    x: w<u32>,
+    y: w<u32>,
+    z: w<u32>,
+    w: w<u32>,
+}
+
+impl XorShiftRng {
+    /// Creates a new XorShiftRng instance which is not seeded.
+    ///
+    /// The initial values of this RNG are constants, so all generators created
+    /// by this function will yield the same stream of random numbers. It is
+    /// highly recommended that this is created through `SeedableRng` instead of
+    /// this function
+    pub fn new_unseeded() -> XorShiftRng {
+        XorShiftRng {
+            x: w(0x193a6754),
+            y: w(0xa8a7d469),
+            z: w(0x97830e05),
+            w: w(0x113ba7bb),
+        }
+    }
+}
+
+impl Rng for XorShiftRng {
+    #[inline]
+    fn next_u32(&mut self) -> u32 {
+        let x = self.x;
+        let t = x ^ (x << 11);
+        self.x = self.y;
+        self.y = self.z;
+        self.z = self.w;
+        let w_ = self.w;
+        self.w = w_ ^ (w_ >> 19) ^ (t ^ (t >> 8));
+        self.w.0
+    }
+}
+
+impl SeedableRng<[u32; 4]> for XorShiftRng {
+    /// Reseed an XorShiftRng. This will panic if `seed` is entirely 0.
+    fn reseed(&mut self, seed: [u32; 4]) {
+        assert!(!seed.iter().all(|&x| x == 0),
+                "XorShiftRng.reseed called with an all zero seed.");
+
+        self.x = w(seed[0]);
+        self.y = w(seed[1]);
+        self.z = w(seed[2]);
+        self.w = w(seed[3]);
+    }
+
+    /// Create a new XorShiftRng. This will panic if `seed` is entirely 0.
+    fn from_seed(seed: [u32; 4]) -> XorShiftRng {
+        assert!(!seed.iter().all(|&x| x == 0),
+                "XorShiftRng::from_seed called with an all zero seed.");
+
+        XorShiftRng {
+            x: w(seed[0]),
+            y: w(seed[1]),
+            z: w(seed[2]),
+            w: w(seed[3]),
+        }
+    }
+}
+
+impl Rand for XorShiftRng {
+    fn rand<R: Rng>(rng: &mut R) -> XorShiftRng {
+        let mut tuple: (u32, u32, u32, u32) = rng.gen();
+        while tuple == (0, 0, 0, 0) {
+            tuple = rng.gen();
+        }
+        let (x, y, z, w_) = tuple;
+        XorShiftRng { x: w(x), y: w(y), z: w(z), w: w(w_) }
+    }
+}
diff --git a/rustc_deps/vendor/rand/src/rand_impls.rs b/rustc_deps/vendor/rand-0.4.2/src/rand_impls.rs
similarity index 100%
rename from rustc_deps/vendor/rand/src/rand_impls.rs
rename to rustc_deps/vendor/rand-0.4.2/src/rand_impls.rs
diff --git a/rustc_deps/vendor/rand/src/read.rs b/rustc_deps/vendor/rand-0.4.2/src/read.rs
similarity index 100%
rename from rustc_deps/vendor/rand/src/read.rs
rename to rustc_deps/vendor/rand-0.4.2/src/read.rs
diff --git a/rustc_deps/vendor/rand/src/reseeding.rs b/rustc_deps/vendor/rand-0.4.2/src/reseeding.rs
similarity index 100%
rename from rustc_deps/vendor/rand/src/reseeding.rs
rename to rustc_deps/vendor/rand-0.4.2/src/reseeding.rs
diff --git a/rustc_deps/vendor/rand-0.4.2/src/seq.rs b/rustc_deps/vendor/rand-0.4.2/src/seq.rs
new file mode 100644
index 0000000..a7889fe
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/src/seq.rs
@@ -0,0 +1,337 @@
+// Copyright 2017 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.
+
+//! Functions for randomly accessing and sampling sequences.
+
+use super::Rng;
+
+// This crate is only enabled when either std or alloc is available.
+// BTreeMap is not as fast in tests, but better than nothing.
+#[cfg(feature="std")] use std::collections::HashMap;
+#[cfg(not(feature="std"))] use alloc::btree_map::BTreeMap;
+
+#[cfg(not(feature="std"))] use alloc::Vec;
+
+/// Randomly sample `amount` elements from a finite iterator.
+///
+/// The following can be returned:
+/// - `Ok`: `Vec` of `amount` non-repeating randomly sampled elements. The order is not random.
+/// - `Err`: `Vec` of all the elements from `iterable` in sequential order. This happens when the
+///   length of `iterable` was less than `amount`. This is considered an error since exactly
+///   `amount` elements is typically expected.
+///
+/// This implementation uses `O(len(iterable))` time and `O(amount)` memory.
+///
+/// # Example
+///
+/// ```rust
+/// use rand::{thread_rng, seq};
+///
+/// let mut rng = thread_rng();
+/// let sample = seq::sample_iter(&mut rng, 1..100, 5).unwrap();
+/// println!("{:?}", sample);
+/// ```
+pub fn sample_iter<T, I, R>(rng: &mut R, iterable: I, amount: usize) -> Result<Vec<T>, Vec<T>>
+    where I: IntoIterator<Item=T>,
+          R: Rng,
+{
+    let mut iter = iterable.into_iter();
+    let mut reservoir = Vec::with_capacity(amount);
+    reservoir.extend(iter.by_ref().take(amount));
+
+    // Continue unless the iterator was exhausted
+    //
+    // note: this prevents iterators that "restart" from causing problems.
+    // If the iterator stops once, then so do we.
+    if reservoir.len() == amount {
+        for (i, elem) in iter.enumerate() {
+            let k = rng.gen_range(0, i + 1 + amount);
+            if let Some(spot) = reservoir.get_mut(k) {
+                *spot = elem;
+            }
+        }
+        Ok(reservoir)
+    } else {
+        // Don't hang onto extra memory. There is a corner case where
+        // `amount` was much less than `len(iterable)`.
+        reservoir.shrink_to_fit();
+        Err(reservoir)
+    }
+}
+
+/// Randomly sample exactly `amount` values from `slice`.
+///
+/// The values are non-repeating and in random order.
+///
+/// This implementation uses `O(amount)` time and memory.
+///
+/// Panics if `amount > slice.len()`
+///
+/// # Example
+///
+/// ```rust
+/// use rand::{thread_rng, seq};
+///
+/// let mut rng = thread_rng();
+/// let values = vec![5, 6, 1, 3, 4, 6, 7];
+/// println!("{:?}", seq::sample_slice(&mut rng, &values, 3));
+/// ```
+pub fn sample_slice<R, T>(rng: &mut R, slice: &[T], amount: usize) -> Vec<T>
+    where R: Rng,
+          T: Clone
+{
+    let indices = sample_indices(rng, slice.len(), amount);
+
+    let mut out = Vec::with_capacity(amount);
+    out.extend(indices.iter().map(|i| slice[*i].clone()));
+    out
+}
+
+/// Randomly sample exactly `amount` references from `slice`.
+///
+/// The references are non-repeating and in random order.
+///
+/// This implementation uses `O(amount)` time and memory.
+///
+/// Panics if `amount > slice.len()`
+///
+/// # Example
+///
+/// ```rust
+/// use rand::{thread_rng, seq};
+///
+/// let mut rng = thread_rng();
+/// let values = vec![5, 6, 1, 3, 4, 6, 7];
+/// println!("{:?}", seq::sample_slice_ref(&mut rng, &values, 3));
+/// ```
+pub fn sample_slice_ref<'a, R, T>(rng: &mut R, slice: &'a [T], amount: usize) -> Vec<&'a T>
+    where R: Rng
+{
+    let indices = sample_indices(rng, slice.len(), amount);
+
+    let mut out = Vec::with_capacity(amount);
+    out.extend(indices.iter().map(|i| &slice[*i]));
+    out
+}
+
+/// Randomly sample exactly `amount` indices from `0..length`.
+///
+/// The values are non-repeating and in random order.
+///
+/// This implementation uses `O(amount)` time and memory.
+///
+/// This method is used internally by the slice sampling methods, but it can sometimes be useful to
+/// have the indices themselves so this is provided as an alternative.
+///
+/// Panics if `amount > length`
+pub fn sample_indices<R>(rng: &mut R, length: usize, amount: usize) -> Vec<usize>
+    where R: Rng,
+{
+    if amount > length {
+        panic!("`amount` must be less than or equal to `slice.len()`");
+    }
+
+    // We are going to have to allocate at least `amount` for the output no matter what. However,
+    // if we use the `cached` version we will have to allocate `amount` as a HashMap as well since
+    // it inserts an element for every loop.
+    //
+    // Therefore, if `amount >= length / 2` then inplace will be both faster and use less memory.
+    // In fact, benchmarks show the inplace version is faster for length up to about 20 times
+    // faster than amount.
+    //
+    // TODO: there is probably even more fine-tuning that can be done here since
+    // `HashMap::with_capacity(amount)` probably allocates more than `amount` in practice,
+    // and a trade off could probably be made between memory/cpu, since hashmap operations
+    // are slower than array index swapping.
+    if amount >= length / 20 {
+        sample_indices_inplace(rng, length, amount)
+    } else {
+        sample_indices_cache(rng, length, amount)
+    }
+}
+
+/// Sample an amount of indices using an inplace partial fisher yates method.
+///
+/// This allocates the entire `length` of indices and randomizes only the first `amount`.
+/// It then truncates to `amount` and returns.
+///
+/// This is better than using a HashMap "cache" when `amount >= length / 2` since it does not
+/// require allocating an extra cache and is much faster.
+fn sample_indices_inplace<R>(rng: &mut R, length: usize, amount: usize) -> Vec<usize>
+    where R: Rng,
+{
+    debug_assert!(amount <= length);
+    let mut indices: Vec<usize> = Vec::with_capacity(length);
+    indices.extend(0..length);
+    for i in 0..amount {
+        let j: usize = rng.gen_range(i, length);
+        let tmp = indices[i];
+        indices[i] = indices[j];
+        indices[j] = tmp;
+    }
+    indices.truncate(amount);
+    debug_assert_eq!(indices.len(), amount);
+    indices
+}
+
+
+/// This method performs a partial fisher-yates on a range of indices using a HashMap
+/// as a cache to record potential collisions.
+///
+/// The cache avoids allocating the entire `length` of values. This is especially useful when
+/// `amount <<< length`, i.e. select 3 non-repeating from 1_000_000
+fn sample_indices_cache<R>(
+    rng: &mut R,
+    length: usize,
+    amount: usize,
+) -> Vec<usize>
+    where R: Rng,
+{
+    debug_assert!(amount <= length);
+    #[cfg(feature="std")] let mut cache = HashMap::with_capacity(amount);
+    #[cfg(not(feature="std"))] let mut cache = BTreeMap::new();
+    let mut out = Vec::with_capacity(amount);
+    for i in 0..amount {
+        let j: usize = rng.gen_range(i, length);
+
+        // equiv: let tmp = slice[i];
+        let tmp = match cache.get(&i) {
+            Some(e) => *e,
+            None => i,
+        };
+
+        // equiv: slice[i] = slice[j];
+        let x = match cache.get(&j) {
+            Some(x) => *x,
+            None => j,
+        };
+
+        // equiv: slice[j] = tmp;
+        cache.insert(j, tmp);
+
+        // note that in the inplace version, slice[i] is automatically "returned" value
+        out.push(x);
+    }
+    debug_assert_eq!(out.len(), amount);
+    out
+}
+
+#[cfg(test)]
+mod test {
+    use super::*;
+    use {thread_rng, XorShiftRng, SeedableRng};
+
+    #[test]
+    fn test_sample_iter() {
+        let min_val = 1;
+        let max_val = 100;
+
+        let mut r = thread_rng();
+        let vals = (min_val..max_val).collect::<Vec<i32>>();
+        let small_sample = sample_iter(&mut r, vals.iter(), 5).unwrap();
+        let large_sample = sample_iter(&mut r, vals.iter(), vals.len() + 5).unwrap_err();
+
+        assert_eq!(small_sample.len(), 5);
+        assert_eq!(large_sample.len(), vals.len());
+        // no randomization happens when amount >= len
+        assert_eq!(large_sample, vals.iter().collect::<Vec<_>>());
+
+        assert!(small_sample.iter().all(|e| {
+            **e >= min_val && **e <= max_val
+        }));
+    }
+    #[test]
+    fn test_sample_slice_boundaries() {
+        let empty: &[u8] = &[];
+
+        let mut r = thread_rng();
+
+        // sample 0 items
+        assert_eq!(sample_slice(&mut r, empty, 0), vec![]);
+        assert_eq!(sample_slice(&mut r, &[42, 2, 42], 0), vec![]);
+
+        // sample 1 item
+        assert_eq!(sample_slice(&mut r, &[42], 1), vec![42]);
+        let v = sample_slice(&mut r, &[1, 42], 1)[0];
+        assert!(v == 1 || v == 42);
+
+        // sample "all" the items
+        let v = sample_slice(&mut r, &[42, 133], 2);
+        assert!(v == vec![42, 133] || v == vec![133, 42]);
+
+        assert_eq!(sample_indices_inplace(&mut r, 0, 0), vec![]);
+        assert_eq!(sample_indices_inplace(&mut r, 1, 0), vec![]);
+        assert_eq!(sample_indices_inplace(&mut r, 1, 1), vec![0]);
+
+        assert_eq!(sample_indices_cache(&mut r, 0, 0), vec![]);
+        assert_eq!(sample_indices_cache(&mut r, 1, 0), vec![]);
+        assert_eq!(sample_indices_cache(&mut r, 1, 1), vec![0]);
+
+        // Make sure lucky 777's aren't lucky
+        let slice = &[42, 777];
+        let mut num_42 = 0;
+        let total = 1000;
+        for _ in 0..total {
+            let v = sample_slice(&mut r, slice, 1);
+            assert_eq!(v.len(), 1);
+            let v = v[0];
+            assert!(v == 42 || v == 777);
+            if v == 42 {
+                num_42 += 1;
+            }
+        }
+        let ratio_42 = num_42 as f64 / 1000 as f64;
+        assert!(0.4 <= ratio_42 || ratio_42 <= 0.6, "{}", ratio_42);
+    }
+
+    #[test]
+    fn test_sample_slice() {
+        let xor_rng = XorShiftRng::from_seed;
+
+        let max_range = 100;
+        let mut r = thread_rng();
+
+        for length in 1usize..max_range {
+            let amount = r.gen_range(0, length);
+            let seed: [u32; 4] = [
+                r.next_u32(), r.next_u32(), r.next_u32(), r.next_u32()
+            ];
+
+            println!("Selecting indices: len={}, amount={}, seed={:?}", length, amount, seed);
+
+            // assert that the two index methods give exactly the same result
+            let inplace = sample_indices_inplace(
+                &mut xor_rng(seed), length, amount);
+            let cache = sample_indices_cache(
+                &mut xor_rng(seed), length, amount);
+            assert_eq!(inplace, cache);
+
+            // assert the basics work
+            let regular = sample_indices(
+                &mut xor_rng(seed), length, amount);
+            assert_eq!(regular.len(), amount);
+            assert!(regular.iter().all(|e| *e < length));
+            assert_eq!(regular, inplace);
+
+            // also test that sampling the slice works
+            let vec: Vec<usize> = (0..length).collect();
+            {
+                let result = sample_slice(&mut xor_rng(seed), &vec, amount);
+                assert_eq!(result, regular);
+            }
+
+            {
+                let result = sample_slice_ref(&mut xor_rng(seed), &vec, amount);
+                let expected = regular.iter().map(|v| v).collect::<Vec<_>>();
+                assert_eq!(result, expected);
+            }
+        }
+    }
+}
diff --git a/rustc_deps/vendor/rand-0.4.2/utils/ziggurat_tables.py b/rustc_deps/vendor/rand-0.4.2/utils/ziggurat_tables.py
new file mode 100755
index 0000000..762f956
--- /dev/null
+++ b/rustc_deps/vendor/rand-0.4.2/utils/ziggurat_tables.py
@@ -0,0 +1,127 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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.
+
+# This creates the tables used for distributions implemented using the
+# ziggurat algorithm in `rand::distributions;`. They are
+# (basically) the tables as used in the ZIGNOR variant (Doornik 2005).
+# They are changed rarely, so the generated file should be checked in
+# to git.
+#
+# It creates 3 tables: X as in the paper, F which is f(x_i), and
+# F_DIFF which is f(x_i) - f(x_{i-1}). The latter two are just cached
+# values which is not done in that paper (but is done in other
+# variants). Note that the adZigR table is unnecessary because of
+# algebra.
+#
+# It is designed to be compatible with Python 2 and 3.
+
+from math import exp, sqrt, log, floor
+import random
+
+# The order should match the return value of `tables`
+TABLE_NAMES = ['X', 'F']
+
+# The actual length of the table is 1 more, to stop
+# index-out-of-bounds errors. This should match the bitwise operation
+# to find `i` in `zigurrat` in `libstd/rand/mod.rs`. Also the *_R and
+# *_V constants below depend on this value.
+TABLE_LEN = 256
+
+# equivalent to `zigNorInit` in Doornik2005, but generalised to any
+# distribution. r = dR, v = dV, f = probability density function,
+# f_inv = inverse of f
+def tables(r, v, f, f_inv):
+    # compute the x_i
+    xvec = [0]*(TABLE_LEN+1)
+
+    xvec[0] = v / f(r)
+    xvec[1] = r
+
+    for i in range(2, TABLE_LEN):
+        last = xvec[i-1]
+        xvec[i] = f_inv(v / last + f(last))
+
+    # cache the f's
+    fvec = [0]*(TABLE_LEN+1)
+    for i in range(TABLE_LEN+1):
+        fvec[i] = f(xvec[i])
+
+    return xvec, fvec
+
+# Distributions
+# N(0, 1)
+def norm_f(x):
+    return exp(-x*x/2.0)
+def norm_f_inv(y):
+    return sqrt(-2.0*log(y))
+
+NORM_R = 3.6541528853610088
+NORM_V = 0.00492867323399
+
+NORM = tables(NORM_R, NORM_V,
+              norm_f, norm_f_inv)
+
+# Exp(1)
+def exp_f(x):
+    return exp(-x)
+def exp_f_inv(y):
+    return -log(y)
+
+EXP_R = 7.69711747013104972
+EXP_V = 0.0039496598225815571993
+
+EXP = tables(EXP_R, EXP_V,
+             exp_f, exp_f_inv)
+
+
+# Output the tables/constants/types
+
+def render_static(name, type, value):
+    # no space or
+    return 'pub static %s: %s =%s;\n' % (name, type, value)
+
+# static `name`: [`type`, .. `len(values)`] =
+#     [values[0], ..., values[3],
+#      values[4], ..., values[7],
+#      ... ];
+def render_table(name, values):
+    rows = []
+    # 4 values on each row
+    for i in range(0, len(values), 4):
+        row = values[i:i+4]
+        rows.append(', '.join('%.18f' % f for f in row))
+
+    rendered = '\n    [%s]' % ',\n     '.join(rows)
+    return render_static(name, '[f64, .. %d]' % len(values), rendered)
+
+
+with open('ziggurat_tables.rs', 'w') as f:
+    f.write('''// Copyright 2013 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.
+
+// Tables for distributions which are sampled using the ziggurat
+// algorithm. Autogenerated by `ziggurat_tables.py`.
+
+pub type ZigTable = &\'static [f64, .. %d];
+'''  % (TABLE_LEN + 1))
+    for name, tables, r in [('NORM', NORM, NORM_R),
+                            ('EXP', EXP, EXP_R)]:
+        f.write(render_static('ZIG_%s_R' % name, 'f64', ' %.18f' % r))
+        for (tabname, table) in zip(TABLE_NAMES, tables):
+            f.write(render_table('ZIG_%s_%s' % (name, tabname), table))
diff --git a/rustc_deps/vendor/rand/.cargo-checksum.json b/rustc_deps/vendor/rand/.cargo-checksum.json
index 9c1f055..5a1037a 100644
--- a/rustc_deps/vendor/rand/.cargo-checksum.json
+++ b/rustc_deps/vendor/rand/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{".travis.yml":"12868a81c3590d8f2c08d53ca51e6b4b9be39d854f81bd4a57f82466cbe8d79a","CHANGELOG.md":"03974fa236c7ac7a29931ef548d05ba1d8e00b1202961310f6d837aca9bc377a","Cargo.toml":"09b6978ce09c8df87e5fe605d1ff5ea920747da588523df8f2f5d1ca3292db80","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"f15d6584b8f417cc743ebcad6b69776874a6ac30807d0ce0ed28f3779be1f151","appveyor.yml":"8796156caf7041ef2a43f7a313df21ea639de3f2563b6181bba1096b1c489f1b","benches/bench.rs":"35c4ab609f2a5f5aab6c52c257415258dc0780621b492b5a82bb12d048cab6db","benches/distributions/exponential.rs":"99cb59c013a0b6bb390d34c5649b341fc3b88ea7df0caf2470bdda8798f9fe3d","benches/distributions/gamma.rs":"3533f311e4b55d743c5b01a7eb6529c94fd97726ef6702a6372f914f5f33666b","benches/distributions/mod.rs":"0028f1cb96f61152ed5b49a4fe91227d809ef6d19035592c36032a538af7f95e","benches/distributions/normal.rs":"4e10c18cb583ccb96301ea953c8e0aa9ee3b6662060271d1b8d19ca23364dc6b","benches/generators.rs":"aaa2f1dbfb399df8323d8a5796b92add6210cd5f0f1d916895ffdd81d60f812b","benches/misc.rs":"bd2f7c5a16f0fcb59022d5aeef66ed3c94e89ebf6c06667851dd23d0b1595504","src/distributions/exponential.rs":"103c8412c8a581b71835f1c00e40f6370e7702adf9d499243933a793d132d4e7","src/distributions/gamma.rs":"7a3f85c8daad4e56e334586ddb9fc9d83df3b0699738ed681a6c41e4ed455be9","src/distributions/mod.rs":"7943c4f83721bac816f831cca3b1574b6136932f7b4927aa6101130080ba62c5","src/distributions/normal.rs":"1562b43f80e4d5f83a8deb5af18de5a18dfeeeeda11fefc577da26672b14c949","src/distributions/range.rs":"a72a538d3ec4ed23f8d632aa55fd4793c464f24a5872d04ce8095ddd5db92115","src/distributions/ziggurat_tables.rs":"4eacf94fc352c91c455a6623de6a721e53842e1690f13a5662b6a79c7fbb73de","src/jitter.rs":"befd4b84bf753c107370b5b9498ad49611c220bdae2e4be9ee4398e9fa497042","src/lib.rs":"c86b28064c2c5abd02694e8bf97c84513b21fefe04e4305f9a78d5e864ef3e3f","src/os.rs":"38c2f26c2784c61ae9a17a7a9c59fcf449dada826a66f66b7f46b0992ef001de","src/prng/chacha.rs":"558007276f9c22933d39e5b8e853f4dd9533e823ed66df8dc1f23ad6925b1d51","src/prng/isaac.rs":"a8a2ee8b38d312663308e3bdf03376e342fd91330655f39144e5bba7392b2a8e","src/prng/isaac64.rs":"f28f7596ccab910db265b42671116abb9d2039fa8a421cbc75312bd0e7715d3a","src/prng/mod.rs":"c1a73450f49e819a20942a5b591f84a08ebb5ac33aa0f65b18ac1dc9a19a3084","src/prng/xorshift.rs":"606c308747293652c868b46dc3cad847d0c3717629c04ba75681c887c7634114","src/rand_impls.rs":"e1f27077fc13d5855bb66235f8ccfb216e116337eb38424d9c30c090e112215c","src/read.rs":"bd0eb508a6b659dc578d546fc2f231484aed80c73cfe8c475e0d65c8d699a769","src/reseeding.rs":"a97b86387b87ea1adc5262ddea480fe735c9c2a86762abaace29119022ac9f6e","src/seq.rs":"76dd58af0f580aed2721c393a5c036322186dc7cb3b4abed33436620c7c49288","utils/ziggurat_tables.py":"a9fc0a2fdae9b5c798c238788f94b720c156e13fd96f2356c409aa533191eb94"},"package":"eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5"}
\ No newline at end of file
+{"files":{".travis.yml":"92eca358a96aca08b5c75579a208f78b01672fcf74fb87040e52a0780e66ce21","CHANGELOG.md":"77575727dec69456b3a9788193c8d583f87b8b6735933b177dff766a47abd8d6","CONTRIBUTING.md":"ce1d116f2991f195479a217ecad883e65812d739476ce313adbbed16425e9730","Cargo.toml":"7c55ef13822709e0059ce4145523a07b0879bf1011834c673a978fa6447bbbdf","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"2a9b60793f4b06217710ba574fb266850f64d265359c00d06ab05e0e3f4b7bb3","UPDATING.md":"995b503e4e25662c63df1710ca557e9688e1095644a4de80c6d19a2aa4281f2d","appveyor.yml":"e72b9bf8fa81ec7bc8939da12f51df6de946b93246542cf1f538ff1119497de6","benches/distributions.rs":"041c5adb223ee3a42bf6d5841e123ed1ea24838463bf88c29a5cb5a5dcfb320b","benches/generators.rs":"ef5e38c2462f9fb6dfeb7892061123b668826404a4546463bf34a8a939b39d1b","benches/misc.rs":"674e06347bc95cdd14588fefa673dbbc52d043b8e93d2bd56ee2fc9ad030d570","examples/monte-carlo.rs":"5b52e0dff8b2c29b2037c1f93f703e1c203d05b884640db99520137307fd9d6e","examples/monty-hall.rs":"d4873d567a606822dcb2be7e06517144f44d0d0ec39990751756b6265acaa88c","src/distributions/bernoulli.rs":"3a8dbab7dc97e6ad8d3225857dd6413e44a78d49ff870c25b1cd2c3bf7fdb6c3","src/distributions/binomial.rs":"38e46f348097920583707d86ec30522fb816355f216fd2a97fb427a5ed03c860","src/distributions/cauchy.rs":"a075e8e4d181bac25136a80f2af6cdc8b6d60c6d16df5b67a5181ea00ae3a34e","src/distributions/exponential.rs":"1702c7640d6027c49913d7e46b12c292646f9f4007ef74ba238c582de47014ee","src/distributions/float.rs":"0d0e79423d002a3187a7dec73e11e5acd9060590e71a3e39ca44375cafc687d4","src/distributions/gamma.rs":"8763faa2f6a244ea95d5af2b1e48ec8ddd1983eb4e170cf873c513fc8bc0746c","src/distributions/integer.rs":"a9c9edda09a457831c06e93ce94e7074af5bf97fd663a940b2f09ea21b1106a9","src/distributions/log_gamma.rs":"9f1fda43162c3f6184af15e9fabf3475de7e4e2e46412e7ae1480de1c7e5a68e","src/distributions/mod.rs":"3b7d190ce0d0c60fabac2902538116af27c5fa9291899287d281e2a16a8078bb","src/distributions/normal.rs":"987dc08c94e33f4f07e227d3b887d3cb522ddc6439bb93adcd0daf9b64097900","src/distributions/other.rs":"9962a738ed861d6c59e46272401290eca4237862127b3a143c7865616d9c1bed","src/distributions/pareto.rs":"ba207487d655295db7a566fec97ed636f0bcf4e50642138da553fd58e613cefe","src/distributions/poisson.rs":"3a44644936dea768ef83b45c9be86626356c67fc72f48f10d72111428ad77ddf","src/distributions/uniform.rs":"6cc7b9916e72a5807a9f7fdd90cb2944e9d175570758a507d6ce5779abda5a45","src/distributions/ziggurat_tables.rs":"4757d144fd1fc13fc0118e073f9ecf2a3cc94144a254a6633900705c3d9f7db3","src/lib.rs":"49648af51a5d2a457a98cf6a5c2cf8c54b5e09f6af4f56d34b648d4ab115b6c7","src/prelude.rs":"a2f76c76bc2c7822bb4ce67ba13b076305b434a542aaa5f07b67f66f65e3e8cc","src/prng/chacha.rs":"f8659eb5beceb19e582f81050584007f6893b537da60e697fa04b1302a1e161f","src/prng/hc128.rs":"0b44d4877159ee82109fcd4415635db6baf27db1381598b0f18cecb7841c975c","src/prng/isaac.rs":"687ba5356daa8a18c91f652756d8fdacbcd87a20464a1e98802388ce7a280073","src/prng/isaac64.rs":"e5f4d7b78e6492724647bbbf5c42fcb06fe4f4269dd5682c50cac36c10ce0829","src/prng/isaac_array.rs":"9371fcd04f29aa21b10a6bba76949853d8a80b72fbb5c61ba9b0d9db8d6bbb3c","src/prng/mod.rs":"1055528c5755d280ef9e420615e69dde35f8267c7cf20d178b75145a722ad462","src/prng/xorshift.rs":"dacb87577d3faafe5a5333c7e4eae6cab5a9f23eef68069a9b7195dfd74a2901","src/rngs/adapter/mod.rs":"1f956553588693682d29be3a61385a6738d0c682719138a32460407aa626d5a3","src/rngs/adapter/read.rs":"72000e758119093ca090b281a5d2e76981e218175162c8502ceaff021b706198","src/rngs/adapter/reseeding.rs":"0b0ad2f47fba9d5aa787c7c2284d7f0dc9464830a63a3347a63270c011b1a1a5","src/rngs/entropy.rs":"8024dde0ae9fa5a87235c7fb09568c59f2a1fcab86324992192ed3e6c5eed7eb","src/rngs/jitter.rs":"24797e2fb6c7f2fa896b824591a74841fe1e5da980725161ab03882404ffd13a","src/rngs/mock.rs":"5ce40a4da78a623dd379035ccb2bc58e713508d0db0e89098dc362f7d7fbb4e3","src/rngs/mod.rs":"a6d2fba84dd76a96f43ba4a47b7ad067625f3acaeb3c532edbc82b9222f62a92","src/rngs/os.rs":"cb94a0b54e47022b2e9b58b45e0196785c61d083760333276226da435cc040d9","src/rngs/small.rs":"a6d51c0066e225bcab8a563b26a0f1b8a555ef1e3aca20210b6cd38513f08c8a","src/rngs/std.rs":"a38628a9bb2ed68daa9f9288380f274713f035b27f287e67a310c5bb4cb14f97","src/rngs/thread.rs":"645cfaa31458ad20d0bebc12a0f1aa4a6a3b00bcc6a446c5e232a14c6a396329","src/seq.rs":"124236e85d71c9cc7a8d065b45f0746cddc1a2af997d34abf664cfdab7354e81","tests/bool.rs":"b57dd7c6e597383f7f84a172cd29e85246475f2686159ca6aa61c52989f762ba","utils/ci/install.sh":"cbc29da047c6e516ff5d13731c8b07812fd40986e7b19b61a7c5deaf5d6ffdd0","utils/ci/script.sh":"309a982ecc8f5669cc1a9d0d67e0f743f3969f1a5a49e8285966ab5518767c43","utils/ziggurat_tables.py":"97d156574ad51465dd023ee63a3fbb52a5603963b09f3f30a50cdfd2bbf1a1e1"},"package":"e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"}
\ No newline at end of file
diff --git a/rustc_deps/vendor/rand/.travis.yml b/rustc_deps/vendor/rand/.travis.yml
index f3d7688..7d3633b 100644
--- a/rustc_deps/vendor/rand/.travis.yml
+++ b/rustc_deps/vendor/rand/.travis.yml
@@ -1,28 +1,108 @@
 language: rust
 sudo: false
 
+# We aim to test all the following in any combination:
+# - standard tests, benches, documentation, all available features
+# - pinned stable, latest stable, beta and nightly Rust releases
+# - Linux, OS X, Android, iOS, bare metal (i.e. no_std)
+# - x86_64, ARMv7, a Big-Endian arch (MIPS)
 matrix:
   include:
-    - rust: 1.15.0
-    - rust: stable
+    - rust: 1.22.0
+      install:
+      script:
+        - cargo test --tests --no-default-features
+        - cargo test --package rand_core --no-default-features
+        - cargo test --features serde1,log
     - rust: stable
       os: osx
+      install:
+      script:
+        - cargo test --tests --no-default-features
+        - cargo test --package rand_core --no-default-features
+        - cargo test --features serde1,log
     - rust: beta
+      install:
+      script:
+        - cargo test --tests --no-default-features
+        - cargo test --package rand_core --no-default-features
+        - cargo test --features serde1,log
     - rust: nightly
-
-    - rust: nightly
+      install:
+        - cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
       before_script:
         - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
       script:
-        - cargo doc --no-deps --all-features
-        - cargo test --benches
-        - cargo test --features nightly
+        - cargo test --tests --no-default-features --features=alloc
+        - cargo test --package rand_core --no-default-features --features=alloc,serde1
+        - cargo test --features serde1,log,nightly,alloc
+        - cargo test --all --benches
+        # remove cached documentation, otherwise files from previous PRs can get included
+        - rm -rf target/doc
+        - cargo doc --no-deps --all --all-features
+        - cargo deadlinks --dir target/doc
       after_success:
         - travis-cargo --only nightly doc-upload
 
+    - rust: nightly
+      install:
+        - rustup target add wasm32-unknown-unknown
+        # Use cargo-update since we need a real update-or-install command
+        # Only install if not already installed:
+        #- cargo --list | egrep "\binstall-update$" -q || cargo install cargo-update
+        #- cargo install-update -i cargo-web
+        # Cargo has errors with sub-commands so ignore updating for now:
+        - cargo --list | egrep "^\s*web$" -q || cargo install cargo-web
+      script:
+        - cargo web test --target wasm32-unknown-unknown --nodejs --features=stdweb
+
+    - rust: nightly
+      install:
+        - rustup target add thumbv6m-none-eabi
+      script:
+        # Bare metal target; no std; only works on nightly
+        - cargo build --no-default-features --target thumbv6m-none-eabi --release
+
+    # Trust cross-built/emulated targets. We must repeat all non-default values.
+    - rust: stable
+      sudo: required
+      dist: trusty
+      services: docker
+      env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1
+    - rust: stable
+      sudo: required
+      dist: trusty
+      services: docker
+      env: TARGET=mips-unknown-linux-gnu
+    - rust: stable
+      sudo: required
+      dist: trusty
+      services: docker
+      env: TARGET=armv7-linux-androideabi DISABLE_TESTS=1
+    - rust: stable
+      os: osx
+      sudo: required
+      dist: trusty
+      services: docker
+      env: TARGET=armv7-apple-ios DISABLE_TESTS=1
+
+before_install:
+  - set -e
+  - rustup self update
+
+# Used by all Trust targets; others must override:
+install:
+  - sh utils/ci/install.sh
+  - source ~/.cargo/env || true
 script:
-  - cargo test
-  - cargo test --manifest-path rand-derive/Cargo.toml
+  - bash utils/ci/script.sh
+
+after_script: set +e
+
+cache: cargo
+before_cache:
+  # Travis can't cache files that are not readable by "others"
+  - chmod -R a+r $HOME/.cargo
 
 env:
   global:
diff --git a/rustc_deps/vendor/rand/CHANGELOG.md b/rustc_deps/vendor/rand/CHANGELOG.md
index 4898fc5..84378f8 100644
--- a/rustc_deps/vendor/rand/CHANGELOG.md
+++ b/rustc_deps/vendor/rand/CHANGELOG.md
@@ -2,18 +2,146 @@
 All notable changes to this project will be documented in this file.
 
 The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
-and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
-## [0.4.2] - 2018-01-05
+A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md).
+
+You may also find the [Update Guide](UPDATING.md) useful.
+
+## [0.5.5] - 2018-08-07
+### Documentation
+- Fix links in documentation (#582)
+
+## [0.5.4] - 2018-07-11
+### Platform support
+- Make `OsRng` work via WASM/stdweb for WebWorkers
+
+## [0.5.3] - 2018-06-26
+### Platform support
+- OpenBSD, Bitrig: fix compilation (broken in 0.5.1) (#530)
+
+## [0.5.2] - 2018-06-18
+### Platform support
+- Hide `OsRng` and `JitterRng` on unsupported platforms (#512; fixes #503).
+
+## [0.5.1] - 2018-06-08
+
+### New distributions
+- Added Cauchy distribution. (#474, #486)
+- Added Pareto distribution. (#495)
+
+### Platform support and `OsRng`
+- Remove blanket Unix implementation. (#484)
+- Remove Wasm unimplemented stub. (#484)
+- Dragonfly BSD: read from `/dev/random`. (#484)
+- Bitrig: use `getentropy` like OpenBSD. (#484)
+- Solaris: (untested) use `getrandom` if available, otherwise `/dev/random`. (#484)
+- Emscripten, `stdweb`: split the read up in chunks. (#484)
+- Emscripten, Haiku: don't do an extra blocking read from `/dev/random`. (#484)
+- Linux, NetBSD, Solaris: read in blocking mode on first use in `fill_bytes`. (#484)
+- Fuchsia, CloudABI: fix compilation (broken in Rand 0.5). (#484)
+
+## [0.5.0] - 2018-05-21
+
+### Crate features and organisation
+- Minimum Rust version update: 1.22.0. (#239)
+- Create a separate `rand_core` crate. (#288)
+- Deprecate `rand_derive`. (#256)
+- Add `prelude` (and module reorganisation). (#435)
+- Add `log` feature. Logging is now available in `JitterRng`, `OsRng`, `EntropyRng` and `ReseedingRng`. (#246)
+- Add `serde1` feature for some PRNGs. (#189)
+- `stdweb` feature for `OsRng` support on WASM via stdweb. (#272, #336)
+
+### `Rng` trait
+- Split `Rng` in `RngCore` and `Rng` extension trait.
+  `next_u32`, `next_u64` and `fill_bytes` are now part of `RngCore`. (#265)
+- Add `Rng::sample`. (#256)
+- Deprecate `Rng::gen_weighted_bool`. (#308)
+- Add `Rng::gen_bool`. (#308)
+- Remove `Rng::next_f32` and `Rng::next_f64`. (#273)
+- Add optimized `Rng::fill` and `Rng::try_fill` methods. (#247)
+- Deprecate `Rng::gen_iter`. (#286)
+- Deprecate `Rng::gen_ascii_chars`. (#279)
+
+### `rand_core` crate
+- `rand` now depends on new `rand_core` crate (#288)
+- `RngCore` and `SeedableRng` are now part of `rand_core`. (#288)
+- Add modules to help implementing RNGs `impl` and `le`. (#209, #228)
+- Add `Error` and `ErrorKind`. (#225)
+- Add `CryptoRng` marker trait. (#273)
+- Add `BlockRngCore` trait. (#281)
+- Add `BlockRng` and `BlockRng64` wrappers to help implementations. (#281, #325)
+- Revise the `SeedableRng` trait. (#233)
+- Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288)
+- Add `RngCore::try_fill_bytes`. (#225)
+
+### Other traits and types
+- Add `FromEntropy` trait. (#233, #375)
+- Add `SmallRng` wrapper. (#296)
+- Rewrite `ReseedingRng` to only work with `BlockRngCore` (substantial performance improvement). (#281)
+- Deprecate `weak_rng`. Use `SmallRng` instead. (#296)
+- Deprecate `AsciiGenerator`. (#279)
+
+### Random number generators
+- Switch `StdRng` and `thread_rng` to HC-128. (#277)
+- `StdRng` must now be created with `from_entropy` instead of `new`
+- Change `thread_rng` reseeding threshold to 32 MiB. (#277)
+- PRNGs no longer implement `Copy`. (#209)
+- `Debug` implementations no longer show internals. (#209)
+- Implement `Clone` for `ReseedingRng`, `JitterRng`, OsRng`. (#383, #384)
+- Implement serialization for `XorShiftRng`, `IsaacRng` and `Isaac64Rng` under the `serde1` feature. (#189)
+- Implement `BlockRngCore` for `ChaChaCore` and `Hc128Core`. (#281)
+- All PRNGs are now portable across big- and little-endian architectures. (#209)
+- `Isaac64Rng::next_u32` no longer throws away half the results. (#209)
+- Add `IsaacRng::new_from_u64` and `Isaac64Rng::new_from_u64`. (#209)
+- Add the HC-128 CSPRNG `Hc128Rng`. (#210)
+- Change ChaCha20 to have 64-bit counter and 64-bit stream. (#349)
+- Changes to `JitterRng` to get its size down from 2112 to 24 bytes. (#251)
+- Various performance improvements to all PRNGs.
+
+### Platform support and `OsRng`
+- Add support for CloudABI. (#224)
+- Remove support for NaCl. (#225)
+- WASM support for `OsRng` via stdweb, behind the `stdweb` feature. (#272, #336)
+- Use `getrandom` on more platforms for Linux, and on Android. (#338)
+- Use the `SecRandomCopyBytes` interface on macOS. (#322)
+- On systems that do not have a syscall interface, only keep a single file descriptor open for `OsRng`. (#239)
+- On Unix, first try a single read from `/dev/random`, then `/dev/urandom`. (#338)
+- Better error handling and reporting in `OsRng` (using new error type). (#225)
+- `OsRng` now uses non-blocking when available. (#225)
+- Add `EntropyRng`, which provides `OsRng`, but has `JitterRng` as a fallback. (#235)
+
+### Distributions
+- New `Distribution` trait. (#256)
+- Add `Distribution::sample_iter` and `Rng::::sample_iter`. (#361)
+- Deprecate `Rand`, `Sample` and `IndependentSample` traits. (#256)
+- Add a `Standard` distribution (replaces most `Rand` implementations). (#256)
+- Add `Binomial` and `Poisson` distributions. (#96)
+- Add `Bernoulli` dsitribution. (#411)
+- Add `Alphanumeric` distribution. (#279)
+- Remove `Closed01` distribution, add `OpenClosed01`. (#274, #420)
+- Rework `Range` type, making it possible to implement it for user types. (#274)
+- Rename `Range` to `Uniform`. (#395)
+- Add `Uniform::new_inclusive` for inclusive ranges. (#274)
+- Use widening multiply method for much faster integer range reduction. (#274)
+- `Standard` distribution for `char` uses `Uniform` internally. (#274)
+- `Standard` distribution for `bool` uses sign test. (#274)
+- Implement `Standard` distribution for `Wrapping<T>`. (#436)
+- Implement `Uniform` distribution for `Duration`. (#427)
+
+
+## [0.4.2] - 2018-01-06
 ### Changed
-- Use winapi on Windows
+- Use `winapi` on Windows
 - Update for Fuchsia OS
 - Remove dev-dependency on `log`
 
+
 ## [0.4.1] - 2017-12-17
 ### Added
 - `no_std` support
 
+
 ## [0.4.0-pre.0] - 2017-12-11
 ### Added
 - `JitterRng` added as a high-quality alternative entropy source using the
@@ -29,6 +157,20 @@
 ### Deprecated
   - `sample` function deprecated (replaced by `sample_iter`)
 
+
+## [0.3.20] - 2018-01-06
+### Changed
+- Remove dev-dependency on `log`
+- Update `fuchsia-zircon` dependency to 0.3.2
+
+
+## [0.3.19] - 2017-12-27
+### Changed
+- Require `log <= 0.3.8` for dev builds
+- Update `fuchsia-zircon` dependency to 0.3
+- Fix broken links in docs (to unblock compiler docs testing CI)
+
+
 ## [0.3.18] - 2017-11-06
 ### Changed
 - `thread_rng` is seeded from the system time if `OsRng` fails
@@ -177,7 +319,7 @@
 - Compatible with Rust master
 
 ### Removed
-- Removed Copy inplementaions from RNGs
+- Removed Copy implementations from RNGs
 
 
 ## [0.1.2] - 2015-02-03
@@ -223,7 +365,7 @@
 - `Rng::gen_ascii_chars()` which will return an infinite stream of random ascii characters
 
 ### Changed
-- Now only depends on libcore!   2adf5363f88ffe06f6d2ea5c338d1b186d47f4a1
+- Now only depends on libcore!
 - Remove `Rng.choose()`, rename `Rng.choose_option()` to `.choose()`
 - Rename OSRng to OsRng
 - The WeightedChoice structure is no longer built with a `Vec<Weighted<T>>`,
@@ -262,4 +404,3 @@
 ## [0.10-pre] - 2014-03-02
 ### Added
 - Seperate `rand` out of the standard library
-
diff --git a/rustc_deps/vendor/rand/CONTRIBUTING.md b/rustc_deps/vendor/rand/CONTRIBUTING.md
new file mode 100644
index 0000000..37c1a9d
--- /dev/null
+++ b/rustc_deps/vendor/rand/CONTRIBUTING.md
@@ -0,0 +1,93 @@
+# Contributing to Rand
+
+Thank you for your interest in contributing to Rand!
+
+The following is a list of notes and tips for when you want to contribute to
+Rand with a pull request.
+
+If you want to make major changes, it is usually best to open an issue to
+discuss the idea first.
+
+Rand doesn't (yet) use rustfmt. It is best to follow the style of the
+surrounding code, and try to keep an 80 character line limit.
+
+
+## Documentation
+
+We especially welcome documentation PRs.
+
+As of Rust 1.25 there are differences in how stable and nightly render
+documentation links. Make sure it works on stable, then nightly should be good
+too. One Travis CI build checks for dead links using `cargo-deadlinks`. If you
+want to run the check locally:
+```sh
+cargo install cargo-deadlinks
+# It is recommended to remove left-over files from previous compilations
+rm -rf /target/doc
+cargo doc --no-deps
+cargo deadlinks --dir target/doc
+```
+
+When making changes to code examples in the documentation, make sure they build
+with:
+```sh
+cargo test --doc
+```
+
+A helpful command to rebuild documentation automatically on save (only works on
+Linux):
+```
+while inotifywait -r -e close_write src/ rand_core/; do cargo doc; done
+```
+
+
+## Testing
+
+Rand already contains a number of unit tests, but could use more. Also the
+existing ones could use clean-up. Any work on the tests is appreciated.
+
+Not every change or new bit of functionality requires tests, but if you can
+think of a test that adds value, please add it.
+
+Depending on the code you change, test with one of:
+```sh
+cargo test
+cargo test --package rand_core
+# Test log, serde and 128-bit support
+cargo test --features serde1,log,nightly
+```
+
+We want to be able to not only run the unit tests with `std` available, but also
+without. Because `thread_rng()` and `FromEntropy` are not available without the
+`std` feature, you may have to disable a new test with `#[cfg(feature="std")]`.
+In other cases using `::test::rng` with a constant seed is a good option:
+```rust
+let mut rng = ::test::rng(528); // just pick some number
+```
+
+Only the unit tests should work in `no_std` mode, we don't want to complicate
+the doc-tests. Run the tests with:
+```sh
+# Test no_std support
+cargo test --lib --no-default-features
+cargo test --package rand_core --no-default-features
+
+# Test no_std+alloc support; requires nightly
+cargo test --lib --no-default-features --features alloc
+```
+
+
+## Benchmarking
+
+A lot of code in Rand is performance-sensitive, most of it is expected to be
+used in hot loops in some libraries/applications. If you change code in the
+`rngs`, `prngs` or `distributions` modules, especially when you see an 'obvious
+cleanup', make sure the benchmarks do not regress. It is nice to report the
+benchmark results in the PR (or to report nothing's changed).
+
+```sh
+# Benchmarks (requires nightly)
+cargo bench
+# Some benchmarks have a faster path with i128_support
+cargo bench --features=nightly
+```
diff --git a/rustc_deps/vendor/rand/Cargo.toml b/rustc_deps/vendor/rand/Cargo.toml
index d20e99f..22f6971 100644
--- a/rustc_deps/vendor/rand/Cargo.toml
+++ b/rustc_deps/vendor/rand/Cargo.toml
@@ -12,28 +12,61 @@
 
 [package]
 name = "rand"
-version = "0.4.2"
+version = "0.5.5"
 authors = ["The Rust Project Developers"]
 description = "Random number generators and other randomness functionality.\n"
-homepage = "https://github.com/rust-lang-nursery/rand"
+homepage = "https://crates.io/crates/rand"
 documentation = "https://docs.rs/rand"
 readme = "README.md"
 keywords = ["random", "rng"]
-categories = ["algorithms"]
+categories = ["algorithms", "no-std"]
 license = "MIT/Apache-2.0"
 repository = "https://github.com/rust-lang-nursery/rand"
+[package.metadata.docs.rs]
+all-features = true
+[dependencies.log]
+version = "0.4"
+optional = true
+
+[dependencies.rand_core]
+version = "0.2"
+default-features = false
+
+[dependencies.serde]
+version = "1"
+optional = true
+
+[dependencies.serde_derive]
+version = "1"
+optional = true
+[dev-dependencies.bincode]
+version = "1.0"
 
 [features]
-alloc = []
+alloc = ["rand_core/alloc"]
 default = ["std"]
 i128_support = []
 nightly = ["i128_support"]
-std = ["libc"]
+serde1 = ["serde", "serde_derive", "rand_core/serde1"]
+std = ["rand_core/std", "alloc", "libc", "winapi", "cloudabi", "fuchsia-zircon"]
+[target."cfg(target_os = \"cloudabi\")".dependencies.cloudabi]
+version = "0.0.3"
+optional = true
 [target."cfg(target_os = \"fuchsia\")".dependencies.fuchsia-zircon]
 version = "0.3.2"
+optional = true
 [target."cfg(unix)".dependencies.libc]
 version = "0.2"
 optional = true
 [target."cfg(windows)".dependencies.winapi]
 version = "0.3"
 features = ["minwindef", "ntsecapi", "profileapi", "winnt"]
+optional = true
+[target.wasm32-unknown-unknown.dependencies.stdweb]
+version = "0.4"
+optional = true
+[badges.appveyor]
+repository = "alexcrichton/rand"
+
+[badges.travis-ci]
+repository = "rust-lang-nursery/rand"
diff --git a/rustc_deps/vendor/rand/LICENSE-APACHE b/rustc_deps/vendor/rand/LICENSE-APACHE
index 16fe87b..17d7468 100644
--- a/rustc_deps/vendor/rand/LICENSE-APACHE
+++ b/rustc_deps/vendor/rand/LICENSE-APACHE
@@ -1,6 +1,6 @@
                               Apache License
                         Version 2.0, January 2004
-                     http://www.apache.org/licenses/
+                     https://www.apache.org/licenses/
 
 TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
 
@@ -192,7 +192,7 @@
 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
+	https://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,
diff --git a/rustc_deps/vendor/rand/README.md b/rustc_deps/vendor/rand/README.md
index ffe3980..75950ed 100644
--- a/rustc_deps/vendor/rand/README.md
+++ b/rustc_deps/vendor/rand/README.md
@@ -1,12 +1,23 @@
-rand
-====
-
-A Rust library for random number generators and other randomness functionality.
+# Rand
 
 [![Build Status](https://travis-ci.org/rust-lang-nursery/rand.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/rand)
-[![Build status](https://ci.appveyor.com/api/projects/status/rm5c9o33k3jhchbw?svg=true)](https://ci.appveyor.com/project/alexcrichton/rand)
+[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-lang-nursery/rand?svg=true)](https://ci.appveyor.com/project/alexcrichton/rand)
+[![Latest version](https://img.shields.io/crates/v/rand.svg)](https://crates.io/crates/rand)
+[![Documentation](https://docs.rs/rand/badge.svg)](https://docs.rs/rand)
+[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-yellow.svg)](https://github.com/rust-lang-nursery/rand#rust-version-requirements)
 
-[Documentation](https://docs.rs/rand)
+A Rust library for random number generation.
+
+Rand provides utilities to generate random numbers, to convert them to useful
+types and distributions, and some randomness-related algorithms.
+
+The core random number generation traits of Rand live in the [rand_core](
+https://crates.io/crates/rand_core) crate; this crate is most useful when
+implementing RNGs.
+
+API reference:
+[master branch](https://rust-lang-nursery.github.io/rand/rand/index.html),
+[by release](https://docs.rs/rand/0.5).
 
 ## Usage
 
@@ -14,129 +25,119 @@
 
 ```toml
 [dependencies]
-rand = "0.4"
+rand = "0.5"
 ```
 
 and this to your crate root:
 
 ```rust
 extern crate rand;
-```
 
-### Versions
-
-The `rand` crate has been at version `0.3` since March 2015. If you wish to
-avoid all breaking changes you may wish to stick with this version.
-
-Version `0.4`was released in December 2017. It contains almost no breaking
-changes since the `0.3` series, but nevertheless contains some significant
-new code, including a new "external" entropy source (`JitterRng`) and `no_std`
-support.
-
-Version `0.5` is in development and contains significant performance
-improvements for the ISAAC random number generators.
-
-## Examples
-
-There is built-in support for a random number generator (RNG) associated with each thread stored in thread-local storage. This RNG can be accessed via thread_rng, or used implicitly via random. This RNG is normally randomly seeded from an operating-system source of randomness, e.g. /dev/urandom on Unix systems, and will automatically reseed itself from this source after generating 32 KiB of random data.
-
-```rust
-let tuple = rand::random::<(f64, char)>();
-println!("{:?}", tuple)
-```
-
-```rust
-use rand::Rng;
-
-let mut rng = rand::thread_rng();
-if rng.gen() { // random bool
-    println!("i32: {}, u32: {}", rng.gen::<i32>(), rng.gen::<u32>())
-}
-```
-
-It is also possible to use other RNG types, which have a similar interface. The following uses the "ChaCha" algorithm instead of the default.
-
-```rust
-use rand::{Rng, ChaChaRng};
-
-let mut rng = rand::ChaChaRng::new_unseeded();
-println!("i32: {}, u32: {}", rng.gen::<i32>(), rng.gen::<u32>())
-```
-
-## Features
-
-By default, `rand` is built with all stable features available. The following
-optional features are available:
-
--   `i128_support` enables support for generating `u128` and `i128` values
--   `nightly` enables all unstable features (`i128_support`)
--   `std` enabled by default; by setting "default-features = false" `no_std`
-    mode is activated; this removes features depending on `std` functionality:
-    
-        -   `OsRng` is entirely unavailable
-        -   `JitterRng` code is still present, but a nanosecond timer must be
-            provided via `JitterRng::new_with_timer`
-        -   Since no external entropy is available, it is not possible to create
-            generators with fresh seeds (user must provide entropy)
-        -   `thread_rng`, `weak_rng` and `random` are all disabled
-        -   exponential, normal and gamma type distributions are unavailable
-            since `exp` and `log` functions are not provided in `core`
-        -   any code requiring `Vec` or `Box`
--   `alloc` can be used instead of `std` to provide `Vec` and `Box`
-
-## Testing
-
-Unfortunately, `cargo test` does not test everything. The following tests are
-recommended:
-
-```
-# Basic tests for rand and sub-crates
-cargo test --all
-
-# Test no_std support (build only since nearly all tests require std)
-cargo build --all --no-default-features
-
-# Test 128-bit support (requires nightly)
-cargo test --all --features nightly
-
-# Benchmarks (requires nightly)
-cargo bench
-# or just to test the benchmark code:
-cargo test --benches
-```
-
-# `derive(Rand)`
-
-You can derive the `Rand` trait for your custom type via the `#[derive(Rand)]`
-directive. To use this first add this to your Cargo.toml:
-
-```toml
-rand = "0.4"
-rand_derive = "0.3"
-```
-
-Next in your crate:
-
-```rust
-extern crate rand;
-#[macro_use]
-extern crate rand_derive;
-
-#[derive(Rand, Debug)]
-struct MyStruct {
-    a: i32,
-    b: u32,
-}
+use rand::prelude::*;
 
 fn main() {
-    println!("{:?}", rand::random::<MyStruct>());
+  // basic usage with random():
+  let x: u8 = random();
+  println!("{}", x);
+
+  let y = random::<f64>();
+  println!("{}", y);
+
+  if random() { // generates a boolean
+      println!("Heads!");
+  }
+
+  // normal usage needs both an RNG and a function to generate the appropriate
+  // type, range, distribution, etc.
+  let mut rng = thread_rng();
+  if rng.gen() { // random bool
+      let x: f64 = rng.gen(); // random number in range [0, 1)
+      println!("x is: {}", x);
+      let ch = rng.gen::<char>(); // Sometimes you need type annotation
+      println!("char is: {}", ch);
+      println!("Number from 0 to 9: {}", rng.gen_range(0, 10));
+  }
 }
 ```
 
+## Functionality
+
+The Rand crate provides:
+
+- A convenient to use default RNG, `thread_rng`: an automatically seeded,
+  crypto-grade generator stored in thread-local memory.
+- Pseudo-random number generators: `StdRng`, `SmallRng`, `prng` module.
+- Functionality for seeding PRNGs: the `FromEntropy` trait, and as sources of
+  external randomness `EntropyRng`, `OsRng` and `JitterRng`.
+- Most content from [`rand_core`](https://crates.io/crates/rand_core)
+  (re-exported): base random number generator traits and error-reporting types.
+- 'Distributions' producing many different types of random values:
+  - A `Standard` distribution for integers, floats, and derived types including
+    tuples, arrays and `Option`
+  - Unbiased sampling from specified `Uniform` ranges.
+  - Sampling from exponential/normal/gamma distributions.
+  - Sampling from binomial/poisson distributions.
+  - `gen_bool` aka Bernoulli distribution.
+- `seq`-uence related functionality:
+  - Sampling a subset of elements.
+  - Randomly shuffling a list.
+
+
+## Versions
+
+Version 0.5 is the latest version and contains many breaking changes.
+See [the Upgrade Guide](UPDATING.md) for guidance on updating from previous
+versions.
+
+Version 0.4 was released in December 2017. It contains almost no breaking
+changes since the 0.3 series.
+
+For more details, see the [changelog](CHANGELOG.md).
+
+### Rust version requirements
+
+The 0.5 release of Rand requires **Rustc version 1.22 or greater**.
+Rand 0.4 and 0.3 (since approx. June 2017) require Rustc version 1.15 or
+greater. Subsets of the Rand code may work with older Rust versions, but this
+is not supported.
+
+Travis CI always has a build with a pinned version of Rustc matching the oldest
+supported Rust release. The current policy is that this can be updated in any
+Rand release if required, but the change must be noted in the changelog.
+
+
+## Crate Features
+
+Rand is built with only the `std` feature enabled by default. The following
+optional features are available:
+
+- `alloc` can be used instead of `std` to provide `Vec` and `Box`.
+- `i128_support` enables support for generating `u128` and `i128` values.
+- `log` enables some logging via the `log` crate.
+- `nightly` enables all unstable features (`i128_support`).
+- `serde1` enables serialization for some types, via Serde version 1.
+- `stdweb` enables support for `OsRng` on `wasm-unknown-unknown` via `stdweb`
+  combined with `cargo-web`.
+
+`no_std` mode is activated by setting `default-features = false`; this removes
+functionality depending on `std`:
+
+- `thread_rng()`, and `random()` are not available, as they require thread-local
+  storage and an entropy source.
+- `OsRng` and `EntropyRng` are unavailable.
+- `JitterRng` code is still present, but a nanosecond timer must be provided via
+  `JitterRng::new_with_timer`
+- Since no external entropy is available, it is not possible to create
+  generators with fresh seeds using the `FromEntropy` trait (user must provide
+  a seed).
+- Exponential, normal and gamma type distributions are unavailable since `exp`
+  and `log` functions are not provided in `core`.
+- The `seq`-uence module is unavailable, as it requires `Vec`.
+
 
 # License
 
-`rand` is primarily distributed under the terms of both the MIT
-license and the Apache License (Version 2.0).
+Rand is distributed under the terms of both the MIT license and the
+Apache License (Version 2.0).
 
-See LICENSE-APACHE, and LICENSE-MIT for details.
+See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) for details.
diff --git a/rustc_deps/vendor/rand/UPDATING.md b/rustc_deps/vendor/rand/UPDATING.md
new file mode 100644
index 0000000..09321b7
--- /dev/null
+++ b/rustc_deps/vendor/rand/UPDATING.md
@@ -0,0 +1,260 @@
+# Update Guide
+
+This guide gives a few more details than the [changelog], in particular giving
+guidance on how to use new features and migrate away from old ones.
+
+[changelog]: CHANGELOG.md
+
+## Rand 0.5
+
+The 0.5 release has quite significant changes over the 0.4 release; as such,
+it may be worth reading through the following coverage of breaking changes.
+This release also contains many optimisations, which are not detailed below.
+
+### Crates
+
+We have a new crate: `rand_core`! This crate houses some important traits,
+`RngCore`, `BlockRngCore`, `SeedableRng` and `CryptoRng`, the error types, as
+well as two modules with helpers for implementations: `le` and `impls`. It is
+recommended that implementations of generators use the `rand_core` crate while
+other users use only the `rand` crate, which re-exports most parts of `rand_core`.
+
+The `rand_derive` crate has been deprecated due to very low usage and
+deprecation of `Rand`.
+
+### Features
+
+Several new Cargo feature flags have been added:
+
+-   `alloc`, used without `std`, allows use of `Box` and `Vec`
+-   `serde1` adds serialization support to some PRNGs
+-   `log` adds logging in a few places (primarily to `OsRng` and `JitterRng`)
+
+### `Rng` and friends (core traits)
+
+`Rng` trait has been split into two traits, a "back end" `RngCore` (implemented
+by generators) and a "front end" `Rng` implementing all the convenient extension
+methods.
+
+Implementations of generators must `impl RngCore` instead. Usage of `rand_core`
+for implementations is encouraged; the `rand_core::{le, impls}` modules may
+prove useful.
+
+Users of `Rng` *who don't need to implement it* won't need to make so many
+changes; often users can forget about `RngCore` and only import `Rng`. Instead
+of `RngCore::next_u32()` / `next_u64()` users should prefer `Rng::gen()`, and
+instead of `RngCore::fill_bytes(dest)`, `Rng::fill(dest)` can be used.
+
+#### `Rng` / `RngCore` methods
+
+To allow error handling from fallible sources (e.g. `OsRng`), a new
+`RngCore::try_fill_bytes` method has been added; for example `EntropyRng` uses
+this mechanism to fall back to `JitterRng` if `OsRng` fails, and various
+handlers produce better error messages.
+As before, the other methods will panic on failure, but since these are usually
+used with algorithmic generators which are usually infallible, this is
+considered an appropriate compromise.
+
+A few methods from the old `Rng` have been removed or deprecated:
+
+-   `next_f32` and `next_f64`; these are no longer implementable by generators;
+    use `gen` instead
+-   `gen_iter`; users may instead use standard iterators with closures:
+    `::std::iter::repeat(()).map(|()| rng.gen())`
+-   `gen_ascii_chars`; use `repeat` as above and `rng.sample(Alphanumeric)`
+-   `gen_weighted_bool(n)`; use `gen_bool(1.0 / n)` instead
+
+`Rng` has a few new methods:
+
+-   `sample(distr)` is a shortcut for `distr.sample(rng)` for any `Distribution`
+-   `gen_bool(p)` generates a boolean with probability `p` of being true
+-   `fill` and `try_fill`, corresponding to `fill_bytes` and `try_fill_bytes`
+    respectively (i.e. the only difference is error handling); these can fill
+    and integer slice / array directly, and provide better performance
+    than `gen()`
+
+#### Constructing PRNGs
+
+##### New randomly-initialised PRNGs
+
+A new trait has been added: `FromEntropy`. This is automatically implemented for
+any type supporting `SeedableRng`, and provides construction from fresh, strong
+entropy:
+
+```rust
+use rand::{ChaChaRng, FromEntropy};
+
+let mut rng = ChaChaRng::from_entropy();
+```
+
+##### Seeding PRNGs
+
+The `SeedableRng` trait has been modified to include the seed type via an
+associated type (`SeedableRng::Seed`) instead of a template parameter
+(`SeedableRng<Seed>`). Additionally, all PRNGs now seed from a byte-array
+(`[u8; N]` for some fixed N). This allows generic handling of PRNG seeding
+which was not previously possible.
+
+PRNGs are no longer constructed from other PRNGs via `Rand` support / `gen()`,
+but through `SeedableRng::from_rng`, which allows error handling and is
+intentionally explicit.
+
+`SeedableRng::reseed` has been removed since it has no utility over `from_seed`
+and its performance advantage is questionable.
+
+Implementations of `SeedableRng` may need to change their `Seed` type to a
+byte-array; this restriction has been made to ensure portable handling of
+Endianness. Helper functions are available in `rand_core::le` to read `u32` and
+`u64` values from byte arrays.
+
+#### Block-based PRNGs
+
+rand_core has a new helper trait, `BlockRngCore`, and implementation,
+`BlockRng`. These are for use by generators which generate a block of random
+data at a time instead of word-sized values. Using this trait and implementation
+has two advantages: optimised `RngCore` methods are provided, and the PRNG can
+be used with `ReseedingRng` with very low overhead.
+
+#### Cryptographic RNGs
+
+A new trait has been added: `CryptoRng`. This is purely a marker trait to
+indicate which generators should be suitable for cryptography, e.g.
+`fn foo<R: Rng + CryptoRng>(rng: &mut R)`. *Suitability for cryptographic
+use cannot be guaranteed.*
+
+### Error handling
+
+A new `Error` type has been added, designed explicitly for no-std compatibility,
+simplicity, and enough flexibility for our uses (carrying a `cause` when
+possible):
+```rust
+pub struct Error {
+    pub kind: ErrorKind,
+    pub msg: &'static str,
+    // some fields omitted
+}
+```
+The associated `ErrorKind` allows broad classification of errors into permanent,
+unexpected, transient and not-yet-ready kinds.
+
+The following use the new error type:
+
+-   `RngCore::try_fill_bytes`
+-   `Rng::try_fill`
+-   `OsRng::new`
+-   `JitterRng::new`
+
+### External generators
+
+We have a new generator, `EntropyRng`, which wraps `OsRng` and `JitterRng`
+(preferring to use the former, but falling back to the latter if necessary).
+This allows easy construction with fallback via `SeedableRng::from_rng`,
+e.g. `IsaacRng::from_rng(EntropyRng::new())?`. This is equivalent to using
+`FromEntropy` except for error handling.
+
+It is recommended to use `EntropyRng` over `OsRng` to avoid errors on platforms
+with broken system generator, but it should be noted that the `JitterRng`
+fallback is very slow.
+
+### PRNGs
+
+*Pseudo-Random Number Generators* (i.e. deterministic algorithmic generators)
+have had a few changes since 0.4, and are now housed in the `prng` module
+(old names remain temporarily available for compatibility; eventually these
+generators will likely be housed outside the `rand` crate).
+
+All PRNGs now do not implement `Copy` to prevent accidental copying of the
+generator's state (and thus repetitions of generated values). Explicit cloning
+via `Clone` is still available. All PRNGs now have a custom implementation of
+`Debug` which does not print any internal state; this helps avoid accidentally
+leaking cryptographic generator state in log files. External PRNG
+implementations are advised to follow this pattern (see also doc on `RngCore`).
+
+`SmallRng` has been added as a wrapper, currently around `XorShiftRng` (but
+likely another algorithm soon). This is for uses where small state and fast
+initialisation are important but cryptographic strength is not required.
+(Actual performance of generation varies by benchmark; dependending on usage
+this may or may not be the fastest algorithm, but will always be fast.)
+
+#### `ReseedingRng`
+
+The `ReseedingRng` wrapper has been signficantly altered to reduce overhead.
+Unfortunately the new `ReseedingRng` is not compatible with all RNGs, but only
+those using `BlockRngCore`.
+
+#### ISAAC PRNGs
+
+The `IsaacRng` and `Isaac64Rng` PRNGs now have an additional construction
+method: `new_from_u64(seed)`. 64 bits of state is insufficient for cryptography
+but may be of use in simulations and games. This will likely be superceeded by
+a method to construct any PRNG from any hashable object in the future.
+
+#### HC-128
+
+This is a new cryptographic generator, selected as one of the "stream ciphers
+suitable for widespread adoption" by eSTREAM. This is now the default
+cryptographic generator, used by `StdRng` and `thread_rng()`.
+
+### Helper functions/traits
+
+The `Rand` trait has been deprecated. Instead, users are encouraged to use
+`Standard` which is a real distribution and supports the same sampling as
+`Rand`. `Rng::gen()` now uses `Standard` and should work exactly as before.
+See the documentation of the `distributions` module on how to implement
+`Distribution<T>` for `Standard` for user types `T`
+
+`weak_rng()` has been deprecated; use `SmallRng::from_entropy()` instead.
+
+### Distributions
+
+The `Sample` and `IndependentSample` traits have been replaced by a single
+trait, `Distribution`. This is largely equivalent to `IndependentSample`, but
+with `ind_sample` replaced by just `sample`. Support for mutable distributions
+has been dropped; although it appears there may be a few genuine uses, these
+are not used widely enough to justify the existance of two independent traits
+or of having to provide mutable access to a distribution object. Both `Sample`
+and `IndependentSample` are still available, but deprecated; they will be
+removed in a future release.
+
+`Distribution::sample` (as well as several other functions) can now be called
+directly on type-erased (unsized) RNGs.
+
+`RandSample` has been removed (see `Rand` deprecation and new `Standard`
+distribution).
+
+The `Closed01` wrapper has been removed, but `OpenClosed01` has been added.
+
+#### Uniform distributions
+
+Two new distributions are available:
+
+-   `Standard` produces uniformly-distributed samples for many different types,
+    and acts as a replacement for `Rand`
+-   `Alphanumeric` samples `char`s from the ranges `a-z A-Z 0-9`
+
+##### Ranges
+
+The `Range` distribution has been heavily adapted, and renamed to `Uniform`:
+
+-   `Uniform::new(low, high)` remains (half open `[low, high)`)
+-   `Uniform::new_inclusive(low, high)` has been added, including `high` in the sample range
+-   `Uniform::sample_single(low, high, rng)` is a faster variant for single usage sampling from `[low, high)`
+
+`Uniform` can now be implemented for user-defined types; see the `uniform` module.
+
+#### Non-uniform distributions
+
+Two distributions have been added:
+
+-   Poisson, modelling the number of events expected from a constant-rate
+    source within a fixed time interval (e.g. nuclear decay)
+-   Binomial, modelling the outcome of a fixed number of yes-no trials
+
+The sampling methods are based on those in "Numerical Recipes in C".
+
+##### Exponential and Normal distributions
+
+The main `Exp` and `Normal` distributions are unchanged, however the
+"standard" versions, `Exp1` and `StandardNormal` are no longer wrapper types,
+but full distributions. Instead of writing `let Exp1(x) = rng.gen();` you now
+write `let x = rng.sample(Exp1);`.
diff --git a/rustc_deps/vendor/rand/appveyor.yml b/rustc_deps/vendor/rand/appveyor.yml
index 02e217f..97d3ce6 100644
--- a/rustc_deps/vendor/rand/appveyor.yml
+++ b/rustc_deps/vendor/rand/appveyor.yml
@@ -32,7 +32,8 @@
 build: false
 
 test_script:
-  - cargo test --benches
-  - cargo test
-  - cargo test --features nightly
-  - cargo test --manifest-path rand-derive/Cargo.toml
+  - cargo test --all # cannot use --all and --features together
+  - cargo test --all --benches
+  - cargo test --features serde1,log,nightly
+  - cargo test --tests --no-default-features --features=alloc,serde1
+  - cargo test --package rand_core --no-default-features --features=alloc,serde1
diff --git a/rustc_deps/vendor/rand/benches/distributions.rs b/rustc_deps/vendor/rand/benches/distributions.rs
new file mode 100644
index 0000000..fd6b5ae
--- /dev/null
+++ b/rustc_deps/vendor/rand/benches/distributions.rs
@@ -0,0 +1,161 @@
+#![feature(test)]
+#![cfg_attr(all(feature="i128_support", feature="nightly"), allow(stable_features))] // stable since 2018-03-27
+#![cfg_attr(all(feature="i128_support", feature="nightly"), feature(i128_type, i128))]
+
+extern crate test;
+extern crate rand;
+
+const RAND_BENCH_N: u64 = 1000;
+
+use std::mem::size_of;
+use test::Bencher;
+
+use rand::{Rng, FromEntropy, XorShiftRng};
+use rand::distributions::*;
+
+macro_rules! distr_int {
+    ($fnn:ident, $ty:ty, $distr:expr) => {
+        #[bench]
+        fn $fnn(b: &mut Bencher) {
+            let mut rng = XorShiftRng::from_entropy();
+            let distr = $distr;
+
+            b.iter(|| {
+                let mut accum = 0 as $ty;
+                for _ in 0..::RAND_BENCH_N {
+                    let x: $ty = distr.sample(&mut rng);
+                    accum = accum.wrapping_add(x);
+                }
+                accum
+            });
+            b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N;
+        }
+    }
+}
+
+macro_rules! distr_float {
+    ($fnn:ident, $ty:ty, $distr:expr) => {
+        #[bench]
+        fn $fnn(b: &mut Bencher) {
+            let mut rng = XorShiftRng::from_entropy();
+            let distr = $distr;
+
+            b.iter(|| {
+                let mut accum = 0.0;
+                for _ in 0..::RAND_BENCH_N {
+                    let x: $ty = distr.sample(&mut rng);
+                    accum += x;
+                }
+                accum
+            });
+            b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N;
+        }
+    }
+}
+
+macro_rules! distr {
+    ($fnn:ident, $ty:ty, $distr:expr) => {
+        #[bench]
+        fn $fnn(b: &mut Bencher) {
+            let mut rng = XorShiftRng::from_entropy();
+            let distr = $distr;
+
+            b.iter(|| {
+                let mut accum = 0u32;
+                for _ in 0..::RAND_BENCH_N {
+                    let x: $ty = distr.sample(&mut rng);
+                    accum = accum.wrapping_add(x as u32);
+                }
+                accum
+            });
+            b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N;
+        }
+    }
+}
+
+// uniform
+distr_int!(distr_uniform_i8, i8, Uniform::new(20i8, 100));
+distr_int!(distr_uniform_i16, i16, Uniform::new(-500i16, 2000));
+distr_int!(distr_uniform_i32, i32, Uniform::new(-200_000_000i32, 800_000_000));
+distr_int!(distr_uniform_i64, i64, Uniform::new(3i64, 123_456_789_123));
+#[cfg(feature = "i128_support")]
+distr_int!(distr_uniform_i128, i128, Uniform::new(-123_456_789_123i128, 123_456_789_123_456_789));
+
+distr_float!(distr_uniform_f32, f32, Uniform::new(2.26f32, 2.319));
+distr_float!(distr_uniform_f64, f64, Uniform::new(2.26f64, 2.319));
+
+// standard
+distr_int!(distr_standard_i8, i8, Standard);
+distr_int!(distr_standard_i16, i16, Standard);
+distr_int!(distr_standard_i32, i32, Standard);
+distr_int!(distr_standard_i64, i64, Standard);
+#[cfg(feature = "i128_support")]
+distr_int!(distr_standard_i128, i128, Standard);
+
+distr!(distr_standard_bool, bool, Standard);
+distr!(distr_standard_alphanumeric, char, Alphanumeric);
+distr!(distr_standard_codepoint, char, Standard);
+
+distr_float!(distr_standard_f32, f32, Standard);
+distr_float!(distr_standard_f64, f64, Standard);
+distr_float!(distr_open01_f32, f32, Open01);
+distr_float!(distr_open01_f64, f64, Open01);
+distr_float!(distr_openclosed01_f32, f32, OpenClosed01);
+distr_float!(distr_openclosed01_f64, f64, OpenClosed01);
+
+// distributions
+distr_float!(distr_exp, f64, Exp::new(1.23 * 4.56));
+distr_float!(distr_normal, f64, Normal::new(-1.23, 4.56));
+distr_float!(distr_log_normal, f64, LogNormal::new(-1.23, 4.56));
+distr_float!(distr_gamma_large_shape, f64, Gamma::new(10., 1.0));
+distr_float!(distr_gamma_small_shape, f64, Gamma::new(0.1, 1.0));
+distr_float!(distr_cauchy, f64, Cauchy::new(4.2, 6.9));
+distr_int!(distr_binomial, u64, Binomial::new(20, 0.7));
+distr_int!(distr_poisson, u64, Poisson::new(4.0));
+distr!(distr_bernoulli, bool, Bernoulli::new(0.18));
+
+
+// construct and sample from a range
+macro_rules! gen_range_int {
+    ($fnn:ident, $ty:ident, $low:expr, $high:expr) => {
+        #[bench]
+        fn $fnn(b: &mut Bencher) {
+            let mut rng = XorShiftRng::from_entropy();
+
+            b.iter(|| {
+                let mut high = $high;
+                let mut accum: $ty = 0;
+                for _ in 0..::RAND_BENCH_N {
+                    accum = accum.wrapping_add(rng.gen_range($low, high));
+                    // force recalculation of range each time
+                    high = high.wrapping_add(1) & std::$ty::MAX;
+                }
+                accum
+            });
+            b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N;
+        }
+    }
+}
+
+gen_range_int!(gen_range_i8, i8, -20i8, 100);
+gen_range_int!(gen_range_i16, i16, -500i16, 2000);
+gen_range_int!(gen_range_i32, i32, -200_000_000i32, 800_000_000);
+gen_range_int!(gen_range_i64, i64, 3i64, 123_456_789_123);
+#[cfg(feature = "i128_support")]
+gen_range_int!(gen_range_i128, i128, -12345678901234i128, 123_456_789_123_456_789);
+
+#[bench]
+fn dist_iter(b: &mut Bencher) {
+    let mut rng = XorShiftRng::from_entropy();
+    let distr = Normal::new(-2.71828, 3.14159);
+    let mut iter = distr.sample_iter(&mut rng);
+
+    b.iter(|| {
+        let mut accum = 0.0;
+        for _ in 0..::RAND_BENCH_N {
+            accum += iter.next().unwrap();
+        }
+        accum
+    });
+    b.bytes = size_of::<f64>() as u64 * ::RAND_BENCH_N;
+}
diff --git a/rustc_deps/vendor/rand/benches/generators.rs b/rustc_deps/vendor/rand/benches/generators.rs
index daee7c5..402a87b 100644
--- a/rustc_deps/vendor/rand/benches/generators.rs
+++ b/rustc_deps/vendor/rand/benches/generators.rs
@@ -9,14 +9,17 @@
 use std::mem::size_of;
 use test::{black_box, Bencher};
 
-use rand::{Rng, StdRng, OsRng, JitterRng};
-use rand::{XorShiftRng, IsaacRng, Isaac64Rng, ChaChaRng};
+use rand::prelude::*;
+use rand::prng::{XorShiftRng, Hc128Rng, IsaacRng, Isaac64Rng, ChaChaRng};
+use rand::prng::hc128::Hc128Core;
+use rand::rngs::adapter::ReseedingRng;
+use rand::rngs::{OsRng, JitterRng, EntropyRng};
 
 macro_rules! gen_bytes {
-    ($fnn:ident, $gen:ident) => {
+    ($fnn:ident, $gen:expr) => {
         #[bench]
         fn $fnn(b: &mut Bencher) {
-            let mut rng: $gen = OsRng::new().unwrap().gen();
+            let mut rng = $gen;
             let mut buf = [0u8; BYTES_LEN];
             b.iter(|| {
                 for _ in 0..RAND_BENCH_N {
@@ -29,80 +32,57 @@
     }
 }
 
-macro_rules! gen_bytes_new {
-    ($fnn:ident, $gen:ident) => {
-        #[bench]
-        fn $fnn(b: &mut Bencher) {
-            let mut rng = $gen::new().unwrap();
-            let mut buf = [0u8; BYTES_LEN];
-            b.iter(|| {
-                for _ in 0..RAND_BENCH_N {
-                    rng.fill_bytes(&mut buf);
-                    black_box(buf);
-                }
-            });
-            b.bytes = BYTES_LEN as u64 * RAND_BENCH_N;
-        }
-    }
-}
-
-gen_bytes!(gen_bytes_xorshift, XorShiftRng);
-gen_bytes!(gen_bytes_isaac, IsaacRng);
-gen_bytes!(gen_bytes_isaac64, Isaac64Rng);
-gen_bytes!(gen_bytes_chacha, ChaChaRng);
-gen_bytes_new!(gen_bytes_std, StdRng);
-gen_bytes_new!(gen_bytes_os, OsRng);
-
+gen_bytes!(gen_bytes_xorshift, XorShiftRng::from_entropy());
+gen_bytes!(gen_bytes_chacha20, ChaChaRng::from_entropy());
+gen_bytes!(gen_bytes_hc128, Hc128Rng::from_entropy());
+gen_bytes!(gen_bytes_isaac, IsaacRng::from_entropy());
+gen_bytes!(gen_bytes_isaac64, Isaac64Rng::from_entropy());
+gen_bytes!(gen_bytes_std, StdRng::from_entropy());
+gen_bytes!(gen_bytes_small, SmallRng::from_entropy());
+gen_bytes!(gen_bytes_os, OsRng::new().unwrap());
 
 macro_rules! gen_uint {
-    ($fnn:ident, $ty:ty, $gen:ident) => {
+    ($fnn:ident, $ty:ty, $gen:expr) => {
         #[bench]
         fn $fnn(b: &mut Bencher) {
-            let mut rng: $gen = OsRng::new().unwrap().gen();
+            let mut rng = $gen;
             b.iter(|| {
+                let mut accum: $ty = 0;
                 for _ in 0..RAND_BENCH_N {
-                    black_box(rng.gen::<$ty>());
+                    accum = accum.wrapping_add(rng.gen::<$ty>());
                 }
+                accum
             });
             b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N;
         }
     }
 }
 
-macro_rules! gen_uint_new {
-    ($fnn:ident, $ty:ty, $gen:ident) => {
-        #[bench]
-        fn $fnn(b: &mut Bencher) {
-            let mut rng = $gen::new().unwrap();
-            b.iter(|| {
-                for _ in 0..RAND_BENCH_N {
-                    black_box(rng.gen::<$ty>());
-                }
-            });
-            b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N;
-        }
-    }
-}
+gen_uint!(gen_u32_xorshift, u32, XorShiftRng::from_entropy());
+gen_uint!(gen_u32_chacha20, u32, ChaChaRng::from_entropy());
+gen_uint!(gen_u32_hc128, u32, Hc128Rng::from_entropy());
+gen_uint!(gen_u32_isaac, u32, IsaacRng::from_entropy());
+gen_uint!(gen_u32_isaac64, u32, Isaac64Rng::from_entropy());
+gen_uint!(gen_u32_std, u32, StdRng::from_entropy());
+gen_uint!(gen_u32_small, u32, SmallRng::from_entropy());
+gen_uint!(gen_u32_os, u32, OsRng::new().unwrap());
 
-gen_uint!(gen_u32_xorshift, u32, XorShiftRng);
-gen_uint!(gen_u32_isaac, u32, IsaacRng);
-gen_uint!(gen_u32_isaac64, u32, Isaac64Rng);
-gen_uint!(gen_u32_chacha, u32, ChaChaRng);
-gen_uint_new!(gen_u32_std, u32, StdRng);
-gen_uint_new!(gen_u32_os, u32, OsRng);
+gen_uint!(gen_u64_xorshift, u64, XorShiftRng::from_entropy());
+gen_uint!(gen_u64_chacha20, u64, ChaChaRng::from_entropy());
+gen_uint!(gen_u64_hc128, u64, Hc128Rng::from_entropy());
+gen_uint!(gen_u64_isaac, u64, IsaacRng::from_entropy());
+gen_uint!(gen_u64_isaac64, u64, Isaac64Rng::from_entropy());
+gen_uint!(gen_u64_std, u64, StdRng::from_entropy());
+gen_uint!(gen_u64_small, u64, SmallRng::from_entropy());
+gen_uint!(gen_u64_os, u64, OsRng::new().unwrap());
 
-gen_uint!(gen_u64_xorshift, u64, XorShiftRng);
-gen_uint!(gen_u64_isaac, u64, IsaacRng);
-gen_uint!(gen_u64_isaac64, u64, Isaac64Rng);
-gen_uint!(gen_u64_chacha, u64, ChaChaRng);
-gen_uint_new!(gen_u64_std, u64, StdRng);
-gen_uint_new!(gen_u64_os, u64, OsRng);
-
+// Do not test JitterRng like the others by running it RAND_BENCH_N times per,
+// measurement, because it is way too slow. Only run it once.
 #[bench]
 fn gen_u64_jitter(b: &mut Bencher) {
     let mut rng = JitterRng::new().unwrap();
     b.iter(|| {
-        black_box(rng.gen::<u64>());
+        rng.gen::<u64>()
     });
     b.bytes = size_of::<u64>() as u64;
 }
@@ -111,16 +91,17 @@
     ($fnn:ident, $gen:ident) => {
         #[bench]
         fn $fnn(b: &mut Bencher) {
-            let mut rng: XorShiftRng = OsRng::new().unwrap().gen();
+            let mut rng = XorShiftRng::from_entropy();
             b.iter(|| {
-                let r2: $gen = rng.gen();
-                black_box(r2);
+                let r2 = $gen::from_rng(&mut rng).unwrap();
+                r2
             });
         }
     }
 }
 
 init_gen!(init_xorshift, XorShiftRng);
+init_gen!(init_hc128, Hc128Rng);
 init_gen!(init_isaac, IsaacRng);
 init_gen!(init_isaac64, Isaac64Rng);
 init_gen!(init_chacha, ChaChaRng);
@@ -128,6 +109,68 @@
 #[bench]
 fn init_jitter(b: &mut Bencher) {
     b.iter(|| {
-        black_box(JitterRng::new().unwrap());
+        JitterRng::new().unwrap()
     });
 }
+
+
+const RESEEDING_THRESHOLD: u64 = 1024*1024*1024; // something high enough to get
+                                                 // deterministic measurements
+
+#[bench]
+fn reseeding_hc128_bytes(b: &mut Bencher) {
+    let mut rng = ReseedingRng::new(Hc128Core::from_entropy(),
+                                    RESEEDING_THRESHOLD,
+                                    EntropyRng::new());
+    let mut buf = [0u8; BYTES_LEN];
+    b.iter(|| {
+        for _ in 0..RAND_BENCH_N {
+            rng.fill_bytes(&mut buf);
+            black_box(buf);
+        }
+    });
+    b.bytes = BYTES_LEN as u64 * RAND_BENCH_N;
+}
+
+macro_rules! reseeding_uint {
+    ($fnn:ident, $ty:ty) => {
+        #[bench]
+        fn $fnn(b: &mut Bencher) {
+            let mut rng = ReseedingRng::new(Hc128Core::from_entropy(),
+                                            RESEEDING_THRESHOLD,
+                                            EntropyRng::new());
+            b.iter(|| {
+                let mut accum: $ty = 0;
+                for _ in 0..RAND_BENCH_N {
+                    accum = accum.wrapping_add(rng.gen::<$ty>());
+                }
+                accum
+            });
+            b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N;
+        }
+    }
+}
+
+reseeding_uint!(reseeding_hc128_u32, u32);
+reseeding_uint!(reseeding_hc128_u64, u64);
+
+
+macro_rules! threadrng_uint {
+    ($fnn:ident, $ty:ty) => {
+        #[bench]
+        fn $fnn(b: &mut Bencher) {
+            let mut rng = thread_rng();
+            b.iter(|| {
+                let mut accum: $ty = 0;
+                for _ in 0..RAND_BENCH_N {
+                    accum = accum.wrapping_add(rng.gen::<$ty>());
+                }
+                accum
+            });
+            b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N;
+        }
+    }
+}
+
+threadrng_uint!(thread_rng_u32, u32);
+threadrng_uint!(thread_rng_u64, u64);
diff --git a/rustc_deps/vendor/rand/benches/misc.rs b/rustc_deps/vendor/rand/benches/misc.rs
index 4251761..a1822a5 100644
--- a/rustc_deps/vendor/rand/benches/misc.rs
+++ b/rustc_deps/vendor/rand/benches/misc.rs
@@ -3,45 +3,122 @@
 extern crate test;
 extern crate rand;
 
-use test::{black_box, Bencher};
+const RAND_BENCH_N: u64 = 1000;
 
-use rand::{Rng, weak_rng};
+use test::Bencher;
+
+use rand::prelude::*;
 use rand::seq::*;
 
 #[bench]
+fn misc_gen_bool_const(b: &mut Bencher) {
+    let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
+    b.iter(|| {
+        let mut accum = true;
+        for _ in 0..::RAND_BENCH_N {
+            accum ^= rng.gen_bool(0.18);
+        }
+        accum
+    })
+}
+
+#[bench]
+fn misc_gen_bool_var(b: &mut Bencher) {
+    let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
+    b.iter(|| {
+        let mut accum = true;
+        let mut p = 0.18;
+        for _ in 0..::RAND_BENCH_N {
+            accum ^= rng.gen_bool(p);
+            p += 0.0001;
+        }
+        accum
+    })
+}
+
+#[bench]
+fn misc_bernoulli_const(b: &mut Bencher) {
+    let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
+    let d = rand::distributions::Bernoulli::new(0.18);
+    b.iter(|| {
+        // Can be evaluated at compile time.
+        let mut accum = true;
+        for _ in 0..::RAND_BENCH_N {
+            accum ^= rng.sample(d);
+        }
+        accum
+    })
+}
+
+#[bench]
+fn misc_bernoulli_var(b: &mut Bencher) {
+    let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
+    b.iter(|| {
+        let mut accum = true;
+        let mut p = 0.18;
+        for _ in 0..::RAND_BENCH_N {
+            let d = rand::distributions::Bernoulli::new(p);
+            accum ^= rng.sample(d);
+            p += 0.0001;
+        }
+        accum
+    })
+}
+
+macro_rules! sample_binomial {
+    ($name:ident, $n:expr, $p:expr) => {
+        #[bench]
+        fn $name(b: &mut Bencher) {
+            let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
+            let (n, p) = ($n, $p);
+            b.iter(|| {
+                let d = rand::distributions::Binomial::new(n, p);
+                rng.sample(d)
+            })
+        }
+    }
+}
+
+sample_binomial!(misc_binomial_1, 1, 0.9);
+sample_binomial!(misc_binomial_10, 10, 0.9);
+sample_binomial!(misc_binomial_100, 100, 0.99);
+sample_binomial!(misc_binomial_1000, 1000, 0.01);
+sample_binomial!(misc_binomial_1e12, 1000_000_000_000, 0.2);
+
+#[bench]
 fn misc_shuffle_100(b: &mut Bencher) {
-    let mut rng = weak_rng();
+    let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
     let x : &mut [usize] = &mut [1; 100];
     b.iter(|| {
         rng.shuffle(x);
-        black_box(&x);
+        x[0]
     })
 }
 
 #[bench]
 fn misc_sample_iter_10_of_100(b: &mut Bencher) {
-    let mut rng = weak_rng();
+    let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
     let x : &[usize] = &[1; 100];
     b.iter(|| {
-        black_box(sample_iter(&mut rng, x, 10).unwrap_or_else(|e| e));
+        sample_iter(&mut rng, x, 10).unwrap_or_else(|e| e)
     })
 }
 
 #[bench]
 fn misc_sample_slice_10_of_100(b: &mut Bencher) {
-    let mut rng = weak_rng();
+    let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
     let x : &[usize] = &[1; 100];
     b.iter(|| {
-        black_box(sample_slice(&mut rng, x, 10));
+        sample_slice(&mut rng, x, 10)
     })
 }
 
 #[bench]
 fn misc_sample_slice_ref_10_of_100(b: &mut Bencher) {
-    let mut rng = weak_rng();
+    let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
     let x : &[usize] = &[1; 100];
     b.iter(|| {
-        black_box(sample_slice_ref(&mut rng, x, 10));
+        sample_slice_ref(&mut rng, x, 10)
     })
 }
 
@@ -49,9 +126,9 @@
     ($name:ident, $amount:expr, $length:expr) => {
         #[bench]
         fn $name(b: &mut Bencher) {
-            let mut rng = weak_rng();
+            let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
             b.iter(|| {
-                black_box(sample_indices(&mut rng, $length, $amount));
+                sample_indices(&mut rng, $length, $amount)
             })
         }
     }
@@ -60,3 +137,58 @@
 sample_indices!(misc_sample_indices_10_of_1k, 10, 1000);
 sample_indices!(misc_sample_indices_50_of_1k, 50, 1000);
 sample_indices!(misc_sample_indices_100_of_1k, 100, 1000);
+
+#[bench]
+fn gen_1k_iter_repeat(b: &mut Bencher) {
+    use std::iter;
+    let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
+    b.iter(|| {
+        let v: Vec<u64> = iter::repeat(()).map(|()| rng.gen()).take(128).collect();
+        v
+    });
+    b.bytes = 1024;
+}
+
+#[bench]
+#[allow(deprecated)]
+fn gen_1k_gen_iter(b: &mut Bencher) {
+    let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
+    b.iter(|| {
+        let v: Vec<u64> = rng.gen_iter().take(128).collect();
+        v
+    });
+    b.bytes = 1024;
+}
+
+#[bench]
+fn gen_1k_sample_iter(b: &mut Bencher) {
+    use rand::distributions::{Distribution, Standard};
+    let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
+    b.iter(|| {
+        let v: Vec<u64> = Standard.sample_iter(&mut rng).take(128).collect();
+        v
+    });
+    b.bytes = 1024;
+}
+
+#[bench]
+fn gen_1k_gen_array(b: &mut Bencher) {
+    let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
+    b.iter(|| {
+        // max supported array length is 32!
+        let v: [[u64; 32]; 4] = rng.gen();
+        v
+    });
+    b.bytes = 1024;
+}
+
+#[bench]
+fn gen_1k_fill(b: &mut Bencher) {
+    let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
+    let mut buf = [0u64; 128];
+    b.iter(|| {
+        rng.fill(&mut buf[..]);
+        buf
+    });
+    b.bytes = 1024;
+}
diff --git a/rustc_deps/vendor/rand/examples/monte-carlo.rs b/rustc_deps/vendor/rand/examples/monte-carlo.rs
new file mode 100644
index 0000000..c18108a
--- /dev/null
+++ b/rustc_deps/vendor/rand/examples/monte-carlo.rs
@@ -0,0 +1,52 @@
+// Copyright 2013-2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// https://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! # Monte Carlo estimation of π
+//!
+//! Imagine that we have a square with sides of length 2 and a unit circle
+//! (radius = 1), both centered at the origin. The areas are:
+//! 
+//! ```text
+//!     area of circle  = πr² = π * r * r = π
+//!     area of square  = 2² = 4
+//! ```
+//!
+//! The circle is entirely within the square, so if we sample many points
+//! randomly from the square, roughly π / 4 of them should be inside the circle.
+//!
+//! We can use the above fact to estimate the value of π: pick many points in
+//! the square at random, calculate the fraction that fall within the circle,
+//! and multiply this fraction by 4.
+
+#![cfg(feature="std")]
+
+
+extern crate rand;
+
+use rand::distributions::{Distribution, Uniform};
+
+fn main() {
+   let range = Uniform::new(-1.0f64, 1.0);
+   let mut rng = rand::thread_rng();
+
+   let total = 1_000_000;
+   let mut in_circle = 0;
+
+   for _ in 0..total {
+       let a = range.sample(&mut rng);
+       let b = range.sample(&mut rng);
+       if a*a + b*b <= 1.0 {
+           in_circle += 1;
+       }
+   }
+
+   // prints something close to 3.14159...
+   println!("π is approximately {}", 4. * (in_circle as f64) / (total as f64));
+}
diff --git a/rustc_deps/vendor/rand/examples/monty-hall.rs b/rustc_deps/vendor/rand/examples/monty-hall.rs
new file mode 100644
index 0000000..3750f8f
--- /dev/null
+++ b/rustc_deps/vendor/rand/examples/monty-hall.rs
@@ -0,0 +1,117 @@
+// Copyright 2013-2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// https://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! ## Monty Hall Problem
+//!
+//! This is a simulation of the [Monty Hall Problem][]:
+//!
+//! > Suppose you're on a game show, and you're given the choice of three doors:
+//! > Behind one door is a car; behind the others, goats. You pick a door, say
+//! > No. 1, and the host, who knows what's behind the doors, opens another
+//! > door, say No. 3, which has a goat. He then says to you, "Do you want to
+//! > pick door No. 2?" Is it to your advantage to switch your choice?
+//!
+//! The rather unintuitive answer is that you will have a 2/3 chance of winning
+//! if you switch and a 1/3 chance of winning if you don't, so it's better to
+//! switch.
+//!
+//! This program will simulate the game show and with large enough simulation
+//! steps it will indeed confirm that it is better to switch.
+//!
+//! [Monty Hall Problem]: https://en.wikipedia.org/wiki/Monty_Hall_problem
+
+#![cfg(feature="std")]
+
+
+extern crate rand;
+
+use rand::Rng;
+use rand::distributions::{Distribution, Uniform};
+
+struct SimulationResult {
+    win: bool,
+    switch: bool,
+}
+
+// Run a single simulation of the Monty Hall problem.
+fn simulate<R: Rng>(random_door: &Uniform<u32>, rng: &mut R)
+                    -> SimulationResult {
+    let car = random_door.sample(rng);
+
+    // This is our initial choice
+    let mut choice = random_door.sample(rng);
+
+    // The game host opens a door
+    let open = game_host_open(car, choice, rng);
+
+    // Shall we switch?
+    let switch = rng.gen();
+    if switch {
+        choice = switch_door(choice, open);
+    }
+
+    SimulationResult { win: choice == car, switch }
+}
+
+// Returns the door the game host opens given our choice and knowledge of
+// where the car is. The game host will never open the door with the car.
+fn game_host_open<R: Rng>(car: u32, choice: u32, rng: &mut R) -> u32 {
+    let choices = free_doors(&[car, choice]);
+    rand::seq::sample_slice(rng, &choices, 1)[0]
+}
+
+// Returns the door we switch to, given our current choice and
+// the open door. There will only be one valid door.
+fn switch_door(choice: u32, open: u32) -> u32 {
+    free_doors(&[choice, open])[0]
+}
+
+fn free_doors(blocked: &[u32]) -> Vec<u32> {
+    (0..3).filter(|x| !blocked.contains(x)).collect()
+}
+
+fn main() {
+    // The estimation will be more accurate with more simulations
+    let num_simulations = 10000;
+
+    let mut rng = rand::thread_rng();
+    let random_door = Uniform::new(0u32, 3);
+
+    let (mut switch_wins, mut switch_losses) = (0, 0);
+    let (mut keep_wins, mut keep_losses) = (0, 0);
+
+    println!("Running {} simulations...", num_simulations);
+    for _ in 0..num_simulations {
+        let result = simulate(&random_door, &mut rng);
+
+        match (result.win, result.switch) {
+            (true, true) => switch_wins += 1,
+            (true, false) => keep_wins += 1,
+            (false, true) => switch_losses += 1,
+            (false, false) => keep_losses += 1,
+        }
+    }
+
+    let total_switches = switch_wins + switch_losses;
+    let total_keeps = keep_wins + keep_losses;
+
+    println!("Switched door {} times with {} wins and {} losses",
+             total_switches, switch_wins, switch_losses);
+
+    println!("Kept our choice {} times with {} wins and {} losses",
+             total_keeps, keep_wins, keep_losses);
+
+    // With a large number of simulations, the values should converge to
+    // 0.667 and 0.333 respectively.
+    println!("Estimated chance to win if we switch: {}",
+             switch_wins as f32 / total_switches as f32);
+    println!("Estimated chance to win if we don't: {}",
+             keep_wins as f32 / total_keeps as f32);
+}
diff --git a/rustc_deps/vendor/rand/src/distributions/bernoulli.rs b/rustc_deps/vendor/rand/src/distributions/bernoulli.rs
new file mode 100644
index 0000000..2361fac
--- /dev/null
+++ b/rustc_deps/vendor/rand/src/distributions/bernoulli.rs
@@ -0,0 +1,120 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// https://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+//! The Bernoulli distribution.
+
+use Rng;
+use distributions::Distribution;
+
+/// The Bernoulli distribution.
+///
+/// This is a special case of the Binomial distribution where `n = 1`.
+///
+/// # Example
+///
+/// ```rust
+/// use rand::distributions::{Bernoulli, Distribution};
+///
+/// let d = Bernoulli::new(0.3);
+/// let v = d.sample(&mut rand::thread_rng());
+/// println!("{} is from a Bernoulli distribution", v);
+/// ```
+///
+/// # Precision
+///
+/// This `Bernoulli` distribution uses 64 bits from the RNG (a `u64`),
+/// so only probabilities that are multiples of 2<sup>-64</sup> can be
+/// represented.
+#[derive(Clone, Copy, Debug)]
+pub struct Bernoulli {
+    /// Probability of success, relative to the maximal integer.
+    p_int: u64,
+}
+
+impl Bernoulli {
+    /// Construct a new `Bernoulli` with the given probability of success `p`.
+    ///
+    /// # Panics
+    ///
+    /// If `p < 0` or `p > 1`.
+    ///
+    /// # Precision
+    ///
+    /// For `p = 1.0`, the resulting distribution will always generate true.
+    /// For `p = 0.0`, the resulting distribution will always generate false.
+    ///
+    /// This method is accurate for any input `p` in the range `[0, 1]` which is
+    /// a multiple of 2<sup>-64</sup>. (Note that not all multiples of
+    /// 2<sup>-64</sup> in `[0, 1]` can be represented as a `f64`.)
+    #[inline]
+    pub fn new(p: f64) -> Bernoulli {
+        assert!((p >= 0.0) & (p <= 1.0), "Bernoulli::new not called with 0 <= p <= 0");
+        // Technically, this should be 2^64 or `u64::MAX + 1` because we compare
+        // using `<` when sampling. However, `u64::MAX` rounds to an `f64`
+        // larger than `u64::MAX` anyway.
+        const MAX_P_INT: f64 = ::core::u64::MAX as f64;
+        let p_int = if p < 1.0 {
+            (p * MAX_P_INT) as u64
+        } else {
+            // Avoid overflow: `MAX_P_INT` cannot be represented as u64.
+            ::core::u64::MAX
+        };
+        Bernoulli { p_int }
+    }
+}
+
+impl Distribution<bool> for Bernoulli {
+    #[inline]
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> bool {
+        // Make sure to always return true for p = 1.0.
+        if self.p_int == ::core::u64::MAX {
+            return true;
+        }
+        let r: u64 = rng.gen();
+        r < self.p_int
+    }
+}
+
+#[cfg(test)]
+mod test {
+    use Rng;
+    use distributions::Distribution;
+    use super::Bernoulli;
+
+    #[test]
+    fn test_trivial() {
+        let mut r = ::test::rng(1);
+        let always_false = Bernoulli::new(0.0);
+        let always_true = Bernoulli::new(1.0);
+        for _ in 0..5 {
+            assert_eq!(r.sample::<bool, _>(&always_false), false);
+            assert_eq!(r.sample::<bool, _>(&always_true), true);
+            assert_eq!(Distribution::<bool>::sample(&always_false, &mut r), false);
+            assert_eq!(Distribution::<bool>::sample(&always_true, &mut r), true);
+        }
+    }
+
+    #[test]
+    fn test_average() {
+        const P: f64 = 0.3;
+        let d = Bernoulli::new(P);
+        const N: u32 = 10_000_000;
+
+        let mut sum: u32 = 0;
+        let mut rng = ::test::rng(2);
+        for _ in 0..N {
+            if d.sample(&mut rng) {
+                sum += 1;
+            }
+        }
+        let avg = (sum as f64) / (N as f64);
+
+        assert!((avg - P).abs() < 1e-3);
+    }
+}
diff --git a/rustc_deps/vendor/rand/src/distributions/binomial.rs b/rustc_deps/vendor/rand/src/distributions/binomial.rs
new file mode 100644
index 0000000..5eb03e3
--- /dev/null
+++ b/rustc_deps/vendor/rand/src/distributions/binomial.rs
@@ -0,0 +1,178 @@
+// Copyright 2016-2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// https://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! The binomial distribution.
+
+use Rng;
+use distributions::{Distribution, Bernoulli, Cauchy};
+use distributions::log_gamma::log_gamma;
+
+/// The binomial distribution `Binomial(n, p)`.
+///
+/// This distribution has density function:
+/// `f(k) = n!/(k! (n-k)!) p^k (1-p)^(n-k)` for `k >= 0`.
+///
+/// # Example
+///
+/// ```
+/// use rand::distributions::{Binomial, Distribution};
+///
+/// let bin = Binomial::new(20, 0.3);
+/// let v = bin.sample(&mut rand::thread_rng());
+/// println!("{} is from a binomial distribution", v);
+/// ```
+#[derive(Clone, Copy, Debug)]
+pub struct Binomial {
+    /// Number of trials.
+    n: u64,
+    /// Probability of success.
+    p: f64,
+}
+
+impl Binomial {
+    /// Construct a new `Binomial` with the given shape parameters `n` (number
+    /// of trials) and `p` (probability of success).
+    ///
+    /// Panics if `p < 0` or `p > 1`.
+    pub fn new(n: u64, p: f64) -> Binomial {
+        assert!(p >= 0.0, "Binomial::new called with p < 0");
+        assert!(p <= 1.0, "Binomial::new called with p > 1");
+        Binomial { n, p }
+    }
+}
+
+impl Distribution<u64> for Binomial {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u64 {
+        // Handle these values directly.
+        if self.p == 0.0 {
+            return 0;
+        } else if self.p == 1.0 {
+            return self.n;
+        }
+        
+        // For low n, it is faster to sample directly. For both methods,
+        // performance is independent of p. On Intel Haswell CPU this method
+        // appears to be faster for approx n < 300.
+        if self.n < 300 {
+            let mut result = 0;
+            let d = Bernoulli::new(self.p);
+            for _ in 0 .. self.n {
+                result += rng.sample(d) as u32;
+            }
+            return result as u64;
+        }
+        
+        // binomial distribution is symmetrical with respect to p -> 1-p, k -> n-k
+        // switch p so that it is less than 0.5 - this allows for lower expected values
+        // we will just invert the result at the end
+        let p = if self.p <= 0.5 {
+            self.p
+        } else {
+            1.0 - self.p
+        };
+
+        // prepare some cached values
+        let float_n = self.n as f64;
+        let ln_fact_n = log_gamma(float_n + 1.0);
+        let pc = 1.0 - p;
+        let log_p = p.ln();
+        let log_pc = pc.ln();
+        let expected = self.n as f64 * p;
+        let sq = (expected * (2.0 * pc)).sqrt();
+
+        let mut lresult;
+
+        // we use the Cauchy distribution as the comparison distribution
+        // f(x) ~ 1/(1+x^2)
+        let cauchy = Cauchy::new(0.0, 1.0);
+        loop {
+            let mut comp_dev: f64;
+            loop {
+                // draw from the Cauchy distribution
+                comp_dev = rng.sample(cauchy);
+                // shift the peak of the comparison ditribution
+                lresult = expected + sq * comp_dev;
+                // repeat the drawing until we are in the range of possible values
+                if lresult >= 0.0 && lresult < float_n + 1.0 {
+                    break;
+                }
+            }
+
+            // the result should be discrete
+            lresult = lresult.floor();
+
+            let log_binomial_dist = ln_fact_n - log_gamma(lresult+1.0) -
+                log_gamma(float_n - lresult + 1.0) + lresult*log_p + (float_n - lresult)*log_pc;
+            // this is the binomial probability divided by the comparison probability
+            // we will generate a uniform random value and if it is larger than this,
+            // we interpret it as a value falling out of the distribution and repeat
+            let comparison_coeff = (log_binomial_dist.exp() * sq) * (1.2 * (1.0 + comp_dev*comp_dev));
+
+            if comparison_coeff >= rng.gen() {
+                break;
+            }
+        }
+
+        // invert the result for p < 0.5
+        if p != self.p {
+            self.n - lresult as u64
+        } else {
+            lresult as u64
+        }
+    }
+}
+
+#[cfg(test)]
+mod test {
+    use Rng;
+    use distributions::Distribution;
+    use super::Binomial;
+
+    fn test_binomial_mean_and_variance<R: Rng>(n: u64, p: f64, rng: &mut R) {
+        let binomial = Binomial::new(n, p);
+
+        let expected_mean = n as f64 * p;
+        let expected_variance = n as f64 * p * (1.0 - p);
+
+        let mut results = [0.0; 1000];
+        for i in results.iter_mut() { *i = binomial.sample(rng) as f64; }
+
+        let mean = results.iter().sum::<f64>() / results.len() as f64;
+        assert!((mean as f64 - expected_mean).abs() < expected_mean / 50.0);
+
+        let variance =
+            results.iter().map(|x| (x - mean) * (x - mean)).sum::<f64>()
+            / results.len() as f64;
+        assert!((variance - expected_variance).abs() < expected_variance / 10.0);
+    }
+
+    #[test]
+    fn test_binomial() {
+        let mut rng = ::test::rng(351);
+        test_binomial_mean_and_variance(150, 0.1, &mut rng);
+        test_binomial_mean_and_variance(70, 0.6, &mut rng);
+        test_binomial_mean_and_variance(40, 0.5, &mut rng);
+        test_binomial_mean_and_variance(20, 0.7, &mut rng);
+        test_binomial_mean_and_variance(20, 0.5, &mut rng);
+    }
+
+    #[test]
+    fn test_binomial_end_points() {
+        let mut rng = ::test::rng(352);
+        assert_eq!(rng.sample(Binomial::new(20, 0.0)), 0);
+        assert_eq!(rng.sample(Binomial::new(20, 1.0)), 20);
+    }
+
+    #[test]
+    #[should_panic]
+    fn test_binomial_invalid_lambda_neg() {
+        Binomial::new(20, -10.0);
+    }
+}
diff --git a/rustc_deps/vendor/rand/src/distributions/cauchy.rs b/rustc_deps/vendor/rand/src/distributions/cauchy.rs
new file mode 100644
index 0000000..5ac55bd
--- /dev/null
+++ b/rustc_deps/vendor/rand/src/distributions/cauchy.rs
@@ -0,0 +1,116 @@
+// Copyright 2016-2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// https://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! The Cauchy distribution.
+
+use Rng;
+use distributions::Distribution;
+use std::f64::consts::PI;
+
+/// The Cauchy distribution `Cauchy(median, scale)`.
+///
+/// This distribution has a density function:
+/// `f(x) = 1 / (pi * scale * (1 + ((x - median) / scale)^2))`
+///
+/// # Example
+///
+/// ```
+/// use rand::distributions::{Cauchy, Distribution};
+///
+/// let cau = Cauchy::new(2.0, 5.0);
+/// let v = cau.sample(&mut rand::thread_rng());
+/// println!("{} is from a Cauchy(2, 5) distribution", v);
+/// ```
+#[derive(Clone, Copy, Debug)]
+pub struct Cauchy {
+    median: f64,
+    scale: f64
+}
+
+impl Cauchy {
+    /// Construct a new `Cauchy` with the given shape parameters
+    /// `median` the peak location and `scale` the scale factor.
+    /// Panics if `scale <= 0`.
+    pub fn new(median: f64, scale: f64) -> Cauchy {
+        assert!(scale > 0.0, "Cauchy::new called with scale factor <= 0");
+        Cauchy {
+            median,
+            scale
+        }
+    }
+}
+
+impl Distribution<f64> for Cauchy {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
+        // sample from [0, 1)
+        let x = rng.gen::<f64>();
+        // get standard cauchy random number
+        // note that π/2 is not exactly representable, even if x=0.5 the result is finite
+        let comp_dev = (PI * x).tan();
+        // shift and scale according to parameters
+        let result = self.median + self.scale * comp_dev;
+        result
+    }
+}
+
+#[cfg(test)]
+mod test {
+    use distributions::Distribution;
+    use super::Cauchy;
+
+    fn median(mut numbers: &mut [f64]) -> f64 {
+        sort(&mut numbers);
+        let mid = numbers.len() / 2;
+        numbers[mid]
+    }
+
+    fn sort(numbers: &mut [f64]) {
+        numbers.sort_by(|a, b| a.partial_cmp(b).unwrap());
+    }
+
+    #[test]
+    fn test_cauchy_median() {
+        let cauchy = Cauchy::new(10.0, 5.0);
+        let mut rng = ::test::rng(123);
+        let mut numbers: [f64; 1000] = [0.0; 1000];
+        for i in 0..1000 {
+            numbers[i] = cauchy.sample(&mut rng);
+        }
+        let median = median(&mut numbers);
+        println!("Cauchy median: {}", median);
+        assert!((median - 10.0).abs() < 0.5); // not 100% certain, but probable enough
+    }
+
+    #[test]
+    fn test_cauchy_mean() {
+        let cauchy = Cauchy::new(10.0, 5.0);
+        let mut rng = ::test::rng(123);
+        let mut sum = 0.0;
+        for _ in 0..1000 {
+            sum += cauchy.sample(&mut rng);
+        }
+        let mean = sum / 1000.0;
+        println!("Cauchy mean: {}", mean);
+        // for a Cauchy distribution the mean should not converge
+        assert!((mean - 10.0).abs() > 0.5); // not 100% certain, but probable enough
+    }
+
+    #[test]
+    #[should_panic]
+    fn test_cauchy_invalid_scale_zero() {
+        Cauchy::new(0.0, 0.0);
+    }
+
+    #[test]
+    #[should_panic]
+    fn test_cauchy_invalid_scale_neg() {
+        Cauchy::new(0.0, -10.0);
+    }
+}
diff --git a/rustc_deps/vendor/rand/src/distributions/exponential.rs b/rustc_deps/vendor/rand/src/distributions/exponential.rs
index c3c924c..e8dbdc9 100644
--- a/rustc_deps/vendor/rand/src/distributions/exponential.rs
+++ b/rustc_deps/vendor/rand/src/distributions/exponential.rs
@@ -1,74 +1,76 @@
 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
+// https://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
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
 //! The exponential distribution.
 
-use {Rng, Rand};
-use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
+use {Rng};
+use distributions::{ziggurat, ziggurat_tables, Distribution};
 
-/// A wrapper around an `f64` to generate Exp(1) random numbers.
+/// Samples floating-point numbers according to the exponential distribution,
+/// with rate parameter `λ = 1`. This is equivalent to `Exp::new(1.0)` or
+/// sampling with `-rng.gen::<f64>().ln()`, but faster.
 ///
 /// See `Exp` for the general exponential distribution.
 ///
-/// Implemented via the ZIGNOR variant[1] of the Ziggurat method. The
-/// exact description in the paper was adjusted to use tables for the
-/// exponential distribution rather than normal.
+/// Implemented via the ZIGNOR variant[^1] of the Ziggurat method. The exact
+/// description in the paper was adjusted to use tables for the exponential
+/// distribution rather than normal.
 ///
-/// [1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to
-/// Generate Normal Random
-/// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield
-/// College, Oxford
+/// [^1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to
+///       Generate Normal Random Samples*](
+///       https://www.doornik.com/research/ziggurat.pdf).
+///       Nuffield College, Oxford
 ///
 /// # Example
+/// ```
+/// use rand::prelude::*;
+/// use rand::distributions::Exp1;
 ///
-/// ```rust
-/// use rand::distributions::exponential::Exp1;
-///
-/// let Exp1(x) = rand::random();
-/// println!("{}", x);
+/// let val: f64 = SmallRng::from_entropy().sample(Exp1);
+/// println!("{}", val);
 /// ```
 #[derive(Clone, Copy, Debug)]
-pub struct Exp1(pub f64);
+pub struct Exp1;
 
 // This could be done via `-rng.gen::<f64>().ln()` but that is slower.
-impl Rand for Exp1 {
+impl Distribution<f64> for Exp1 {
     #[inline]
-    fn rand<R:Rng>(rng: &mut R) -> Exp1 {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
         #[inline]
         fn pdf(x: f64) -> f64 {
             (-x).exp()
         }
         #[inline]
-        fn zero_case<R:Rng>(rng: &mut R, _u: f64) -> f64 {
+        fn zero_case<R: Rng + ?Sized>(rng: &mut R, _u: f64) -> f64 {
             ziggurat_tables::ZIG_EXP_R - rng.gen::<f64>().ln()
         }
 
-        Exp1(ziggurat(rng, false,
-                      &ziggurat_tables::ZIG_EXP_X,
-                      &ziggurat_tables::ZIG_EXP_F,
-                      pdf, zero_case))
+        ziggurat(rng, false,
+                 &ziggurat_tables::ZIG_EXP_X,
+                 &ziggurat_tables::ZIG_EXP_F,
+                 pdf, zero_case)
     }
 }
 
 /// The exponential distribution `Exp(lambda)`.
 ///
-/// This distribution has density function: `f(x) = lambda *
-/// exp(-lambda * x)` for `x > 0`.
+/// This distribution has density function: `f(x) = lambda * exp(-lambda * x)`
+/// for `x > 0`.
 ///
 /// # Example
 ///
-/// ```rust
-/// use rand::distributions::{Exp, IndependentSample};
+/// ```
+/// use rand::distributions::{Exp, Distribution};
 ///
 /// let exp = Exp::new(2.0);
-/// let v = exp.ind_sample(&mut rand::thread_rng());
+/// let v = exp.sample(&mut rand::thread_rng());
 /// println!("{} is from a Exp(2) distribution", v);
 /// ```
 #[derive(Clone, Copy, Debug)]
@@ -87,28 +89,24 @@
     }
 }
 
-impl Sample<f64> for Exp {
-    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
-}
-impl IndependentSample<f64> for Exp {
-    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
-        let Exp1(n) = rng.gen::<Exp1>();
+impl Distribution<f64> for Exp {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
+        let n: f64 = rng.sample(Exp1);
         n * self.lambda_inverse
     }
 }
 
 #[cfg(test)]
 mod test {
-    use distributions::{Sample, IndependentSample};
+    use distributions::Distribution;
     use super::Exp;
 
     #[test]
     fn test_exp() {
-        let mut exp = Exp::new(10.0);
-        let mut rng = ::test::rng();
+        let exp = Exp::new(10.0);
+        let mut rng = ::test::rng(221);
         for _ in 0..1000 {
             assert!(exp.sample(&mut rng) >= 0.0);
-            assert!(exp.ind_sample(&mut rng) >= 0.0);
         }
     }
     #[test]
diff --git a/rustc_deps/vendor/rand/src/distributions/float.rs b/rustc_deps/vendor/rand/src/distributions/float.rs
new file mode 100644
index 0000000..0058122
--- /dev/null
+++ b/rustc_deps/vendor/rand/src/distributions/float.rs
@@ -0,0 +1,206 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// https://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Basic floating-point number distributions
+
+use core::mem;
+use Rng;
+use distributions::{Distribution, Standard};
+
+/// A distribution to sample floating point numbers uniformly in the half-open
+/// interval `(0, 1]`, i.e. including 1 but not 0.
+///
+/// All values that can be generated are of the form `n * ε/2`. For `f32`
+/// the 23 most significant random bits of a `u32` are used and for `f64` the
+/// 53 most significant bits of a `u64` are used. The conversion uses the
+/// multiplicative method.
+///
+/// See also: [`Standard`] which samples from `[0, 1)`, [`Open01`]
+/// which samples from `(0, 1)` and [`Uniform`] which samples from arbitrary
+/// ranges.
+///
+/// # Example
+/// ```
+/// use rand::{thread_rng, Rng};
+/// use rand::distributions::OpenClosed01;
+///
+/// let val: f32 = thread_rng().sample(OpenClosed01);
+/// println!("f32 from (0, 1): {}", val);
+/// ```
+///
+/// [`Standard`]: struct.Standard.html
+/// [`Open01`]: struct.Open01.html
+/// [`Uniform`]: uniform/struct.Uniform.html
+#[derive(Clone, Copy, Debug)]
+pub struct OpenClosed01;
+
+/// A distribution to sample floating point numbers uniformly in the open
+/// interval `(0, 1)`, i.e. not including either endpoint.
+///
+/// All values that can be generated are of the form `n * ε + ε/2`. For `f32`
+/// the 22 most significant random bits of an `u32` are used, for `f64` 52 from
+/// an `u64`. The conversion uses a transmute-based method.
+///
+/// See also: [`Standard`] which samples from `[0, 1)`, [`OpenClosed01`]
+/// which samples from `(0, 1]` and [`Uniform`] which samples from arbitrary
+/// ranges.
+///
+/// # Example
+/// ```
+/// use rand::{thread_rng, Rng};
+/// use rand::distributions::Open01;
+///
+/// let val: f32 = thread_rng().sample(Open01);
+/// println!("f32 from (0, 1): {}", val);
+/// ```
+///
+/// [`Standard`]: struct.Standard.html
+/// [`OpenClosed01`]: struct.OpenClosed01.html
+/// [`Uniform`]: uniform/struct.Uniform.html
+#[derive(Clone, Copy, Debug)]
+pub struct Open01;
+
+
+pub(crate) trait IntoFloat {
+    type F;
+
+    /// Helper method to combine the fraction and a contant exponent into a
+    /// float.
+    ///
+    /// Only the least significant bits of `self` may be set, 23 for `f32` and
+    /// 52 for `f64`.
+    /// The resulting value will fall in a range that depends on the exponent.
+    /// As an example the range with exponent 0 will be
+    /// [2<sup>0</sup>..2<sup>1</sup>), which is [1..2).
+    fn into_float_with_exponent(self, exponent: i32) -> Self::F;
+}
+
+macro_rules! float_impls {
+    ($ty:ty, $uty:ty, $fraction_bits:expr, $exponent_bias:expr) => {
+        impl IntoFloat for $uty {
+            type F = $ty;
+            #[inline(always)]
+            fn into_float_with_exponent(self, exponent: i32) -> $ty {
+                // The exponent is encoded using an offset-binary representation
+                let exponent_bits =
+                    (($exponent_bias + exponent) as $uty) << $fraction_bits;
+                unsafe { mem::transmute(self | exponent_bits) }
+            }
+        }
+
+        impl Distribution<$ty> for Standard {
+            fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> $ty {
+                // Multiply-based method; 24/53 random bits; [0, 1) interval.
+                // We use the most significant bits because for simple RNGs
+                // those are usually more random.
+                let float_size = mem::size_of::<$ty>() * 8;
+                let precision = $fraction_bits + 1;
+                let scale = 1.0 / ((1 as $uty << precision) as $ty);
+
+                let value: $uty = rng.gen();
+                scale * (value >> (float_size - precision)) as $ty
+            }
+        }
+
+        impl Distribution<$ty> for OpenClosed01 {
+            fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> $ty {
+                // Multiply-based method; 24/53 random bits; (0, 1] interval.
+                // We use the most significant bits because for simple RNGs
+                // those are usually more random.
+                let float_size = mem::size_of::<$ty>() * 8;
+                let precision = $fraction_bits + 1;
+                let scale = 1.0 / ((1 as $uty << precision) as $ty);
+
+                let value: $uty = rng.gen();
+                let value = value >> (float_size - precision);
+                // Add 1 to shift up; will not overflow because of right-shift:
+                scale * (value + 1) as $ty
+            }
+        }
+
+        impl Distribution<$ty> for Open01 {
+            fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> $ty {
+                // Transmute-based method; 23/52 random bits; (0, 1) interval.
+                // We use the most significant bits because for simple RNGs
+                // those are usually more random.
+                const EPSILON: $ty = 1.0 / (1u64 << $fraction_bits) as $ty;
+                let float_size = mem::size_of::<$ty>() * 8;
+
+                let value: $uty = rng.gen();
+                let fraction = value >> (float_size - $fraction_bits);
+                fraction.into_float_with_exponent(0) - (1.0 - EPSILON / 2.0)
+            }
+        }
+    }
+}
+float_impls! { f32, u32, 23, 127 }
+float_impls! { f64, u64, 52, 1023 }
+
+
+#[cfg(test)]
+mod tests {
+    use Rng;
+    use distributions::{Open01, OpenClosed01};
+    use rngs::mock::StepRng;
+
+    const EPSILON32: f32 = ::core::f32::EPSILON;
+    const EPSILON64: f64 = ::core::f64::EPSILON;
+
+    #[test]
+    fn standard_fp_edge_cases() {
+        let mut zeros = StepRng::new(0, 0);
+        assert_eq!(zeros.gen::<f32>(), 0.0);
+        assert_eq!(zeros.gen::<f64>(), 0.0);
+
+        let mut one32 = StepRng::new(1 << 8, 0);
+        assert_eq!(one32.gen::<f32>(), EPSILON32 / 2.0);
+
+        let mut one64 = StepRng::new(1 << 11, 0);
+        assert_eq!(one64.gen::<f64>(), EPSILON64 / 2.0);
+
+        let mut max = StepRng::new(!0, 0);
+        assert_eq!(max.gen::<f32>(), 1.0 - EPSILON32 / 2.0);
+        assert_eq!(max.gen::<f64>(), 1.0 - EPSILON64 / 2.0);
+    }
+
+    #[test]
+    fn openclosed01_edge_cases() {
+        let mut zeros = StepRng::new(0, 0);
+        assert_eq!(zeros.sample::<f32, _>(OpenClosed01), 0.0 + EPSILON32 / 2.0);
+        assert_eq!(zeros.sample::<f64, _>(OpenClosed01), 0.0 + EPSILON64 / 2.0);
+
+        let mut one32 = StepRng::new(1 << 8, 0);
+        assert_eq!(one32.sample::<f32, _>(OpenClosed01), EPSILON32);
+
+        let mut one64 = StepRng::new(1 << 11, 0);
+        assert_eq!(one64.sample::<f64, _>(OpenClosed01), EPSILON64);
+
+        let mut max = StepRng::new(!0, 0);
+        assert_eq!(max.sample::<f32, _>(OpenClosed01), 1.0);
+        assert_eq!(max.sample::<f64, _>(OpenClosed01), 1.0);
+    }
+
+    #[test]
+    fn open01_edge_cases() {
+        let mut zeros = StepRng::new(0, 0);
+        assert_eq!(zeros.sample::<f32, _>(Open01), 0.0 + EPSILON32 / 2.0);
+        assert_eq!(zeros.sample::<f64, _>(Open01), 0.0 + EPSILON64 / 2.0);
+
+        let mut one32 = StepRng::new(1 << 9, 0);
+        assert_eq!(one32.sample::<f32, _>(Open01), EPSILON32 / 2.0 * 3.0);
+
+        let mut one64 = StepRng::new(1 << 12, 0);
+        assert_eq!(one64.sample::<f64, _>(Open01), EPSILON64 / 2.0 * 3.0);
+
+        let mut max = StepRng::new(!0, 0);
+        assert_eq!(max.sample::<f32, _>(Open01), 1.0 - EPSILON32 / 2.0);
+        assert_eq!(max.sample::<f64, _>(Open01), 1.0 - EPSILON64 / 2.0);
+    }
+}
diff --git a/rustc_deps/vendor/rand/src/distributions/gamma.rs b/rustc_deps/vendor/rand/src/distributions/gamma.rs
index 2806495..f02cf3b 100644
--- a/rustc_deps/vendor/rand/src/distributions/gamma.rs
+++ b/rustc_deps/vendor/rand/src/distributions/gamma.rs
@@ -1,23 +1,21 @@
 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
+// https://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
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
-//
-// ignore-lexer-test FIXME #15679
 
 //! The Gamma and derived distributions.
 
 use self::GammaRepr::*;
 use self::ChiSquaredRepr::*;
 
-use {Rng, Open01};
-use super::normal::StandardNormal;
-use super::{IndependentSample, Sample, Exp};
+use Rng;
+use distributions::normal::StandardNormal;
+use distributions::{Distribution, Exp, Open01};
 
 /// The Gamma distribution `Gamma(shape, scale)` distribution.
 ///
@@ -30,25 +28,25 @@
 /// where `Γ` is the Gamma function, `k` is the shape and `θ` is the
 /// scale and both `k` and `θ` are strictly positive.
 ///
-/// The algorithm used is that described by Marsaglia & Tsang 2000[1],
+/// The algorithm used is that described by Marsaglia & Tsang 2000[^1],
 /// falling back to directly sampling from an Exponential for `shape
-/// == 1`, and using the boosting technique described in [1] for
+/// == 1`, and using the boosting technique described in that paper for
 /// `shape < 1`.
 ///
 /// # Example
 ///
-/// ```rust
-/// use rand::distributions::{IndependentSample, Gamma};
+/// ```
+/// use rand::distributions::{Distribution, Gamma};
 ///
 /// let gamma = Gamma::new(2.0, 5.0);
-/// let v = gamma.ind_sample(&mut rand::thread_rng());
+/// let v = gamma.sample(&mut rand::thread_rng());
 /// println!("{} is from a Gamma(2, 5) distribution", v);
 /// ```
 ///
-/// [1]: George Marsaglia and Wai Wan Tsang. 2000. "A Simple Method
-/// for Generating Gamma Variables" *ACM Trans. Math. Softw.* 26, 3
-/// (September 2000),
-/// 363-372. DOI:[10.1145/358407.358414](http://doi.acm.org/10.1145/358407.358414)
+/// [^1]: George Marsaglia and Wai Wan Tsang. 2000. "A Simple Method for
+///       Generating Gamma Variables" *ACM Trans. Math. Softw.* 26, 3
+///       (September 2000), 363-372.
+///       DOI:[10.1145/358407.358414](https://doi.acm.org/10.1145/358407.358414)
 #[derive(Clone, Copy, Debug)]
 pub struct Gamma {
     repr: GammaRepr,
@@ -109,7 +107,7 @@
         } else {
             Large(GammaLargeShape::new_raw(shape, scale))
         };
-        Gamma { repr: repr }
+        Gamma { repr }
     }
 }
 
@@ -126,50 +124,40 @@
     fn new_raw(shape: f64, scale: f64) -> GammaLargeShape {
         let d = shape - 1. / 3.;
         GammaLargeShape {
-            scale: scale,
+            scale,
             c: 1. / (9. * d).sqrt(),
-            d: d
+            d
         }
     }
 }
 
-impl Sample<f64> for Gamma {
-    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
-}
-impl Sample<f64> for GammaSmallShape {
-    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
-}
-impl Sample<f64> for GammaLargeShape {
-    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
-}
-
-impl IndependentSample<f64> for Gamma {
-    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
+impl Distribution<f64> for Gamma {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
         match self.repr {
-            Small(ref g) => g.ind_sample(rng),
-            One(ref g) => g.ind_sample(rng),
-            Large(ref g) => g.ind_sample(rng),
+            Small(ref g) => g.sample(rng),
+            One(ref g) => g.sample(rng),
+            Large(ref g) => g.sample(rng),
         }
     }
 }
-impl IndependentSample<f64> for GammaSmallShape {
-    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
-        let Open01(u) = rng.gen::<Open01<f64>>();
+impl Distribution<f64> for GammaSmallShape {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
+        let u: f64 = rng.sample(Open01);
 
-        self.large_shape.ind_sample(rng) * u.powf(self.inv_shape)
+        self.large_shape.sample(rng) * u.powf(self.inv_shape)
     }
 }
-impl IndependentSample<f64> for GammaLargeShape {
-    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
+impl Distribution<f64> for GammaLargeShape {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
         loop {
-            let StandardNormal(x) = rng.gen::<StandardNormal>();
+            let x = rng.sample(StandardNormal);
             let v_cbrt = 1.0 + self.c * x;
             if v_cbrt <= 0.0 { // a^3 <= 0 iff a <= 0
                 continue
             }
 
             let v = v_cbrt * v_cbrt * v_cbrt;
-            let Open01(u) = rng.gen::<Open01<f64>>();
+            let u: f64 = rng.sample(Open01);
 
             let x_sqr = x * x;
             if u < 1.0 - 0.0331 * x_sqr * x_sqr ||
@@ -190,11 +178,11 @@
 ///
 /// # Example
 ///
-/// ```rust
-/// use rand::distributions::{ChiSquared, IndependentSample};
+/// ```
+/// use rand::distributions::{ChiSquared, Distribution};
 ///
 /// let chi = ChiSquared::new(11.0);
-/// let v = chi.ind_sample(&mut rand::thread_rng());
+/// let v = chi.sample(&mut rand::thread_rng());
 /// println!("{} is from a χ²(11) distribution", v)
 /// ```
 #[derive(Clone, Copy, Debug)]
@@ -221,21 +209,18 @@
             assert!(k > 0.0, "ChiSquared::new called with `k` < 0");
             DoFAnythingElse(Gamma::new(0.5 * k, 2.0))
         };
-        ChiSquared { repr: repr }
+        ChiSquared { repr }
     }
 }
-impl Sample<f64> for ChiSquared {
-    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
-}
-impl IndependentSample<f64> for ChiSquared {
-    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
+impl Distribution<f64> for ChiSquared {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
         match self.repr {
             DoFExactlyOne => {
                 // k == 1 => N(0,1)^2
-                let StandardNormal(norm) = rng.gen::<StandardNormal>();
+                let norm = rng.sample(StandardNormal);
                 norm * norm
             }
-            DoFAnythingElse(ref g) => g.ind_sample(rng)
+            DoFAnythingElse(ref g) => g.sample(rng)
         }
     }
 }
@@ -248,11 +233,11 @@
 ///
 /// # Example
 ///
-/// ```rust
-/// use rand::distributions::{FisherF, IndependentSample};
+/// ```
+/// use rand::distributions::{FisherF, Distribution};
 ///
 /// let f = FisherF::new(2.0, 32.0);
-/// let v = f.ind_sample(&mut rand::thread_rng());
+/// let v = f.sample(&mut rand::thread_rng());
 /// println!("{} is from an F(2, 32) distribution", v)
 /// ```
 #[derive(Clone, Copy, Debug)]
@@ -278,12 +263,9 @@
         }
     }
 }
-impl Sample<f64> for FisherF {
-    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
-}
-impl IndependentSample<f64> for FisherF {
-    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
-        self.numer.ind_sample(rng) / self.denom.ind_sample(rng) * self.dof_ratio
+impl Distribution<f64> for FisherF {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
+        self.numer.sample(rng) / self.denom.sample(rng) * self.dof_ratio
     }
 }
 
@@ -292,11 +274,11 @@
 ///
 /// # Example
 ///
-/// ```rust
-/// use rand::distributions::{StudentT, IndependentSample};
+/// ```
+/// use rand::distributions::{StudentT, Distribution};
 ///
 /// let t = StudentT::new(11.0);
-/// let v = t.ind_sample(&mut rand::thread_rng());
+/// let v = t.sample(&mut rand::thread_rng());
 /// println!("{} is from a t(11) distribution", v)
 /// ```
 #[derive(Clone, Copy, Debug)]
@@ -316,46 +298,40 @@
         }
     }
 }
-impl Sample<f64> for StudentT {
-    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
-}
-impl IndependentSample<f64> for StudentT {
-    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
-        let StandardNormal(norm) = rng.gen::<StandardNormal>();
-        norm * (self.dof / self.chi.ind_sample(rng)).sqrt()
+impl Distribution<f64> for StudentT {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
+        let norm = rng.sample(StandardNormal);
+        norm * (self.dof / self.chi.sample(rng)).sqrt()
     }
 }
 
 #[cfg(test)]
 mod test {
-    use distributions::{Sample, IndependentSample};
+    use distributions::Distribution;
     use super::{ChiSquared, StudentT, FisherF};
 
     #[test]
     fn test_chi_squared_one() {
-        let mut chi = ChiSquared::new(1.0);
-        let mut rng = ::test::rng();
+        let chi = ChiSquared::new(1.0);
+        let mut rng = ::test::rng(201);
         for _ in 0..1000 {
             chi.sample(&mut rng);
-            chi.ind_sample(&mut rng);
         }
     }
     #[test]
     fn test_chi_squared_small() {
-        let mut chi = ChiSquared::new(0.5);
-        let mut rng = ::test::rng();
+        let chi = ChiSquared::new(0.5);
+        let mut rng = ::test::rng(202);
         for _ in 0..1000 {
             chi.sample(&mut rng);
-            chi.ind_sample(&mut rng);
         }
     }
     #[test]
     fn test_chi_squared_large() {
-        let mut chi = ChiSquared::new(30.0);
-        let mut rng = ::test::rng();
+        let chi = ChiSquared::new(30.0);
+        let mut rng = ::test::rng(203);
         for _ in 0..1000 {
             chi.sample(&mut rng);
-            chi.ind_sample(&mut rng);
         }
     }
     #[test]
@@ -366,21 +342,19 @@
 
     #[test]
     fn test_f() {
-        let mut f = FisherF::new(2.0, 32.0);
-        let mut rng = ::test::rng();
+        let f = FisherF::new(2.0, 32.0);
+        let mut rng = ::test::rng(204);
         for _ in 0..1000 {
             f.sample(&mut rng);
-            f.ind_sample(&mut rng);
         }
     }
 
     #[test]
     fn test_t() {
-        let mut t = StudentT::new(11.0);
-        let mut rng = ::test::rng();
+        let t = StudentT::new(11.0);
+        let mut rng = ::test::rng(205);
         for _ in 0..1000 {
             t.sample(&mut rng);
-            t.ind_sample(&mut rng);
         }
     }
 }
diff --git a/rustc_deps/vendor/rand/src/distributions/integer.rs b/rustc_deps/vendor/rand/src/distributions/integer.rs
new file mode 100644
index 0000000..a23ddd5
--- /dev/null
+++ b/rustc_deps/vendor/rand/src/distributions/integer.rs
@@ -0,0 +1,113 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// https://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! The implementations of the `Standard` distribution for integer types.
+
+use {Rng};
+use distributions::{Distribution, Standard};
+
+impl Distribution<u8> for Standard {
+    #[inline]
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u8 {
+        rng.next_u32() as u8
+    }
+}
+
+impl Distribution<u16> for Standard {
+    #[inline]
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u16 {
+        rng.next_u32() as u16
+    }
+}
+
+impl Distribution<u32> for Standard {
+    #[inline]
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u32 {
+        rng.next_u32()
+    }
+}
+
+impl Distribution<u64> for Standard {
+    #[inline]
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u64 {
+        rng.next_u64()
+    }
+}
+
+#[cfg(feature = "i128_support")]
+impl Distribution<u128> for Standard {
+    #[inline]
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u128 {
+        // Use LE; we explicitly generate one value before the next.
+        let x = rng.next_u64() as u128;
+        let y = rng.next_u64() as u128;
+        (y << 64) | x
+    }
+}
+
+impl Distribution<usize> for Standard {
+    #[inline]
+    #[cfg(any(target_pointer_width = "32", target_pointer_width = "16"))]
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> usize {
+        rng.next_u32() as usize
+    }
+
+    #[inline]
+    #[cfg(target_pointer_width = "64")]
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> usize {
+        rng.next_u64() as usize
+    }
+}
+
+macro_rules! impl_int_from_uint {
+    ($ty:ty, $uty:ty) => {
+        impl Distribution<$ty> for Standard {
+            #[inline]
+            fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> $ty {
+                rng.gen::<$uty>() as $ty
+            }
+        }
+    }
+}
+
+impl_int_from_uint! { i8, u8 }
+impl_int_from_uint! { i16, u16 }
+impl_int_from_uint! { i32, u32 }
+impl_int_from_uint! { i64, u64 }
+#[cfg(feature = "i128_support")] impl_int_from_uint! { i128, u128 }
+impl_int_from_uint! { isize, usize }
+
+
+#[cfg(test)]
+mod tests {
+    use Rng;
+    use distributions::{Standard};
+    
+    #[test]
+    fn test_integers() {
+        let mut rng = ::test::rng(806);
+        
+        rng.sample::<isize, _>(Standard);
+        rng.sample::<i8, _>(Standard);
+        rng.sample::<i16, _>(Standard);
+        rng.sample::<i32, _>(Standard);
+        rng.sample::<i64, _>(Standard);
+        #[cfg(feature = "i128_support")]
+        rng.sample::<i128, _>(Standard);
+        
+        rng.sample::<usize, _>(Standard);
+        rng.sample::<u8, _>(Standard);
+        rng.sample::<u16, _>(Standard);
+        rng.sample::<u32, _>(Standard);
+        rng.sample::<u64, _>(Standard);
+        #[cfg(feature = "i128_support")]
+        rng.sample::<u128, _>(Standard);
+    }
+}
diff --git a/rustc_deps/vendor/rand/src/distributions/log_gamma.rs b/rustc_deps/vendor/rand/src/distributions/log_gamma.rs
new file mode 100644
index 0000000..f1fa383
--- /dev/null
+++ b/rustc_deps/vendor/rand/src/distributions/log_gamma.rs
@@ -0,0 +1,51 @@
+// Copyright 2016-2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// https://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+/// Calculates ln(gamma(x)) (natural logarithm of the gamma
+/// function) using the Lanczos approximation.
+///
+/// The approximation expresses the gamma function as:
+/// `gamma(z+1) = sqrt(2*pi)*(z+g+0.5)^(z+0.5)*exp(-z-g-0.5)*Ag(z)`
+/// `g` is an arbitrary constant; we use the approximation with `g=5`.
+///
+/// Noting that `gamma(z+1) = z*gamma(z)` and applying `ln` to both sides:
+/// `ln(gamma(z)) = (z+0.5)*ln(z+g+0.5)-(z+g+0.5) + ln(sqrt(2*pi)*Ag(z)/z)`
+///
+/// `Ag(z)` is an infinite series with coefficients that can be calculated
+/// ahead of time - we use just the first 6 terms, which is good enough
+/// for most purposes.
+pub fn log_gamma(x: f64) -> f64 {
+    // precalculated 6 coefficients for the first 6 terms of the series
+    let coefficients: [f64; 6] = [
+        76.18009172947146,
+        -86.50532032941677,
+        24.01409824083091,
+        -1.231739572450155,
+        0.1208650973866179e-2,
+        -0.5395239384953e-5,
+    ];
+
+    // (x+0.5)*ln(x+g+0.5)-(x+g+0.5)
+    let tmp = x + 5.5;
+    let log = (x + 0.5) * tmp.ln() - tmp;
+
+    // the first few terms of the series for Ag(x)
+    let mut a = 1.000000000190015;
+    let mut denom = x;
+    for coeff in &coefficients {
+        denom += 1.0;
+        a += coeff / denom;
+    }
+
+    // get everything together
+    // a is Ag(x)
+    // 2.5066... is sqrt(2pi)
+    log + (2.5066282746310005 * a / x).ln()
+}
diff --git a/rustc_deps/vendor/rand/src/distributions/mod.rs b/rustc_deps/vendor/rand/src/distributions/mod.rs
index 5de8efb..24dd3a3 100644
--- a/rustc_deps/vendor/rand/src/distributions/mod.rs
+++ b/rustc_deps/vendor/rand/src/distributions/mod.rs
@@ -1,46 +1,223 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2013-2017 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
+// https://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
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Sampling from random distributions.
+//! Generating random samples from probability distributions.
 //!
-//! This is a generalization of `Rand` to allow parameters to control the
-//! exact properties of the generated values, e.g. the mean and standard
-//! deviation of a normal distribution. The `Sample` trait is the most
-//! general, and allows for generating values that change some state
-//! internally. The `IndependentSample` trait is for generating values
-//! that do not need to record state.
+//! This module is the home of the [`Distribution`] trait and several of its
+//! implementations. It is the workhorse behind some of the convenient
+//! functionality of the [`Rng`] trait, including [`gen`], [`gen_range`] and
+//! of course [`sample`].
+//!
+//! Abstractly, a [probability distribution] describes the probability of
+//! occurance of each value in its sample space.
+//!
+//! More concretely, an implementation of `Distribution<T>` for type `X` is an
+//! algorithm for choosing values from the sample space (a subset of `T`)
+//! according to the distribution `X` represents, using an external source of
+//! randomness (an RNG supplied to the `sample` function).
+//!
+//! A type `X` may implement `Distribution<T>` for multiple types `T`.
+//! Any type implementing [`Distribution`] is stateless (i.e. immutable),
+//! but it may have internal parameters set at construction time (for example,
+//! [`Uniform`] allows specification of its sample space as a range within `T`).
+//!
+//!
+//! # The `Standard` distribution
+//!
+//! The [`Standard`] distribution is important to mention. This is the
+//! distribution used by [`Rng::gen()`] and represents the "default" way to
+//! produce a random value for many different types, including most primitive
+//! types, tuples, arrays, and a few derived types. See the documentation of
+//! [`Standard`] for more details.
+//!
+//! Implementing `Distribution<T>` for [`Standard`] for user types `T` makes it
+//! possible to generate type `T` with [`Rng::gen()`], and by extension also
+//! with the [`random()`] function.
+//!
+//!
+//! # Distribution to sample from a `Uniform` range
+//!
+//! The [`Uniform`] distribution is more flexible than [`Standard`], but also
+//! more specialised: it supports fewer target types, but allows the sample
+//! space to be specified as an arbitrary range within its target type `T`.
+//! Both [`Standard`] and [`Uniform`] are in some sense uniform distributions.
+//!
+//! Values may be sampled from this distribution using [`Rng::gen_range`] or
+//! by creating a distribution object with [`Uniform::new`],
+//! [`Uniform::new_inclusive`] or `From<Range>`. When the range limits are not
+//! known at compile time it is typically faster to reuse an existing
+//! distribution object than to call [`Rng::gen_range`].
+//!
+//! User types `T` may also implement `Distribution<T>` for [`Uniform`],
+//! although this is less straightforward than for [`Standard`] (see the
+//! documentation in the [`uniform` module]. Doing so enables generation of
+//! values of type `T` with  [`Rng::gen_range`].
+//!
+//!
+//! # Other distributions
+//!
+//! There are surprisingly many ways to uniformly generate random floats. A
+//! range between 0 and 1 is standard, but the exact bounds (open vs closed)
+//! and accuracy differ. In addition to the [`Standard`] distribution Rand offers
+//! [`Open01`] and [`OpenClosed01`]. See [Floating point implementation] for
+//! more details.
+//!
+//! [`Alphanumeric`] is a simple distribution to sample random letters and
+//! numbers of the `char` type; in contrast [`Standard`] may sample any valid
+//! `char`.
+//!
+//!
+//! # Non-uniform probability distributions
+//!
+//! Rand currently provides the following probability distributions:
+//!
+//! - Related to real-valued quantities that grow linearly
+//!   (e.g. errors, offsets):
+//!   - [`Normal`] distribution, and [`StandardNormal`] as a primitive
+//!   - [`Cauchy`] distribution
+//! - Related to Bernoulli trials (yes/no events, with a given probability):
+//!   - [`Binomial`] distribution
+//!   - [`Bernoulli`] distribution, similar to [`Rng::gen_bool`].
+//! - Related to positive real-valued quantities that grow exponentially
+//!   (e.g. prices, incomes, populations):
+//!   - [`LogNormal`] distribution
+//! - Related to the occurrence of independent events at a given rate:
+//!   - [`Poisson`] distribution
+//!   - [`Exp`]onential distribution, and [`Exp1`] as a primitive
+//! - Gamma and derived distributions:
+//!   - [`Gamma`] distribution
+//!   - [`ChiSquared`] distribution
+//!   - [`StudentT`] distribution
+//!   - [`FisherF`] distribution
+//!
+//!
+//! # Examples
+//!
+//! Sampling from a distribution:
+//!
+//! ```
+//! use rand::{thread_rng, Rng};
+//! use rand::distributions::Exp;
+//!
+//! let exp = Exp::new(2.0);
+//! let v = thread_rng().sample(exp);
+//! println!("{} is from an Exp(2) distribution", v);
+//! ```
+//!
+//! Implementing the [`Standard`] distribution for a user type:
+//!
+//! ```
+//! # #![allow(dead_code)]
+//! use rand::Rng;
+//! use rand::distributions::{Distribution, Standard};
+//!
+//! struct MyF32 {
+//!     x: f32,
+//! }
+//!
+//! impl Distribution<MyF32> for Standard {
+//!     fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> MyF32 {
+//!         MyF32 { x: rng.gen() }
+//!     }
+//! }
+//! ```
+//!
+//!
+//! [probability distribution]: https://en.wikipedia.org/wiki/Probability_distribution
+//! [`Distribution`]: trait.Distribution.html
+//! [`gen_range`]: ../trait.Rng.html#method.gen_range
+//! [`gen`]: ../trait.Rng.html#method.gen
+//! [`sample`]: ../trait.Rng.html#method.sample
+//! [`new_inclusive`]: struct.Uniform.html#method.new_inclusive
+//! [`random()`]: ../fn.random.html
+//! [`Rng::gen_bool`]: ../trait.Rng.html#method.gen_bool
+//! [`Rng::gen_range`]: ../trait.Rng.html#method.gen_range
+//! [`Rng::gen()`]: ../trait.Rng.html#method.gen
+//! [`Rng`]: ../trait.Rng.html
+//! [`uniform` module]: uniform/index.html
+//! [Floating point implementation]: struct.Standard.html#floating-point-implementation
+// distributions
+//! [`Alphanumeric`]: struct.Alphanumeric.html
+//! [`Bernoulli`]: struct.Bernoulli.html
+//! [`Binomial`]: struct.Binomial.html
+//! [`Cauchy`]: struct.Cauchy.html
+//! [`ChiSquared`]: struct.ChiSquared.html
+//! [`Exp`]: struct.Exp.html
+//! [`Exp1`]: struct.Exp1.html
+//! [`FisherF`]: struct.FisherF.html
+//! [`Gamma`]: struct.Gamma.html
+//! [`LogNormal`]: struct.LogNormal.html
+//! [`Normal`]: struct.Normal.html
+//! [`Open01`]: struct.Open01.html
+//! [`OpenClosed01`]: struct.OpenClosed01.html
+//! [`Pareto`]: struct.Pareto.html
+//! [`Poisson`]: struct.Poisson.html
+//! [`Standard`]: struct.Standard.html
+//! [`StandardNormal`]: struct.StandardNormal.html
+//! [`StudentT`]: struct.StudentT.html
+//! [`Uniform`]: struct.Uniform.html
+//! [`Uniform::new`]: struct.Uniform.html#method.new
+//! [`Uniform::new_inclusive`]: struct.Uniform.html#method.new_inclusive
 
-use core::marker;
+use Rng;
 
-use {Rng, Rand};
+#[doc(inline)] pub use self::other::Alphanumeric;
+#[doc(inline)] pub use self::uniform::Uniform;
+#[doc(inline)] pub use self::float::{OpenClosed01, Open01};
+#[deprecated(since="0.5.0", note="use Uniform instead")]
+pub use self::uniform::Uniform as Range;
+#[cfg(feature="std")]
+#[doc(inline)] pub use self::gamma::{Gamma, ChiSquared, FisherF, StudentT};
+#[cfg(feature="std")]
+#[doc(inline)] pub use self::normal::{Normal, LogNormal, StandardNormal};
+#[cfg(feature="std")]
+#[doc(inline)] pub use self::exponential::{Exp, Exp1};
+#[cfg(feature="std")]
+#[doc(inline)] pub use self::pareto::Pareto;
+#[cfg(feature = "std")]
+#[doc(inline)] pub use self::poisson::Poisson;
+#[cfg(feature = "std")]
+#[doc(inline)] pub use self::binomial::Binomial;
+#[doc(inline)] pub use self::bernoulli::Bernoulli;
+#[cfg(feature = "std")]
+#[doc(inline)] pub use self::cauchy::Cauchy;
 
-pub use self::range::Range;
+pub mod uniform;
 #[cfg(feature="std")]
-pub use self::gamma::{Gamma, ChiSquared, FisherF, StudentT};
+#[doc(hidden)] pub mod gamma;
 #[cfg(feature="std")]
-pub use self::normal::{Normal, LogNormal};
+#[doc(hidden)] pub mod normal;
 #[cfg(feature="std")]
-pub use self::exponential::Exp;
+#[doc(hidden)] pub mod exponential;
+#[cfg(feature="std")]
+#[doc(hidden)] pub mod pareto;
+#[cfg(feature = "std")]
+#[doc(hidden)] pub mod poisson;
+#[cfg(feature = "std")]
+#[doc(hidden)] pub mod binomial;
+#[doc(hidden)] pub mod bernoulli;
+#[cfg(feature = "std")]
+#[doc(hidden)] pub mod cauchy;
 
-pub mod range;
+mod float;
+mod integer;
 #[cfg(feature="std")]
-pub mod gamma;
-#[cfg(feature="std")]
-pub mod normal;
-#[cfg(feature="std")]
-pub mod exponential;
-
+mod log_gamma;
+mod other;
 #[cfg(feature="std")]
 mod ziggurat_tables;
+#[cfg(feature="std")]
+use distributions::float::IntoFloat;
 
 /// Types that can be used to create a random instance of `Support`.
+#[deprecated(since="0.5.0", note="use Distribution instead")]
 pub trait Sample<Support> {
     /// Generate a random value of `Support`, using `rng` as the
     /// source of randomness.
@@ -52,42 +229,234 @@
 /// Since no state is recorded, each sample is (statistically)
 /// independent of all others, assuming the `Rng` used has this
 /// property.
-// FIXME maybe having this separate is overkill (the only reason is to
-// take &self rather than &mut self)? or maybe this should be the
-// trait called `Sample` and the other should be `DependentSample`.
+#[allow(deprecated)]
+#[deprecated(since="0.5.0", note="use Distribution instead")]
 pub trait IndependentSample<Support>: Sample<Support> {
     /// Generate a random value.
     fn ind_sample<R: Rng>(&self, &mut R) -> Support;
 }
 
-/// A wrapper for generating types that implement `Rand` via the
-/// `Sample` & `IndependentSample` traits.
+/// DEPRECATED: Use `distributions::uniform` instead.
+#[deprecated(since="0.5.0", note="use uniform instead")]
+pub mod range {
+    pub use distributions::uniform::Uniform as Range;
+    pub use distributions::uniform::SampleUniform as SampleRange;
+}
+
+#[allow(deprecated)]
+mod impls {
+    use Rng;
+    use distributions::{Distribution, Sample, IndependentSample,
+            WeightedChoice};
+    #[cfg(feature="std")]
+    use distributions::exponential::Exp;
+    #[cfg(feature="std")]
+    use distributions::gamma::{Gamma, ChiSquared, FisherF, StudentT};
+    #[cfg(feature="std")]
+    use distributions::normal::{Normal, LogNormal};
+    use distributions::range::{Range, SampleRange};
+    
+    impl<'a, T: Clone> Sample<T> for WeightedChoice<'a, T> {
+        fn sample<R: Rng>(&mut self, rng: &mut R) -> T {
+            Distribution::sample(self, rng)
+        }
+    }
+    impl<'a, T: Clone> IndependentSample<T> for WeightedChoice<'a, T> {
+        fn ind_sample<R: Rng>(&self, rng: &mut R) -> T {
+            Distribution::sample(self, rng)
+        }
+    }
+    
+    impl<T: SampleRange> Sample<T> for Range<T> {
+        fn sample<R: Rng>(&mut self, rng: &mut R) -> T {
+            Distribution::sample(self, rng)
+        }
+    }
+    impl<T: SampleRange> IndependentSample<T> for Range<T> {
+        fn ind_sample<R: Rng>(&self, rng: &mut R) -> T {
+            Distribution::sample(self, rng)
+        }
+    }
+    
+    #[cfg(feature="std")]
+    macro_rules! impl_f64 {
+        ($($name: ident), *) => {
+            $(
+                impl Sample<f64> for $name {
+                    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 {
+                        Distribution::sample(self, rng)
+                    }
+                }
+                impl IndependentSample<f64> for $name {
+                    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
+                        Distribution::sample(self, rng)
+                    }
+                }
+            )*
+        }
+    }
+    #[cfg(feature="std")]
+    impl_f64!(Exp, Gamma, ChiSquared, FisherF, StudentT, Normal, LogNormal);
+}
+
+/// Types (distributions) that can be used to create a random instance of `T`.
+///
+/// It is possible to sample from a distribution through both the
+/// `Distribution` and [`Rng`] traits, via `distr.sample(&mut rng)` and
+/// `rng.sample(distr)`. They also both offer the [`sample_iter`] method, which
+/// produces an iterator that samples from the distribution.
+///
+/// All implementations are expected to be immutable; this has the significant
+/// advantage of not needing to consider thread safety, and for most
+/// distributions efficient state-less sampling algorithms are available.
+///
+/// [`Rng`]: ../trait.Rng.html
+/// [`sample_iter`]: trait.Distribution.html#method.sample_iter
+pub trait Distribution<T> {
+    /// Generate a random value of `T`, using `rng` as the source of randomness.
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> T;
+
+    /// Create an iterator that generates random values of `T`, using `rng` as
+    /// the source of randomness.
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// use rand::thread_rng;
+    /// use rand::distributions::{Distribution, Alphanumeric, Uniform, Standard};
+    ///
+    /// let mut rng = thread_rng();
+    ///
+    /// // Vec of 16 x f32:
+    /// let v: Vec<f32> = Standard.sample_iter(&mut rng).take(16).collect();
+    ///
+    /// // String:
+    /// let s: String = Alphanumeric.sample_iter(&mut rng).take(7).collect();
+    ///
+    /// // Dice-rolling:
+    /// let die_range = Uniform::new_inclusive(1, 6);
+    /// let mut roll_die = die_range.sample_iter(&mut rng);
+    /// while roll_die.next().unwrap() != 6 {
+    ///     println!("Not a 6; rolling again!");
+    /// }
+    /// ```
+    fn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T>
+        where Self: Sized, R: Rng
+    {
+        DistIter {
+            distr: self,
+            rng: rng,
+            phantom: ::core::marker::PhantomData,
+        }
+    }
+}
+
+impl<'a, T, D: Distribution<T>> Distribution<T> for &'a D {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> T {
+        (*self).sample(rng)
+    }
+}
+
+
+/// An iterator that generates random values of `T` with distribution `D`,
+/// using `R` as the source of randomness.
+///
+/// This `struct` is created by the [`sample_iter`] method on [`Distribution`].
+/// See its documentation for more.
+///
+/// [`Distribution`]: trait.Distribution.html
+/// [`sample_iter`]: trait.Distribution.html#method.sample_iter
 #[derive(Debug)]
-pub struct RandSample<Sup> {
-    _marker: marker::PhantomData<fn() -> Sup>,
+pub struct DistIter<'a, D: 'a, R: 'a, T> {
+    distr: &'a D,
+    rng: &'a mut R,
+    phantom: ::core::marker::PhantomData<T>,
 }
 
-impl<Sup> Copy for RandSample<Sup> {}
-impl<Sup> Clone for RandSample<Sup> {
-    fn clone(&self) -> Self { *self }
-}
+impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T>
+    where D: Distribution<T>, R: Rng + 'a
+{
+    type Item = T;
 
-impl<Sup: Rand> Sample<Sup> for RandSample<Sup> {
-    fn sample<R: Rng>(&mut self, rng: &mut R) -> Sup { self.ind_sample(rng) }
-}
+    #[inline(always)]
+    fn next(&mut self) -> Option<T> {
+        Some(self.distr.sample(self.rng))
+    }
 
-impl<Sup: Rand> IndependentSample<Sup> for RandSample<Sup> {
-    fn ind_sample<R: Rng>(&self, rng: &mut R) -> Sup {
-        rng.gen()
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        (usize::max_value(), None)
     }
 }
 
-impl<Sup> RandSample<Sup> {
-    pub fn new() -> RandSample<Sup> {
-        RandSample { _marker: marker::PhantomData }
+
+/// A generic random value distribution, implemented for many primitive types.
+/// Usually generates values with a numerically uniform distribution, and with a
+/// range appropriate to the type.
+/// 
+/// ## Built-in Implementations
+///
+/// Assuming the provided `Rng` is well-behaved, these implementations
+/// generate values with the following ranges and distributions:
+///
+/// * Integers (`i32`, `u32`, `isize`, `usize`, etc.): Uniformly distributed
+///   over all values of the type.
+/// * `char`: Uniformly distributed over all Unicode scalar values, i.e. all
+///   code points in the range `0...0x10_FFFF`, except for the range
+///   `0xD800...0xDFFF` (the surrogate code points). This includes
+///   unassigned/reserved code points.
+/// * `bool`: Generates `false` or `true`, each with probability 0.5.
+/// * Floating point types (`f32` and `f64`): Uniformly distributed in the
+///   half-open range `[0, 1)`. See notes below.
+/// * Wrapping integers (`Wrapping<T>`), besides the type identical to their
+///   normal integer variants.
+///
+/// The following aggregate types also implement the distribution `Standard` as
+/// long as their component types implement it:
+///
+/// * Tuples and arrays: Each element of the tuple or array is generated
+///   independently, using the `Standard` distribution recursively.
+/// * `Option<T>` where `Standard` is implemented for `T`: Returns `None` with
+///   probability 0.5; otherwise generates a random `x: T` and returns `Some(x)`.
+///
+/// # Example
+/// ```
+/// use rand::prelude::*;
+/// use rand::distributions::Standard;
+///
+/// let val: f32 = SmallRng::from_entropy().sample(Standard);
+/// println!("f32 from [0, 1): {}", val);
+/// ```
+///
+/// # Floating point implementation
+/// The floating point implementations for `Standard` generate a random value in
+/// the half-open interval `[0, 1)`, i.e. including 0 but not 1.
+///
+/// All values that can be generated are of the form `n * ε/2`. For `f32`
+/// the 23 most significant random bits of a `u32` are used and for `f64` the
+/// 53 most significant bits of a `u64` are used. The conversion uses the
+/// multiplicative method: `(rng.gen::<$uty>() >> N) as $ty * (ε/2)`.
+///
+/// See also: [`Open01`] which samples from `(0, 1)`, [`OpenClosed01`] which
+/// samples from `(0, 1]` and `Rng::gen_range(0, 1)` which also samples from
+/// `[0, 1)`. Note that `Open01` and `gen_range` (which uses [`Uniform`]) use
+/// transmute-based methods which yield 1 bit less precision but may perform
+/// faster on some architectures (on modern Intel CPUs all methods have
+/// approximately equal performance).
+///
+/// [`Open01`]: struct.Open01.html
+/// [`OpenClosed01`]: struct.OpenClosed01.html
+/// [`Uniform`]: uniform/struct.Uniform.html
+#[derive(Clone, Copy, Debug)]
+pub struct Standard;
+
+#[allow(deprecated)]
+impl<T> ::Rand for T where Standard: Distribution<T> {
+    fn rand<R: Rng>(rng: &mut R) -> Self {
+        Standard.sample(rng)
     }
 }
 
+
 /// A value with a particular weight for use with `WeightedChoice`.
 #[derive(Copy, Clone, Debug)]
 pub struct Weighted<T> {
@@ -102,15 +471,14 @@
 /// Each item has an associated weight that influences how likely it
 /// is to be chosen: higher weight is more likely.
 ///
-/// The `Clone` restriction is a limitation of the `Sample` and
-/// `IndependentSample` traits. Note that `&T` is (cheaply) `Clone` for
-/// all `T`, as is `u32`, so one can store references or indices into
-/// another vector.
+/// The `Clone` restriction is a limitation of the `Distribution` trait.
+/// Note that `&T` is (cheaply) `Clone` for all `T`, as is `u32`, so one can
+/// store references or indices into another vector.
 ///
 /// # Example
 ///
-/// ```rust
-/// use rand::distributions::{Weighted, WeightedChoice, IndependentSample};
+/// ```
+/// use rand::distributions::{Weighted, WeightedChoice, Distribution};
 ///
 /// let mut items = vec!(Weighted { weight: 2, item: 'a' },
 ///                      Weighted { weight: 4, item: 'b' },
@@ -119,13 +487,13 @@
 /// let mut rng = rand::thread_rng();
 /// for _ in 0..16 {
 ///      // on average prints 'a' 4 times, 'b' 8 and 'c' twice.
-///      println!("{}", wc.ind_sample(&mut rng));
+///      println!("{}", wc.sample(&mut rng));
 /// }
 /// ```
 #[derive(Debug)]
 pub struct WeightedChoice<'a, T:'a> {
     items: &'a mut [Weighted<T>],
-    weight_range: Range<u32>
+    weight_range: Uniform<u32>,
 }
 
 impl<'a, T: Clone> WeightedChoice<'a, T> {
@@ -157,26 +525,22 @@
         assert!(running_total != 0, "WeightedChoice::new called with a total weight of 0");
 
         WeightedChoice {
-            items: items,
+            items,
             // we're likely to be generating numbers in this range
             // relatively often, so might as well cache it
-            weight_range: Range::new(0, running_total)
+            weight_range: Uniform::new(0, running_total)
         }
     }
 }
 
-impl<'a, T: Clone> Sample<T> for WeightedChoice<'a, T> {
-    fn sample<R: Rng>(&mut self, rng: &mut R) -> T { self.ind_sample(rng) }
-}
-
-impl<'a, T: Clone> IndependentSample<T> for WeightedChoice<'a, T> {
-    fn ind_sample<R: Rng>(&self, rng: &mut R) -> T {
+impl<'a, T: Clone> Distribution<T> for WeightedChoice<'a, T> {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> T {
         // we want to find the first element that has cumulative
         // weight > sample_weight, which we do by binary since the
         // cumulative weights of self.items are sorted.
 
         // choose a weight in [0, total_weight)
-        let sample_weight = self.weight_range.ind_sample(rng);
+        let sample_weight = self.weight_range.sample(rng);
 
         // short circuit when it's the first item
         if sample_weight < self.items[0].weight {
@@ -208,7 +572,7 @@
             }
             modifier /= 2;
         }
-        return self.items[idx + 1].item.clone();
+        self.items[idx + 1].item.clone()
     }
 }
 
@@ -229,7 +593,7 @@
 // size from force-inlining.
 #[cfg(feature="std")]
 #[inline(always)]
-fn ziggurat<R: Rng, P, Z>(
+fn ziggurat<R: Rng + ?Sized, P, Z>(
             rng: &mut R,
             symmetric: bool,
             x_tab: ziggurat_tables::ZigTable,
@@ -237,28 +601,26 @@
             mut pdf: P,
             mut zero_case: Z)
             -> f64 where P: FnMut(f64) -> f64, Z: FnMut(&mut R, f64) -> f64 {
-    const SCALE: f64 = (1u64 << 53) as f64;
     loop {
-        // reimplement the f64 generation as an optimisation suggested
-        // by the Doornik paper: we have a lot of precision-space
-        // (i.e. there are 11 bits of the 64 of a u64 to use after
-        // creating a f64), so we might as well reuse some to save
-        // generating a whole extra random number. (Seems to be 15%
-        // faster.)
-        //
-        // This unfortunately misses out on the benefits of direct
-        // floating point generation if an RNG like dSMFT is
-        // used. (That is, such RNGs create floats directly, highly
-        // efficiently and overload next_f32/f64, so by not calling it
-        // this may be slower than it would be otherwise.)
-        // FIXME: investigate/optimise for the above.
-        let bits: u64 = rng.gen();
-        let i = (bits & 0xff) as usize;
-        let f = (bits >> 11) as f64 / SCALE;
+        // As an optimisation we re-implement the conversion to a f64.
+        // From the remaining 12 most significant bits we use 8 to construct `i`.
+        // This saves us generating a whole extra random number, while the added
+        // precision of using 64 bits for f64 does not buy us much.
+        let bits = rng.next_u64();
+        let i = bits as usize & 0xff;
 
-        // u is either U(-1, 1) or U(0, 1) depending on if this is a
-        // symmetric distribution or not.
-        let u = if symmetric {2.0 * f - 1.0} else {f};
+        let u = if symmetric {
+            // Convert to a value in the range [2,4) and substract to get [-1,1)
+            // We can't convert to an open range directly, that would require
+            // substracting `3.0 - EPSILON`, which is not representable.
+            // It is possible with an extra step, but an open range does not
+            // seem neccesary for the ziggurat algorithm anyway.
+            (bits >> 12).into_float_with_exponent(1) - 3.0
+        } else {
+            // Convert to a value in the range [1,2) and substract to get (0,1)
+            (bits >> 12).into_float_with_exponent(0)
+            - (1.0 - ::core::f64::EPSILON / 2.0)
+        };
         let x = u * x_tab[i];
 
         let test_x = if symmetric { x.abs() } else {x};
@@ -279,89 +641,67 @@
 
 #[cfg(test)]
 mod tests {
+    use Rng;
+    use rngs::mock::StepRng;
+    use super::{WeightedChoice, Weighted, Distribution};
 
-    use {Rng, Rand};
-    use super::{RandSample, WeightedChoice, Weighted, Sample, IndependentSample};
-
-    #[derive(PartialEq, Debug)]
-    struct ConstRand(usize);
-    impl Rand for ConstRand {
-        fn rand<R: Rng>(_: &mut R) -> ConstRand {
-            ConstRand(0)
-        }
-    }
-
-    // 0, 1, 2, 3, ...
-    struct CountingRng { i: u32 }
-    impl Rng for CountingRng {
-        fn next_u32(&mut self) -> u32 {
-            self.i += 1;
-            self.i - 1
-        }
-        fn next_u64(&mut self) -> u64 {
-            self.next_u32() as u64
-        }
-    }
-
-    #[test]
-    fn test_rand_sample() {
-        let mut rand_sample = RandSample::<ConstRand>::new();
-
-        assert_eq!(rand_sample.sample(&mut ::test::rng()), ConstRand(0));
-        assert_eq!(rand_sample.ind_sample(&mut ::test::rng()), ConstRand(0));
-    }
     #[test]
     fn test_weighted_choice() {
         // this makes assumptions about the internal implementation of
-        // WeightedChoice, specifically: it doesn't reorder the items,
-        // it doesn't do weird things to the RNG (so 0 maps to 0, 1 to
-        // 1, internally; modulo a modulo operation).
+        // WeightedChoice. It may fail when the implementation in
+        // `distributions::uniform::UniformInt` changes.
 
         macro_rules! t {
             ($items:expr, $expected:expr) => {{
                 let mut items = $items;
+                let mut total_weight = 0;
+                for item in &items { total_weight += item.weight; }
+
                 let wc = WeightedChoice::new(&mut items);
                 let expected = $expected;
 
-                let mut rng = CountingRng { i: 0 };
+                // Use extremely large steps between the random numbers, because
+                // we test with small ranges and `UniformInt` is designed to prefer
+                // the most significant bits.
+                let mut rng = StepRng::new(0, !0 / (total_weight as u64));
 
                 for &val in expected.iter() {
-                    assert_eq!(wc.ind_sample(&mut rng), val)
+                    assert_eq!(wc.sample(&mut rng), val)
                 }
             }}
         }
 
-        t!(vec!(Weighted { weight: 1, item: 10}), [10]);
+        t!([Weighted { weight: 1, item: 10}], [10]);
 
         // skip some
-        t!(vec!(Weighted { weight: 0, item: 20},
-                Weighted { weight: 2, item: 21},
-                Weighted { weight: 0, item: 22},
-                Weighted { weight: 1, item: 23}),
-           [21,21, 23]);
+        t!([Weighted { weight: 0, item: 20},
+            Weighted { weight: 2, item: 21},
+            Weighted { weight: 0, item: 22},
+            Weighted { weight: 1, item: 23}],
+           [21, 21, 23]);
 
         // different weights
-        t!(vec!(Weighted { weight: 4, item: 30},
-                Weighted { weight: 3, item: 31}),
-           [30,30,30,30, 31,31,31]);
+        t!([Weighted { weight: 4, item: 30},
+            Weighted { weight: 3, item: 31}],
+           [30, 31, 30, 31, 30, 31, 30]);
 
         // check that we're binary searching
         // correctly with some vectors of odd
         // length.
-        t!(vec!(Weighted { weight: 1, item: 40},
-                Weighted { weight: 1, item: 41},
-                Weighted { weight: 1, item: 42},
-                Weighted { weight: 1, item: 43},
-                Weighted { weight: 1, item: 44}),
+        t!([Weighted { weight: 1, item: 40},
+            Weighted { weight: 1, item: 41},
+            Weighted { weight: 1, item: 42},
+            Weighted { weight: 1, item: 43},
+            Weighted { weight: 1, item: 44}],
            [40, 41, 42, 43, 44]);
-        t!(vec!(Weighted { weight: 1, item: 50},
-                Weighted { weight: 1, item: 51},
-                Weighted { weight: 1, item: 52},
-                Weighted { weight: 1, item: 53},
-                Weighted { weight: 1, item: 54},
-                Weighted { weight: 1, item: 55},
-                Weighted { weight: 1, item: 56}),
-           [50, 51, 52, 53, 54, 55, 56]);
+        t!([Weighted { weight: 1, item: 50},
+            Weighted { weight: 1, item: 51},
+            Weighted { weight: 1, item: 52},
+            Weighted { weight: 1, item: 53},
+            Weighted { weight: 1, item: 54},
+            Weighted { weight: 1, item: 55},
+            Weighted { weight: 1, item: 56}],
+           [50, 54, 51, 55, 52, 56, 53]);
     }
 
     #[test]
@@ -400,10 +740,45 @@
     }
     #[test] #[should_panic]
     fn test_weighted_choice_weight_overflows() {
-        let x = ::std::u32::MAX / 2; // x + x + 2 is the overflow
+        let x = ::core::u32::MAX / 2; // x + x + 2 is the overflow
         WeightedChoice::new(&mut [Weighted { weight: x, item: 0 },
                                   Weighted { weight: 1, item: 1 },
                                   Weighted { weight: x, item: 2 },
                                   Weighted { weight: 1, item: 3 }]);
     }
+    
+    #[test] #[allow(deprecated)]
+    fn test_backwards_compat_sample() {
+        use distributions::{Sample, IndependentSample};
+        
+        struct Constant<T> { val: T }
+        impl<T: Copy> Sample<T> for Constant<T> {
+            fn sample<R: Rng>(&mut self, _: &mut R) -> T { self.val }
+        }
+        impl<T: Copy> IndependentSample<T> for Constant<T> {
+            fn ind_sample<R: Rng>(&self, _: &mut R) -> T { self.val }
+        }
+        
+        let mut sampler = Constant{ val: 293 };
+        assert_eq!(sampler.sample(&mut ::test::rng(233)), 293);
+        assert_eq!(sampler.ind_sample(&mut ::test::rng(234)), 293);
+    }
+    
+    #[cfg(feature="std")]
+    #[test] #[allow(deprecated)]
+    fn test_backwards_compat_exp() {
+        use distributions::{IndependentSample, Exp};
+        let sampler = Exp::new(1.0);
+        sampler.ind_sample(&mut ::test::rng(235));
+    }
+
+    #[cfg(feature="std")]
+    #[test]
+    fn test_distributions_iter() {
+        use distributions::Normal;
+        let mut rng = ::test::rng(210);
+        let distr = Normal::new(10.0, 10.0);
+        let results: Vec<_> = distr.sample_iter(&mut rng).take(100).collect();
+        println!("{:?}", results);
+    }
 }
diff --git a/rustc_deps/vendor/rand/src/distributions/normal.rs b/rustc_deps/vendor/rand/src/distributions/normal.rs
index 280613d..f053fb6 100644
--- a/rustc_deps/vendor/rand/src/distributions/normal.rs
+++ b/rustc_deps/vendor/rand/src/distributions/normal.rs
@@ -1,49 +1,50 @@
 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
+// https://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
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
 //! The normal and derived distributions.
 
-use {Rng, Rand, Open01};
-use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
+use Rng;
+use distributions::{ziggurat, ziggurat_tables, Distribution, Open01};
 
-/// A wrapper around an `f64` to generate N(0, 1) random numbers
-/// (a.k.a.  a standard normal, or Gaussian).
+/// Samples floating-point numbers according to the normal distribution
+/// `N(0, 1)` (a.k.a. a standard normal, or Gaussian). This is equivalent to
+/// `Normal::new(0.0, 1.0)` but faster.
 ///
 /// See `Normal` for the general normal distribution.
 ///
-/// Implemented via the ZIGNOR variant[1] of the Ziggurat method.
+/// Implemented via the ZIGNOR variant[^1] of the Ziggurat method.
 ///
-/// [1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to
-/// Generate Normal Random
-/// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield
-/// College, Oxford
+/// [^1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to
+///       Generate Normal Random Samples*](
+///       https://www.doornik.com/research/ziggurat.pdf).
+///       Nuffield College, Oxford
 ///
 /// # Example
+/// ```
+/// use rand::prelude::*;
+/// use rand::distributions::StandardNormal;
 ///
-/// ```rust
-/// use rand::distributions::normal::StandardNormal;
-///
-/// let StandardNormal(x) = rand::random();
-/// println!("{}", x);
+/// let val: f64 = SmallRng::from_entropy().sample(StandardNormal);
+/// println!("{}", val);
 /// ```
 #[derive(Clone, Copy, Debug)]
-pub struct StandardNormal(pub f64);
+pub struct StandardNormal;
 
-impl Rand for StandardNormal {
-    fn rand<R:Rng>(rng: &mut R) -> StandardNormal {
+impl Distribution<f64> for StandardNormal {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
         #[inline]
         fn pdf(x: f64) -> f64 {
             (-x*x/2.0).exp()
         }
         #[inline]
-        fn zero_case<R:Rng>(rng: &mut R, u: f64) -> f64 {
+        fn zero_case<R: Rng + ?Sized>(rng: &mut R, u: f64) -> f64 {
             // compute a random number in the tail by hand
 
             // strange initial conditions, because the loop is not
@@ -54,8 +55,8 @@
             let mut y = 0.0f64;
 
             while -2.0 * y < x * x {
-                let Open01(x_) = rng.gen::<Open01<f64>>();
-                let Open01(y_) = rng.gen::<Open01<f64>>();
+                let x_: f64 = rng.sample(Open01);
+                let y_: f64 = rng.sample(Open01);
 
                 x = x_.ln() / ziggurat_tables::ZIG_NORM_R;
                 y = y_.ln();
@@ -64,28 +65,26 @@
             if u < 0.0 { x - ziggurat_tables::ZIG_NORM_R } else { ziggurat_tables::ZIG_NORM_R - x }
         }
 
-        StandardNormal(ziggurat(
-            rng,
-            true, // this is symmetric
-            &ziggurat_tables::ZIG_NORM_X,
-            &ziggurat_tables::ZIG_NORM_F,
-            pdf, zero_case))
+        ziggurat(rng, true, // this is symmetric
+                 &ziggurat_tables::ZIG_NORM_X,
+                 &ziggurat_tables::ZIG_NORM_F,
+                 pdf, zero_case)
     }
 }
 
 /// The normal distribution `N(mean, std_dev**2)`.
 ///
-/// This uses the ZIGNOR variant of the Ziggurat method, see
-/// `StandardNormal` for more details.
+/// This uses the ZIGNOR variant of the Ziggurat method, see `StandardNormal`
+/// for more details.
 ///
 /// # Example
 ///
-/// ```rust
-/// use rand::distributions::{Normal, IndependentSample};
+/// ```
+/// use rand::distributions::{Normal, Distribution};
 ///
 /// // mean 2, standard deviation 3
 /// let normal = Normal::new(2.0, 3.0);
-/// let v = normal.ind_sample(&mut rand::thread_rng());
+/// let v = normal.sample(&mut rand::thread_rng());
 /// println!("{} is from a N(2, 9) distribution", v)
 /// ```
 #[derive(Clone, Copy, Debug)]
@@ -105,17 +104,14 @@
     pub fn new(mean: f64, std_dev: f64) -> Normal {
         assert!(std_dev >= 0.0, "Normal::new called with `std_dev` < 0");
         Normal {
-            mean: mean,
-            std_dev: std_dev
+            mean,
+            std_dev
         }
     }
 }
-impl Sample<f64> for Normal {
-    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
-}
-impl IndependentSample<f64> for Normal {
-    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
-        let StandardNormal(n) = rng.gen::<StandardNormal>();
+impl Distribution<f64> for Normal {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
+        let n = rng.sample(StandardNormal);
         self.mean + self.std_dev * n
     }
 }
@@ -123,17 +119,17 @@
 
 /// The log-normal distribution `ln N(mean, std_dev**2)`.
 ///
-/// If `X` is log-normal distributed, then `ln(X)` is `N(mean,
-/// std_dev**2)` distributed.
+/// If `X` is log-normal distributed, then `ln(X)` is `N(mean, std_dev**2)`
+/// distributed.
 ///
 /// # Example
 ///
-/// ```rust
-/// use rand::distributions::{LogNormal, IndependentSample};
+/// ```
+/// use rand::distributions::{LogNormal, Distribution};
 ///
 /// // mean 2, standard deviation 3
 /// let log_normal = LogNormal::new(2.0, 3.0);
-/// let v = log_normal.ind_sample(&mut rand::thread_rng());
+/// let v = log_normal.sample(&mut rand::thread_rng());
 /// println!("{} is from an ln N(2, 9) distribution", v)
 /// ```
 #[derive(Clone, Copy, Debug)]
@@ -154,27 +150,23 @@
         LogNormal { norm: Normal::new(mean, std_dev) }
     }
 }
-impl Sample<f64> for LogNormal {
-    fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) }
-}
-impl IndependentSample<f64> for LogNormal {
-    fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
-        self.norm.ind_sample(rng).exp()
+impl Distribution<f64> for LogNormal {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
+        self.norm.sample(rng).exp()
     }
 }
 
 #[cfg(test)]
 mod tests {
-    use distributions::{Sample, IndependentSample};
+    use distributions::Distribution;
     use super::{Normal, LogNormal};
 
     #[test]
     fn test_normal() {
-        let mut norm = Normal::new(10.0, 10.0);
-        let mut rng = ::test::rng();
+        let norm = Normal::new(10.0, 10.0);
+        let mut rng = ::test::rng(210);
         for _ in 0..1000 {
             norm.sample(&mut rng);
-            norm.ind_sample(&mut rng);
         }
     }
     #[test]
@@ -186,11 +178,10 @@
 
     #[test]
     fn test_log_normal() {
-        let mut lnorm = LogNormal::new(10.0, 10.0);
-        let mut rng = ::test::rng();
+        let lnorm = LogNormal::new(10.0, 10.0);
+        let mut rng = ::test::rng(211);
         for _ in 0..1000 {
             lnorm.sample(&mut rng);
-            lnorm.ind_sample(&mut rng);
         }
     }
     #[test]
diff --git a/rustc_deps/vendor/rand/src/distributions/other.rs b/rustc_deps/vendor/rand/src/distributions/other.rs
new file mode 100644
index 0000000..f23d2b8
--- /dev/null
+++ b/rustc_deps/vendor/rand/src/distributions/other.rs
@@ -0,0 +1,215 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// https://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! The implementations of the `Standard` distribution for other built-in types.
+
+use core::char;
+use core::num::Wrapping;
+
+use {Rng};
+use distributions::{Distribution, Standard, Uniform};
+
+// ----- Sampling distributions -----
+
+/// Sample a `char`, uniformly distributed over ASCII letters and numbers:
+/// a-z, A-Z and 0-9.
+/// 
+/// # Example
+///
+/// ```
+/// use std::iter;
+/// use rand::{Rng, thread_rng};
+/// use rand::distributions::Alphanumeric;
+/// 
+/// let mut rng = thread_rng();
+/// let chars: String = iter::repeat(())
+///         .map(|()| rng.sample(Alphanumeric))
+///         .take(7)
+///         .collect();
+/// println!("Random chars: {}", chars);
+/// ```
+#[derive(Debug)]
+pub struct Alphanumeric;
+
+
+// ----- Implementations of distributions -----
+
+impl Distribution<char> for Standard {
+    #[inline]
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> char {
+        let range = Uniform::new(0u32, 0x11_0000);
+        loop {
+            match char::from_u32(range.sample(rng)) {
+                Some(c) => return c,
+                // About 0.2% of numbers in the range 0..0x110000 are invalid
+                // codepoints (surrogates).
+                None => {}
+            }
+        }
+    }
+}
+
+impl Distribution<char> for Alphanumeric {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> char {
+        const RANGE: u32 = 26 + 26 + 10;
+        const GEN_ASCII_STR_CHARSET: &[u8] =
+            b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
+                abcdefghijklmnopqrstuvwxyz\
+                0123456789";
+        // We can pick from 62 characters. This is so close to a power of 2, 64,
+        // that we can do better than `Uniform`. Use a simple bitshift and
+        // rejection sampling. We do not use a bitmask, because for small RNGs
+        // the most significant bits are usually of higher quality.
+        loop {
+            let var = rng.next_u32() >> (32 - 6);
+            if var < RANGE {
+                return GEN_ASCII_STR_CHARSET[var as usize] as char
+            }
+        }
+    }
+}
+
+impl Distribution<bool> for Standard {
+    #[inline]
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> bool {
+        // We can compare against an arbitrary bit of an u32 to get a bool.
+        // Because the least significant bits of a lower quality RNG can have
+        // simple patterns, we compare against the most significant bit. This is
+        // easiest done using a sign test.
+        (rng.next_u32() as i32) < 0
+    }
+}
+
+macro_rules! tuple_impl {
+    // use variables to indicate the arity of the tuple
+    ($($tyvar:ident),* ) => {
+        // the trailing commas are for the 1 tuple
+        impl< $( $tyvar ),* >
+            Distribution<( $( $tyvar ),* , )>
+            for Standard
+            where $( Standard: Distribution<$tyvar> ),*
+        {
+            #[inline]
+            fn sample<R: Rng + ?Sized>(&self, _rng: &mut R) -> ( $( $tyvar ),* , ) {
+                (
+                    // use the $tyvar's to get the appropriate number of
+                    // repeats (they're not actually needed)
+                    $(
+                        _rng.gen::<$tyvar>()
+                    ),*
+                    ,
+                )
+            }
+        }
+    }
+}
+
+impl Distribution<()> for Standard {
+    #[inline]
+    fn sample<R: Rng + ?Sized>(&self, _: &mut R) -> () { () }
+}
+tuple_impl!{A}
+tuple_impl!{A, B}
+tuple_impl!{A, B, C}
+tuple_impl!{A, B, C, D}
+tuple_impl!{A, B, C, D, E}
+tuple_impl!{A, B, C, D, E, F}
+tuple_impl!{A, B, C, D, E, F, G}
+tuple_impl!{A, B, C, D, E, F, G, H}
+tuple_impl!{A, B, C, D, E, F, G, H, I}
+tuple_impl!{A, B, C, D, E, F, G, H, I, J}
+tuple_impl!{A, B, C, D, E, F, G, H, I, J, K}
+tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L}
+
+macro_rules! array_impl {
+    // recursive, given at least one type parameter:
+    {$n:expr, $t:ident, $($ts:ident,)*} => {
+        array_impl!{($n - 1), $($ts,)*}
+
+        impl<T> Distribution<[T; $n]> for Standard where Standard: Distribution<T> {
+            #[inline]
+            fn sample<R: Rng + ?Sized>(&self, _rng: &mut R) -> [T; $n] {
+                [_rng.gen::<$t>(), $(_rng.gen::<$ts>()),*]
+            }
+        }
+    };
+    // empty case:
+    {$n:expr,} => {
+        impl<T> Distribution<[T; $n]> for Standard {
+            fn sample<R: Rng + ?Sized>(&self, _rng: &mut R) -> [T; $n] { [] }
+        }
+    };
+}
+
+array_impl!{32, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,}
+
+impl<T> Distribution<Option<T>> for Standard where Standard: Distribution<T> {
+    #[inline]
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Option<T> {
+        // UFCS is needed here: https://github.com/rust-lang/rust/issues/24066
+        if rng.gen::<bool>() {
+            Some(rng.gen())
+        } else {
+            None
+        }
+    }
+}
+
+impl<T> Distribution<Wrapping<T>> for Standard where Standard: Distribution<T> {
+    #[inline]
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Wrapping<T> {
+        Wrapping(rng.gen())
+    }
+}
+
+
+#[cfg(test)]
+mod tests {
+    use {Rng, RngCore, Standard};
+    use distributions::Alphanumeric;
+    #[cfg(all(not(feature="std"), feature="alloc"))] use alloc::string::String;
+
+    #[test]
+    fn test_misc() {
+        let rng: &mut RngCore = &mut ::test::rng(820);
+        
+        rng.sample::<char, _>(Standard);
+        rng.sample::<bool, _>(Standard);
+    }
+    
+    #[cfg(feature="alloc")]
+    #[test]
+    fn test_chars() {
+        use core::iter;
+        let mut rng = ::test::rng(805);
+
+        // Test by generating a relatively large number of chars, so we also
+        // take the rejection sampling path.
+        let word: String = iter::repeat(())
+                .map(|()| rng.gen::<char>()).take(1000).collect();
+        assert!(word.len() != 0);
+    }
+
+    #[test]
+    fn test_alphanumeric() {
+        let mut rng = ::test::rng(806);
+
+        // Test by generating a relatively large number of chars, so we also
+        // take the rejection sampling path.
+        let mut incorrect = false;
+        for _ in 0..100 {
+            let c = rng.sample(Alphanumeric);
+            incorrect |= !((c >= '0' && c <= '9') ||
+                           (c >= 'A' && c <= 'Z') ||
+                           (c >= 'a' && c <= 'z') );
+        }
+        assert!(incorrect == false);
+    }
+}
diff --git a/rustc_deps/vendor/rand/src/distributions/pareto.rs b/rustc_deps/vendor/rand/src/distributions/pareto.rs
new file mode 100644
index 0000000..ba628e0
--- /dev/null
+++ b/rustc_deps/vendor/rand/src/distributions/pareto.rs
@@ -0,0 +1,76 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// https://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! The Pareto distribution.
+
+use Rng;
+use distributions::{Distribution, OpenClosed01};
+
+/// Samples floating-point numbers according to the Pareto distribution
+///
+/// # Example
+/// ```
+/// use rand::prelude::*;
+/// use rand::distributions::Pareto;
+///
+/// let val: f64 = SmallRng::from_entropy().sample(Pareto::new(1., 2.));
+/// println!("{}", val);
+/// ```
+#[derive(Clone, Copy, Debug)]
+pub struct Pareto {
+    scale: f64,
+    inv_neg_shape: f64,
+}
+
+impl Pareto {
+    /// Construct a new Pareto distribution with given `scale` and `shape`.
+    ///
+    /// In the literature, `scale` is commonly written as x<sub>m</sub> or k and
+    /// `shape` is often written as α.
+    ///
+    /// # Panics
+    ///
+    /// `scale` and `shape` have to be non-zero and positive.
+    pub fn new(scale: f64, shape: f64) -> Pareto {
+        assert!((scale > 0.) & (shape > 0.));
+        Pareto { scale, inv_neg_shape: -1.0 / shape }
+    }
+}
+
+impl Distribution<f64> for Pareto {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
+        let u: f64 = rng.sample(OpenClosed01);
+        self.scale * u.powf(self.inv_neg_shape)
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use distributions::Distribution;
+    use super::Pareto;
+
+    #[test]
+    #[should_panic]
+    fn invalid() {
+        Pareto::new(0., 0.);
+    }
+
+    #[test]
+    fn sample() {
+        let scale = 1.0;
+        let shape = 2.0;
+        let d = Pareto::new(scale, shape);
+        let mut rng = ::test::rng(1);
+        for _ in 0..1000 {
+            let r = d.sample(&mut rng);
+            assert!(r >= scale);
+        }
+    }
+}
diff --git a/rustc_deps/vendor/rand/src/distributions/poisson.rs b/rustc_deps/vendor/rand/src/distributions/poisson.rs
new file mode 100644
index 0000000..bdecb77
--- /dev/null
+++ b/rustc_deps/vendor/rand/src/distributions/poisson.rs
@@ -0,0 +1,158 @@
+// Copyright 2016-2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// https://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! The Poisson distribution.
+
+use Rng;
+use distributions::{Distribution, Cauchy};
+use distributions::log_gamma::log_gamma;
+
+/// The Poisson distribution `Poisson(lambda)`.
+///
+/// This distribution has a density function:
+/// `f(k) = lambda^k * exp(-lambda) / k!` for `k >= 0`.
+///
+/// # Example
+///
+/// ```
+/// use rand::distributions::{Poisson, Distribution};
+///
+/// let poi = Poisson::new(2.0);
+/// let v = poi.sample(&mut rand::thread_rng());
+/// println!("{} is from a Poisson(2) distribution", v);
+/// ```
+#[derive(Clone, Copy, Debug)]
+pub struct Poisson {
+    lambda: f64,
+    // precalculated values
+    exp_lambda: f64,
+    log_lambda: f64,
+    sqrt_2lambda: f64,
+    magic_val: f64,
+}
+
+impl Poisson {
+    /// Construct a new `Poisson` with the given shape parameter
+    /// `lambda`. Panics if `lambda <= 0`.
+    pub fn new(lambda: f64) -> Poisson {
+        assert!(lambda > 0.0, "Poisson::new called with lambda <= 0");
+        let log_lambda = lambda.ln();
+        Poisson {
+            lambda,
+            exp_lambda: (-lambda).exp(),
+            log_lambda,
+            sqrt_2lambda: (2.0 * lambda).sqrt(),
+            magic_val: lambda * log_lambda - log_gamma(1.0 + lambda),
+        }
+    }
+}
+
+impl Distribution<u64> for Poisson {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u64 {
+        // using the algorithm from Numerical Recipes in C
+
+        // for low expected values use the Knuth method
+        if self.lambda < 12.0 {
+            let mut result = 0;
+            let mut p = 1.0;
+            while p > self.exp_lambda {
+                p *= rng.gen::<f64>();
+                result += 1;
+            }
+            result - 1
+        }
+        // high expected values - rejection method
+        else {
+            let mut int_result: u64;
+
+            // we use the Cauchy distribution as the comparison distribution
+            // f(x) ~ 1/(1+x^2)
+            let cauchy = Cauchy::new(0.0, 1.0);
+
+            loop {
+                let mut result;
+                let mut comp_dev;
+
+                loop {
+                    // draw from the Cauchy distribution
+                    comp_dev = rng.sample(cauchy);
+                    // shift the peak of the comparison ditribution
+                    result = self.sqrt_2lambda * comp_dev + self.lambda;
+                    // repeat the drawing until we are in the range of possible values
+                    if result >= 0.0 {
+                        break;
+                    }
+                }
+                // now the result is a random variable greater than 0 with Cauchy distribution
+                // the result should be an integer value
+                result = result.floor();
+                int_result = result as u64;
+
+                // this is the ratio of the Poisson distribution to the comparison distribution
+                // the magic value scales the distribution function to a range of approximately 0-1
+                // since it is not exact, we multiply the ratio by 0.9 to avoid ratios greater than 1
+                // this doesn't change the resulting distribution, only increases the rate of failed drawings
+                let check = 0.9 * (1.0 + comp_dev * comp_dev)
+                    * (result * self.log_lambda - log_gamma(1.0 + result) - self.magic_val).exp();
+
+                // check with uniform random value - if below the threshold, we are within the target distribution
+                if rng.gen::<f64>() <= check {
+                    break;
+                }
+            }
+            int_result
+        }
+    }
+}
+
+#[cfg(test)]
+mod test {
+    use distributions::Distribution;
+    use super::Poisson;
+
+    #[test]
+    fn test_poisson_10() {
+        let poisson = Poisson::new(10.0);
+        let mut rng = ::test::rng(123);
+        let mut sum = 0;
+        for _ in 0..1000 {
+            sum += poisson.sample(&mut rng);
+        }
+        let avg = (sum as f64) / 1000.0;
+        println!("Poisson average: {}", avg);
+        assert!((avg - 10.0).abs() < 0.5); // not 100% certain, but probable enough
+    }
+
+    #[test]
+    fn test_poisson_15() {
+        // Take the 'high expected values' path
+        let poisson = Poisson::new(15.0);
+        let mut rng = ::test::rng(123);
+        let mut sum = 0;
+        for _ in 0..1000 {
+            sum += poisson.sample(&mut rng);
+        }
+        let avg = (sum as f64) / 1000.0;
+        println!("Poisson average: {}", avg);
+        assert!((avg - 15.0).abs() < 0.5); // not 100% certain, but probable enough
+    }
+
+    #[test]
+    #[should_panic]
+    fn test_poisson_invalid_lambda_zero() {
+        Poisson::new(0.0);
+    }
+
+    #[test]
+    #[should_panic]
+    fn test_poisson_invalid_lambda_neg() {
+        Poisson::new(-10.0);
+    }
+}
diff --git a/rustc_deps/vendor/rand/src/distributions/uniform.rs b/rustc_deps/vendor/rand/src/distributions/uniform.rs
new file mode 100644
index 0000000..8fda031
--- /dev/null
+++ b/rustc_deps/vendor/rand/src/distributions/uniform.rs
@@ -0,0 +1,856 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// https://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! A distribution uniformly sampling numbers within a given range.
+//!
+//! [`Uniform`] is the standard distribution to sample uniformly from a range;
+//! e.g. `Uniform::new_inclusive(1, 6)` can sample integers from 1 to 6, like a
+//! standard die. [`Rng::gen_range`] supports any type supported by
+//! [`Uniform`].
+//!
+//! This distribution is provided with support for several primitive types
+//! (all integer and floating-point types) as well as `std::time::Duration`,
+//! and supports extension to user-defined types via a type-specific *back-end*
+//! implementation.
+//!
+//! The types [`UniformInt`], [`UniformFloat`] and [`UniformDuration`] are the
+//! back-ends supporting sampling from primitive integer and floating-point
+//! ranges as well as from `std::time::Duration`; these types do not normally
+//! need to be used directly (unless implementing a derived back-end).
+//!
+//! # Example usage
+//!
+//! ```
+//! use rand::{Rng, thread_rng};
+//! use rand::distributions::Uniform;
+//! 
+//! let mut rng = thread_rng();
+//! let side = Uniform::new(-10.0, 10.0);
+//! 
+//! // sample between 1 and 10 points
+//! for _ in 0..rng.gen_range(1, 11) {
+//!     // sample a point from the square with sides -10 - 10 in two dimensions
+//!     let (x, y) = (rng.sample(side), rng.sample(side));
+//!     println!("Point: {}, {}", x, y);
+//! }
+//! ```
+//!
+//! # Extending `Uniform` to support a custom type
+//!
+//! To extend [`Uniform`] to support your own types, write a back-end which
+//! implements the [`UniformSampler`] trait, then implement the [`SampleUniform`]
+//! helper trait to "register" your back-end. See the `MyF32` example below.
+//!
+//! At a minimum, the back-end needs to store any parameters needed for sampling
+//! (e.g. the target range) and implement `new`, `new_inclusive` and `sample`.
+//! Those methods should include an assert to check the range is valid (i.e.
+//! `low < high`). The example below merely wraps another back-end.
+//!
+//! ```
+//! use rand::prelude::*;
+//! use rand::distributions::uniform::{Uniform, SampleUniform,
+//!         UniformSampler, UniformFloat};
+//!
+//! struct MyF32(f32);
+//!
+//! #[derive(Clone, Copy, Debug)]
+//! struct UniformMyF32 {
+//!     inner: UniformFloat<f32>,
+//! }
+//!
+//! impl UniformSampler for UniformMyF32 {
+//!     type X = MyF32;
+//!     fn new(low: Self::X, high: Self::X) -> Self {
+//!         UniformMyF32 {
+//!             inner: UniformFloat::<f32>::new(low.0, high.0),
+//!         }
+//!     }
+//!     fn new_inclusive(low: Self::X, high: Self::X) -> Self {
+//!         UniformSampler::new(low, high)
+//!     }
+//!     fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::X {
+//!         MyF32(self.inner.sample(rng))
+//!     }
+//! }
+//!
+//! impl SampleUniform for MyF32 {
+//!     type Sampler = UniformMyF32;
+//! }
+//!
+//! let (low, high) = (MyF32(17.0f32), MyF32(22.0f32));
+//! let uniform = Uniform::new(low, high);
+//! let x = uniform.sample(&mut thread_rng());
+//! ```
+//!
+//! [`Uniform`]: struct.Uniform.html
+//! [`Rng::gen_range`]: ../../trait.Rng.html#method.gen_range
+//! [`SampleUniform`]: trait.SampleUniform.html
+//! [`UniformSampler`]: trait.UniformSampler.html
+//! [`UniformInt`]: struct.UniformInt.html
+//! [`UniformFloat`]: struct.UniformFloat.html
+//! [`UniformDuration`]: struct.UniformDuration.html
+
+#[cfg(feature = "std")]
+use std::time::Duration;
+
+use Rng;
+use distributions::Distribution;
+use distributions::float::IntoFloat;
+
+/// Sample values uniformly between two bounds.
+///
+/// [`Uniform::new`] and [`Uniform::new_inclusive`] construct a uniform
+/// distribution sampling from the given range; these functions may do extra
+/// work up front to make sampling of multiple values faster.
+///
+/// When sampling from a constant range, many calculations can happen at
+/// compile-time and all methods should be fast; for floating-point ranges and
+/// the full range of integer types this should have comparable performance to
+/// the `Standard` distribution.
+///
+/// Steps are taken to avoid bias which might be present in naive
+/// implementations; for example `rng.gen::<u8>() % 170` samples from the range
+/// `[0, 169]` but is twice as likely to select numbers less than 85 than other
+/// values. Further, the implementations here give more weight to the high-bits
+/// generated by the RNG than the low bits, since with some RNGs the low-bits
+/// are of lower quality than the high bits.
+///
+/// Implementations should attempt to sample in `[low, high)` for
+/// `Uniform::new(low, high)`, i.e., excluding `high`, but this may be very
+/// difficult. All the primitive integer types satisfy this property, and the
+/// float types normally satisfy it, but rounding may mean `high` can occur.
+///
+/// # Example
+///
+/// ```
+/// use rand::distributions::{Distribution, Uniform};
+///
+/// fn main() {
+///     let between = Uniform::from(10..10000);
+///     let mut rng = rand::thread_rng();
+///     let mut sum = 0;
+///     for _ in 0..1000 {
+///         sum += between.sample(&mut rng);
+///     }
+///     println!("{}", sum);
+/// }
+/// ```
+///
+/// [`Uniform::new`]: struct.Uniform.html#method.new
+/// [`Uniform::new_inclusive`]: struct.Uniform.html#method.new_inclusive
+/// [`new`]: struct.Uniform.html#method.new
+/// [`new_inclusive`]: struct.Uniform.html#method.new_inclusive
+#[derive(Clone, Copy, Debug)]
+pub struct Uniform<X: SampleUniform> {
+    inner: X::Sampler,
+}
+
+impl<X: SampleUniform> Uniform<X> {
+    /// Create a new `Uniform` instance which samples uniformly from the half
+    /// open range `[low, high)` (excluding `high`). Panics if `low >= high`.
+    pub fn new(low: X, high: X) -> Uniform<X> {
+        Uniform { inner: X::Sampler::new(low, high) }
+    }
+
+    /// Create a new `Uniform` instance which samples uniformly from the closed
+    /// range `[low, high]` (inclusive). Panics if `low > high`.
+    pub fn new_inclusive(low: X, high: X) -> Uniform<X> {
+        Uniform { inner: X::Sampler::new_inclusive(low, high) }
+    }
+}
+
+impl<X: SampleUniform> Distribution<X> for Uniform<X> {
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> X {
+        self.inner.sample(rng)
+    }
+}
+
+/// Helper trait for creating objects using the correct implementation of
+/// [`UniformSampler`] for the sampling type.
+///
+/// See the [module documentation] on how to implement [`Uniform`] range
+/// sampling for a custom type.
+///
+/// [`UniformSampler`]: trait.UniformSampler.html
+/// [module documentation]: index.html
+/// [`Uniform`]: struct.Uniform.html
+pub trait SampleUniform: Sized {
+    /// The `UniformSampler` implementation supporting type `X`.
+    type Sampler: UniformSampler<X = Self>;
+}
+
+/// Helper trait handling actual uniform sampling.
+///
+/// See the [module documentation] on how to implement [`Uniform`] range
+/// sampling for a custom type.
+///
+/// Implementation of [`sample_single`] is optional, and is only useful when
+/// the implementation can be faster than `Self::new(low, high).sample(rng)`.
+///
+/// [module documentation]: index.html
+/// [`Uniform`]: struct.Uniform.html
+/// [`sample_single`]: trait.UniformSampler.html#method.sample_single
+pub trait UniformSampler: Sized {
+    /// The type sampled by this implementation.
+    type X;
+
+    /// Construct self, with inclusive lower bound and exclusive upper bound
+    /// `[low, high)`.
+    ///
+    /// Usually users should not call this directly but instead use
+    /// `Uniform::new`, which asserts that `low < high` before calling this.
+    fn new(low: Self::X, high: Self::X) -> Self;
+
+    /// Construct self, with inclusive bounds `[low, high]`.
+    ///
+    /// Usually users should not call this directly but instead use
+    /// `Uniform::new_inclusive`, which asserts that `low <= high` before
+    /// calling this.
+    fn new_inclusive(low: Self::X, high: Self::X) -> Self;
+
+    /// Sample a value.
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::X;
+
+    /// Sample a single value uniformly from a range with inclusive lower bound
+    /// and exclusive upper bound `[low, high)`.
+    ///
+    /// Usually users should not call this directly but instead use
+    /// `Uniform::sample_single`, which asserts that `low < high` before calling
+    /// this.
+    ///
+    /// Via this method, implementations can provide a method optimized for
+    /// sampling only a single value from the specified range. The default
+    /// implementation simply calls `UniformSampler::new` then `sample` on the
+    /// result.
+    fn sample_single<R: Rng + ?Sized>(low: Self::X, high: Self::X, rng: &mut R)
+        -> Self::X
+    {
+        let uniform: Self = UniformSampler::new(low, high);
+        uniform.sample(rng)
+    }
+}
+
+impl<X: SampleUniform> From<::core::ops::Range<X>> for Uniform<X> {
+    fn from(r: ::core::ops::Range<X>) -> Uniform<X> {
+        Uniform::new(r.start, r.end)
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+// What follows are all back-ends.
+
+
+/// The back-end implementing [`UniformSampler`] for integer types.
+///
+/// Unless you are implementing [`UniformSampler`] for your own type, this type
+/// should not be used directly, use [`Uniform`] instead.
+///
+/// # Implementation notes
+///
+/// For a closed range, the number of possible numbers we should generate is
+/// `range = (high - low + 1)`. It is not possible to end up with a uniform
+/// distribution if we map *all* the random integers that can be generated to
+/// this range. We have to map integers from a `zone` that is a multiple of the
+/// range. The rest of the integers, that cause a bias, are rejected.
+///
+/// The problem with `range` is that to cover the full range of the type, it has
+/// to store `unsigned_max + 1`, which can't be represented. But if the range
+/// covers the full range of the type, no modulus is needed. A range of size 0
+/// can't exist, so we use that to represent this special case. Wrapping
+/// arithmetic even makes representing `unsigned_max + 1` as 0 simple.
+///
+/// We don't calculate `zone` directly, but first calculate the number of
+/// integers to reject. To handle `unsigned_max + 1` not fitting in the type,
+/// we use:
+/// `ints_to_reject = (unsigned_max + 1) % range;`
+/// `ints_to_reject = (unsigned_max - range + 1) % range;`
+///
+/// The smallest integer PRNGs generate is `u32`. That is why for small integer
+/// sizes (`i8`/`u8` and `i16`/`u16`) there is an optimization: don't pick the
+/// largest zone that can fit in the small type, but pick the largest zone that
+/// can fit in an `u32`. `ints_to_reject` is always less than half the size of
+/// the small integer. This means the first bit of `zone` is always 1, and so
+/// are all the other preceding bits of a larger integer. The easiest way to
+/// grow the `zone` for the larger type is to simply sign extend it.
+///
+/// An alternative to using a modulus is widening multiply: After a widening
+/// multiply by `range`, the result is in the high word. Then comparing the low
+/// word against `zone` makes sure our distribution is uniform.
+///
+/// [`UniformSampler`]: trait.UniformSampler.html
+/// [`Uniform`]: struct.Uniform.html
+#[derive(Clone, Copy, Debug)]
+pub struct UniformInt<X> {
+    low: X,
+    range: X,
+    zone: X,
+}
+
+macro_rules! uniform_int_impl {
+    ($ty:ty, $signed:ty, $unsigned:ident,
+     $i_large:ident, $u_large:ident) => {
+        impl SampleUniform for $ty {
+            type Sampler = UniformInt<$ty>;
+        }
+
+        impl UniformSampler for UniformInt<$ty> {
+            // We play free and fast with unsigned vs signed here
+            // (when $ty is signed), but that's fine, since the
+            // contract of this macro is for $ty and $unsigned to be
+            // "bit-equal", so casting between them is a no-op.
+
+            type X = $ty;
+
+            #[inline] // if the range is constant, this helps LLVM to do the
+                      // calculations at compile-time.
+            fn new(low: Self::X, high: Self::X) -> Self {
+                assert!(low < high, "Uniform::new called with `low >= high`");
+                UniformSampler::new_inclusive(low, high - 1)
+            }
+
+            #[inline] // if the range is constant, this helps LLVM to do the
+                      // calculations at compile-time.
+            fn new_inclusive(low: Self::X, high: Self::X) -> Self {
+                assert!(low <= high,
+                        "Uniform::new_inclusive called with `low > high`");
+                let unsigned_max = ::core::$unsigned::MAX;
+
+                let range = high.wrapping_sub(low).wrapping_add(1) as $unsigned;
+                let ints_to_reject =
+                    if range > 0 {
+                        (unsigned_max - range + 1) % range
+                    } else {
+                        0
+                    };
+                let zone = unsigned_max - ints_to_reject;
+
+                UniformInt {
+                    low: low,
+                    // These are really $unsigned values, but store as $ty:
+                    range: range as $ty,
+                    zone: zone as $ty
+                }
+            }
+
+            fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::X {
+                let range = self.range as $unsigned as $u_large;
+                if range > 0 {
+                    // Grow `zone` to fit a type of at least 32 bits, by
+                    // sign-extending it (the first bit is always 1, so are all
+                    // the preceding bits of the larger type).
+                    // For types that already have the right size, all the
+                    // casting is a no-op.
+                    let zone = self.zone as $signed as $i_large as $u_large;
+                    loop {
+                        let v: $u_large = rng.gen();
+                        let (hi, lo) = v.wmul(range);
+                        if lo <= zone {
+                            return self.low.wrapping_add(hi as $ty);
+                        }
+                    }
+                } else {
+                    // Sample from the entire integer range.
+                    rng.gen()
+                }
+            }
+
+            fn sample_single<R: Rng + ?Sized>(low: Self::X,
+                                              high: Self::X,
+                                              rng: &mut R) -> Self::X
+            {
+                assert!(low < high,
+                        "Uniform::sample_single called with low >= high");
+                let range = high.wrapping_sub(low) as $unsigned as $u_large;
+                let zone =
+                    if ::core::$unsigned::MAX <= ::core::u16::MAX as $unsigned {
+                        // Using a modulus is faster than the approximation for
+                        // i8 and i16. I suppose we trade the cost of one
+                        // modulus for near-perfect branch prediction.
+                        let unsigned_max: $u_large = ::core::$u_large::MAX;
+                        let ints_to_reject = (unsigned_max - range + 1) % range;
+                        unsigned_max - ints_to_reject
+                    } else {
+                        // conservative but fast approximation
+                       range << range.leading_zeros()
+                    };
+
+                loop {
+                    let v: $u_large = rng.gen();
+                    let (hi, lo) = v.wmul(range);
+                    if lo <= zone {
+                        return low.wrapping_add(hi as $ty);
+                    }
+                }
+            }
+        }
+    }
+}
+
+uniform_int_impl! { i8, i8, u8, i32, u32 }
+uniform_int_impl! { i16, i16, u16, i32, u32 }
+uniform_int_impl! { i32, i32, u32, i32, u32 }
+uniform_int_impl! { i64, i64, u64, i64, u64 }
+#[cfg(feature = "i128_support")]
+uniform_int_impl! { i128, i128, u128, u128, u128 }
+uniform_int_impl! { isize, isize, usize, isize, usize }
+uniform_int_impl! { u8, i8, u8, i32, u32 }
+uniform_int_impl! { u16, i16, u16, i32, u32 }
+uniform_int_impl! { u32, i32, u32, i32, u32 }
+uniform_int_impl! { u64, i64, u64, i64, u64 }
+uniform_int_impl! { usize, isize, usize, isize, usize }
+#[cfg(feature = "i128_support")]
+uniform_int_impl! { u128, u128, u128, i128, u128 }
+
+
+trait WideningMultiply<RHS = Self> {
+    type Output;
+
+    fn wmul(self, x: RHS) -> Self::Output;
+}
+
+macro_rules! wmul_impl {
+    ($ty:ty, $wide:ty, $shift:expr) => {
+        impl WideningMultiply for $ty {
+            type Output = ($ty, $ty);
+
+            #[inline(always)]
+            fn wmul(self, x: $ty) -> Self::Output {
+                let tmp = (self as $wide) * (x as $wide);
+                ((tmp >> $shift) as $ty, tmp as $ty)
+            }
+        }
+    }
+}
+wmul_impl! { u8, u16, 8 }
+wmul_impl! { u16, u32, 16 }
+wmul_impl! { u32, u64, 32 }
+#[cfg(feature = "i128_support")]
+wmul_impl! { u64, u128, 64 }
+
+// This code is a translation of the __mulddi3 function in LLVM's
+// compiler-rt. It is an optimised variant of the common method
+// `(a + b) * (c + d) = ac + ad + bc + bd`.
+//
+// For some reason LLVM can optimise the C version very well, but
+// keeps shuffeling registers in this Rust translation.
+macro_rules! wmul_impl_large {
+    ($ty:ty, $half:expr) => {
+        impl WideningMultiply for $ty {
+            type Output = ($ty, $ty);
+
+            #[inline(always)]
+            fn wmul(self, b: $ty) -> Self::Output {
+                const LOWER_MASK: $ty = !0 >> $half;
+                let mut low = (self & LOWER_MASK).wrapping_mul(b & LOWER_MASK);
+                let mut t = low >> $half;
+                low &= LOWER_MASK;
+                t += (self >> $half).wrapping_mul(b & LOWER_MASK);
+                low += (t & LOWER_MASK) << $half;
+                let mut high = t >> $half;
+                t = low >> $half;
+                low &= LOWER_MASK;
+                t += (b >> $half).wrapping_mul(self & LOWER_MASK);
+                low += (t & LOWER_MASK) << $half;
+                high += t >> $half;
+                high += (self >> $half).wrapping_mul(b >> $half);
+
+                (high, low)
+            }
+        }
+    }
+}
+#[cfg(not(feature = "i128_support"))]
+wmul_impl_large! { u64, 32 }
+#[cfg(feature = "i128_support")]
+wmul_impl_large! { u128, 64 }
+
+macro_rules! wmul_impl_usize {
+    ($ty:ty) => {
+        impl WideningMultiply for usize {
+            type Output = (usize, usize);
+
+            #[inline(always)]
+            fn wmul(self, x: usize) -> Self::Output {
+                let (high, low) = (self as $ty).wmul(x as $ty);
+                (high as usize, low as usize)
+            }
+        }
+    }
+}
+#[cfg(target_pointer_width = "32")]
+wmul_impl_usize! { u32 }
+#[cfg(target_pointer_width = "64")]
+wmul_impl_usize! { u64 }
+
+
+
+/// The back-end implementing [`UniformSampler`] for floating-point types.
+///
+/// Unless you are implementing [`UniformSampler`] for your own type, this type
+/// should not be used directly, use [`Uniform`] instead.
+///
+/// # Implementation notes
+///
+/// Instead of generating a float in the `[0, 1)` range using [`Standard`], the
+/// `UniformFloat` implementation converts the output of an PRNG itself. This
+/// way one or two steps can be optimized out.
+///
+/// The floats are first converted to a value in the `[1, 2)` interval using a
+/// transmute-based method, and then mapped to the expected range with a
+/// multiply and addition. Values produced this way have what equals 22 bits of
+/// random digits for an `f32`, and 52 for an `f64`.
+///
+/// Currently there is no difference between [`new`] and [`new_inclusive`],
+/// because the boundaries of a floats range are a bit of a fuzzy concept due to
+/// rounding errors.
+///
+/// [`UniformSampler`]: trait.UniformSampler.html
+/// [`new`]: trait.UniformSampler.html#tymethod.new
+/// [`new_inclusive`]: trait.UniformSampler.html#tymethod.new_inclusive
+/// [`Uniform`]: struct.Uniform.html
+/// [`Standard`]: ../struct.Standard.html
+#[derive(Clone, Copy, Debug)]
+pub struct UniformFloat<X> {
+    scale: X,
+    offset: X,
+}
+
+macro_rules! uniform_float_impl {
+    ($ty:ty, $bits_to_discard:expr, $next_u:ident) => {
+        impl SampleUniform for $ty {
+            type Sampler = UniformFloat<$ty>;
+        }
+
+        impl UniformSampler for UniformFloat<$ty> {
+            type X = $ty;
+
+            fn new(low: Self::X, high: Self::X) -> Self {
+                assert!(low < high, "Uniform::new called with `low >= high`");
+                let scale = high - low;
+                let offset = low - scale;
+                UniformFloat {
+                    scale: scale,
+                    offset: offset,
+                }
+            }
+
+            fn new_inclusive(low: Self::X, high: Self::X) -> Self {
+                assert!(low <= high,
+                        "Uniform::new_inclusive called with `low > high`");
+                let scale = high - low;
+                let offset = low - scale;
+                UniformFloat {
+                    scale: scale,
+                    offset: offset,
+                }
+            }
+
+            fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::X {
+                // Generate a value in the range [1, 2)
+                let value1_2 = (rng.$next_u() >> $bits_to_discard)
+                               .into_float_with_exponent(0);
+                // We don't use `f64::mul_add`, because it is not available with
+                // `no_std`. Furthermore, it is slower for some targets (but
+                // faster for others). However, the order of multiplication and
+                // addition is important, because on some platforms (e.g. ARM)
+                // it will be optimized to a single (non-FMA) instruction.
+                value1_2 * self.scale + self.offset
+            }
+
+            fn sample_single<R: Rng + ?Sized>(low: Self::X,
+                                              high: Self::X,
+                                              rng: &mut R) -> Self::X {
+                assert!(low < high,
+                        "Uniform::sample_single called with low >= high");
+                let scale = high - low;
+                let offset = low - scale;
+                // Generate a value in the range [1, 2)
+                let value1_2 = (rng.$next_u() >> $bits_to_discard)
+                               .into_float_with_exponent(0);
+                // Doing multiply before addition allows some architectures to
+                // use a single instruction.
+                value1_2 * scale + offset
+            }
+        }
+    }
+}
+
+uniform_float_impl! { f32, 32 - 23, next_u32 }
+uniform_float_impl! { f64, 64 - 52, next_u64 }
+
+
+
+/// The back-end implementing [`UniformSampler`] for `Duration`.
+///
+/// Unless you are implementing [`UniformSampler`] for your own types, this type
+/// should not be used directly, use [`Uniform`] instead.
+///
+/// [`UniformSampler`]: trait.UniformSampler.html
+/// [`Uniform`]: struct.Uniform.html
+#[cfg(feature = "std")]
+#[derive(Clone, Copy, Debug)]
+pub struct UniformDuration {
+    offset: Duration,
+    mode: UniformDurationMode,
+}
+
+#[cfg(feature = "std")]
+#[derive(Debug, Copy, Clone)]
+enum UniformDurationMode {
+    Small {
+        nanos: Uniform<u64>,
+    },
+    Large {
+        size: Duration,
+        secs: Uniform<u64>,
+    }
+}
+
+#[cfg(feature = "std")]
+impl SampleUniform for Duration {
+    type Sampler = UniformDuration;
+}
+
+#[cfg(feature = "std")]
+impl UniformSampler for UniformDuration {
+    type X = Duration;
+
+    #[inline]
+    fn new(low: Duration, high: Duration) -> UniformDuration {
+        assert!(low < high, "Uniform::new called with `low >= high`");
+        UniformDuration::new_inclusive(low, high - Duration::new(0, 1))
+    }
+
+    #[inline]
+    fn new_inclusive(low: Duration, high: Duration) -> UniformDuration {
+        assert!(low <= high, "Uniform::new_inclusive called with `low > high`");
+        let size = high - low;
+        let nanos = size
+            .as_secs()
+            .checked_mul(1_000_000_000)
+            .and_then(|n| n.checked_add(size.subsec_nanos() as u64));
+
+        let mode = match nanos {
+            Some(nanos) => {
+                UniformDurationMode::Small {
+                    nanos: Uniform::new_inclusive(0, nanos),
+                }
+            }
+            None => {
+                UniformDurationMode::Large {
+                    size: size,
+                    secs: Uniform::new_inclusive(0, size.as_secs()),
+                }
+            }
+        };
+
+        UniformDuration {
+            mode,
+            offset: low,
+        }
+    }
+
+    #[inline]
+    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Duration {
+        let d = match self.mode {
+            UniformDurationMode::Small { nanos } => {
+                let nanos = nanos.sample(rng);
+                Duration::new(nanos / 1_000_000_000, (nanos % 1_000_000_000) as u32)
+            }
+            UniformDurationMode::Large { size, secs } => {
+                // constant folding means this is at least as fast as `gen_range`
+                let nano_range = Uniform::new(0, 1_000_000_000);
+                loop {
+                    let d = Duration::new(secs.sample(rng), nano_range.sample(rng));
+                    if d <= size {
+                        break d;
+                    }
+                }
+            }
+        };
+
+        self.offset + d
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use Rng;
+    use distributions::uniform::{Uniform, UniformSampler, UniformFloat, SampleUniform};
+
+    #[should_panic]
+    #[test]
+    fn test_uniform_bad_limits_equal_int() {
+        Uniform::new(10, 10);
+    }
+
+    #[should_panic]
+    #[test]
+    fn test_uniform_bad_limits_equal_float() {
+        Uniform::new(10., 10.);
+    }
+
+    #[test]
+    fn test_uniform_good_limits_equal_int() {
+        let mut rng = ::test::rng(804);
+        let dist = Uniform::new_inclusive(10, 10);
+        for _ in 0..20 {
+            assert_eq!(rng.sample(dist), 10);
+        }
+    }
+
+    #[test]
+    fn test_uniform_good_limits_equal_float() {
+        let mut rng = ::test::rng(805);
+        let dist = Uniform::new_inclusive(10., 10.);
+        for _ in 0..20 {
+            assert_eq!(rng.sample(dist), 10.);
+        }
+    }
+
+    #[should_panic]
+    #[test]
+    fn test_uniform_bad_limits_flipped_int() {
+        Uniform::new(10, 5);
+    }
+
+    #[should_panic]
+    #[test]
+    fn test_uniform_bad_limits_flipped_float() {
+        Uniform::new(10., 5.);
+    }
+
+    #[test]
+    fn test_integers() {
+        let mut rng = ::test::rng(251);
+        macro_rules! t {
+            ($($ty:ident),*) => {{
+                $(
+                   let v: &[($ty, $ty)] = &[(0, 10),
+                                            (10, 127),
+                                            (::core::$ty::MIN, ::core::$ty::MAX)];
+                   for &(low, high) in v.iter() {
+                        let my_uniform = Uniform::new(low, high);
+                        for _ in 0..1000 {
+                            let v: $ty = rng.sample(my_uniform);
+                            assert!(low <= v && v < high);
+                        }
+
+                        let my_uniform = Uniform::new_inclusive(low, high);
+                        for _ in 0..1000 {
+                            let v: $ty = rng.sample(my_uniform);
+                            assert!(low <= v && v <= high);
+                        }
+
+                        for _ in 0..1000 {
+                            let v: $ty = rng.gen_range(low, high);
+                            assert!(low <= v && v < high);
+                        }
+                    }
+                 )*
+            }}
+        }
+        t!(i8, i16, i32, i64, isize,
+           u8, u16, u32, u64, usize);
+        #[cfg(feature = "i128_support")]
+        t!(i128, u128)
+    }
+
+    #[test]
+    fn test_floats() {
+        let mut rng = ::test::rng(252);
+        macro_rules! t {
+            ($($ty:ty),*) => {{
+                $(
+                   let v: &[($ty, $ty)] = &[(0.0, 100.0),
+                                            (-1e35, -1e25),
+                                            (1e-35, 1e-25),
+                                            (-1e35, 1e35)];
+                   for &(low, high) in v.iter() {
+                        let my_uniform = Uniform::new(low, high);
+                        for _ in 0..1000 {
+                            let v: $ty = rng.sample(my_uniform);
+                            assert!(low <= v && v < high);
+                        }
+                    }
+                 )*
+            }}
+        }
+
+        t!(f32, f64)
+    }
+
+    #[test]
+    #[cfg(feature = "std")]
+    fn test_durations() {
+        use std::time::Duration;
+
+        let mut rng = ::test::rng(253);
+
+        let v = &[(Duration::new(10, 50000), Duration::new(100, 1234)),
+                  (Duration::new(0, 100), Duration::new(1, 50)),
+                  (Duration::new(0, 0), Duration::new(u64::max_value(), 999_999_999))];
+        for &(low, high) in v.iter() {
+            let my_uniform = Uniform::new(low, high);
+            for _ in 0..1000 {
+                let v = rng.sample(my_uniform);
+                assert!(low <= v && v < high);
+            }
+        }
+    }
+
+    #[test]
+    fn test_custom_uniform() {
+        #[derive(Clone, Copy, PartialEq, PartialOrd)]
+        struct MyF32 {
+            x: f32,
+        }
+        #[derive(Clone, Copy, Debug)]
+        struct UniformMyF32 {
+            inner: UniformFloat<f32>,
+        }
+        impl UniformSampler for UniformMyF32 {
+            type X = MyF32;
+            fn new(low: Self::X, high: Self::X) -> Self {
+                UniformMyF32 {
+                    inner: UniformFloat::<f32>::new(low.x, high.x),
+                }
+            }
+            fn new_inclusive(low: Self::X, high: Self::X) -> Self {
+                UniformSampler::new(low, high)
+            }
+            fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::X {
+                MyF32 { x: self.inner.sample(rng) }
+            }
+        }
+        impl SampleUniform for MyF32 {
+            type Sampler = UniformMyF32;
+        }
+
+        let (low, high) = (MyF32{ x: 17.0f32 }, MyF32{ x: 22.0f32 });
+        let uniform = Uniform::new(low, high);
+        let mut rng = ::test::rng(804);
+        for _ in 0..100 {
+            let x: MyF32 = rng.sample(uniform);
+            assert!(low <= x && x < high);
+        }
+    }
+
+    #[test]
+    fn test_uniform_from_std_range() {
+        let r = Uniform::from(2u32..7);
+        assert_eq!(r.inner.low, 2);
+        assert_eq!(r.inner.range, 5);
+        let r = Uniform::from(2.0f64..7.0);
+        assert_eq!(r.inner.offset, -3.0);
+        assert_eq!(r.inner.scale, 5.0);
+    }
+}
diff --git a/rustc_deps/vendor/rand/src/distributions/ziggurat_tables.rs b/rustc_deps/vendor/rand/src/distributions/ziggurat_tables.rs
index b6de4bf..11a2172 100644
--- a/rustc_deps/vendor/rand/src/distributions/ziggurat_tables.rs
+++ b/rustc_deps/vendor/rand/src/distributions/ziggurat_tables.rs
@@ -1,10 +1,10 @@
 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
+// https://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
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
diff --git a/rustc_deps/vendor/rand/src/lib.rs b/rustc_deps/vendor/rand/src/lib.rs
index 960a567..bbea5cb 100644
--- a/rustc_deps/vendor/rand/src/lib.rs
+++ b/rustc_deps/vendor/rand/src/lib.rs
@@ -1,467 +1,423 @@
 // Copyright 2013-2017 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
+// https://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
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
 //! Utilities for random number generation
 //!
-//! The key functions are `random()` and `Rng::gen()`. These are polymorphic and
-//! so can be used to generate any type that implements `Rand`. Type inference
-//! means that often a simple call to `rand::random()` or `rng.gen()` will
-//! suffice, but sometimes an annotation is required, e.g.
-//! `rand::random::<f64>()`.
+//! Rand provides utilities to generate random numbers, to convert them to
+//! useful types and distributions, and some randomness-related algorithms.
 //!
-//! See the `distributions` submodule for sampling random numbers from
-//! distributions like normal and exponential.
+//! # Basic usage
 //!
-//! # Usage
+//! To get you started quickly, the easiest and highest-level way to get
+//! a random value is to use [`random()`].
 //!
-//! This crate is [on crates.io](https://crates.io/crates/rand) and can be
-//! used by adding `rand` to the dependencies in your project's `Cargo.toml`.
+//! ```
+//! let x: u8 = rand::random();
+//! println!("{}", x);
 //!
-//! ```toml
-//! [dependencies]
-//! rand = "0.4"
+//! let y = rand::random::<f64>();
+//! println!("{}", y);
+//!
+//! if rand::random() { // generates a boolean
+//!     println!("Heads!");
+//! }
 //! ```
 //!
-//! and this to your crate root:
+//! This supports generating most common types but is not very flexible, thus
+//! you probably want to learn a bit more about the Rand library.
 //!
-//! ```rust
-//! extern crate rand;
+//!
+//! # The two-step process to get a random value
+//!
+//! Generating random values is typically a two-step process:
+//!
+//! - get some *random data* (an integer or bit/byte sequence) from a random
+//!   number generator (RNG);
+//! - use some function to transform that *data* into the type of value you want
+//!   (this function is an implementation of some *distribution* describing the
+//!   kind of value produced).
+//!
+//! Rand represents the first step with the [`RngCore`] trait and the second
+//! step via a combination of the [`Rng`] extension trait and the
+//! [`distributions` module].
+//! In practice you probably won't use [`RngCore`] directly unless you are
+//! implementing a random number generator (RNG).
+//!
+//! There are many kinds of RNGs, with different trade-offs. You can read more
+//! about them in the [`rngs` module] and even more in the [`prng` module],
+//! however, often you can just use [`thread_rng()`]. This function
+//! automatically initializes an RNG in thread-local memory, then returns a
+//! reference to it. It is fast, good quality, and secure (unpredictable).
+//!
+//! To turn the output of the RNG into something usable, you usually want to use
+//! the methods from the [`Rng`] trait. Some of the most useful methods are:
+//!
+//! - [`gen`] generates a random value appropriate for the type (just like
+//!   [`random()`]). For integers this is normally the full representable range
+//!   (e.g. from `0u32` to `std::u32::MAX`), for floats this is between 0 and 1,
+//!   and some other types are supported, including arrays and tuples. See the
+//!   [`Standard`] distribution which provides the implementations.
+//! - [`gen_range`] samples from a specific range of values; this is like
+//!   [`gen`] but with specific upper and lower bounds.
+//! - [`sample`] samples directly from some distribution.
+//!
+//! [`random()`] is defined using just the above: `thread_rng().gen()`.
+//!
+//! ## Distributions
+//!
+//! What are distributions, you ask? Specifying only the type and range of
+//! values (known as the *sample space*) is not enough; samples must also have
+//! a *probability distribution*, describing the relative probability of
+//! sampling each value in that space.
+//!
+//! In many cases a *uniform* distribution is used, meaning roughly that each
+//! value is equally likely (or for "continuous" types like floats, that each
+//! equal-sized sub-range has the same probability of containing a sample).
+//! [`gen`] and [`gen_range`] both use statistically uniform distributions.
+//!
+//! The [`distributions` module] provides implementations
+//! of some other distributions, including Normal, Log-Normal and Exponential.
+//! 
+//! It is worth noting that the functionality already mentioned is implemented
+//! with distributions: [`gen`] samples values using the [`Standard`]
+//! distribution, while [`gen_range`] uses [`Uniform`].
+//!
+//! ## Importing (prelude)
+//!
+//! The most convenient way to import items from Rand is to use the [prelude].
+//! This includes the most important parts of Rand, but only those unlikely to
+//! cause name conflicts.
+//!
+//! Note that Rand 0.5 has significantly changed the module organization and
+//! contents relative to previous versions. Where possible old names have been
+//! kept (but are hidden in the documentation), however these will be removed
+//! in the future. We therefore recommend migrating to use the prelude or the
+//! new module organization in your imports.
+//!
+//!
+//! ## Examples
+//!
 //! ```
+//! use rand::prelude::*;
 //!
-//! # Thread-local RNG
-//!
-//! There is built-in support for a RNG associated with each thread stored
-//! in thread-local storage. This RNG can be accessed via `thread_rng`, or
-//! used implicitly via `random`. This RNG is normally randomly seeded
-//! from an operating-system source of randomness, e.g. `/dev/urandom` on
-//! Unix systems, and will automatically reseed itself from this source
-//! after generating 32 KiB of random data.
-//!
-//! # Cryptographic security
-//!
-//! An application that requires an entropy source for cryptographic purposes
-//! must use `OsRng`, which reads randomness from the source that the operating
-//! system provides (e.g. `/dev/urandom` on Unixes or `CryptGenRandom()` on
-//! Windows).
-//! The other random number generators provided by this module are not suitable
-//! for such purposes.
-//!
-//! *Note*: many Unix systems provide `/dev/random` as well as `/dev/urandom`.
-//! This module uses `/dev/urandom` for the following reasons:
-//!
-//! -   On Linux, `/dev/random` may block if entropy pool is empty;
-//!     `/dev/urandom` will not block.  This does not mean that `/dev/random`
-//!     provides better output than `/dev/urandom`; the kernel internally runs a
-//!     cryptographically secure pseudorandom number generator (CSPRNG) based on
-//!     entropy pool for random number generation, so the "quality" of
-//!     `/dev/random` is not better than `/dev/urandom` in most cases.  However,
-//!     this means that `/dev/urandom` can yield somewhat predictable randomness
-//!     if the entropy pool is very small, such as immediately after first
-//!     booting.  Linux 3.17 added the `getrandom(2)` system call which solves
-//!     the issue: it blocks if entropy pool is not initialized yet, but it does
-//!     not block once initialized.  `OsRng` tries to use `getrandom(2)` if
-//!     available, and use `/dev/urandom` fallback if not.  If an application
-//!     does not have `getrandom` and likely to be run soon after first booting,
-//!     or on a system with very few entropy sources, one should consider using
-//!     `/dev/random` via `ReadRng`.
-//! -   On some systems (e.g. FreeBSD, OpenBSD and Mac OS X) there is no
-//!     difference between the two sources. (Also note that, on some systems
-//!     e.g.  FreeBSD, both `/dev/random` and `/dev/urandom` may block once if
-//!     the CSPRNG has not seeded yet.)
-//!
-//! # Examples
-//!
-//! ```rust
-//! use rand::Rng;
-//!
-//! let mut rng = rand::thread_rng();
+//! // thread_rng is often the most convenient source of randomness:
+//! let mut rng = thread_rng();
+//! 
 //! if rng.gen() { // random bool
-//!     println!("i32: {}, u32: {}", rng.gen::<i32>(), rng.gen::<u32>())
+//!     let x: f64 = rng.gen(); // random number in range [0, 1)
+//!     println!("x is: {}", x);
+//!     let ch = rng.gen::<char>(); // using type annotation
+//!     println!("char is: {}", ch);
+//!     println!("Number from 0 to 9: {}", rng.gen_range(0, 10));
 //! }
 //! ```
 //!
-//! ```rust
-//! let tuple = rand::random::<(f64, char)>();
-//! println!("{:?}", tuple)
-//! ```
 //!
-//! ## Monte Carlo estimation of π
+//! # More functionality
 //!
-//! For this example, imagine we have a square with sides of length 2 and a unit
-//! circle, both centered at the origin. Since the area of a unit circle is π,
-//! we have:
+//! The [`Rng`] trait includes a few more methods not mentioned above:
 //!
-//! ```text
-//!     (area of unit circle) / (area of square) = π / 4
-//! ```
+//! - [`Rng::sample_iter`] allows iterating over values from a chosen
+//!   distribution.
+//! - [`Rng::gen_bool`] generates boolean "events" with a given probability.
+//! - [`Rng::fill`] and [`Rng::try_fill`] are fast alternatives to fill a slice
+//!   of integers.
+//! - [`Rng::shuffle`] randomly shuffles elements in a slice.
+//! - [`Rng::choose`] picks one element at random from a slice.
 //!
-//! So if we sample many points randomly from the square, roughly π / 4 of them
-//! should be inside the circle.
+//! For more slice/sequence related functionality, look in the [`seq` module].
 //!
-//! We can use the above fact to estimate the value of π: pick many points in
-//! the square at random, calculate the fraction that fall within the circle,
-//! and multiply this fraction by 4.
+//! There is also [`distributions::WeightedChoice`], which can be used to pick
+//! elements at random with some probability. But it does not work well at the
+//! moment and is going through a redesign.
 //!
-//! ```
-//! use rand::distributions::{IndependentSample, Range};
 //!
-//! fn main() {
-//!    let between = Range::new(-1f64, 1.);
-//!    let mut rng = rand::thread_rng();
+//! # Error handling
 //!
-//!    let total = 1_000_000;
-//!    let mut in_circle = 0;
+//! Error handling in Rand is a compromise between simplicity and necessity.
+//! Most RNGs and sampling functions will never produce errors, and making these
+//! able to handle errors would add significant overhead (to code complexity
+//! and ergonomics of usage at least, and potentially also performance,
+//! depending on the approach).
+//! However, external RNGs can fail, and being able to handle this is important.
 //!
-//!    for _ in 0..total {
-//!        let a = between.ind_sample(&mut rng);
-//!        let b = between.ind_sample(&mut rng);
-//!        if a*a + b*b <= 1. {
-//!            in_circle += 1;
-//!        }
-//!    }
+//! It has therefore been decided that *most* methods should not return a
+//! `Result` type, with as exceptions [`Rng::try_fill`],
+//! [`RngCore::try_fill_bytes`], and [`SeedableRng::from_rng`].
 //!
-//!    // prints something close to 3.14159...
-//!    println!("{}", 4. * (in_circle as f64) / (total as f64));
-//! }
-//! ```
+//! Note that it is the RNG that panics when it fails but is not used through a
+//! method that can report errors. Currently Rand contains only three RNGs that
+//! can return an error (and thus may panic), and documents this property:
+//! [`OsRng`], [`EntropyRng`] and [`ReadRng`]. Other RNGs, like [`ThreadRng`]
+//! and [`StdRng`], can be used with all methods without concern.
 //!
-//! ## Monty Hall Problem
+//! One further problem is that if Rand is unable to get any external randomness
+//! when initializing an RNG with [`EntropyRng`], it will panic in
+//! [`FromEntropy::from_entropy`], and notably in [`thread_rng()`]. Except by
+//! compromising security, this problem is as unsolvable as running out of
+//! memory.
 //!
-//! This is a simulation of the [Monty Hall Problem][]:
 //!
-//! > Suppose you're on a game show, and you're given the choice of three doors:
-//! > Behind one door is a car; behind the others, goats. You pick a door, say
-//! > No. 1, and the host, who knows what's behind the doors, opens another
-//! > door, say No. 3, which has a goat. He then says to you, "Do you want to
-//! > pick door No. 2?" Is it to your advantage to switch your choice?
+//! # Distinction between Rand and `rand_core`
 //!
-//! The rather unintuitive answer is that you will have a 2/3 chance of winning
-//! if you switch and a 1/3 chance of winning if you don't, so it's better to
-//! switch.
+//! The [`rand_core`] crate provides the necessary traits and functionality for
+//! implementing RNGs; this includes the [`RngCore`] and [`SeedableRng`] traits
+//! and the [`Error`] type.
+//! Crates implementing RNGs should depend on [`rand_core`].
 //!
-//! This program will simulate the game show and with large enough simulation
-//! steps it will indeed confirm that it is better to switch.
+//! Applications and libraries consuming random values are encouraged to use the
+//! Rand crate, which re-exports the common parts of [`rand_core`].
 //!
-//! [Monty Hall Problem]: http://en.wikipedia.org/wiki/Monty_Hall_problem
 //!
-//! ```
-//! use rand::Rng;
-//! use rand::distributions::{IndependentSample, Range};
+//! # More examples
 //!
-//! struct SimulationResult {
-//!     win: bool,
-//!     switch: bool,
-//! }
+//! For some inspiration, see the examples:
 //!
-//! // Run a single simulation of the Monty Hall problem.
-//! fn simulate<R: Rng>(random_door: &Range<u32>, rng: &mut R)
-//!                     -> SimulationResult {
-//!     let car = random_door.ind_sample(rng);
+//! - [Monte Carlo estimation of π](
+//!   https://github.com/rust-lang-nursery/rand/blob/master/examples/monte-carlo.rs)
+//! - [Monty Hall Problem](
+//!    https://github.com/rust-lang-nursery/rand/blob/master/examples/monty-hall.rs)
 //!
-//!     // This is our initial choice
-//!     let mut choice = random_door.ind_sample(rng);
 //!
-//!     // The game host opens a door
-//!     let open = game_host_open(car, choice, rng);
-//!
-//!     // Shall we switch?
-//!     let switch = rng.gen();
-//!     if switch {
-//!         choice = switch_door(choice, open);
-//!     }
-//!
-//!     SimulationResult { win: choice == car, switch: switch }
-//! }
-//!
-//! // Returns the door the game host opens given our choice and knowledge of
-//! // where the car is. The game host will never open the door with the car.
-//! fn game_host_open<R: Rng>(car: u32, choice: u32, rng: &mut R) -> u32 {
-//!     let choices = free_doors(&[car, choice]);
-//!     rand::seq::sample_slice(rng, &choices, 1)[0]
-//! }
-//!
-//! // Returns the door we switch to, given our current choice and
-//! // the open door. There will only be one valid door.
-//! fn switch_door(choice: u32, open: u32) -> u32 {
-//!     free_doors(&[choice, open])[0]
-//! }
-//!
-//! fn free_doors(blocked: &[u32]) -> Vec<u32> {
-//!     (0..3).filter(|x| !blocked.contains(x)).collect()
-//! }
-//!
-//! fn main() {
-//!     // The estimation will be more accurate with more simulations
-//!     let num_simulations = 10000;
-//!
-//!     let mut rng = rand::thread_rng();
-//!     let random_door = Range::new(0, 3);
-//!
-//!     let (mut switch_wins, mut switch_losses) = (0, 0);
-//!     let (mut keep_wins, mut keep_losses) = (0, 0);
-//!
-//!     println!("Running {} simulations...", num_simulations);
-//!     for _ in 0..num_simulations {
-//!         let result = simulate(&random_door, &mut rng);
-//!
-//!         match (result.win, result.switch) {
-//!             (true, true) => switch_wins += 1,
-//!             (true, false) => keep_wins += 1,
-//!             (false, true) => switch_losses += 1,
-//!             (false, false) => keep_losses += 1,
-//!         }
-//!     }
-//!
-//!     let total_switches = switch_wins + switch_losses;
-//!     let total_keeps = keep_wins + keep_losses;
-//!
-//!     println!("Switched door {} times with {} wins and {} losses",
-//!              total_switches, switch_wins, switch_losses);
-//!
-//!     println!("Kept our choice {} times with {} wins and {} losses",
-//!              total_keeps, keep_wins, keep_losses);
-//!
-//!     // With a large number of simulations, the values should converge to
-//!     // 0.667 and 0.333 respectively.
-//!     println!("Estimated chance to win if we switch: {}",
-//!              switch_wins as f32 / total_switches as f32);
-//!     println!("Estimated chance to win if we don't: {}",
-//!              keep_wins as f32 / total_keeps as f32);
-//! }
-//! ```
+//! [`distributions` module]: distributions/index.html
+//! [`distributions::WeightedChoice`]: distributions/struct.WeightedChoice.html
+//! [`FromEntropy::from_entropy`]: trait.FromEntropy.html#tymethod.from_entropy
+//! [`EntropyRng`]: rngs/struct.EntropyRng.html
+//! [`Error`]: struct.Error.html
+//! [`gen_range`]: trait.Rng.html#method.gen_range
+//! [`gen`]: trait.Rng.html#method.gen
+//! [`OsRng`]: rngs/struct.OsRng.html
+//! [prelude]: prelude/index.html
+//! [`rand_core`]: https://crates.io/crates/rand_core
+//! [`random()`]: fn.random.html
+//! [`ReadRng`]: rngs/adapter/struct.ReadRng.html
+//! [`Rng::choose`]: trait.Rng.html#method.choose
+//! [`Rng::fill`]: trait.Rng.html#method.fill
+//! [`Rng::gen_bool`]: trait.Rng.html#method.gen_bool
+//! [`Rng::gen`]: trait.Rng.html#method.gen
+//! [`Rng::sample_iter`]: trait.Rng.html#method.sample_iter
+//! [`Rng::shuffle`]: trait.Rng.html#method.shuffle
+//! [`RngCore`]: trait.RngCore.html
+//! [`RngCore::try_fill_bytes`]: trait.RngCore.html#method.try_fill_bytes
+//! [`rngs` module]: rngs/index.html
+//! [`prng` module]: prng/index.html
+//! [`Rng`]: trait.Rng.html
+//! [`Rng::try_fill`]: trait.Rng.html#method.try_fill
+//! [`sample`]: trait.Rng.html#method.sample
+//! [`SeedableRng`]: trait.SeedableRng.html
+//! [`SeedableRng::from_rng`]: trait.SeedableRng.html#method.from_rng
+//! [`seq` module]: seq/index.html
+//! [`SmallRng`]: rngs/struct.SmallRng.html
+//! [`StdRng`]: rngs/struct.StdRng.html
+//! [`thread_rng()`]: fn.thread_rng.html
+//! [`ThreadRng`]: rngs/struct.ThreadRng.html
+//! [`Standard`]: distributions/struct.Standard.html
+//! [`Uniform`]: distributions/struct.Uniform.html
+
 
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
        html_favicon_url = "https://www.rust-lang.org/favicon.ico",
-       html_root_url = "https://docs.rs/rand/0.3")]
+       html_root_url = "https://docs.rs/rand/0.5.5")]
 
+#![deny(missing_docs)]
 #![deny(missing_debug_implementations)]
+#![doc(test(attr(allow(unused_variables), deny(warnings))))]
 
 #![cfg_attr(not(feature="std"), no_std)]
 #![cfg_attr(all(feature="alloc", not(feature="std")), feature(alloc))]
-#![cfg_attr(feature = "i128_support", feature(i128_type, i128))]
+#![cfg_attr(all(feature="i128_support", feature="nightly"), allow(stable_features))] // stable since 2018-03-27
+#![cfg_attr(all(feature="i128_support", feature="nightly"), feature(i128_type, i128))]
+#![cfg_attr(feature = "stdweb", recursion_limit="128")]
 
 #[cfg(feature="std")] extern crate std as core;
 #[cfg(all(feature = "alloc", not(feature="std")))] extern crate alloc;
 
-use core::marker;
-use core::mem;
-#[cfg(feature="std")] use std::cell::RefCell;
-#[cfg(feature="std")] use std::io;
-#[cfg(feature="std")] use std::rc::Rc;
+#[cfg(test)] #[cfg(feature="serde1")] extern crate bincode;
+#[cfg(feature="serde1")] extern crate serde;
+#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive;
 
-// external rngs
-pub use jitter::JitterRng;
-#[cfg(feature="std")] pub use os::OsRng;
+#[cfg(all(target_arch="wasm32", not(target_os="emscripten"), feature="stdweb"))]
+#[macro_use]
+extern crate stdweb;
 
-// pseudo rngs
-pub use isaac::{IsaacRng, Isaac64Rng};
-pub use chacha::ChaChaRng;
-pub use prng::XorShiftRng;
+extern crate rand_core;
 
-// local use declarations
-#[cfg(target_pointer_width = "32")]
-use prng::IsaacRng as IsaacWordRng;
-#[cfg(target_pointer_width = "64")]
-use prng::Isaac64Rng as IsaacWordRng;
+#[cfg(feature = "log")] #[macro_use] extern crate log;
+#[allow(unuse