]> git.lizzy.rs Git - rust.git/commitdiff
rollup merge of #18324 : jakub-/eneedstest
authorAlex Crichton <alex@alexcrichton.com>
Mon, 27 Oct 2014 16:07:42 +0000 (09:07 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 27 Oct 2014 22:12:30 +0000 (15:12 -0700)
13 files changed:
src/test/compile-fail/issue-12863.rs [new file with mode: 0644]
src/test/compile-fail/issue-14721.rs [new file with mode: 0644]
src/test/compile-fail/issue-16683.rs [new file with mode: 0644]
src/test/compile-fail/issue-17551.rs [new file with mode: 0644]
src/test/compile-fail/issue-18118.rs [new file with mode: 0644]
src/test/compile-fail/issue-18252.rs [new file with mode: 0644]
src/test/compile-fail/issue-6991.rs [new file with mode: 0644]
src/test/compile-fail/issue-7867.rs [new file with mode: 0644]
src/test/run-pass/closure-syntax.rs
src/test/run-pass/issue-12028.rs [new file with mode: 0644]
src/test/run-pass/issue-14901.rs [new file with mode: 0644]
src/test/run-pass/issue-16560.rs [new file with mode: 0644]
src/test/run-pass/issue-16668.rs [new file with mode: 0644]

diff --git a/src/test/compile-fail/issue-12863.rs b/src/test/compile-fail/issue-12863.rs
new file mode 100644 (file)
index 0000000..0767667
--- /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.
+
+mod foo { pub fn bar() {} }
+
+fn main() {
+    match () {
+        foo::bar => {} //~ ERROR `bar` is not an enum variant, struct or const
+    }
+}
diff --git a/src/test/compile-fail/issue-14721.rs b/src/test/compile-fail/issue-14721.rs
new file mode 100644 (file)
index 0000000..92add18
--- /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 foo = "str";
+    println!("{}", foo.desc); //~ ERROR attempted access of field `desc` on type `&str`,
+                              //        but no field with that name was found
+}
diff --git a/src/test/compile-fail/issue-16683.rs b/src/test/compile-fail/issue-16683.rs
new file mode 100644 (file)
index 0000000..d9dfaac
--- /dev/null
@@ -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.
+
+trait T<'a> {
+    fn a(&'a self) -> &'a bool;
+    fn b(&self) {
+        self.a(); //~ ERROR mismatched types: expected `&'a Self`, found `&Self` (lifetime mismatch)
+    }
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-17551.rs b/src/test/compile-fail/issue-17551.rs
new file mode 100644 (file)
index 0000000..197319b
--- /dev/null
@@ -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.
+
+#![feature(unboxed_closures)]
+
+struct B<T>;
+
+fn main() {
+    let foo = B; //~ ERROR unable to infer enough type information to locate the impl of the trait
+    let closure = |:| foo;
+}
diff --git a/src/test/compile-fail/issue-18118.rs b/src/test/compile-fail/issue-18118.rs
new file mode 100644 (file)
index 0000000..4497c80
--- /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.
+
+pub fn main() {
+    static z: &'static int = {
+        let p = 3;
+        &p
+//~^ ERROR cannot borrow a local variable inside a static block, define a separate static instead
+    };
+}
diff --git a/src/test/compile-fail/issue-18252.rs b/src/test/compile-fail/issue-18252.rs
new file mode 100644 (file)
index 0000000..c884f02
--- /dev/null
@@ -0,0 +1,19 @@
+// 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)]
+
+enum Foo {
+    Variant { x: uint }
+}
+
+fn main() {
+    let f = Variant(42u); //~ ERROR expected function, found `Foo`
+}
diff --git a/src/test/compile-fail/issue-6991.rs b/src/test/compile-fail/issue-6991.rs
new file mode 100644 (file)
index 0000000..a5d23c7
--- /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.
+
+static x: &'static uint = &1;
+static y: uint = *x;
+//~^ ERROR cannot refer to other statics by value,
+//         use the address-of operator or a constant instead
+fn main() {}
diff --git a/src/test/compile-fail/issue-7867.rs b/src/test/compile-fail/issue-7867.rs
new file mode 100644 (file)
index 0000000..0ab5516
--- /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.
+
+enum A { B, C }
+
+mod foo { pub fn bar() {} }
+
+fn main() {
+    match (true, false) {
+        B => (), //~ ERROR expected `(bool,bool)`, found `A` (expected tuple, found enum A)
+        _ => ()
+    }
+
+    match &Some(42i) {
+        Some(x) => (), //~ ERROR expected `&core::option::Option<int>`,
+                       //        found `core::option::Option<<generic #4>>`
+        None => ()     //~ ERROR expected `&core::option::Option<int>`,
+                       //        found `core::option::Option<<generic #5>>`
+    }
+}
index b5a94a02b346b319ad6c8e7d0c599ea78e4d089b..9d98a7ac12f9ba1809d7845d3630ea3a3fde7ac9 100644 (file)
@@ -9,6 +9,9 @@
 // except according to those terms.
 
 #![allow(dead_code)]
+#![feature(unboxed_closures, unboxed_closure_sugar)]
+
+// compile-flags:-g
 
 fn foo<T>() {}
 
@@ -82,6 +85,9 @@ fn bar<'b>() {
     // issue #13490
     let _ = || -> ! loop {};
     let _ = proc() -> ! loop {};
+
+    // issue #17021
+    let c = box |&:| {};
 }
 
 struct B<T>;
diff --git a/src/test/run-pass/issue-12028.rs b/src/test/run-pass/issue-12028.rs
new file mode 100644 (file)
index 0000000..4d64103
--- /dev/null
@@ -0,0 +1,44 @@
+// 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.
+
+trait Hash<H> {
+    fn hash2(&self, hasher: &H) -> u64;
+}
+
+trait Stream {
+    fn input(&mut self, bytes: &[u8]);
+    fn result(&self) -> u64;
+}
+
+trait StreamHasher<S: Stream> {
+    fn stream(&self) -> S;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+trait StreamHash<S: Stream, H: StreamHasher<S>>: Hash<H> {
+    fn input_stream(&self, stream: &mut S);
+}
+
+impl<S: Stream, H: StreamHasher<S>> Hash<H> for u8 {
+    fn hash2(&self, hasher: &H) -> u64 {
+        let mut stream = hasher.stream();
+        self.input_stream(&mut stream);
+        stream.result()
+    }
+}
+
+impl<S: Stream, H: StreamHasher<S>> StreamHash<S, H> for u8 {
+    fn input_stream(&self, stream: &mut S) {
+        stream.input([*self]);
+    }
+}
+
+fn main() {}
diff --git a/src/test/run-pass/issue-14901.rs b/src/test/run-pass/issue-14901.rs
new file mode 100644 (file)
index 0000000..f93347f
--- /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.
+
+use std::io::Reader;
+
+enum Wrapper<'a> {
+    WrapReader(&'a Reader + 'a)
+}
+
+trait Wrap<'a> {
+    fn wrap(self) -> Wrapper<'a>;
+}
+
+impl<'a, R: Reader> Wrap<'a> for &'a mut R {
+    fn wrap(self) -> Wrapper<'a> {
+        WrapReader(self as &'a mut Reader)
+    }
+}
+
+pub fn main() {}
diff --git a/src/test/run-pass/issue-16560.rs b/src/test/run-pass/issue-16560.rs
new file mode 100644 (file)
index 0000000..77eba02
--- /dev/null
@@ -0,0 +1,25 @@
+// 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(unboxed_closures)]
+
+use std::mem;
+
+fn main() {
+    let y = 0u8;
+    let closure = move |&: x| y + x;
+
+    // Check that both closures are capturing by value
+    assert_eq!(1, mem::size_of_val(&closure));
+
+    spawn(proc() {
+        let ok = closure;
+    })
+}
diff --git a/src/test/run-pass/issue-16668.rs b/src/test/run-pass/issue-16668.rs
new file mode 100644 (file)
index 0000000..1bfa79b
--- /dev/null
@@ -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.
+
+#![feature(unboxed_closures)]
+
+struct Parser<'a, I, O> {
+    parse: Box<FnMut<(I,), Result<O, String>> + 'a>
+}
+
+impl<'a, I, O: 'a> Parser<'a, I, O> {
+    fn compose<K: 'a>(mut self, mut rhs: Parser<O, K>) -> Parser<'a, I, K> {
+        Parser {
+            parse: box move |&mut: x: I| {
+                match self.parse.call_mut((x,)) {
+                    Ok(r) => rhs.parse.call_mut((r,)),
+                    Err(e) => Err(e)
+                }
+            }
+        }
+    }
+}
+
+fn main() {}