]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/get_unwrap.rs
Fix `#[expect]` for `clippy::ptr_arg`
[rust.git] / tests / ui / get_unwrap.rs
index 244a2ef25a163ce495c52db0deb89bdb5e920b1a..a2a323c14fb7c827f6a439e8495d17708b3fa3a3 100644 (file)
@@ -1,10 +1,12 @@
 // run-rustfix
-#![allow(unused_mut)]
+
+#![allow(unused_mut, clippy::from_iter_instead_of_collect, clippy::get_first)]
+#![warn(clippy::unwrap_used)]
+#![deny(clippy::get_unwrap)]
 
 use std::collections::BTreeMap;
 use std::collections::HashMap;
 use std::collections::VecDeque;
-use std::iter::FromIterator;
 
 struct GetFalsePositive {
     arr: [u32; 3],
@@ -36,6 +38,7 @@ fn main() {
         let _ = some_vecdeque.get(0).unwrap();
         let _ = some_hashmap.get(&1).unwrap();
         let _ = some_btreemap.get(&1).unwrap();
+        #[allow(clippy::unwrap_used)]
         let _ = false_positive.get(0).unwrap();
         // Test with deref
         let _: u8 = *boxed_slice.get(1).unwrap();
@@ -48,9 +51,12 @@ fn main() {
         *some_vec.get_mut(0).unwrap() = 1;
         *some_vecdeque.get_mut(0).unwrap() = 1;
         // Check false positives
-        *some_hashmap.get_mut(&1).unwrap() = 'b';
-        *some_btreemap.get_mut(&1).unwrap() = 'b';
-        *false_positive.get_mut(0).unwrap() = 1;
+        #[allow(clippy::unwrap_used)]
+        {
+            *some_hashmap.get_mut(&1).unwrap() = 'b';
+            *some_btreemap.get_mut(&1).unwrap() = 'b';
+            *false_positive.get_mut(0).unwrap() = 1;
+        }
     }
 
     {