]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/clippy/tests/ui/needless_late_init.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / needless_late_init.rs
index 54e66b391b8d8a46068df048cf91c17bf8a5d03c..402d9f9ef7f81945f4dd9087c314ca0dfe0f8b32 100644 (file)
@@ -1,5 +1,13 @@
+// run-rustfix
 #![feature(let_chains)]
-#![allow(unused, clippy::nonminimal_bool, clippy::let_unit_value)]
+#![allow(
+    unused,
+    clippy::assign_op_pattern,
+    clippy::blocks_in_if_conditions,
+    clippy::let_and_return,
+    clippy::let_unit_value,
+    clippy::nonminimal_bool
+)]
 
 use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
 use std::rc::Rc;
@@ -11,6 +19,22 @@ impl std::ops::Drop for SignificantDrop {
     }
 }
 
+fn simple() {
+    let a;
+    a = "zero";
+
+    let b;
+    let c;
+    b = 1;
+    c = 2;
+
+    let d: usize;
+    d = 1;
+
+    let e;
+    e = format!("{}", d);
+}
+
 fn main() {
     let a;
     let n = 1;
@@ -229,3 +253,21 @@ fn does_not_lint() {
     let y = SignificantDrop;
     x = SignificantDrop;
 }
+
+#[rustfmt::skip]
+fn issue8911() -> u32 {
+    let x;
+    match 1 {
+        _ if { x = 1; false } => return 1,
+        _ => return 2,
+    }
+
+    let x;
+    if { x = 1; true } {
+        return 1;
+    } else {
+        return 2;
+    }
+
+    3
+}