about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2015-04-14 12:49:26 +0200
committerFelix S. Klock II <pnkfelix@pnkfx.org>2015-04-14 12:49:26 +0200
commit58dc3bb57534800ae2842cd249e2aa390e00bdd0 (patch)
tree3ef64c5d68ec4e10b9d407efcca881cdb19c5bc3
parent32d5f742cb0bb8dd6c1f37a88b8ec6ad0595ae1b (diff)
downloadrust-58dc3bb57534800ae2842cd249e2aa390e00bdd0.tar.gz
rust-58dc3bb57534800ae2842cd249e2aa390e00bdd0.zip
Regression tests for issues that led me to revise typeck.
Close #23729
Close #23827
Close #24356
-rw-r--r--src/test/compile-fail/issue-23729.rs43
-rw-r--r--src/test/compile-fail/issue-23827.rs43
-rw-r--r--src/test/compile-fail/issue-24356.rs40
3 files changed, 126 insertions, 0 deletions
diff --git a/src/test/compile-fail/issue-23729.rs b/src/test/compile-fail/issue-23729.rs
new file mode 100644
index 00000000000..3d77d171ace
--- /dev/null
+++ b/src/test/compile-fail/issue-23729.rs
@@ -0,0 +1,43 @@
+// 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.
+
+// Regression test for #23729
+
+fn main() {
+    let fib = {
+        struct Recurrence {
+            mem: [u64; 2],
+            pos: usize,
+        }
+
+        impl Iterator for Recurrence {
+            //~^ ERROR not all trait items implemented, missing: `Item` [E0046]
+            #[inline]
+            fn next(&mut self) -> Option<u64> {
+                if self.pos < 2 {
+                    let next_val = self.mem[self.pos];
+                    self.pos += 1;
+                    Some(next_val)
+                } else {
+                    let next_val = (self.mem[0] + self.mem[1]);
+                    self.mem[0] = self.mem[1];
+                    self.mem[1] = next_val;
+                    Some(next_val)
+                }
+            }
+        }
+
+        Recurrence { mem: [0, 1], pos: 0 }
+    };
+
+    for e in fib.take(10) {
+        println!("{}", e)
+    }
+}
diff --git a/src/test/compile-fail/issue-23827.rs b/src/test/compile-fail/issue-23827.rs
new file mode 100644
index 00000000000..6c42c88bee6
--- /dev/null
+++ b/src/test/compile-fail/issue-23827.rs
@@ -0,0 +1,43 @@
+// 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.
+
+// Regression test for #23827
+
+#![feature(core, unboxed_closures)]
+
+pub struct Prototype {
+    pub target: u32
+}
+
+trait Component {
+    fn apply(self, e: u32);
+}
+
+impl<C: Component> Fn<(C,)> for Prototype {
+    extern "rust-call" fn call(&self, (comp,): (C,)) -> Prototype {
+        comp.apply(self.target);
+        *self
+    }
+}
+
+impl<C: Component> FnMut<(C,)> for Prototype {
+    extern "rust-call" fn call_mut(&mut self, (comp,): (C,)) -> Prototype {
+        Fn::call(*&self, (comp,))
+    }
+}
+
+impl<C: Component> FnOnce<(C,)> for Prototype {
+    //~^ ERROR not all trait items implemented, missing: `Output` [E0046]
+    extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype {
+        Fn::call(&self, (comp,))
+    }
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-24356.rs b/src/test/compile-fail/issue-24356.rs
new file mode 100644
index 00000000000..22f71835336
--- /dev/null
+++ b/src/test/compile-fail/issue-24356.rs
@@ -0,0 +1,40 @@
+// 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.
+
+// Regression test for #24356
+
+// ignore-tidy-linelength
+
+fn main() {
+    {
+        use std::ops::Deref;
+
+        struct Thing(i8);
+
+        /*
+        // Correct impl
+        impl Deref for Thing {
+            type Target = i8;
+            fn deref(&self) -> &i8 { &self.0 }
+        }
+        */
+
+        // Causes ICE
+        impl Deref for Thing {
+            //~^ ERROR not all trait items implemented, missing: `Target` [E0046]
+            fn deref(&self) -> i8 { self.0 }
+            //~^ ERROR method `deref` has an incompatible type for trait: expected &-ptr, found i8 [E0053]
+        }
+
+        let thing = Thing(72);
+
+        *thing
+    };
+}