summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/let_with_type_underscore.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/let_with_type_underscore.rs')
-rw-r--r--src/tools/clippy/tests/ui/let_with_type_underscore.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/let_with_type_underscore.rs b/src/tools/clippy/tests/ui/let_with_type_underscore.rs
new file mode 100644
index 000000000..175718b94
--- /dev/null
+++ b/src/tools/clippy/tests/ui/let_with_type_underscore.rs
@@ -0,0 +1,19 @@
+#![allow(unused)]
+#![warn(clippy::let_with_type_underscore)]
+#![allow(clippy::let_unit_value)]
+
+fn func() -> &'static str {
+ ""
+}
+
+fn main() {
+ // Will lint
+ let x: _ = 1;
+ let _: _ = 2;
+ let x: _ = func();
+
+ let x = 1; // Will not lint, Rust inferres this to an integer before Clippy
+ let x = func();
+ let x: Vec<_> = Vec::<u32>::new();
+ let x: [_; 1] = [1];
+}