]> git.lizzy.rs Git - rust.git/commitdiff
Add tests for a few A-needstest issues
authorJakub Wieczorek <jakub@jakub.cc>
Thu, 11 Sep 2014 22:54:44 +0000 (00:54 +0200)
committerJakub Wieczorek <jakub@jakub.cc>
Mon, 15 Sep 2014 16:09:24 +0000 (18:09 +0200)
Closes #7813.
Closes #10902.
Closes #11374.
Closes #11714.
Closes #12920.
Closes #13202.
Closes #13624.
Closes #14039.
Closes #15730.
Closes #15783.

src/test/compile-fail/issue-11374.rs [new file with mode: 0644]
src/test/compile-fail/issue-11714.rs [new file with mode: 0644]
src/test/compile-fail/issue-13624.rs [new file with mode: 0644]
src/test/compile-fail/issue-15730.rs [new file with mode: 0644]
src/test/compile-fail/issue-15783.rs [new file with mode: 0644]
src/test/compile-fail/issue-7813.rs [new file with mode: 0644]
src/test/run-fail/issue-12920.rs [new file with mode: 0644]
src/test/run-fail/issue-13202.rs [new file with mode: 0644]
src/test/run-pass/issue-10902.rs [new file with mode: 0644]
src/test/run-pass/issue-14039.rs [new file with mode: 0644]

diff --git a/src/test/compile-fail/issue-11374.rs b/src/test/compile-fail/issue-11374.rs
new file mode 100644 (file)
index 0000000..9705994
--- /dev/null
@@ -0,0 +1,37 @@
+// 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.
+
+use std::io;
+use std::vec;
+
+pub struct Container<'a> {
+    reader: &'a mut Reader //~ ERROR explicit lifetime bound required
+}
+
+impl<'a> Container<'a> {
+    pub fn wrap<'s>(reader: &'s mut Reader) -> Container<'s> {
+        Container { reader: reader }
+    }
+
+    pub fn read_to(&mut self, vec: &mut [u8]) {
+        self.reader.read(vec);
+    }
+}
+
+pub fn for_stdin<'a>() -> Container<'a> {
+    let mut r = io::stdin();
+    Container::wrap(&mut r as &mut Reader)
+}
+
+fn main() {
+    let mut c = for_stdin();
+    let mut v = vec::Vec::from_elem(10, 0u8);
+    c.read_to(v.as_mut_slice());
+}
diff --git a/src/test/compile-fail/issue-11714.rs b/src/test/compile-fail/issue-11714.rs
new file mode 100644 (file)
index 0000000..d57182e
--- /dev/null
@@ -0,0 +1,17 @@
+// 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.
+
+fn blah() -> int { //~ ERROR not all control paths return a value
+    1i
+
+    ; //~ NOTE consider removing this semicolon:
+}
+
+fn main() { }
diff --git a/src/test/compile-fail/issue-13624.rs b/src/test/compile-fail/issue-13624.rs
new file mode 100644 (file)
index 0000000..0593b49
--- /dev/null
@@ -0,0 +1,39 @@
+// 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.
+
+#![feature(struct_variant)]
+
+mod a {
+  pub enum Enum {
+    EnumStructVariant { x: u8, y: u8, z: u8 }
+  }
+
+  pub fn get_enum_struct_variant() -> () {
+    EnumStructVariant { x: 1, y: 2, z: 3 }
+//~^ ERROR mismatched types: expected `()`, found `a::Enum` (expected (), found enum a::Enum)
+  }
+}
+
+mod b {
+  mod test {
+    use a;
+
+    fn test_enum_struct_variant() {
+      let enum_struct_variant = ::a::get_enum_struct_variant();
+      match enum_struct_variant {
+        a::EnumStructVariant { x, y, z } => {
+        //~^ ERROR error: mismatched types: expected `()`, found a structure pattern
+        }
+      }
+    }
+  }
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-15730.rs b/src/test/compile-fail/issue-15730.rs
new file mode 100644 (file)
index 0000000..6cddd8e
--- /dev/null
@@ -0,0 +1,15 @@
+// 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.
+
+fn main() {
+    let mut array = [1, 2, 3];
+//~^ ERROR cannot determine a type for this local variable: cannot determine the type of this integ
+    let pie_slice = array.slice(1, 2);
+}
diff --git a/src/test/compile-fail/issue-15783.rs b/src/test/compile-fail/issue-15783.rs
new file mode 100644 (file)
index 0000000..32a920b
--- /dev/null
@@ -0,0 +1,20 @@
+// 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.
+
+pub fn foo(params: Option<&[&str]>) -> uint {
+    params.unwrap().head().unwrap().len()
+}
+
+fn main() {
+    let name = "Foo";
+    let msg = foo(Some(&[name.as_slice()]));
+//~^ ERROR mismatched types: expected `core::option::Option<&[&str]>`
+    assert_eq!(msg, 3);
+}
diff --git a/src/test/compile-fail/issue-7813.rs b/src/test/compile-fail/issue-7813.rs
new file mode 100644 (file)
index 0000000..be8b671
--- /dev/null
@@ -0,0 +1,14 @@
+// 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.
+
+fn main() {
+    let v = &[]; //~ ERROR cannot determine a type for this local variable: unconstrained type
+    let it = v.iter();
+}
diff --git a/src/test/run-fail/issue-12920.rs b/src/test/run-fail/issue-12920.rs
new file mode 100644 (file)
index 0000000..b5b8d48
--- /dev/null
@@ -0,0 +1,15 @@
+// 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.
+
+// error-pattern:explicit failure
+
+pub fn main() {
+    fail!(); println!("{}", 1i);
+}
diff --git a/src/test/run-fail/issue-13202.rs b/src/test/run-fail/issue-13202.rs
new file mode 100644 (file)
index 0000000..8000693
--- /dev/null
@@ -0,0 +1,15 @@
+// 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.
+
+// error-pattern:bad input
+
+fn main() {
+    Some("foo").unwrap_or(fail!("bad input")).to_string();
+}
diff --git a/src/test/run-pass/issue-10902.rs b/src/test/run-pass/issue-10902.rs
new file mode 100644 (file)
index 0000000..f8fd961
--- /dev/null
@@ -0,0 +1,27 @@
+// 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.
+
+pub mod two_tuple {
+    trait T {}
+    struct P<'a>(&'a T + 'a, &'a T + 'a);
+    pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> {
+        P(car, cdr)
+    }
+}
+
+pub mod two_fields {
+    trait T {}
+    struct P<'a> { car: &'a T + 'a, cdr: &'a T + 'a }
+    pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> {
+        P{ car: car, cdr: cdr }
+    }
+}
+
+fn main() {}
diff --git a/src/test/run-pass/issue-14039.rs b/src/test/run-pass/issue-14039.rs
new file mode 100644 (file)
index 0000000..c017a9d
--- /dev/null
@@ -0,0 +1,17 @@
+// 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.
+
+fn main() {
+    if true {
+        proc(_) {}
+    } else {
+        proc(_: &mut ()) {}
+    };
+}