summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@chromium.org>2018-12-12 14:33:42 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-12-13 19:28:04 -0800
commit2bac1e7a9c710d6ad3e50a10463f758a1b5db40a (patch)
treefefb6ff3f38f84698b5e558f2692af15793bdde0
parent3397126b3c862fbd58c7fd31e90eb64c524d27ec (diff)
downloadcrosvm-2bac1e7a9c710d6ad3e50a10463f758a1b5db40a.tar
crosvm-2bac1e7a9c710d6ad3e50a10463f758a1b5db40a.tar.gz
crosvm-2bac1e7a9c710d6ad3e50a10463f758a1b5db40a.tar.bz2
crosvm-2bac1e7a9c710d6ad3e50a10463f758a1b5db40a.tar.lz
crosvm-2bac1e7a9c710d6ad3e50a10463f758a1b5db40a.tar.xz
crosvm-2bac1e7a9c710d6ad3e50a10463f758a1b5db40a.tar.zst
crosvm-2bac1e7a9c710d6ad3e50a10463f758a1b5db40a.zip
toolchain: Update to Rust 1.31.0
We updated the production toolchain from 1.30 to 1.31 in CL:1366446.
This CL does the same upgrade for the local developer toolchain and
Kokoro.

The relevant changes are in rust-toolchain and kokoro/Dockerfile.
The rest are from rustfmt.

TEST=cargo fmt --all -- --check
TEST=as described in kokoro/README.md

Change-Id: I3b4913f3e237baa36c664b4953be360c09efffd4
Reviewed-on: https://chromium-review.googlesource.com/1374376
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
-rw-r--r--aarch64/src/lib.rs12
-rw-r--r--arch/src/lib.rs6
-rw-r--r--devices/src/bus.rs6
-rw-r--r--devices/src/virtio/balloon.rs6
-rw-r--r--devices/src/virtio/block.rs3
-rw-r--r--devices/src/virtio/gpu/mod.rs9
-rw-r--r--devices/src/virtio/net.rs6
-rw-r--r--devices/src/virtio/p9.rs3
-rw-r--r--devices/src/virtio/rng.rs6
-rw-r--r--devices/src/virtio/vhost/net.rs6
-rw-r--r--devices/src/virtio/vhost/worker.rs6
-rw-r--r--devices/src/virtio/virtio_pci_common_config.rs12
-rw-r--r--devices/src/virtio/virtio_pci_device.rs3
-rw-r--r--devices/src/virtio/wl.rs6
-rw-r--r--gpu_buffer/src/lib.rs15
-rw-r--r--gpu_display/src/lib.rs6
-rw-r--r--gpu_renderer/src/generated/epoxy_egl.rs245
-rw-r--r--gpu_renderer/src/lib.rs12
-rw-r--r--kokoro/Dockerfile2
-rw-r--r--kvm/src/lib.rs34
-rw-r--r--kvm/tests/dirty_log.rs3
-rw-r--r--kvm/tests/read_only_memory.rs6
-rw-r--r--msg_socket/tests/enum.rs3
-rw-r--r--msg_socket/tests/struct.rs3
-rw-r--r--p9/src/protocol/wire_format.rs21
-rw-r--r--p9/src/server.rs6
-rw-r--r--plugin_proto/build.rs6
-rw-r--r--qcow/src/qcow.rs21
-rw-r--r--qcow/src/refcount.rs9
-rw-r--r--qcow/src/vec_cache.rs12
-rw-r--r--qcow_utils/src/qcow_utils.rs6
-rw-r--r--rust-toolchain2
-rw-r--r--src/linux.rs18
-rw-r--r--src/main.rs27
-rw-r--r--src/plugin/mod.rs6
-rw-r--r--sys_util/src/fork.rs6
-rw-r--r--sys_util/src/guest_memory.rs3
-rw-r--r--sys_util/src/sock_ctrl_msg.rs3
-rw-r--r--tests/plugins.rs9
-rw-r--r--x86_64/src/lib.rs18
-rw-r--r--x86_64/src/mptable.rs26
41 files changed, 413 insertions, 205 deletions
diff --git a/aarch64/src/lib.rs b/aarch64/src/lib.rs
index 7c15ef1..c1696e4 100644
--- a/aarch64/src/lib.rs
+++ b/aarch64/src/lib.rs
@@ -193,8 +193,10 @@ pub struct AArch64;
 impl arch::LinuxArch for AArch64 {
     fn build_vm<F>(mut components: VmComponents, virtio_devs: F) -> Result<RunnableLinuxVm>
     where
-        F: FnOnce(&GuestMemory, &EventFd)
-            -> Result<Vec<(Box<PciDevice + 'static>, Option<Minijail>)>>,
+        F: FnOnce(
+            &GuestMemory,
+            &EventFd,
+        ) -> Result<Vec<(Box<PciDevice + 'static>, Option<Minijail>)>>,
     {
         let mut resources =
             Self::get_resource_allocator(components.memory_mb, components.wayland_dmabuf);
@@ -241,7 +243,8 @@ impl arch::LinuxArch for AArch64 {
                 AARCH64_PCI_CFG_BASE,
                 AARCH64_PCI_CFG_SIZE,
                 false,
-            ).map_err(Error::RegisterPci)?;
+            )
+            .map_err(Error::RegisterPci)?;
 
         for param in components.extra_kernel_params {
             cmdline.insert_str(&param).map_err(Error::Cmdline)?;
@@ -360,7 +363,8 @@ impl AArch64 {
             AARCH64_SERIAL_ADDR,
             AARCH64_SERIAL_SIZE,
             false,
-        ).expect("failed to add serial device");
+        )
+        .expect("failed to add serial device");
 
         let rtc = Arc::new(Mutex::new(devices::pl030::Pl030::new(rtc_evt)));
         bus.insert(rtc, AARCH64_RTC_ADDR, AARCH64_RTC_SIZE, false)
diff --git a/arch/src/lib.rs b/arch/src/lib.rs
index bce3803..34f3f3d 100644
--- a/arch/src/lib.rs
+++ b/arch/src/lib.rs
@@ -70,8 +70,10 @@ pub trait LinuxArch {
     /// * `virtio_devs` - Function to generate a list of virtio devices.
     fn build_vm<F>(components: VmComponents, virtio_devs: F) -> Result<RunnableLinuxVm>
     where
-        F: FnOnce(&GuestMemory, &EventFd)
-            -> Result<Vec<(Box<PciDevice + 'static>, Option<Minijail>)>>;
+        F: FnOnce(
+            &GuestMemory,
+            &EventFd,
+        ) -> Result<Vec<(Box<PciDevice + 'static>, Option<Minijail>)>>;
 }
 
 /// Errors for device manager.
diff --git a/devices/src/bus.rs b/devices/src/bus.rs
index 8bee1d0..8124d87 100644
--- a/devices/src/bus.rs
+++ b/devices/src/bus.rs
@@ -111,7 +111,8 @@ impl Bus {
                     len: 1,
                     full_addr: false,
                 },
-            ).rev()
+            )
+            .rev()
             .next()?;
         Some((*range, dev))
     }
@@ -160,7 +161,8 @@ impl Bus {
                     full_addr,
                 },
                 device,
-            ).is_some()
+            )
+            .is_some()
         {
             return Err(Error::Overlap);
         }
diff --git a/devices/src/virtio/balloon.rs b/devices/src/virtio/balloon.rs
index c7614c4..d67c532 100644
--- a/devices/src/virtio/balloon.rs
+++ b/devices/src/virtio/balloon.rs
@@ -139,10 +139,12 @@ impl Worker {
             .and_then(|pc| {
                 pc.add(&self.command_socket, Token::CommandSocket)
                     .and(Ok(pc))
-            }).and_then(|pc| {
+            })
+            .and_then(|pc| {
                 pc.add(&self.interrupt_resample_evt, Token::InterruptResample)
                     .and(Ok(pc))
-            }).and_then(|pc| pc.add(&kill_evt, Token::Kill).and(Ok(pc)))
+            })
+            .and_then(|pc| pc.add(&kill_evt, Token::Kill).and(Ok(pc)))
         {
             Ok(pc) => pc,
             Err(e) => {
diff --git a/devices/src/virtio/block.rs b/devices/src/virtio/block.rs
index f817e89..0371809 100644
--- a/devices/src/virtio/block.rs
+++ b/devices/src/virtio/block.rs
@@ -558,7 +558,8 @@ impl<T: DiskFile> Worker<T> {
             .and_then(|pc| {
                 pc.add(&self.interrupt_resample_evt, Token::InterruptResample)
                     .and(Ok(pc))
-            }).and_then(|pc| pc.add(&kill_evt, Token::Kill).and(Ok(pc)))
+            })
+            .and_then(|pc| pc.add(&kill_evt, Token::Kill).and(Ok(pc)))
         {
             Ok(pc) => pc,
             Err(e) => {
diff --git a/devices/src/virtio/gpu/mod.rs b/devices/src/virtio/gpu/mod.rs
index bcab27e..f2b7f12 100644
--- a/devices/src/virtio/gpu/mod.rs
+++ b/devices/src/virtio/gpu/mod.rs
@@ -496,10 +496,12 @@ impl Worker {
             .and_then(|pc| {
                 pc.add(&*self.state.display().borrow(), Token::Display)
                     .and(Ok(pc))
-            }).and_then(|pc| {
+            })
+            .and_then(|pc| {
                 pc.add(&self.interrupt_resample_evt, Token::InterruptResample)
                     .and(Ok(pc))
-            }).and_then(|pc| pc.add(&self.kill_evt, Token::Kill).and(Ok(pc)))
+            })
+            .and_then(|pc| pc.add(&self.kill_evt, Token::Kill).and(Ok(pc)))
         {
             Ok(pc) => pc,
             Err(e) => {
@@ -779,7 +781,8 @@ impl VirtioDevice for Gpu {
                 resource_bridge,
                 kill_evt,
                 state: Frontend::new(Backend::new(device, display, renderer)),
-            }.run()
+            }
+            .run()
         });
     }
 }
diff --git a/devices/src/virtio/net.rs b/devices/src/virtio/net.rs
index 8fa4d8d..dd8afd9 100644
--- a/devices/src/virtio/net.rs
+++ b/devices/src/virtio/net.rs
@@ -241,7 +241,8 @@ where
             .and_then(|pc| {
                 pc.add(&self.interrupt_resample_evt, Token::InterruptResample)
                     .and(Ok(pc))
-            }).and_then(|pc| pc.add(&kill_evt, Token::Kill).and(Ok(pc)))
+            })
+            .and_then(|pc| pc.add(&kill_evt, Token::Kill).and(Ok(pc)))
             .map_err(NetError::CreatePollContext)?;
 
         'poll: loop {
@@ -320,7 +321,8 @@ where
         // changes to this set, also change the corresponding feature set in vm_concierge.
         tap.set_offload(
             net_sys::TUN_F_CSUM | net_sys::TUN_F_UFO | net_sys::TUN_F_TSO4 | net_sys::TUN_F_TSO6,
-        ).map_err(NetError::TapSetOffload)?;
+        )
+        .map_err(NetError::TapSetOffload)?;
 
         let vnet_hdr_size = mem::size_of::<virtio_net_hdr_v1>() as i32;
         tap.set_vnet_hdr_size(vnet_hdr_size)
diff --git a/devices/src/virtio/p9.rs b/devices/src/virtio/p9.rs
index 2c1faa6..e9bdbb7 100644
--- a/devices/src/virtio/p9.rs
+++ b/devices/src/virtio/p9.rs
@@ -278,7 +278,8 @@ impl Worker {
             .and_then(|pc| {
                 pc.add(&self.interrupt_resample_evt, Token::InterruptResample)
                     .and(Ok(pc))
-            }).and_then(|pc| pc.add(&kill_evt, Token::Kill).and(Ok(pc)))
+            })
+            .and_then(|pc| pc.add(&kill_evt, Token::Kill).and(Ok(pc)))
             .map_err(P9Error::CreatePollContext)?;
 
         loop {
diff --git a/devices/src/virtio/rng.rs b/devices/src/virtio/rng.rs
index ee83980..96d0d4f 100644
--- a/devices/src/virtio/rng.rs
+++ b/devices/src/virtio/rng.rs
@@ -51,7 +51,8 @@ impl Worker {
                         avail_desc.addr,
                         &mut self.random_file,
                         avail_desc.len as usize,
-                    ).is_ok()
+                    )
+                    .is_ok()
                 {
                     len = avail_desc.len;
                 }
@@ -86,7 +87,8 @@ impl Worker {
             .and_then(|pc| {
                 pc.add(&self.interrupt_resample_evt, Token::InterruptResample)
                     .and(Ok(pc))
-            }).and_then(|pc| pc.add(&kill_evt, Token::Kill).and(Ok(pc)))
+            })
+            .and_then(|pc| pc.add(&kill_evt, Token::Kill).and(Ok(pc)))
         {
             Ok(pc) => pc,
             Err(e) => {
diff --git a/devices/src/virtio/vhost/net.rs b/devices/src/virtio/vhost/net.rs
index 2b8c08b..4727bbc 100644
--- a/devices/src/virtio/vhost/net.rs
+++ b/devices/src/virtio/vhost/net.rs
@@ -58,7 +58,8 @@ where
         // Set offload flags to match the virtio features below.
         tap.set_offload(
             net_sys::TUN_F_CSUM | net_sys::TUN_F_UFO | net_sys::TUN_F_TSO4 | net_sys::TUN_F_TSO6,
-        ).map_err(Error::TapSetOffload)?;
+        )
+        .map_err(Error::TapSetOffload)?;
 
         // We declare VIRTIO_NET_F_MRG_RXBUF, so set the vnet hdr size to match.
         let vnet_hdr_size = mem::size_of::<virtio_net::virtio_net_hdr_mrg_rxbuf>() as i32;
@@ -237,7 +238,8 @@ pub mod tests {
             Ipv4Addr::new(255, 255, 255, 0),
             "de:21:e8:47:6b:6a".parse().unwrap(),
             &guest_memory,
-        ).unwrap()
+        )
+        .unwrap()
     }
 
     #[test]
diff --git a/devices/src/virtio/vhost/worker.rs b/devices/src/virtio/vhost/worker.rs
index abd063b..e9ee2fb 100644
--- a/devices/src/virtio/vhost/worker.rs
+++ b/devices/src/virtio/vhost/worker.rs
@@ -97,7 +97,8 @@ impl<T: Vhost> Worker<T> {
                     queue.used_ring,
                     queue.avail_ring,
                     None,
-                ).map_err(Error::VhostSetVringAddr)?;
+                )
+                .map_err(Error::VhostSetVringAddr)?;
             self.vhost_handle
                 .set_vring_base(queue_index, 0)
                 .map_err(Error::VhostSetVringBase)?;
@@ -123,7 +124,8 @@ impl<T: Vhost> Worker<T> {
             .and_then(|pc| {
                 pc.add(&self.interrupt_resample_evt, Token::InterruptResample)
                     .and(Ok(pc))
-            }).and_then(|pc| pc.add(&kill_evt, Token::Kill).and(Ok(pc)))
+            })
+            .and_then(|pc| pc.add(&kill_evt, Token::Kill).and(Ok(pc)))
             .map_err(Error::CreatePollContext)?;
 
         'poll: loop {
diff --git a/devices/src/virtio/virtio_pci_common_config.rs b/devices/src/virtio/virtio_pci_common_config.rs
index 4f30b3d..fb428dd 100644
--- a/devices/src/virtio/virtio_pci_common_config.rs
+++ b/devices/src/virtio/virtio_pci_common_config.rs
@@ -108,11 +108,13 @@ impl VirtioPciCommonConfig {
             0x12 => queues.len() as u16, // num_queues
             0x16 => self.queue_select,
             0x18 => self.with_queue(queues, |q| q.size).unwrap_or(0),
-            0x1c => if self.with_queue(queues, |q| q.ready).unwrap_or(false) {
-                1
-            } else {
-                0
-            },
+            0x1c => {
+                if self.with_queue(queues, |q| q.ready).unwrap_or(false) {
+                    1
+                } else {
+                    0
+                }
+            }
             0x1e => self.queue_select, // notify_off
             _ => 0,
         }
diff --git a/devices/src/virtio/virtio_pci_device.rs b/devices/src/virtio/virtio_pci_device.rs
index c362477..6a9ca5e 100644
--- a/devices/src/virtio/virtio_pci_device.rs
+++ b/devices/src/virtio/virtio_pci_device.rs
@@ -333,7 +333,8 @@ impl PciDevice for VirtioPciDevice {
                     notify_base + i as u64 * NOTIFY_OFF_MULTIPLIER as u64,
                     Datamatch::U16(Some(i as u16)),
                 )
-            }).collect()
+            })
+            .collect()
     }
 
     fn config_registers(&self) -> &PciConfiguration {
diff --git a/devices/src/virtio/wl.rs b/devices/src/virtio/wl.rs
index 9c3b517..2be0d7e 100644
--- a/devices/src/virtio/wl.rs
+++ b/devices/src/virtio/wl.rs
@@ -1256,8 +1256,7 @@ impl WlState {
                     }
                 },
                 #[cfg(feature = "gpu")]
-                VIRTIO_WL_CTRL_VFD_SEND_KIND_VIRTGPU if self.resource_bridge.is_some() =>
-                {
+                VIRTIO_WL_CTRL_VFD_SEND_KIND_VIRTGPU if self.resource_bridge.is_some() => {
                     if let Err(e) = self
                         .resource_bridge
                         .as_ref()
@@ -1779,7 +1778,8 @@ impl VirtioDevice for Wl {
                             vm_socket,
                             use_transition_flags,
                             resource_bridge,
-                        ).run(queue_evts, kill_evt);
+                        )
+                        .run(queue_evts, kill_evt);
                     });
 
             if let Err(e) = worker_result {
diff --git a/gpu_buffer/src/lib.rs b/gpu_buffer/src/lib.rs
index ad8dd63..49f346d 100644
--- a/gpu_buffer/src/lib.rs
+++ b/gpu_buffer/src/lib.rs
@@ -782,7 +782,8 @@ mod tests {
                 512,
                 Format::new(b'X', b'R', b'2', b'4'),
                 Flags::empty().use_scanout(true),
-            ).expect("failed to create buffer");
+            )
+            .expect("failed to create buffer");
 
         assert_eq!(bo.width(), 1024);
         assert_eq!(bo.height(), 512);
@@ -801,7 +802,8 @@ mod tests {
                 1024,
                 Format::new(b'X', b'R', b'2', b'4'),
                 Flags::empty().use_scanout(true),
-            ).expect("failed to create buffer");
+            )
+            .expect("failed to create buffer");
         bo.export_plane_fd(0).expect("failed to export plane");
     }
 
@@ -816,7 +818,8 @@ mod tests {
                 1024,
                 Format::new(b'X', b'R', b'2', b'4'),
                 Flags::empty().use_scanout(true).use_linear(true),
-            ).expect("failed to create buffer");
+            )
+            .expect("failed to create buffer");
         let mut dst: Vec<u8> = Vec::new();
         dst.resize((bo.stride() * bo.height()) as usize, 0x4A);
         let dst_len = dst.len() as u64;
@@ -830,7 +833,8 @@ mod tests {
             [dst.as_mut_slice().get_slice(0, dst_len).unwrap()]
                 .iter()
                 .cloned(),
-        ).expect("failed to read bo");
+        )
+        .expect("failed to read bo");
         bo.read_to_volatile(
             0,
             0,
@@ -838,7 +842,8 @@ mod tests {
             1024,
             0,
             dst.as_mut_slice().get_slice(0, dst_len).unwrap(),
-        ).expect("failed to read bo");
+        )
+        .expect("failed to read bo");
         assert!(dst.iter().all(|&x| x == 0x4A));
     }
 }
diff --git a/gpu_display/src/lib.rs b/gpu_display/src/lib.rs
index da9d473..6b93bbc 100644
--- a/gpu_display/src/lib.rs
+++ b/gpu_display/src/lib.rs
@@ -219,7 +219,8 @@ impl GpuDisplay {
         let buffer_size = round_up_to_page_size(fb_size as usize * BUFFER_COUNT);
         let mut buffer_shm = SharedMemory::new(Some(
             CStr::from_bytes_with_nul(b"GpuDisplaySurface\0").unwrap(),
-        )).map_err(GpuDisplayError::CreateShm)?;
+        ))
+        .map_err(GpuDisplayError::CreateShm)?;
         buffer_shm
             .set_size(buffer_size as u64)
             .map_err(GpuDisplayError::SetSize)?;
@@ -273,7 +274,8 @@ impl GpuDisplay {
             .get_slice(
                 (buffer_index * surface.buffer_size) as u64,
                 surface.buffer_size as u64,
-            ).ok()
+            )
+            .ok()
     }
 
     /// Commits any pending state for the identified surface.
diff --git a/gpu_renderer/src/generated/epoxy_egl.rs b/gpu_renderer/src/generated/epoxy_egl.rs
index e7db2e3..1f61998 100644
--- a/gpu_renderer/src/generated/epoxy_egl.rs
+++ b/gpu_renderer/src/generated/epoxy_egl.rs
@@ -7290,22 +7290,31 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_glAreProgramsResidentNV"]
     pub static mut epoxy_glAreProgramsResidentNV: ::std::option::Option<
-        unsafe extern "C" fn(n: GLsizei, programs: *const GLuint, residences: *mut GLboolean)
-            -> GLboolean,
+        unsafe extern "C" fn(
+            n: GLsizei,
+            programs: *const GLuint,
+            residences: *mut GLboolean,
+        ) -> GLboolean,
     >;
 }
 extern "C" {
     #[link_name = "\u{1}epoxy_glAreTexturesResident"]
     pub static mut epoxy_glAreTexturesResident: ::std::option::Option<
-        unsafe extern "C" fn(n: GLsizei, textures: *const GLuint, residences: *mut GLboolean)
-            -> GLboolean,
+        unsafe extern "C" fn(
+            n: GLsizei,
+            textures: *const GLuint,
+            residences: *mut GLboolean,
+        ) -> GLboolean,
     >;
 }
 extern "C" {
     #[link_name = "\u{1}epoxy_glAreTexturesResidentEXT"]
     pub static mut epoxy_glAreTexturesResidentEXT: ::std::option::Option<
-        unsafe extern "C" fn(n: GLsizei, textures: *const GLuint, residences: *mut GLboolean)
-            -> GLboolean,
+        unsafe extern "C" fn(
+            n: GLsizei,
+            textures: *const GLuint,
+            residences: *mut GLboolean,
+        ) -> GLboolean,
     >;
 }
 extern "C" {
@@ -10640,8 +10649,11 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_glCreateShaderProgramv"]
     pub static mut epoxy_glCreateShaderProgramv: ::std::option::Option<
-        unsafe extern "C" fn(type_: GLenum, count: GLsizei, strings: *const *const GLchar)
-            -> GLuint,
+        unsafe extern "C" fn(
+            type_: GLenum,
+            count: GLsizei,
+            strings: *const *const GLchar,
+        ) -> GLuint,
     >;
 }
 extern "C" {
@@ -10658,8 +10670,11 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_glCreateSyncFromCLeventARB"]
     pub static mut epoxy_glCreateSyncFromCLeventARB: ::std::option::Option<
-        unsafe extern "C" fn(context: *mut _cl_context, event: *mut _cl_event, flags: GLbitfield)
-            -> GLsync,
+        unsafe extern "C" fn(
+            context: *mut _cl_context,
+            event: *mut _cl_event,
+            flags: GLbitfield,
+        ) -> GLsync,
     >;
 }
 extern "C" {
@@ -15351,29 +15366,41 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_glGetProgramResourceIndex"]
     pub static mut epoxy_glGetProgramResourceIndex: ::std::option::Option<
-        unsafe extern "C" fn(program: GLuint, programInterface: GLenum, name: *const GLchar)
-            -> GLuint,
+        unsafe extern "C" fn(
+            program: GLuint,
+            programInterface: GLenum,
+            name: *const GLchar,
+        ) -> GLuint,
     >;
 }
 extern "C" {
     #[link_name = "\u{1}epoxy_glGetProgramResourceLocation"]
     pub static mut epoxy_glGetProgramResourceLocation: ::std::option::Option<
-        unsafe extern "C" fn(program: GLuint, programInterface: GLenum, name: *const GLchar)
-            -> GLint,
+        unsafe extern "C" fn(
+            program: GLuint,
+            programInterface: GLenum,
+            name: *const GLchar,
+        ) -> GLint,
     >;
 }
 extern "C" {
     #[link_name = "\u{1}epoxy_glGetProgramResourceLocationIndex"]
     pub static mut epoxy_glGetProgramResourceLocationIndex: ::std::option::Option<
-        unsafe extern "C" fn(program: GLuint, programInterface: GLenum, name: *const GLchar)
-            -> GLint,
+        unsafe extern "C" fn(
+            program: GLuint,
+            programInterface: GLenum,
+            name: *const GLchar,
+        ) -> GLint,
     >;
 }
 extern "C" {
     #[link_name = "\u{1}epoxy_glGetProgramResourceLocationIndexEXT"]
     pub static mut epoxy_glGetProgramResourceLocationIndexEXT: ::std::option::Option<
-        unsafe extern "C" fn(program: GLuint, programInterface: GLenum, name: *const GLchar)
-            -> GLint,
+        unsafe extern "C" fn(
+            program: GLuint,
+            programInterface: GLenum,
+            name: *const GLchar,
+        ) -> GLint,
     >;
 }
 extern "C" {
@@ -20047,8 +20074,11 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_glNewObjectBufferATI"]
     pub static mut epoxy_glNewObjectBufferATI: ::std::option::Option<
-        unsafe extern "C" fn(size: GLsizei, pointer: *const ::std::os::raw::c_void, usage: GLenum)
-            -> GLuint,
+        unsafe extern "C" fn(
+            size: GLsizei,
+            pointer: *const ::std::os::raw::c_void,
+            usage: GLenum,
+        ) -> GLuint,
     >;
 }
 extern "C" {
@@ -30301,15 +30331,23 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglClientWaitSync"]
     pub static mut epoxy_eglClientWaitSync: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, sync: EGLSync, flags: EGLint, timeout: EGLTime)
-            -> EGLint,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            sync: EGLSync,
+            flags: EGLint,
+            timeout: EGLTime,
+        ) -> EGLint,
     >;
 }
 extern "C" {
     #[link_name = "\u{1}epoxy_eglClientWaitSyncKHR"]
     pub static mut epoxy_eglClientWaitSyncKHR: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, sync: EGLSyncKHR, flags: EGLint, timeout: EGLTimeKHR)
-            -> EGLint,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            sync: EGLSyncKHR,
+            flags: EGLint,
+            timeout: EGLTimeKHR,
+        ) -> EGLint,
     >;
 }
 extern "C" {
@@ -30321,8 +30359,11 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglCopyBuffers"]
     pub static mut epoxy_eglCopyBuffers: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, surface: EGLSurface, target: EGLNativePixmapType)
-            -> EGLBoolean,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            surface: EGLSurface,
+            target: EGLNativePixmapType,
+        ) -> EGLBoolean,
     >;
 }
 extern "C" {
@@ -30345,8 +30386,11 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglCreateFenceSyncNV"]
     pub static mut epoxy_eglCreateFenceSyncNV: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, condition: EGLenum, attrib_list: *const EGLint)
-            -> EGLSyncNV,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            condition: EGLenum,
+            attrib_list: *const EGLint,
+        ) -> EGLSyncNV,
     >;
 }
 extern "C" {
@@ -30393,8 +30437,11 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglCreatePbufferSurface"]
     pub static mut epoxy_eglCreatePbufferSurface: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, config: EGLConfig, attrib_list: *const EGLint)
-            -> EGLSurface,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            config: EGLConfig,
+            attrib_list: *const EGLint,
+        ) -> EGLSurface,
     >;
 }
 extern "C" {
@@ -30411,8 +30458,11 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglCreatePixmapSurfaceHI"]
     pub static mut epoxy_eglCreatePixmapSurfaceHI: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, config: EGLConfig, pixmap: *mut EGLClientPixmapHI)
-            -> EGLSurface,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            config: EGLConfig,
+            pixmap: *mut EGLClientPixmapHI,
+        ) -> EGLSurface,
     >;
 }
 extern "C" {
@@ -30468,8 +30518,10 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglCreateStreamFromFileDescriptorKHR"]
     pub static mut epoxy_eglCreateStreamFromFileDescriptorKHR: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, file_descriptor: EGLNativeFileDescriptorKHR)
-            -> EGLStreamKHR,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            file_descriptor: EGLNativeFileDescriptorKHR,
+        ) -> EGLStreamKHR,
     >;
 }
 extern "C" {
@@ -30503,22 +30555,31 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglCreateSync"]
     pub static mut epoxy_eglCreateSync: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, type_: EGLenum, attrib_list: *const EGLAttrib)
-            -> EGLSync,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            type_: EGLenum,
+            attrib_list: *const EGLAttrib,
+        ) -> EGLSync,
     >;
 }
 extern "C" {
     #[link_name = "\u{1}epoxy_eglCreateSync64KHR"]
     pub static mut epoxy_eglCreateSync64KHR: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, type_: EGLenum, attrib_list: *const EGLAttribKHR)
-            -> EGLSyncKHR,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            type_: EGLenum,
+            attrib_list: *const EGLAttribKHR,
+        ) -> EGLSyncKHR,
     >;
 }
 extern "C" {
     #[link_name = "\u{1}epoxy_eglCreateSyncKHR"]
     pub static mut epoxy_eglCreateSyncKHR: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, type_: EGLenum, attrib_list: *const EGLint)
-            -> EGLSyncKHR,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            type_: EGLenum,
+            attrib_list: *const EGLint,
+        ) -> EGLSyncKHR,
     >;
 }
 extern "C" {
@@ -30721,8 +30782,9 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglGetProcAddress"]
     pub static mut epoxy_eglGetProcAddress: ::std::option::Option<
-        unsafe extern "C" fn(procname: *const ::std::os::raw::c_char)
-            -> __eglMustCastToProperFunctionPointerType,
+        unsafe extern "C" fn(
+            procname: *const ::std::os::raw::c_char,
+        ) -> __eglMustCastToProperFunctionPointerType,
     >;
 }
 extern "C" {
@@ -30789,15 +30851,22 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglLockSurfaceKHR"]
     pub static mut epoxy_eglLockSurfaceKHR: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, surface: EGLSurface, attrib_list: *const EGLint)
-            -> EGLBoolean,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            surface: EGLSurface,
+            attrib_list: *const EGLint,
+        ) -> EGLBoolean,
     >;
 }
 extern "C" {
     #[link_name = "\u{1}epoxy_eglMakeCurrent"]
     pub static mut epoxy_eglMakeCurrent: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, draw: EGLSurface, read: EGLSurface, ctx: EGLContext)
-            -> EGLBoolean,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            draw: EGLSurface,
+            read: EGLSurface,
+            ctx: EGLContext,
+        ) -> EGLBoolean,
     >;
 }
 extern "C" {
@@ -30838,8 +30907,11 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglPresentationTimeANDROID"]
     pub static mut epoxy_eglPresentationTimeANDROID: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, surface: EGLSurface, time: EGLnsecsANDROID)
-            -> EGLBoolean,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            surface: EGLSurface,
+            time: EGLnsecsANDROID,
+        ) -> EGLBoolean,
     >;
 }
 extern "C" {
@@ -30866,8 +30938,11 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglQueryDeviceAttribEXT"]
     pub static mut epoxy_eglQueryDeviceAttribEXT: ::std::option::Option<
-        unsafe extern "C" fn(device: EGLDeviceEXT, attribute: EGLint, value: *mut EGLAttrib)
-            -> EGLBoolean,
+        unsafe extern "C" fn(
+            device: EGLDeviceEXT,
+            attribute: EGLint,
+            value: *mut EGLAttrib,
+        ) -> EGLBoolean,
     >;
 }
 extern "C" {
@@ -30889,15 +30964,21 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglQueryDisplayAttribEXT"]
     pub static mut epoxy_eglQueryDisplayAttribEXT: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, attribute: EGLint, value: *mut EGLAttrib)
-            -> EGLBoolean,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            attribute: EGLint,
+            value: *mut EGLAttrib,
+        ) -> EGLBoolean,
     >;
 }
 extern "C" {
     #[link_name = "\u{1}epoxy_eglQueryDisplayAttribNV"]
     pub static mut epoxy_eglQueryDisplayAttribNV: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, attribute: EGLint, value: *mut EGLAttrib)
-            -> EGLBoolean,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            attribute: EGLint,
+            value: *mut EGLAttrib,
+        ) -> EGLBoolean,
     >;
 }
 extern "C" {
@@ -30933,15 +31014,21 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglQueryNativePixmapNV"]
     pub static mut epoxy_eglQueryNativePixmapNV: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, surf: EGLSurface, pixmap: *mut EGLNativePixmapType)
-            -> EGLBoolean,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            surf: EGLSurface,
+            pixmap: *mut EGLNativePixmapType,
+        ) -> EGLBoolean,
     >;
 }
 extern "C" {
     #[link_name = "\u{1}epoxy_eglQueryNativeWindowNV"]
     pub static mut epoxy_eglQueryNativeWindowNV: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, surf: EGLSurface, window: *mut EGLNativeWindowType)
-            -> EGLBoolean,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            surf: EGLSurface,
+            window: *mut EGLNativeWindowType,
+        ) -> EGLBoolean,
     >;
 }
 extern "C" {
@@ -30958,8 +31045,11 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglQueryOutputLayerStringEXT"]
     pub static mut epoxy_eglQueryOutputLayerStringEXT: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, layer: EGLOutputLayerEXT, name: EGLint)
-            -> *const ::std::os::raw::c_char,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            layer: EGLOutputLayerEXT,
+            name: EGLint,
+        ) -> *const ::std::os::raw::c_char,
     >;
 }
 extern "C" {
@@ -30976,8 +31066,11 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglQueryOutputPortStringEXT"]
     pub static mut epoxy_eglQueryOutputPortStringEXT: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, port: EGLOutputPortEXT, name: EGLint)
-            -> *const ::std::os::raw::c_char,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            port: EGLOutputPortEXT,
+            name: EGLint,
+        ) -> *const ::std::os::raw::c_char,
     >;
 }
 extern "C" {
@@ -31164,8 +31257,11 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglStreamConsumerAcquireAttribKHR"]
     pub static mut epoxy_eglStreamConsumerAcquireAttribKHR: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, stream: EGLStreamKHR, attrib_list: *const EGLAttrib)
-            -> EGLBoolean,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            stream: EGLStreamKHR,
+            attrib_list: *const EGLAttrib,
+        ) -> EGLBoolean,
     >;
 }
 extern "C" {
@@ -31177,8 +31273,11 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglStreamConsumerGLTextureExternalAttribsNV"]
     pub static mut epoxy_eglStreamConsumerGLTextureExternalAttribsNV: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, stream: EGLStreamKHR, attrib_list: *mut EGLAttrib)
-            -> EGLBoolean,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            stream: EGLStreamKHR,
+            attrib_list: *mut EGLAttrib,
+        ) -> EGLBoolean,
     >;
 }
 extern "C" {
@@ -31190,15 +31289,21 @@ extern "C" {
 extern "C" {
     #[link_name = "\u{1}epoxy_eglStreamConsumerOutputEXT"]
     pub static mut epoxy_eglStreamConsumerOutputEXT: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, stream: EGLStreamKHR, layer: EGLOutputLayerEXT)
-            -> EGLBoolean,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            stream: EGLStreamKHR,
+            layer: EGLOutputLayerEXT,
+        ) -> EGLBoolean,
     >;
 }
 extern "C" {
     #[link_name = "\u{1}epoxy_eglStreamConsumerReleaseAttribKHR"]
     pub static mut epoxy_eglStreamConsumerReleaseAttribKHR: ::std::option::Option<
-        unsafe extern "C" fn(dpy: EGLDisplay, stream: EGLStreamKHR, attrib_list: *const EGLAttrib)
-            -> EGLBoolean,
+        unsafe extern "C" fn(
+            dpy: EGLDisplay,
+            stream: EGLStreamKHR,
+            attrib_list: *const EGLAttrib,
+        ) -> EGLBoolean,
     >;
 }
 extern "C" {
diff --git a/gpu_renderer/src/lib.rs b/gpu_renderer/src/lib.rs
index 6864fe9..c82e99c 100644
--- a/gpu_renderer/src/lib.rs
+++ b/gpu_renderer/src/lib.rs
@@ -281,9 +281,12 @@ struct EGLFunctionsInner {
     GetDisplay: unsafe extern "C" fn(display_id: EGLNativeDisplayType) -> EGLDisplay,
     Initialize:
         unsafe extern "C" fn(dpy: EGLDisplay, major: *mut EGLint, minor: *mut EGLint) -> EGLBoolean,
-    MakeCurrent:
-        unsafe extern "C" fn(dpy: EGLDisplay, draw: EGLSurface, read: EGLSurface, ctx: EGLContext)
-            -> EGLBoolean,
+    MakeCurrent: unsafe extern "C" fn(
+        dpy: EGLDisplay,
+        draw: EGLSurface,
+        read: EGLSurface,
+        ctx: EGLContext,
+    ) -> EGLBoolean,
     no_sync_send: PhantomData<*mut ()>,
 }
 
@@ -1043,7 +1046,8 @@ mod tests {
                 Box3::new_2d(0, 5, 0, 1),
                 0,
                 &mut pix_buf[..],
-            ).expect("failed to read back resource data");
+            )
+            .expect("failed to read back resource data");
 
         // Check that the pixels are the color we cleared to. The red and blue channels are switched
         // because the surface was created with the BGR format, but the colors are RGB order in the
diff --git a/kokoro/Dockerfile b/kokoro/Dockerfile
index 526d6c3..f2901f8 100644
--- a/kokoro/Dockerfile
+++ b/kokoro/Dockerfile
@@ -32,7 +32,7 @@ RUN apt-get update && apt-get install -y \
 ENV RUSTUP_HOME=/usr/local/rustup \
     CARGO_HOME=/usr/local/cargo \
     PATH=/usr/local/cargo/bin:$PATH \
-    RUST_VERSION=1.30.0
+    RUST_VERSION=1.31.0
 
 # Debian usually has an old rust version in the repository. Instead of using that, we use rustup to
 # pull in a toolchain versions of our choosing.
diff --git a/kvm/src/lib.rs b/kvm/src/lib.rs
index 72bea5e..32bee6c 100644
--- a/kvm/src/lib.rs
+++ b/kvm/src/lib.rs
@@ -1658,10 +1658,9 @@ mod tests {
         let mut vm = Vm::new(&kvm, gm).unwrap();
         let mem_size = 0x2000;
         let mem = MemoryMapping::new(mem_size).unwrap();
-        assert!(
-            vm.add_device_memory(GuestAddress(0x2000), mem, false, false)
-                .is_err()
-        );
+        assert!(vm
+            .add_device_memory(GuestAddress(0x2000), mem, false, false)
+            .is_err());
     }
 
     #[test]
@@ -1720,22 +1719,26 @@ mod tests {
             &evtfd,
             IoeventAddress::Pio(0xc1),
             Datamatch::U8(Some(0x7fu8)),
-        ).unwrap();
+        )
+        .unwrap();
         vm.register_ioevent(
             &evtfd,
             IoeventAddress::Pio(0xc2),
             Datamatch::U16(Some(0x1337u16)),
-        ).unwrap();
+        )
+        .unwrap();
         vm.register_ioevent(
             &evtfd,
             IoeventAddress::Pio(0xc4),
             Datamatch::U32(Some(0xdeadbeefu32)),
-        ).unwrap();
+        )
+        .unwrap();
         vm.register_ioevent(
             &evtfd,
             IoeventAddress::Pio(0xc8),
             Datamatch::U64(Some(0xdeadbeefdeadbeefu64)),
-        ).unwrap();
+        )
+        .unwrap();
     }
 
     #[test]
@@ -1752,7 +1755,8 @@ mod tests {
             &evtfd,
             IoeventAddress::Mmio(0x1004),
             Datamatch::U8(Some(0x7fu8)),
-        ).unwrap();
+        )
+        .unwrap();
         vm.unregister_ioevent(&evtfd, IoeventAddress::Pio(0xf4), Datamatch::AnyLength)
             .unwrap();
         vm.unregister_ioevent(&evtfd, IoeventAddress::Mmio(0x1000), Datamatch::AnyLength)
@@ -1761,7 +1765,8 @@ mod tests {
             &evtfd,
             IoeventAddress::Mmio(0x1004),
             Datamatch::U8(Some(0x7fu8)),
-        ).unwrap();
+        )
+        .unwrap();
     }
 
     #[test]
@@ -1821,14 +1826,16 @@ mod tests {
                 chip: KVM_IRQCHIP_IOAPIC,
                 pin: 3,
             },
-        }]).unwrap();
+        }])
+        .unwrap();
         vm.set_gsi_routing(&[IrqRoute {
             gsi: 1,
             source: IrqSource::Msi {
                 address: 0xf000000,
                 data: 0xa0,
             },
-        }]).unwrap();
+        }])
+        .unwrap();
         vm.set_gsi_routing(&[
             IrqRoute {
                 gsi: 1,
@@ -1844,7 +1851,8 @@ mod tests {
                     data: 0xa0,
                 },
             },
-        ]).unwrap();
+        ])
+        .unwrap();
     }
 
     #[test]
diff --git a/kvm/tests/dirty_log.rs b/kvm/tests/dirty_log.rs
index 269e465..645a01d 100644
--- a/kvm/tests/dirty_log.rs
+++ b/kvm/tests/dirty_log.rs
@@ -53,7 +53,8 @@ fn test_run() {
                 .expect("failed to create memory mapping"),
             false,
             true,
-        ).expect("failed to register memory");
+        )
+        .expect("failed to register memory");
 
     loop {
         match vcpu.run().expect("run failed") {
diff --git a/kvm/tests/read_only_memory.rs b/kvm/tests/read_only_memory.rs
index 4bd4778..5114ce4 100644
--- a/kvm/tests/read_only_memory.rs
+++ b/kvm/tests/read_only_memory.rs
@@ -54,7 +54,8 @@ fn test_run() {
         MemoryMapping::from_fd(&mem, mem_size as usize).expect("failed to create memory mapping"),
         false,
         false,
-    ).expect("failed to register memory");
+    )
+    .expect("failed to register memory");
 
     // Give some read only memory for the test code to read from and force a vcpu exit when it reads
     // from it.
@@ -71,7 +72,8 @@ fn test_run() {
         MemoryMapping::from_fd(&mem_ro, 0x1000).expect("failed to create memory mapping"),
         true,
         false,
-    ).expect("failed to register memory");
+    )
+    .expect("failed to register memory");
 
     // Ensure we get exactly 1 exit from attempting to write to read only memory.
     let mut exits = 0;
diff --git a/msg_socket/tests/enum.rs b/msg_socket/tests/enum.rs
index d63cfc1..9134f6e 100644
--- a/msg_socket/tests/enum.rs
+++ b/msg_socket/tests/enum.rs
@@ -55,7 +55,8 @@ fn sock_send_recv_enum() {
     res.send(&Response::E {
         f0: 0x12,
         f1: 0x0f0f,
-    }).unwrap();
+    })
+    .unwrap();
     match req.recv().unwrap() {
         Response::E { f0, f1 } => {
             assert_eq!(f0, 0x12);
diff --git a/msg_socket/tests/struct.rs b/msg_socket/tests/struct.rs
index ab97a6f..07cde3e 100644
--- a/msg_socket/tests/struct.rs
+++ b/msg_socket/tests/struct.rs
@@ -25,7 +25,8 @@ fn sock_send_recv_struct() {
         field0: 2,
         field1: e0,
         field2: 0xf0f0,
-    }).unwrap();
+    })
+    .unwrap();
     let r = res.recv().unwrap();
     assert_eq!(r.field0, 2);
     assert_eq!(r.field2, 0xf0f0);
diff --git a/p9/src/protocol/wire_format.rs b/p9/src/protocol/wire_format.rs
index afdc097..bd3d67b 100644
--- a/p9/src/protocol/wire_format.rs
+++ b/p9/src/protocol/wire_format.rs
@@ -336,7 +336,8 @@ mod test {
                     0x0c, 0x00, 0x47, 0x6F, 0x6F, 0x67, 0x6C, 0x65, 0x20, 0x56, 0x69, 0x64, 0x65,
                     0x6F,
                 ][..]
-            )).unwrap()
+            ))
+            .unwrap()
         );
         assert_eq!(
             String::from("网页 图片 资讯更多 »"),
@@ -346,7 +347,8 @@ mod test {
                     0x89, 0x87, 0x20, 0xE8, 0xB5, 0x84, 0xE8, 0xAE, 0xAF, 0xE6, 0x9B, 0xB4, 0xE5,
                     0xA4, 0x9A, 0x20, 0xC2, 0xBB,
                 ][..]
-            )).unwrap()
+            ))
+            .unwrap()
         );
         assert_eq!(
             String::from("Παγκόσμιος Ιστός"),
@@ -356,7 +358,8 @@ mod test {
                     0x83, 0xCE, 0xBC, 0xCE, 0xB9, 0xCE, 0xBF, 0xCF, 0x82, 0x20, 0xCE, 0x99, 0xCF,
                     0x83, 0xCF, 0x84, 0xCF, 0x8C, 0xCF, 0x82,
                 ][..]
-            )).unwrap()
+            ))
+            .unwrap()
         );
         assert_eq!(
             String::from("Поиск страниц на русском"),
@@ -367,7 +370,8 @@ mod test {
                     0x86, 0x20, 0xD0, 0xBD, 0xD0, 0xB0, 0x20, 0xD1, 0x80, 0xD1, 0x83, 0xD1, 0x81,
                     0xD1, 0x81, 0xD0, 0xBA, 0xD0, 0xBE, 0xD0, 0xBC,
                 ][..]
-            )).unwrap()
+            ))
+            .unwrap()
         );
         assert_eq!(
             String::from("전체서비스"),
@@ -376,7 +380,8 @@ mod test {
                     0x0f, 0x00, 0xEC, 0xA0, 0x84, 0xEC, 0xB2, 0xB4, 0xEC, 0x84, 0x9C, 0xEB, 0xB9,
                     0x84, 0xEC, 0x8A, 0xA4,
                 ][..]
-            )).unwrap()
+            ))
+            .unwrap()
         );
     }
 
@@ -384,11 +389,13 @@ mod test {
     fn invalid_string_decode() {
         let _ = <String as WireFormat>::decode(&mut Cursor::new(&[
             0x06, 0x00, 0xed, 0xa0, 0x80, 0xed, 0xbf, 0xbf,
-        ])).expect_err("surrogate code point");
+        ]))
+        .expect_err("surrogate code point");
 
         let _ = <String as WireFormat>::decode(&mut Cursor::new(&[
             0x05, 0x00, 0xf8, 0x80, 0x80, 0x80, 0xbf,
-        ])).expect_err("overlong sequence");
+        ]))
+        .expect_err("overlong sequence");
 
         let _ =
             <String as WireFormat>::decode(&mut Cursor::new(&[0x04, 0x00, 0xf4, 0x90, 0x80, 0x80]))
diff --git a/p9/src/server.rs b/p9/src/server.rs
index d3d7547..4b47956 100644
--- a/p9/src/server.rs
+++ b/p9/src/server.rs
@@ -402,7 +402,8 @@ impl Server {
             msg: Rmessage::Read(Rread {
                 data: Data(Vec::new()),
             }),
-        }.byte_size();
+        }
+        .byte_size();
 
         let capacity = min(self.msize - header_size, read.count);
         let mut buf = Data(Vec::with_capacity(capacity as usize));
@@ -779,7 +780,8 @@ impl Server {
             msg: Rmessage::Readdir(Rreaddir {
                 data: Data(Vec::new()),
             }),
-        }.byte_size();
+        }
+        .byte_size();
         let count = min(self.msize - header_size, readdir.count);
         let mut cursor = Cursor::new(Vec::with_capacity(count as usize));
 
diff --git a/plugin_proto/build.rs b/plugin_proto/build.rs
index 852a1ae..726f454 100644
--- a/plugin_proto/build.rs
+++ b/plugin_proto/build.rs
@@ -16,12 +16,14 @@ fn main() {
         out_dir: out_dir.as_os_str().to_str().unwrap(),
         input: &["protos/plugin.proto"],
         includes: &["protos"],
-    }).expect("protoc");
+    })
+    .expect("protoc");
 
     let mut mod_out = fs::File::create(out_dir.join("proto_include.rs")).unwrap();
     writeln!(
         mod_out,
         "#[path = \"{}\"] pub mod plugin_proto;\npub use plugin_proto::*;",
         out_dir.join("plugin.rs").display()
-    ).unwrap();
+    )
+    .unwrap();
 }
diff --git a/qcow/src/qcow.rs b/qcow/src/qcow.rs
index 6373d01..ad771c5 100644
--- a/qcow/src/qcow.rs
+++ b/qcow/src/qcow.rs
@@ -242,7 +242,8 @@ impl QcowHeader {
         let refcount_blocks_size = u64::from(self.refcount_table_clusters) * cluster_size;
         file.seek(SeekFrom::Start(
             self.refcount_table_offset + refcount_blocks_size - 2,
-        )).map_err(Error::WritingHeader)?;
+        ))
+        .map_err(Error::WritingHeader)?;
         file.write(&[0u8]).map_err(Error::WritingHeader)?;
 
         Ok(())
@@ -368,7 +369,8 @@ impl QcowFile {
                     header.l1_table_offset,
                     num_l2_clusters,
                     Some(L1_TABLE_OFFSET_MASK),
-                ).map_err(Error::ReadingHeader)?,
+                )
+                .map_err(Error::ReadingHeader)?,
         );
 
         let num_clusters = div_round_up_u64(header.size, cluster_size);
@@ -384,7 +386,8 @@ impl QcowFile {
             refcount_clusters,
             refcount_block_entries,
             cluster_size,
-        ).map_err(Error::ReadingRefCounts)?;
+        )
+        .map_err(Error::ReadingRefCounts)?;
 
         let l2_entries = cluster_size / size_of::<u64>() as u64;
 
@@ -475,7 +478,8 @@ impl QcowFile {
                         evicted.get_values(),
                         CLUSTER_USED_FLAG,
                     )
-                }).map_err(Error::EvictingCache)?;
+                })
+                .map_err(Error::EvictingCache)?;
         }
 
         // The index must exist as it was just inserted if it didn't already.
@@ -584,7 +588,8 @@ impl QcowFile {
                     header.l1_table_offset,
                     header.l1_size as u64,
                     Some(L1_TABLE_OFFSET_MASK),
-                ).map_err(Error::ReadingPointers)?;
+                )
+                .map_err(Error::ReadingPointers)?;
             for l1_index in 0..header.l1_size as usize {
                 let l2_addr_disk = *l1_table.get(l1_index).ok_or(Error::InvalidIndex)?;
                 if l2_addr_disk != 0 {
@@ -597,7 +602,8 @@ impl QcowFile {
                             l2_addr_disk,
                             cluster_size / size_of::<u64>() as u64,
                             Some(L2_TABLE_OFFSET_MASK),
-                        ).map_err(Error::ReadingPointers)?;
+                        )
+                        .map_err(Error::ReadingPointers)?;
                     for data_cluster_addr in l2_table {
                         if data_cluster_addr != 0 {
                             add_ref(refcounts, cluster_size, data_cluster_addr)?;
@@ -691,7 +697,8 @@ impl QcowFile {
                         .write_refcount_block(
                             *refblock_addr + refblock.len() as u64 * 2,
                             &refblock_padding,
-                        ).map_err(Error::WritingHeader)?;
+                        )
+                        .map_err(Error::WritingHeader)?;
                 }
             }
 
diff --git a/qcow/src/refcount.rs b/qcow/src/refcount.rs
index db7d8d4..a64d218 100644
--- a/qcow/src/refcount.rs
+++ b/qcow/src/refcount.rs
@@ -101,7 +101,8 @@ impl RefCount {
                 self.refblock_cache
                     .insert(table_index, table, |index, evicted| {
                         raw_file.write_refcount_block(ref_table[index], evicted.get_values())
-                    }).map_err(Error::EvictingRefCounts)?;
+                    })
+                    .map_err(Error::EvictingRefCounts)?;
             } else {
                 if block_addr_disk == 0 {
                     return Err(Error::NeedNewCluster);
@@ -181,7 +182,8 @@ impl RefCount {
             self.refblock_cache
                 .insert(table_index, table, |index, evicted| {
                     raw_file.write_refcount_block(ref_table[index], evicted.get_values())
-                }).map_err(Error::EvictingRefCounts)?;
+                })
+                .map_err(Error::EvictingRefCounts)?;
         }
         Ok(self.refblock_cache.get(&table_index).unwrap()[block_index])
     }
@@ -212,7 +214,8 @@ impl RefCount {
             self.refblock_cache
                 .insert(table_index, table, |index, evicted| {
                     raw_file.write_refcount_block(ref_table[index], evicted.get_values())
-                }).map_err(Error::EvictingRefCounts)?;
+                })
+                .map_err(Error::EvictingRefCounts)?;
         }
         // The index must exist as it was just inserted if it didn't already.
         Ok(Some(
diff --git a/qcow/src/vec_cache.rs b/qcow/src/vec_cache.rs
index 48f9d86..ecd7673 100644
--- a/qcow/src/vec_cache.rs
+++ b/qcow/src/vec_cache.rs
@@ -151,25 +151,29 @@ mod tests {
             .insert(0, NumCache(5), |index, _| {
                 evicted = Some(index);
                 Ok(())
-            }).unwrap();
+            })
+            .unwrap();
         assert_eq!(evicted, None);
         cache
             .insert(1, NumCache(6), |index, _| {
                 evicted = Some(index);
                 Ok(())
-            }).unwrap();
+            })
+            .unwrap();
         assert_eq!(evicted, None);
         cache
             .insert(2, NumCache(7), |index, _| {
                 evicted = Some(index);
                 Ok(())
-            }).unwrap();
+            })
+            .unwrap();
         assert_eq!(evicted, None);
         cache
             .insert(3, NumCache(8), |index, _| {
                 evicted = Some(index);
                 Ok(())
-            }).unwrap();
+            })
+            .unwrap();
         assert!(evicted.is_some());
 
         // Check that three of the four items inserted are still there and that the most recently
diff --git a/qcow_utils/src/qcow_utils.rs b/qcow_utils/src/qcow_utils.rs
index 33f20ae..faf7aed 100644
--- a/qcow_utils/src/qcow_utils.rs
+++ b/qcow_utils/src/qcow_utils.rs
@@ -65,7 +65,8 @@ pub unsafe extern "C" fn convert_to_qcow2(src_fd: c_int, dst_fd: c_int) -> c_int
                     Ok(_) => 0,
                     Err(_) => -EIO,
                 },
-            ).unwrap_or(-EIO)
+            )
+            .unwrap_or(-EIO)
         }
         _ => -EBADFD,
     }
@@ -88,7 +89,8 @@ pub unsafe extern "C" fn convert_to_raw(src_fd: c_int, dst_fd: c_int) -> c_int {
             catch_unwind(|| match qcow::convert(src_file, dst_file, ImageType::Raw) {
                 Ok(_) => 0,
                 Err(_) => -EIO,
-            }).unwrap_or(-EIO)
+            })
+            .unwrap_or(-EIO)
         }
         _ => -EBADFD,
     }
diff --git a/rust-toolchain b/rust-toolchain
index 034552a..34aae15 100644
--- a/rust-toolchain
+++ b/rust-toolchain
@@ -1 +1 @@
-1.30.0
+1.31.0
diff --git a/src/linux.rs b/src/linux.rs
index 1cb99cc..7d9fa1b 100644
--- a/src/linux.rs
+++ b/src/linux.rs
@@ -356,7 +356,8 @@ fn create_virtio_devs(
                             netmask,
                             mac_address,
                             &mem,
-                        ).map_err(Error::VhostNetDeviceNew)?,
+                        )
+                        .map_err(Error::VhostNetDeviceNew)?,
                     )
                 } else {
                     Box::new(
@@ -418,7 +419,8 @@ fn create_virtio_devs(
                         "tmpfs",
                         (libc::MS_NOSUID | libc::MS_NODEV | libc::MS_NOEXEC) as usize,
                         "size=67108864",
-                    ).unwrap();
+                    )
+                    .unwrap();
 
                     // Device nodes required for DRM.
                     let sys_dev_char_path = Path::new("/sys/dev/char");
@@ -496,7 +498,8 @@ fn create_virtio_devs(
                 },
                 wayland_device_socket,
                 resource_bridge_wl_socket,
-            ).map_err(Error::WaylandDeviceNew)?,
+            )
+            .map_err(Error::WaylandDeviceNew)?,
         );
 
         let jail = if cfg.multiprocess {
@@ -511,7 +514,8 @@ fn create_virtio_devs(
                 "tmpfs",
                 (libc::MS_NOSUID | libc::MS_NODEV | libc::MS_NOEXEC) as usize,
                 "size=67108864",
-            ).unwrap();
+            )
+            .unwrap();
 
             // Bind mount the wayland socket's directory into jail's root. This is necessary since
             // each new wayland context must open() the socket. If the wayland socket is ever
@@ -738,7 +742,8 @@ fn run_vcpu(
             exit_evt
                 .write(1)
                 .expect("failed to signal vcpu exit eventfd");
-        }).map_err(Error::SpawnVcpu)
+        })
+        .map_err(Error::SpawnVcpu)
 }
 
 // Reads the contents of a file and converts them into a u64.
@@ -797,7 +802,8 @@ pub fn run_config(cfg: Config) -> Result<()> {
 
     let linux = Arch::build_vm(components, |m, e| {
         create_virtio_devs(cfg, m, e, wayland_device_socket, balloon_device_socket)
-    }).map_err(Error::BuildingVm)?;
+    })
+    .map_err(Error::BuildingVm)?;
     run_control(linux, control_sockets, balloon_host_socket, sigchld_fd)
 }
 
diff --git a/src/main.rs b/src/main.rs
index a492437..d901cbf 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -350,7 +350,8 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument::
                 .ok_or_else(|| argument::Error::InvalidValue {
                     value: param.to_owned(),
                     expected: "missing tag for `shared-dir`",
-                })?.to_owned();
+                })?
+                .to_owned();
 
             if !src.is_dir() {
                 return Err(argument::Error::InvalidValue {
@@ -466,7 +467,8 @@ fn run_vm(args: std::env::Args) -> std::result::Result<(), ()> {
     let mut cfg = Config::default();
     let match_res = set_arguments(args, &arguments[..], |name, value| {
         set_argument(&mut cfg, name, value)
-    }).and_then(|_| {
+    })
+    .and_then(|_| {
         if cfg.kernel_path.as_os_str().is_empty() && cfg.plugin.is_none() {
             return Err(argument::Error::ExpectedArgument("`KERNEL`".to_owned()));
         }
@@ -505,19 +507,16 @@ fn run_vm(args: std::env::Args) -> std::result::Result<(), ()> {
 
     match match_res {
         #[cfg(feature = "plugin")]
-        Ok(()) if cfg.plugin.is_some() =>
-        {
-            match plugin::run_config(cfg) {
-                Ok(_) => {
-                    info!("crosvm and plugin have exited normally");
-                    Ok(())
-                }
-                Err(e) => {
-                    error!("{}", e);
-                    Err(())
-                }
+        Ok(()) if cfg.plugin.is_some() => match plugin::run_config(cfg) {
+            Ok(_) => {
+                info!("crosvm and plugin have exited normally");
+                Ok(())
             }
-        }
+            Err(e) => {
+                error!("{}", e);
+                Err(())
+            }
+        },
         Ok(()) => match linux::run_config(cfg) {
             Ok(_) => {
                 info!("crosvm has exited normally");
diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs
index 745fa4e..0aa2ff4 100644
--- a/src/plugin/mod.rs
+++ b/src/plugin/mod.rs
@@ -254,7 +254,8 @@ fn create_plugin_jail(root: &Path, seccomp_policy: &Path) -> Result<Minijail> {
         "tmpfs",
         (MS_NOSUID | MS_NODEV) as usize,
         "size=67108864",
-    ).map_err(Error::MountRoot)?;
+    )
+    .map_err(Error::MountRoot)?;
 
     Ok(j)
 }
@@ -439,7 +440,8 @@ pub fn run_vcpus(
                     vcpu_exit_evt
                         .write(1)
                         .expect("failed to signal vcpu exit eventfd");
-                }).map_err(Error::SpawnVcpu)?,
+                })
+                .map_err(Error::SpawnVcpu)?,
         );
     }
     Ok(())
diff --git a/sys_util/src/fork.rs b/sys_util/src/fork.rs
index 426b2ae..2941c44 100644
--- a/sys_util/src/fork.rs
+++ b/sys_util/src/fork.rs
@@ -120,7 +120,8 @@ mod tests {
             } else {
                 evt_fd_fork.write(2).unwrap()
             }
-        }).expect("failed to clone");
+        })
+        .expect("failed to clone");
         assert_eq!(evt_fd.read(), Ok(1));
     }
 
@@ -131,7 +132,8 @@ mod tests {
 
         clone_process(CloneNamespace::Inherit, || {
             assert!(false);
-        }).expect("failed to clone");
+        })
+        .expect("failed to clone");
 
         // This should never happen;
         if pid != getpid() {
diff --git a/sys_util/src/guest_memory.rs b/sys_util/src/guest_memory.rs
index 3622085..6644ff2 100644
--- a/sys_util/src/guest_memory.rs
+++ b/sys_util/src/guest_memory.rs
@@ -496,7 +496,8 @@ mod tests {
         let gm = GuestMemory::new(&vec![
             (start_region1, size_region1),
             (start_region2, size_region2),
-        ]).unwrap();
+        ])
+        .unwrap();
 
         let mem_size = gm.memory_size();
         assert_eq!(mem_size, size_region1 + size_region2);
diff --git a/sys_util/src/sock_ctrl_msg.rs b/sys_util/src/sock_ctrl_msg.rs
index 337dbb9..07b5d2b 100644
--- a/sys_util/src/sock_ctrl_msg.rs
+++ b/sys_util/src/sock_ctrl_msg.rs
@@ -88,7 +88,8 @@ impl CmsgBuffer {
                         cmsg_type: 0,
                     };
                     cap_in_cmsghdr_units
-                ].into_boxed_slice(),
+                ]
+                .into_boxed_slice(),
             )
         }
     }
diff --git a/tests/plugins.rs b/tests/plugins.rs
index 27bbc47..20adcab 100644
--- a/tests/plugins.rs
+++ b/tests/plugins.rs
@@ -36,7 +36,8 @@ fn get_target_path() -> PathBuf {
         .map(|mut path| {
             path.pop();
             path
-        }).expect("failed to get crosvm binary directory")
+        })
+        .expect("failed to get crosvm binary directory")
 }
 
 fn get_crosvm_path() -> PathBuf {
@@ -48,7 +49,8 @@ fn get_crosvm_path() -> PathBuf {
                 path.pop();
             }
             path
-        }).expect("failed to get crosvm binary directory")
+        })
+        .expect("failed to get crosvm binary directory")
 }
 
 fn build_plugin(src: &str) -> RemovePath {
@@ -98,7 +100,8 @@ fn run_plugin(bin_path: &Path, with_sandbox: bool) {
         "--seccomp-policy-dir",
         "tests",
         "--plugin",
-    ]).arg(
+    ])
+    .arg(
         bin_path
             .canonicalize()
             .expect("failed to canonicalize plugin path"),
diff --git a/x86_64/src/lib.rs b/x86_64/src/lib.rs
index 861e1be..524013c 100644
--- a/x86_64/src/lib.rs
+++ b/x86_64/src/lib.rs
@@ -266,8 +266,10 @@ fn arch_memory_regions(size: u64) -> Vec<(GuestAddress, u64)> {
 impl arch::LinuxArch for X8664arch {
     fn build_vm<F>(mut components: VmComponents, virtio_devs: F) -> Result<RunnableLinuxVm>
     where
-        F: FnOnce(&GuestMemory, &EventFd)
-            -> Result<Vec<(Box<PciDevice + 'static>, Option<Minijail>)>>,
+        F: FnOnce(
+            &GuestMemory,
+            &EventFd,
+        ) -> Result<Vec<(Box<PciDevice + 'static>, Option<Minijail>)>>,
     {
         let mut resources =
             Self::get_resource_allocator(components.memory_mb, components.wayland_dmabuf);
@@ -483,7 +485,8 @@ impl X8664arch {
                 0x2f8,
                 0x8,
                 false,
-            ).unwrap();
+            )
+            .unwrap();
         io_bus
             .insert(
                 Arc::new(Mutex::new(devices::Serial::new_sink(
@@ -492,7 +495,8 @@ impl X8664arch {
                 0x3e8,
                 0x8,
                 false,
-            ).unwrap();
+            )
+            .unwrap();
         io_bus
             .insert(
                 Arc::new(Mutex::new(devices::Serial::new_sink(
@@ -501,7 +505,8 @@ impl X8664arch {
                 0x2e8,
                 0x8,
                 false,
-            ).unwrap();
+            )
+            .unwrap();
         io_bus
             .insert(Arc::new(Mutex::new(devices::Cmos::new())), 0x70, 0x2, false)
             .unwrap();
@@ -513,7 +518,8 @@ impl X8664arch {
                 0x061,
                 0x4,
                 false,
-            ).unwrap();
+            )
+            .unwrap();
         io_bus
             .insert(nul_device.clone(), 0x040, 0x8, false)
             .unwrap(); // ignore pit
diff --git a/x86_64/src/mptable.rs b/x86_64/src/mptable.rs
index 1421c2c..4c3bae4 100644
--- a/x86_64/src/mptable.rs
+++ b/x86_64/src/mptable.rs
@@ -166,11 +166,12 @@ pub fn setup_mptable(
         mpc_cpu.type_ = MP_PROCESSOR as u8;
         mpc_cpu.apicid = cpu_id;
         mpc_cpu.apicver = APIC_VERSION;
-        mpc_cpu.cpuflag = CPU_ENABLED as u8 | if cpu_id == 0 {
-            CPU_BOOTPROCESSOR as u8
-        } else {
-            0
-        };
+        mpc_cpu.cpuflag = CPU_ENABLED as u8
+            | if cpu_id == 0 {
+                CPU_BOOTPROCESSOR as u8
+            } else {
+                0
+            };
         mpc_cpu.cpufeature = CPU_STEPPING;
         mpc_cpu.featureflag = CPU_FEATURE_APIC | CPU_FEATURE_FPU;
         mem.write_obj_at_addr(mpc_cpu, base_mp)
@@ -348,7 +349,8 @@ mod tests {
         let mem = GuestMemory::new(&[(
             GuestAddress(MPTABLE_START),
             compute_mp_size(num_cpus) as u64,
-        )]).unwrap();
+        )])
+        .unwrap();
 
         setup_mptable(&mem, num_cpus, Vec::new()).unwrap();
     }
@@ -359,7 +361,8 @@ mod tests {
         let mem = GuestMemory::new(&[(
             GuestAddress(MPTABLE_START),
             (compute_mp_size(num_cpus) - 1) as u64,
-        )]).unwrap();
+        )])
+        .unwrap();
 
         assert!(setup_mptable(&mem, num_cpus, Vec::new()).is_err());
     }
@@ -370,7 +373,8 @@ mod tests {
         let mem = GuestMemory::new(&[(
             GuestAddress(MPTABLE_START),
             compute_mp_size(num_cpus) as u64,
-        )]).unwrap();
+        )])
+        .unwrap();
 
         setup_mptable(&mem, num_cpus, Vec::new()).unwrap();
 
@@ -385,7 +389,8 @@ mod tests {
         let mem = GuestMemory::new(&[(
             GuestAddress(MPTABLE_START),
             compute_mp_size(num_cpus) as u64,
-        )]).unwrap();
+        )])
+        .unwrap();
 
         setup_mptable(&mem, num_cpus, Vec::new()).unwrap();
 
@@ -418,7 +423,8 @@ mod tests {
         let mem = GuestMemory::new(&[(
             GuestAddress(MPTABLE_START),
             compute_mp_size(MAX_CPUS) as u64,
-        )]).unwrap();
+        )])
+        .unwrap();
 
         for i in 0..MAX_CPUS {
             setup_mptable(&mem, i, Vec::new()).unwrap();