diff options
author | David Tolnay <dtolnay@chromium.org> | 2019-04-15 15:30:21 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-04-17 17:22:57 -0700 |
commit | 1c5e2557e2eb3992c320b658ef117cb578bc6fe1 (patch) | |
tree | 03c48568332467b36db736f8d173ead442c7963e /sys_util/src/handle_eintr.rs | |
parent | 35ee9d918404ee87abdd23a450fdb483388e1932 (diff) | |
download | crosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.tar crosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.tar.gz crosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.tar.bz2 crosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.tar.lz crosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.tar.xz crosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.tar.zst crosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.zip |
edition: Eliminate blocks superseded by NLL
Before the new borrow checker in the 2018 edition, we sometimes used to have to manually insert curly braced blocks to limit the scope of borrows. These are no longer needed. Details in: https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/non-lexical-lifetimes.html TEST=cargo check --all-features TEST=local kokoro Change-Id: I59f9f98dcc03c8790c53e080a527ad9b68c8d6f3 Reviewed-on: https://chromium-review.googlesource.com/1568075 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 'sys_util/src/handle_eintr.rs')
-rw-r--r-- | sys_util/src/handle_eintr.rs | 96 |
1 files changed, 44 insertions, 52 deletions
diff --git a/sys_util/src/handle_eintr.rs b/sys_util/src/handle_eintr.rs index 670e8d2..d8cc0b3 100644 --- a/sys_util/src/handle_eintr.rs +++ b/sys_util/src/handle_eintr.rs @@ -184,76 +184,68 @@ mod tests { #[test] fn i32_eintr_rc() { let mut count = 3; - { - let mut dummy = || { - count -= 1; - if count > 0 { - EINTR - } else { - 0 - } - }; - let res = handle_eintr_rc!(dummy()); - assert_eq!(res, 0); - } + let mut dummy = || { + count -= 1; + if count > 0 { + EINTR + } else { + 0 + } + }; + let res = handle_eintr_rc!(dummy()); + assert_eq!(res, 0); assert_eq!(count, 0); } #[test] fn i32_eintr_errno() { let mut count = 3; - { - let mut dummy = || { - count -= 1; - if count > 0 { - set_errno(EINTR); - -1 - } else { - 56 - } - }; - let res = handle_eintr_errno!(dummy()); - assert_eq!(res, 56); - } + let mut dummy = || { + count -= 1; + if count > 0 { + set_errno(EINTR); + -1 + } else { + 56 + } + }; + let res = handle_eintr_errno!(dummy()); + assert_eq!(res, 56); assert_eq!(count, 0); } #[test] fn sys_eintr() { let mut count = 7; - { - let mut dummy = || { - count -= 1; - if count > 1 { - Err(SysError::new(EINTR)) - } else { - Ok(101) - } - }; - let res = handle_eintr!(dummy()); - assert_eq!(res, Ok(101)); - } + let mut dummy = || { + count -= 1; + if count > 1 { + Err(SysError::new(EINTR)) + } else { + Ok(101) + } + }; + let res = handle_eintr!(dummy()); + assert_eq!(res, Ok(101)); assert_eq!(count, 1); } #[test] fn io_eintr() { let mut count = 108; - { - let mut dummy = || { - count -= 1; - if count > 99 { - Err(io::Error::new( - io::ErrorKind::Interrupted, - "interrupted again :(", - )) - } else { - Ok(32) - } - }; - let res = handle_eintr!(dummy()); - assert_eq!(res.unwrap(), 32); - } + let mut dummy = || { + count -= 1; + if count > 99 { + Err(io::Error::new( + io::ErrorKind::Interrupted, + "interrupted again :(", + )) + } else { + Ok(32) + } + }; + let res = handle_eintr!(dummy()); + assert_eq!(res.unwrap(), 32); assert_eq!(count, 99); } } |