]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui-toml/unwrap_used/unwrap_used.rs
Add size_of_ref lint
[rust.git] / tests / ui-toml / unwrap_used / unwrap_used.rs
index 74d0d7c2650dd09db2575527b1f8cd4e16510849..bc8e8c1f0703a3c9c9b0827b739006c5ef3903f0 100644 (file)
@@ -1,6 +1,6 @@
 // compile-flags: --test
 
-#![allow(unused_mut, clippy::from_iter_instead_of_collect)]
+#![allow(unused_mut, clippy::get_first, clippy::from_iter_instead_of_collect)]
 #![warn(clippy::unwrap_used)]
 #![deny(clippy::get_unwrap)]
 
@@ -66,8 +66,21 @@ fn main() {
     }
 }
 
-#[test]
-fn test() {
-    let boxed_slice: Box<[u8]> = Box::new([0, 1, 2, 3]);
-    let _ = boxed_slice.get(1).unwrap();
+#[cfg(test)]
+mod issue9612 {
+    // should not lint in `#[cfg(test)]` modules
+    #[test]
+    fn test_fn() {
+        let _a: u8 = 2.try_into().unwrap();
+        let _a: u8 = 3.try_into().expect("");
+
+        util();
+    }
+
+    fn util() {
+        let _a: u8 = 4.try_into().unwrap();
+        let _a: u8 = 5.try_into().expect("");
+        // should still warn
+        let _ = Box::new([0]).get(1).unwrap();
+    }
 }