]> git.lizzy.rs Git - rust.git/commitdiff
Remove a fixme
authorCorey Richardson <corey@octayn.net>
Wed, 1 Jan 2014 00:07:41 +0000 (19:07 -0500)
committerCorey Richardson <corey@octayn.net>
Mon, 6 Jan 2014 02:36:53 +0000 (21:36 -0500)
pcwalton says this is right, and it looks right to me too.

Closes #4731

src/librustc/middle/check_match.rs
src/test/compile-fail/struct-pattern-match-useless.rs [new file with mode: 0644]
src/test/run-pass/struct-pattern-matching.rs

index 079c275026887d9f297b73f0e02bafb6afbceb9d..5739225a5eae988eafad6f1be4f58aa1b2025649 100644 (file)
@@ -673,7 +673,6 @@ fn specialize(cx: &MatchCheckCtxt,
 
                     DefFn(..) |
                     DefStruct(..) => {
-                        // FIXME #4731: Is this right? --pcw
                         let new_args;
                         match args {
                             Some(args) => new_args = args,
diff --git a/src/test/compile-fail/struct-pattern-match-useless.rs b/src/test/compile-fail/struct-pattern-match-useless.rs
new file mode 100644 (file)
index 0000000..b9c0be9
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// 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.
+
+struct Foo {
+    x: int,
+    y: int,
+}
+
+pub fn main() {
+    let a = Foo { x: 1, y: 2 };
+    match a {
+        Foo { x: x, y: y } => (),
+        Foo { .. } => () //~ ERROR unreachable pattern
+    }
+
+}
index d2b038fab0e9d0d58e92cbdf32d4f2b8b104e2c4..6033554d0cbeeef5001f5db809d911ea039a0738 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -18,4 +18,8 @@ pub fn main() {
     match a {
         Foo { x: x, y: y } => println!("yes, {}, {}", x, y)
     }
+
+    match a {
+        Foo { .. } => ()
+    }
 }