summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/mut_mutex_lock.fixed
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/mut_mutex_lock.fixed')
-rw-r--r--src/tools/clippy/tests/ui/mut_mutex_lock.fixed21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/mut_mutex_lock.fixed b/src/tools/clippy/tests/ui/mut_mutex_lock.fixed
new file mode 100644
index 000000000..36bc52e33
--- /dev/null
+++ b/src/tools/clippy/tests/ui/mut_mutex_lock.fixed
@@ -0,0 +1,21 @@
+// run-rustfix
+#![allow(dead_code, unused_mut)]
+#![warn(clippy::mut_mutex_lock)]
+
+use std::sync::{Arc, Mutex};
+
+fn mut_mutex_lock() {
+ let mut value_rc = Arc::new(Mutex::new(42_u8));
+ let value_mutex = Arc::get_mut(&mut value_rc).unwrap();
+
+ let mut value = value_mutex.get_mut().unwrap();
+ *value += 1;
+}
+
+fn no_owned_mutex_lock() {
+ let mut value_rc = Arc::new(Mutex::new(42_u8));
+ let mut value = value_rc.lock().unwrap();
+ *value += 1;
+}
+
+fn main() {}