diff options
author | David Tolnay <dtolnay@chromium.org> | 2019-04-15 15:56:35 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-04-18 19:51:01 -0700 |
commit | 64cd5eae5778b86f6e498a6fa1b1962693aa5a46 (patch) | |
tree | 9b68f7fce3385c410f4fd9c4e978660a9b5a0973 /src | |
parent | b1de6323ab8c96c52a60e0ff735e4bbb8a8464c9 (diff) | |
download | crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.gz crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.bz2 crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.lz crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.xz crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.zst crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.zip |
edition: Eliminate ref keyword
As described in: https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/default-match-bindings.html which also covers the new mental model that the Rust Book will use for teaching binding modes and has been found to be more friendly for both beginners and experienced users. Before: match *opt { Some(ref v) => ..., None => ..., } After: match opt { Some(v) => ..., None => ..., } TEST=cargo check --all-features TEST=local kokoro Change-Id: I3c5800a9be36aaf5d3290ae3bd3116f699cb00b7 Reviewed-on: https://chromium-review.googlesource.com/1566669 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/argument.rs | 2 | ||||
-rw-r--r-- | src/linux.rs | 10 | ||||
-rw-r--r-- | src/plugin/mod.rs | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src/argument.rs b/src/argument.rs index 6b4cfe9..7cb56d6 100644 --- a/src/argument.rs +++ b/src/argument.rs @@ -324,7 +324,7 @@ pub fn print_help(program_name: &str, required_arg: &str, args: &[Argument]) { println!("Argument{}:", if args.len() > 1 { "s" } else { "" }); for arg in args { match arg.short { - Some(ref s) => print!(" -{}, ", s), + Some(s) => print!(" -{}, ", s), None => print!(" "), } if arg.long.is_empty() { diff --git a/src/linux.rs b/src/linux.rs index 7ece6e3..977f7bf 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -164,8 +164,8 @@ impl Display for Error { Disk(e) => write!(f, "failed to load disk image: {}", e), DiskImageLock(e) => write!(f, "failed to lock disk image: {}", e), DropCapabilities(e) => write!(f, "failed to drop process capabilities: {}", e), - InputDeviceNew(ref e) => write!(f, "failed to set up input device: {}", e), - InputEventsOpen(ref e) => write!(f, "failed to open event device: {}", e), + InputDeviceNew(e) => write!(f, "failed to set up input device: {}", e), + InputEventsOpen(e) => write!(f, "failed to open event device: {}", e), InvalidFdPath => write!(f, "failed parsing a /proc/self/fd/*"), InvalidWaylandPath => write!(f, "wayland socket path has no parent or file name"), IoJail(e) => write!(f, "{}", e), @@ -1275,7 +1275,7 @@ fn run_control( // Watch for low memory notifications and take memory back from the VM. let low_mem = File::open("/dev/chromeos-low-mem").ok(); - if let Some(ref low_mem) = low_mem { + if let Some(low_mem) = &low_mem { poll_ctx .add(low_mem, Token::LowMemory) .map_err(Error::PollContextAdd)?; @@ -1415,7 +1415,7 @@ fn run_control( } } Token::LowMemory => { - if let Some(ref low_mem) = low_mem { + if let Some(low_mem) = &low_mem { let old_balloon_memory = current_balloon_memory; current_balloon_memory = min( current_balloon_memory + balloon_memory_increment, @@ -1453,7 +1453,7 @@ fn run_control( // Acknowledge the timer. lowmem_timer.wait().map_err(Error::TimerFd)?; - if let Some(ref low_mem) = low_mem { + if let Some(low_mem) = &low_mem { // Start polling the lowmem device again. poll_ctx .add(low_mem, Token::LowMemory) diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs index c01ff80..beedea4 100644 --- a/src/plugin/mod.rs +++ b/src/plugin/mod.rs @@ -467,8 +467,8 @@ pub fn run_config(cfg: Config) -> Result<()> { let jail = if cfg.sandbox { // An empty directory for jailed plugin pivot root. - let root_path = match cfg.plugin_root { - Some(ref dir) => Path::new(dir), + let root_path = match &cfg.plugin_root { + Some(dir) => dir, None => Path::new("/var/empty"), }; @@ -599,7 +599,7 @@ pub fn run_config(cfg: Config) -> Result<()> { let plugin_socket_count = plugin.sockets().len(); let events = { let poll_res = match dying_instant { - Some(ref inst) => poll_ctx.wait_timeout(duration_to_die - inst.elapsed()), + Some(inst) => poll_ctx.wait_timeout(duration_to_die - inst.elapsed()), None => poll_ctx.wait(), }; match poll_res { |