]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/match_overlapping_arm.rs
iterate List by value
[rust.git] / tests / ui / match_overlapping_arm.rs
index 5350f933ae57ff20fc958fa0f4d896a12b4a57a0..97789bb766f891027817d4c65204c23377adef18 100644 (file)
@@ -1,13 +1,5 @@
-// 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(exclusive_range_pattern)]
+#![feature(half_open_range_patterns)]
 #![warn(clippy::match_overlapping_arm)]
 #![allow(clippy::redundant_pattern_matching)]
 
@@ -17,33 +9,33 @@ fn overlapping() {
     const FOO: u64 = 2;
 
     match 42 {
-        0...10 => println!("0 ... 10"),
-        0...11 => println!("0 ... 11"),
+        0..=10 => println!("0 ... 10"),
+        0..=11 => println!("0 ... 11"),
         _ => (),
     }
 
     match 42 {
-        0...5 => println!("0 ... 5"),
-        6...7 => println!("6 ... 7"),
-        FOO...11 => println!("0 ... 11"),
+        0..=5 => println!("0 ... 5"),
+        6..=7 => println!("6 ... 7"),
+        FOO..=11 => println!("0 ... 11"),
         _ => (),
     }
 
     match 42 {
         2 => println!("2"),
-        0...5 => println!("0 ... 5"),
+        0..=5 => println!("0 ... 5"),
         _ => (),
     }
 
     match 42 {
         2 => println!("2"),
-        0...2 => println!("0 ... 2"),
+        0..=2 => println!("0 ... 2"),
         _ => (),
     }
 
     match 42 {
-        0...10 => println!("0 ... 10"),
-        11...50 => println!("11 ... 50"),
+        0..=10 => println!("0 ... 10"),
+        11..=50 => println!("11 ... 50"),
         _ => (),
     }
 
@@ -61,9 +53,24 @@ fn overlapping() {
 
     match 42 {
         0..11 => println!("0 .. 11"),
-        0...11 => println!("0 ... 11"),
+        0..=11 => println!("0 ... 11"),
+        _ => (),
+    }
+
+    /*
+    // FIXME(JohnTitor): uncomment this once rustfmt knows half-open patterns
+    match 42 {
+        0.. => println!("0 .. 42"),
+        3.. => println!("3 .. 42"),
+        _ => (),
+    }
+
+    match 42 {
+        ..=23 => println!("0 ... 23"),
+        ..26 => println!("0 .. 26"),
         _ => (),
     }
+    */
 
     if let None = Some(42) {
         // nothing