about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui-toml/min_rust_version/min_rust_version.rs24
-rw-r--r--tests/ui-toml/min_rust_version/min_rust_version.stderr10
2 files changed, 32 insertions, 2 deletions
diff --git a/tests/ui-toml/min_rust_version/min_rust_version.rs b/tests/ui-toml/min_rust_version/min_rust_version.rs
index 8e104926524..1e3ec123a3c 100644
--- a/tests/ui-toml/min_rust_version/min_rust_version.rs
+++ b/tests/ui-toml/min_rust_version/min_rust_version.rs
@@ -1,6 +1,7 @@
-#![allow(clippy::redundant_clone)]
-#![warn(clippy::manual_non_exhaustive)]
+#![allow(clippy::redundant_clone, clippy::unnecessary_operation)]
+#![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)]
 
+use std::mem::{size_of, size_of_val};
 use std::ops::Deref;
 
 mod enums {
@@ -68,6 +69,24 @@ fn check_index_refutable_slice() {
     }
 }
 
+fn map_clone_suggest_copied() {
+    // This should still trigger the lint but suggest `cloned()` instead of `copied()`
+    let _: Option<u64> = Some(&16).map(|b| *b);
+}
+
+fn borrow_as_ptr() {
+    let val = 1;
+    let _p = &val as *const i32;
+
+    let mut val_mut = 1;
+    let _p_mut = &mut val_mut as *mut i32;
+}
+
+fn manual_bits() {
+    size_of::<i8>() * 8;
+    size_of_val(&0u32) * 8;
+}
+
 fn main() {
     option_as_ref_deref();
     match_like_matches();
@@ -75,4 +94,5 @@ fn main() {
     match_same_arms2();
     manual_strip_msrv();
     check_index_refutable_slice();
+    borrow_as_ptr();
 }
diff --git a/tests/ui-toml/min_rust_version/min_rust_version.stderr b/tests/ui-toml/min_rust_version/min_rust_version.stderr
new file mode 100644
index 00000000000..a1e7361c0cb
--- /dev/null
+++ b/tests/ui-toml/min_rust_version/min_rust_version.stderr
@@ -0,0 +1,10 @@
+error: you are using an explicit closure for copying elements
+  --> $DIR/min_rust_version.rs:74:26
+   |
+LL |     let _: Option<u64> = Some(&16).map(|b| *b);
+   |                          ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `Some(&16).cloned()`
+   |
+   = note: `-D clippy::map-clone` implied by `-D warnings`
+
+error: aborting due to previous error
+