summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/crashes/mut_mut_macro.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/tools/clippy/tests/ui/crashes/mut_mut_macro.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui/crashes/mut_mut_macro.rs')
-rw-r--r--src/tools/clippy/tests/ui/crashes/mut_mut_macro.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/crashes/mut_mut_macro.rs b/src/tools/clippy/tests/ui/crashes/mut_mut_macro.rs
new file mode 100644
index 000000000..a238e7896
--- /dev/null
+++ b/src/tools/clippy/tests/ui/crashes/mut_mut_macro.rs
@@ -0,0 +1,34 @@
+#![deny(clippy::mut_mut, clippy::zero_ptr, clippy::cmp_nan)]
+#![allow(dead_code)]
+
+// FIXME: compiletest + extern crates doesn't work together. To make this test work, it would need
+// the following three lines and the lazy_static crate.
+//
+// #[macro_use]
+// extern crate lazy_static;
+// use std::collections::HashMap;
+
+/// ensure that we don't suggest `is_nan` and `is_null` inside constants
+/// FIXME: once const fn is stable, suggest these functions again in constants
+
+const BAA: *const i32 = 0 as *const i32;
+static mut BAR: *const i32 = BAA;
+static mut FOO: *const i32 = 0 as *const i32;
+static mut BUH: bool = 42.0 < f32::NAN;
+
+#[allow(unused_variables, unused_mut)]
+fn main() {
+ /*
+ lazy_static! {
+ static ref MUT_MAP : HashMap<usize, &'static str> = {
+ let mut m = HashMap::new();
+ m.insert(0, "zero");
+ m
+ };
+ static ref MUT_COUNT : usize = MUT_MAP.len();
+ }
+ assert_eq!(*MUT_COUNT, 1);
+ */
+ // FIXME: don't lint in array length, requires `check_body`
+ //let _ = [""; (42.0 < f32::NAN) as usize];
+}