about summary refs log tree commit diff
path: root/src/test/compile-fail
diff options
context:
space:
mode:
authorJakub Wieczorek <jakub@jakub.cc>2014-10-02 21:52:06 +0200
committerJakub Wieczorek <jakub@jakub.cc>2014-10-02 22:21:50 +0200
commit52d2f2a938c793bb20964156a2657271fa7f91ab (patch)
tree6d8169b5b7ca70bda7faef60227035447f79187c /src/test/compile-fail
parentb224dfe1a6ff1b392fd68004cf7a0a04dfec9975 (diff)
downloadrust-52d2f2a938c793bb20964156a2657271fa7f91ab.tar.gz
rust-52d2f2a938c793bb20964156a2657271fa7f91ab.zip
Add tests for a few resolved issues
Diffstat (limited to 'src/test/compile-fail')
-rw-r--r--src/test/compile-fail/issue-13497-2.rs17
-rw-r--r--src/test/compile-fail/issue-13497.rs18
-rw-r--r--src/test/compile-fail/issue-14366.rs17
-rw-r--r--src/test/compile-fail/issue-14853.rs30
4 files changed, 82 insertions, 0 deletions
diff --git a/src/test/compile-fail/issue-13497-2.rs b/src/test/compile-fail/issue-13497-2.rs
new file mode 100644
index 00000000000..c7a8c87bb23
--- /dev/null
+++ b/src/test/compile-fail/issue-13497-2.rs
@@ -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 read_lines_borrowed<'a>() -> Vec<&'a str> {
+    let rawLines: Vec<String> = vec!["foo  ".to_string(), "  bar".to_string()];
+    rawLines //~ ERROR `rawLines` does not live long enough
+        .iter().map(|l| l.as_slice().trim()).collect()
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-13497.rs b/src/test/compile-fail/issue-13497.rs
new file mode 100644
index 00000000000..da8b93e3c93
--- /dev/null
+++ b/src/test/compile-fail/issue-13497.rs
@@ -0,0 +1,18 @@
+// 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 read_lines_borrowed1() -> Vec<
+    &str //~ ERROR missing lifetime specifier
+> {
+    let rawLines: Vec<String> = vec!["foo  ".to_string(), "  bar".to_string()];
+    rawLines.iter().map(|l| l.as_slice().trim()).collect()
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-14366.rs b/src/test/compile-fail/issue-14366.rs
new file mode 100644
index 00000000000..ceb6daac65e
--- /dev/null
+++ b/src/test/compile-fail/issue-14366.rs
@@ -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() {
+    let _x = "test" as &::std::any::Any;
+//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str`
+//~^^ NOTE the trait `core::kinds::Sized` must be implemented for the cast to the object type
+//~^^^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str`
+//~^^^^ NOTE the trait `core::kinds::Sized` must be implemented for the cast to the object type
+}
diff --git a/src/test/compile-fail/issue-14853.rs b/src/test/compile-fail/issue-14853.rs
new file mode 100644
index 00000000000..4243b98e0dd
--- /dev/null
+++ b/src/test/compile-fail/issue-14853.rs
@@ -0,0 +1,30 @@
+// 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::fmt::Show;
+
+trait Something {
+    fn yay<T: Show>(_: Option<Self>, thing: &[T]) -> String {
+    }
+}
+
+struct X { data: u32 }
+
+impl Something for X {
+    fn yay<T: Str>(_:Option<X>, thing: &[T]) -> String {
+//~^ ERROR in method `yay`, type parameter 0 requires bound `core::str::Str`, which is not required
+        format!("{:s}", thing[0])
+    }
+}
+
+fn main() {
+    let arr = &["one", "two", "three"];
+    println!("{}", Something::yay(None::<X>, arr));
+}