]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/patterns.rs
iterate List by value
[rust.git] / tests / ui / patterns.rs
index 2b42aae63ea0e5d7c94e53dc524705867606d750..5848ecd38d98db5e846e652a042c0c0e51bce09d 100644 (file)
@@ -1,26 +1,36 @@
-// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-
-#![feature(tool_lints)]
-
+// run-rustfix
 #![allow(unused)]
 #![warn(clippy::all)]
 
 fn main() {
     let v = Some(true);
+    let s = [0, 1, 2, 3, 4];
     match v {
         Some(x) => (),
-        y @ _   => (),
+        y @ _ => (),
     }
     match v {
-        Some(x)  => (),
-        y @ None => (),  // no error
+        Some(x) => (),
+        y @ None => (), // no error
+    }
+    match s {
+        [x, inside @ .., y] => (), // no error
+        [..] => (),
+    }
+
+    let mut mutv = vec![1, 2, 3];
+
+    // required "ref" left out in suggestion: #5271
+    match mutv {
+        ref mut x @ _ => {
+            x.push(4);
+            println!("vec: {:?}", x);
+        },
+        ref y if y == &vec![0] => (),
+    }
+
+    match mutv {
+        ref x @ _ => println!("vec: {:?}", x),
+        ref y if y == &vec![0] => (),
     }
 }