]> git.lizzy.rs Git - rust.git/commitdiff
Merge pull request #544 from RalfJung/let_
authorOliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer <github35764891676564198441@oli-obk.de>
Mon, 26 Nov 2018 17:06:54 +0000 (18:06 +0100)
committerGitHub <noreply@github.com>
Mon, 26 Nov 2018 17:06:54 +0000 (18:06 +0100)
do not use 'let _', it is strange

24 files changed:
tests/compile-fail-fullmir/ptr_offset_overflow.rs
tests/compile-fail/invalid_enum_discriminant.rs
tests/compile-fail/pointer_byte_read_1.rs
tests/compile-fail/pointer_byte_read_2.rs
tests/compile-fail/ptr_bitops2.rs
tests/compile-fail/ptr_int_cast.rs
tests/compile-fail/ptr_offset_int_plus_int.rs
tests/compile-fail/ptr_offset_int_plus_ptr.rs
tests/compile-fail/ptr_rem.rs
tests/compile-fail/ptr_wrapping_offset_int_plus_ptr.rs
tests/compile-fail/transmute_fat1.rs
tests/compile-fail/validity/invalid_char.rs
tests/compile-fail/zst.rs
tests/run-pass-fullmir/catch.rs
tests/run-pass-fullmir/from_utf8.rs
tests/run-pass-fullmir/threads.rs
tests/run-pass/closure-drop.rs
tests/run-pass/drop_empty_slice.rs
tests/run-pass/issue-20575.rs
tests/run-pass/issue-26709.rs
tests/run-pass/issue-33387.rs
tests/run-pass/issue-miri-184.rs
tests/run-pass/sendable-class.rs
tests/run-pass/slices.rs

index 32ab2daebf0d0443b5aab4572cfa2e5892b1b8d5..babd0246e7e1afcd0f2a1ed0ac540bfcc45443dc 100644 (file)
@@ -2,5 +2,5 @@
 fn main() {
     let v = [1i8, 2];
     let x = &v[1] as *const i8;
-    let _ = unsafe { x.offset(isize::min_value()) };
+    let _val = unsafe { x.offset(isize::min_value()) };
 }
index bd5cb55b6c92b815cd42a5112cd8e347e95df7c4..c1b8727c129b9a17b4bc8553e497503e6c3341fc 100644 (file)
@@ -12,5 +12,5 @@ pub enum Foo {
 
 fn main() {
     let f = unsafe { std::mem::transmute::<i32, Foo>(42) };
-    let _ = mem::discriminant(&f);
+    let _val = mem::discriminant(&f);
 }
index b25f09d485fb39e2a1800e37c4d4593468258295..a584863654cef267071ce6724fae3a0a0a074141 100644 (file)
@@ -3,5 +3,5 @@ fn main() {
     let y = &x;
     let z = &y as *const &i32 as *const usize;
     let ptr_bytes = unsafe { *z }; // the actual deref is fine, because we read the entire pointer at once
-    let _ = ptr_bytes / 432; //~ ERROR invalid arithmetic on pointers that would leak base addresses
+    let _val = ptr_bytes / 432; //~ ERROR invalid arithmetic on pointers that would leak base addresses
 }
index 5df8c4782c7f88fcc2e00b102d38d5d836c6871b..ddb9bc1f995f28448c6ca1b7dccc05a09225bbc6 100644 (file)
@@ -3,5 +3,5 @@ fn main() {
     let y = &x;
     let z = &y as *const &i32 as *const u8;
     // the deref fails, because we are reading only a part of the pointer
-    let _ = unsafe { *z }; //~ ERROR tried to access part of a pointer value as raw bytes
+    let _val = unsafe { *z }; //~ ERROR tried to access part of a pointer value as raw bytes
 }
index 233c9a733c999d740984c7dfccd095e1e15e2f7c..5d5eab155083b4f6e34ca4f69e2f62a751e13c79 100644 (file)
@@ -1,5 +1,5 @@
 fn main() {
     let val = 13usize;
     let addr = &val as *const _ as usize;
-    let _ = addr & 13; //~ ERROR access part of a pointer value as raw bytes
+    let _val = addr & 13; //~ ERROR access part of a pointer value as raw bytes
 }
index 576f0c333d189d3992177c9750a03c8054552389..a823a0f49b630fe8454ccf99700f077e653558a0 100644 (file)
@@ -4,5 +4,5 @@ fn main() {
     let x = x as *const i32;
     let x = x as u8; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes
     let x = x as *const i32;
-    let _ = unsafe { *x };
+    let _val = unsafe { *x };
 }
index fa4efa323654ae9e4b430a136ebe631595ba7462..d02739610814415057670800990d939fde28886c 100644 (file)
@@ -3,6 +3,6 @@
 fn main() {
     // Can't offset an integer pointer by non-zero offset.
     unsafe {
-        let _ = (1 as *mut u8).offset(1);
+        let _val = (1 as *mut u8).offset(1);
     }
 }
index b45548935807c1695e83a92932c3d72faa62a60a..b49c758c72f786404ec2fb4390db3eb8cd043ccc 100644 (file)
@@ -4,6 +4,6 @@ fn main() {
     let ptr = Box::into_raw(Box::new(0u32));
     // Can't start with an integer pointer and get to something usable
     unsafe {
-        let _ = (1 as *mut u8).offset(ptr as isize);
+        let _val = (1 as *mut u8).offset(ptr as isize);
     }
 }
index 8a3665872f7cb4a0ff41342844c0040259bfe2c6..dfc91e9dc1b12eba0805296eab816917dec8b9f2 100644 (file)
@@ -1,5 +1,5 @@
 fn main() {
     let val = 13usize;
     let addr = &val as *const _ as usize;
-    let _ = addr % 16; //~ ERROR access part of a pointer value as raw bytes
+    let _val = addr % 16; //~ ERROR access part of a pointer value as raw bytes
 }
index b3dda27fad1e7a065e837980a8f61acb5223706f..eacb9f07fffd79be6663c124841bd785bcca0859 100644 (file)
@@ -4,5 +4,5 @@ fn main() {
     let ptr = Box::into_raw(Box::new(0u32));
     // Can't start with an integer pointer and get to something usable
     let ptr = (1 as *mut u8).wrapping_offset(ptr as isize);
-    let _ = unsafe { *ptr };
+    let _val = unsafe { *ptr };
 }
index ede0486be4130c5e065cd303eb85c5611f5f8f9c..ddc78c8bf1d4ae75a43254c5a41f016713a09648 100644 (file)
@@ -10,5 +10,5 @@ fn main() {
     let bad = unsafe {
         std::mem::transmute::<&[u8], [u8; 8]>(&[1u8])
     };
-    let _ = bad[0] + bad[bad.len()-1]; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes
+    let _val = bad[0] + bad[bad.len()-1]; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes
 }
index 0d75ad9d28905d628055c769effa06a99ea75b1b..a3f90703634919f81894cc55dc30db888d9fcaf5 100644 (file)
@@ -1,6 +1,6 @@
 fn main() {
     assert!(std::char::from_u32(-1_i32 as u32).is_none());
-    let _ = match unsafe { std::mem::transmute::<i32, char>(-1) } { //~ ERROR encountered 4294967295, but expected something less or equal to 1114111
+    let _val = match unsafe { std::mem::transmute::<i32, char>(-1) } { //~ ERROR encountered 4294967295, but expected something less or equal to 1114111
         'a' => {true},
         'b' => {false},
         _ => {true},
index 544d65a1bffa66fdef177d5814328317d8324096..0488926870a21bd8bc00bbee72b12bc76305d100 100644 (file)
@@ -1,4 +1,4 @@
 fn main() {
     let x = &() as *const () as *const i32;
-    let _ = unsafe { *x }; //~ ERROR access memory with alignment 1, but alignment 4 is required
+    let _val = unsafe { *x }; //~ ERROR access memory with alignment 1, but alignment 4 is required
 }
index 960297daa7ef5059b4b6a6022ee2f723ab6e8560..aa7bccaa5ff3acfe7099b7da53f91158d2347c05 100644 (file)
@@ -3,6 +3,6 @@
 
 fn main() {
     let mut i = 3;
-    let _ = catch_unwind(AssertUnwindSafe(|| {i -= 2;} ));
+    let _val = catch_unwind(AssertUnwindSafe(|| {i -= 2;} ));
     println!("{}", i);
 }
index 69e6c521af6efe9c439bd40d4d896d42e43f0349..ce59e60a932d5cd005ccfd3d4c8fcb643299a0c1 100644 (file)
@@ -1,3 +1,3 @@
 fn main() {
-    let _ = ::std::str::from_utf8(b"a");
+    let _val = ::std::str::from_utf8(b"a");
 }
index f920bc52edde3b91ae378c5d9ae4bac13cd963e6..dad47d85a24663e68abbf8fdb2f246d851e4c323 100644 (file)
@@ -5,15 +5,15 @@
 
 fn main() {
     let m = sync::Mutex::new(0);
-    let _ = m.lock();
+    drop(m.lock());
     drop(m);
 
     // We don't provide RwLock on Windows
     #[cfg(not(target_os = "windows"))]
     {
         let rw = sync::RwLock::new(0);
-        let _ = rw.read();
-        let _ = rw.write();
+        drop(rw.read());
+        drop(rw.write());
         drop(rw);
     }
 }
index f1bdafaeb1354a2619e2ed38ad5d810786010a86..374efb6032bf53b30d2388f5296c64d7c9665085 100644 (file)
@@ -17,7 +17,7 @@ fn main() {
         // this closure never by val uses its captures
         // so it's basically a fn(&self)
         // the shim used to not drop the `x`
-        let x = move || { let _ = x; };
+        let x = move || { let _val = x; };
         f(x);
     }
     assert!(ran_drop);
index b21c8a612c57b064a7dc6878cb04e6679eca6e54..8b481a0a2dd8984e2f94d95e1c7573ccc82f3440 100644 (file)
@@ -3,5 +3,5 @@
 fn main() {
     // With the nested Vec, this is calling Offset(Unique::empty(), 0) on drop.
     let args : Vec<Vec<i32>> = Vec::new();
-    let _ = box args;
+    let _val = box args;
 }
index 137d84c256bef8f758b6f032daf85b237bf85180..01371f5bec6830e592f9a960e890b5808db8d44e 100644 (file)
@@ -13,5 +13,5 @@
 fn main() {
     let functions: [Box<Fn() -> Option<()>>; 1] = [Box::new(|| None)];
 
-    let _: Option<Vec<()>> = functions.iter().map(|f| (*f)()).collect();
+    let _val: Option<Vec<()>> = functions.iter().map(|f| (*f)()).collect();
 }
index 62626d75865cfc87f424ae16bf1c01705b0cc716..e29e5fbcc40812e3b99544aa30071c2d2716a319 100644 (file)
@@ -20,7 +20,7 @@ fn main() {
     let mut x = 0;
     {
         let wrapper = Box::new(Wrapper(&mut x, 123));
-        let _: Box<Wrapper<Send>> = wrapper;
+        let _val: Box<Wrapper<Send>> = wrapper;
     }
     assert_eq!(432, x)
 }
index edbf2b81ce941e2ae140848723c64f36ae8b9462..62a4263c1069bcab90a79a219cc072bb4a896789 100644 (file)
@@ -15,5 +15,5 @@ trait Foo {}
 impl Foo for [u8; 2] {}
 
 fn main() {
-    let _: Arc<Foo + Send> = Arc::new([3, 4]);
+    let _val: Arc<Foo + Send> = Arc::new([3, 4]);
 }
index 24775fe8a2d9df52dac1bb65ab614e17399e6eb1..39c841403ef0c8f94f99e0af76a8ddd80312201b 100644 (file)
@@ -1,4 +1,4 @@
 pub fn main() {
     let bytes: [u8; 8] = unsafe { ::std::mem::transmute(0u64) };
-    let _: &[u8] = &bytes;
+    let _val: &[u8] = &bytes;
 }
index 66f0c84e23c1a2d4064e12c507ca2485297278b2..3280c36e0a7292f75c8b0c2e7db1b71cc097e7e1 100644 (file)
@@ -27,6 +27,6 @@ fn foo(i:isize, j: char) -> Foo {
 
 pub fn main() {
     let (tx, rx) = channel();
-    let _ = tx.send(foo(42, 'c'));
-    let _ = rx;
+    tx.send(foo(42, 'c')).unwrap();
+    let _val = rx;
 }
index 45a2a74db08dac88752251565a87334fc80cfa35..4506a72e8dd0284ed1af91809a565ae8183a8392 100644 (file)
@@ -4,7 +4,7 @@ fn slice_of_zst() {
     fn foo<T>(v: &[T]) -> Option<&[T]> {
         let mut it = v.iter();
         for _ in 0..5 {
-            let _ = it.next();
+            it.next();
         }
         Some(it.as_slice())
     }
@@ -12,7 +12,7 @@ fn foo<T>(v: &[T]) -> Option<&[T]> {
     fn foo_mut<T>(v: &mut [T]) -> Option<&mut [T]> {
         let mut it = v.iter_mut();
         for _ in 0..5 {
-            let _ = it.next();
+            it.next();
         }
         Some(it.into_slice())
     }