]> git.lizzy.rs Git - rust.git/commitdiff
Add tests for #22638, #22872, #23024, #23046
authorAndrew Paseltiner <apaseltiner@gmail.com>
Thu, 10 Sep 2015 15:26:19 +0000 (11:26 -0400)
committerAndrew Paseltiner <apaseltiner@gmail.com>
Thu, 10 Sep 2015 15:31:23 +0000 (11:31 -0400)
Closes #22638.
Closes #22872.
Closes #23024.
Closes #23046.

src/test/compile-fail/issue-22638.rs [new file with mode: 0644]
src/test/compile-fail/issue-22872.rs [new file with mode: 0644]
src/test/compile-fail/issue-23024.rs [new file with mode: 0644]
src/test/compile-fail/issue-23046.rs [new file with mode: 0644]

diff --git a/src/test/compile-fail/issue-22638.rs b/src/test/compile-fail/issue-22638.rs
new file mode 100644 (file)
index 0000000..3f4f2ce
--- /dev/null
@@ -0,0 +1,67 @@
+// Copyright 2015 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.
+
+#![allow(unused)]
+
+#[derive(Clone)]
+struct A (B);
+
+impl A {
+    pub fn matches<F: Fn()>(&self, f: &F) {
+        //~^ ERROR reached the recursion limit during monomorphization
+        let &A(ref term) = self;
+        term.matches(f);
+    }
+}
+
+#[derive(Clone)]
+enum B {
+    Variant1,
+    Variant2(C),
+}
+
+impl B {
+    pub fn matches<F: Fn()>(&self, f: &F) {
+        match self {
+            &B::Variant2(ref factor) => {
+                factor.matches(&|| ())
+            }
+            _ => unreachable!("")
+        }
+    }
+}
+
+#[derive(Clone)]
+struct C (D);
+
+impl C {
+    pub fn matches<F: Fn()>(&self, f: &F) {
+        let &C(ref base) = self;
+        base.matches(&|| {
+            C(base.clone()).matches(f)
+        })
+    }
+}
+
+#[derive(Clone)]
+struct D (Box<A>);
+
+impl D {
+    pub fn matches<F: Fn()>(&self, f: &F) {
+        let &D(ref a) = self;
+        a.matches(f)
+    }
+}
+
+pub fn matches() {
+    A(B::Variant1).matches(&(|| ()))
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-22872.rs b/src/test/compile-fail/issue-22872.rs
new file mode 100644 (file)
index 0000000..8698228
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright 2015 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 Wrap<'b> {
+    fn foo(&'b mut self);
+}
+
+struct Wrapper<P>(P);
+
+impl<'b, P> Wrap<'b> for Wrapper<P>
+where P: Process<'b>,
+      <P as Process<'b>>::Item: Iterator {
+    fn foo(&mut self) {}
+}
+
+
+pub trait Process<'a> {
+    type Item;
+    fn bar(&'a self);
+}
+
+fn push_process<P>(process: P) where P: Process<'static> {
+    let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process));
+    //~^ ERROR the trait `for<'b> Process<'b>` is not implemented for the type `P` [E0277]
+    //~| ERROR the trait `for<'b> core::iter::Iterator` is not implemented for the type
+    //~| ERROR cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-23024.rs b/src/test/compile-fail/issue-23024.rs
new file mode 100644 (file)
index 0000000..92610c1
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2015 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(box_syntax)]
+use std::any::Any;
+
+fn main()
+{
+    fn h(x:i32) -> i32 {3*x}
+    let mut vfnfer:Vec<Box<Any>> = vec![];
+    vfnfer.push(box h);
+    println!("{:?}",(vfnfer[0] as Fn)(3));
+    //~^ ERROR the precise format of `Fn`-family traits'
+    //~| ERROR wrong number of type arguments: expected 1, found 0
+    //~| ERROR the value of the associated type `Output` (from the trait `core::ops::FnOnce`)
+}
diff --git a/src/test/compile-fail/issue-23046.rs b/src/test/compile-fail/issue-23046.rs
new file mode 100644 (file)
index 0000000..8c83c4c
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright 2015 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 enum Expr<'var, VAR> {
+    Let(Box<Expr<'var, VAR>>,
+        Box<for<'v: 'var> Fn(Expr<'v, VAR>) -> Expr<'v, VAR> + 'var>)
+}
+
+pub fn add<'var, VAR>
+                      (a: Expr<'var, VAR>, b: Expr<'var, VAR>) -> Expr<'var, VAR> {
+    loop {}
+}
+
+pub fn let_<'var, VAR, F: for<'v: 'var> Fn(Expr<'v, VAR>) -> Expr<'v, VAR>>
+                       (a: Expr<'var, VAR>, b: F) -> Expr<'var, VAR> {
+    loop {}
+}
+
+fn main() {
+    let ex =  (|x| {
+        let_(add(x,x), |y| { //~ ERROR unable to infer enough type information about `_`
+            let_(add(x, x), |x|x)})});
+}