]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/clippy/tests/ui/starts_ends_with.fixed
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / src / tools / clippy / tests / ui / starts_ends_with.fixed
diff --git a/src/tools/clippy/tests/ui/starts_ends_with.fixed b/src/tools/clippy/tests/ui/starts_ends_with.fixed
new file mode 100644 (file)
index 0000000..7dfcf9c
--- /dev/null
@@ -0,0 +1,46 @@
+// run-rustfix
+#![allow(dead_code, unused_must_use)]
+
+fn main() {}
+
+#[allow(clippy::unnecessary_operation)]
+fn starts_with() {
+    "".starts_with(' ');
+    !"".starts_with(' ');
+}
+
+fn chars_cmp_with_unwrap() {
+    let s = String::from("foo");
+    if s.starts_with('f') {
+        // s.starts_with('f')
+        // Nothing here
+    }
+    if s.ends_with('o') {
+        // s.ends_with('o')
+        // Nothing here
+    }
+    if s.ends_with('o') {
+        // s.ends_with('o')
+        // Nothing here
+    }
+    if !s.starts_with('f') {
+        // !s.starts_with('f')
+        // Nothing here
+    }
+    if !s.ends_with('o') {
+        // !s.ends_with('o')
+        // Nothing here
+    }
+    if !s.ends_with('o') {
+        // !s.ends_with('o')
+        // Nothing here
+    }
+}
+
+#[allow(clippy::unnecessary_operation)]
+fn ends_with() {
+    "".ends_with(' ');
+    !"".ends_with(' ');
+    "".ends_with(' ');
+    !"".ends_with(' ');
+}