about summary refs log tree commit diff
diff options
context:
space:
mode:
authortamaron <tamaron1203@gmail.com>2022-01-30 15:39:47 +0900
committertamaron <tamaron1203@gmail.com>2022-01-30 15:39:47 +0900
commit447ed5ce5234e645df298847fd616817d3dfd6e4 (patch)
tree01f16dbd5d611d75566e486e7b8336ec2a12c08e
parentdf6ef6059bb977cf57223495dde31d346b22d5f9 (diff)
downloadrust-447ed5ce5234e645df298847fd616817d3dfd6e4.tar.gz
rust-447ed5ce5234e645df298847fd616817d3dfd6e4.zip
add attributes
-rw-r--r--tests/ui/get_unwrap.fixed10
-rw-r--r--tests/ui/get_unwrap.rs10
-rw-r--r--tests/ui/get_unwrap.stderr62
3 files changed, 29 insertions, 53 deletions
diff --git a/tests/ui/get_unwrap.fixed b/tests/ui/get_unwrap.fixed
index e9749e85208..c3a36dcabd1 100644
--- a/tests/ui/get_unwrap.fixed
+++ b/tests/ui/get_unwrap.fixed
@@ -39,6 +39,7 @@ fn main() {
         let _ = &some_vecdeque[0];
         let _ = &some_hashmap[&1];
         let _ = &some_btreemap[&1];
+        #[allow(clippy::unwrap_used)]
         let _ = false_positive.get(0).unwrap();
         // Test with deref
         let _: u8 = boxed_slice[1];
@@ -51,9 +52,12 @@ fn main() {
         some_vec[0] = 1;
         some_vecdeque[0] = 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;
+        }
     }
 
     {
diff --git a/tests/ui/get_unwrap.rs b/tests/ui/get_unwrap.rs
index 86c6bf533cd..d77a202aa39 100644
--- a/tests/ui/get_unwrap.rs
+++ b/tests/ui/get_unwrap.rs
@@ -39,6 +39,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();
@@ -51,9 +52,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;
+        }
     }
 
     {
diff --git a/tests/ui/get_unwrap.stderr b/tests/ui/get_unwrap.stderr
index a710bd59f80..cb5f44fbd59 100644
--- a/tests/ui/get_unwrap.stderr
+++ b/tests/ui/get_unwrap.stderr
@@ -89,22 +89,14 @@ LL |         let _ = some_btreemap.get(&1).unwrap();
    |
    = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
 
-error: used `unwrap()` on `an Option` value
-  --> $DIR/get_unwrap.rs:42:17
-   |
-LL |         let _ = false_positive.get(0).unwrap();
-   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
-
 error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
-  --> $DIR/get_unwrap.rs:44:21
+  --> $DIR/get_unwrap.rs:45:21
    |
 LL |         let _: u8 = *boxed_slice.get(1).unwrap();
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[1]`
 
 error: used `unwrap()` on `an Option` value
-  --> $DIR/get_unwrap.rs:44:22
+  --> $DIR/get_unwrap.rs:45:22
    |
 LL |         let _: u8 = *boxed_slice.get(1).unwrap();
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -112,13 +104,13 @@ LL |         let _: u8 = *boxed_slice.get(1).unwrap();
    = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
 
 error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
-  --> $DIR/get_unwrap.rs:49:9
+  --> $DIR/get_unwrap.rs:50:9
    |
 LL |         *boxed_slice.get_mut(0).unwrap() = 1;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[0]`
 
 error: used `unwrap()` on `an Option` value
-  --> $DIR/get_unwrap.rs:49:10
+  --> $DIR/get_unwrap.rs:50:10
    |
 LL |         *boxed_slice.get_mut(0).unwrap() = 1;
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -126,13 +118,13 @@ LL |         *boxed_slice.get_mut(0).unwrap() = 1;
    = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
 
 error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
-  --> $DIR/get_unwrap.rs:50:9
+  --> $DIR/get_unwrap.rs:51:9
    |
 LL |         *some_slice.get_mut(0).unwrap() = 1;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_slice[0]`
 
 error: used `unwrap()` on `an Option` value
-  --> $DIR/get_unwrap.rs:50:10
+  --> $DIR/get_unwrap.rs:51:10
    |
 LL |         *some_slice.get_mut(0).unwrap() = 1;
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -140,13 +132,13 @@ LL |         *some_slice.get_mut(0).unwrap() = 1;
    = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
 
 error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise
-  --> $DIR/get_unwrap.rs:51:9
+  --> $DIR/get_unwrap.rs:52:9
    |
 LL |         *some_vec.get_mut(0).unwrap() = 1;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0]`
 
 error: used `unwrap()` on `an Option` value
-  --> $DIR/get_unwrap.rs:51:10
+  --> $DIR/get_unwrap.rs:52:10
    |
 LL |         *some_vec.get_mut(0).unwrap() = 1;
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -154,51 +146,27 @@ LL |         *some_vec.get_mut(0).unwrap() = 1;
    = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
 
 error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise
-  --> $DIR/get_unwrap.rs:52:9
+  --> $DIR/get_unwrap.rs:53:9
    |
 LL |         *some_vecdeque.get_mut(0).unwrap() = 1;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vecdeque[0]`
 
 error: used `unwrap()` on `an Option` value
-  --> $DIR/get_unwrap.rs:52:10
+  --> $DIR/get_unwrap.rs:53:10
    |
 LL |         *some_vecdeque.get_mut(0).unwrap() = 1;
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
 
-error: used `unwrap()` on `an Option` value
-  --> $DIR/get_unwrap.rs:54:10
-   |
-LL |         *some_hashmap.get_mut(&1).unwrap() = 'b';
-   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
-
-error: used `unwrap()` on `an Option` value
-  --> $DIR/get_unwrap.rs:55:10
-   |
-LL |         *some_btreemap.get_mut(&1).unwrap() = 'b';
-   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
-
-error: used `unwrap()` on `an Option` value
-  --> $DIR/get_unwrap.rs:56:10
-   |
-LL |         *false_positive.get_mut(0).unwrap() = 1;
-   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
-
 error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise
-  --> $DIR/get_unwrap.rs:61:17
+  --> $DIR/get_unwrap.rs:65:17
    |
 LL |         let _ = some_vec.get(0..1).unwrap().to_vec();
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]`
 
 error: used `unwrap()` on `an Option` value
-  --> $DIR/get_unwrap.rs:61:17
+  --> $DIR/get_unwrap.rs:65:17
    |
 LL |         let _ = some_vec.get(0..1).unwrap().to_vec();
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -206,18 +174,18 @@ LL |         let _ = some_vec.get(0..1).unwrap().to_vec();
    = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
 
 error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise
-  --> $DIR/get_unwrap.rs:62:17
+  --> $DIR/get_unwrap.rs:66:17
    |
 LL |         let _ = some_vec.get_mut(0..1).unwrap().to_vec();
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]`
 
 error: used `unwrap()` on `an Option` value
-  --> $DIR/get_unwrap.rs:62:17
+  --> $DIR/get_unwrap.rs:66:17
    |
 LL |         let _ = some_vec.get_mut(0..1).unwrap().to_vec();
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
 
-error: aborting due to 30 previous errors
+error: aborting due to 26 previous errors