about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-09-15 06:14:26 -0700
committerGitHub <noreply@github.com>2016-09-15 06:14:26 -0700
commitdc75933abaf3f6d619ada2bbc12b01bc85ddb4ae (patch)
tree034d03910e6757b5455e0792aacf4ed021c72383 /src/test
parente2c64d16906dbb29763d6cbf022164a09247ef9f (diff)
parentec08128882b165a93b3fd1f99c9606ad5e09b3dc (diff)
downloadrust-dc75933abaf3f6d619ada2bbc12b01bc85ddb4ae.tar.gz
rust-dc75933abaf3f6d619ada2bbc12b01bc85ddb4ae.zip
Auto merge of #36491 - Manishearth:rollup, r=Manishearth
Rollup of 9 pull requests

- Successful merges: #36384, #36405, #36425, #36429, #36438, #36454, #36459, #36461, #36463
- Failed merges: #36444
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail-fulldeps/qquote.rs4
-rw-r--r--src/test/compile-fail/E0407.rs2
-rw-r--r--src/test/compile-fail/E0438.rs6
-rw-r--r--src/test/compile-fail/borrowck/borrowck-union-borrow-nested.rs6
-rw-r--r--src/test/compile-fail/borrowck/borrowck-union-borrow.rs6
-rw-r--r--src/test/compile-fail/issue-36053-2.rs21
-rw-r--r--src/test/compile-fail/macro-expansion-tests.rs46
-rw-r--r--src/test/compile-fail/union/union-copy.rs4
-rw-r--r--src/test/compile-fail/union/union-derive-clone.rs41
-rw-r--r--src/test/compile-fail/union/union-derive-eq.rs30
-rw-r--r--src/test/compile-fail/union/union-derive.rs2
-rw-r--r--src/test/run-fail-fulldeps/qquote.rs4
-rw-r--r--src/test/run-fail/bounds-check-no-overflow.rs2
-rw-r--r--src/test/run-pass-fulldeps/qquote.rs4
-rw-r--r--src/test/run-pass/auxiliary/typeid-intrinsic-aux1.rs5
-rw-r--r--src/test/run-pass/auxiliary/typeid-intrinsic-aux2.rs5
-rw-r--r--src/test/run-pass/issue-35546.rs28
-rw-r--r--src/test/run-pass/issue-36053.rs32
-rw-r--r--src/test/run-pass/typeid-intrinsic.rs9
-rw-r--r--src/test/run-pass/union/union-c-interop.rs7
-rw-r--r--src/test/run-pass/union/union-derive.rs20
21 files changed, 252 insertions, 32 deletions
diff --git a/src/test/compile-fail-fulldeps/qquote.rs b/src/test/compile-fail-fulldeps/qquote.rs
index e29ded8a052..3e5d17e2ffb 100644
--- a/src/test/compile-fail-fulldeps/qquote.rs
+++ b/src/test/compile-fail-fulldeps/qquote.rs
@@ -22,11 +22,11 @@ use syntax_pos::DUMMY_SP;
 
 fn main() {
     let ps = syntax::parse::ParseSess::new();
-    let mut loader = syntax::ext::base::DummyMacroLoader;
+    let mut resolver = syntax::ext::base::DummyResolver;
     let mut cx = syntax::ext::base::ExtCtxt::new(
         &ps, vec![],
         syntax::ext::expand::ExpansionConfig::default("qquote".to_string()),
-        &mut loader);
+        &mut resolver);
     cx.bt_push(syntax::codemap::ExpnInfo {
         call_site: DUMMY_SP,
         callee: syntax::codemap::NameAndSpan {
diff --git a/src/test/compile-fail/E0407.rs b/src/test/compile-fail/E0407.rs
index 2a150b74512..c207dbfca55 100644
--- a/src/test/compile-fail/E0407.rs
+++ b/src/test/compile-fail/E0407.rs
@@ -18,7 +18,7 @@ impl Foo for Bar {
     fn a() {}
     fn b() {}
     //~^ ERROR E0407
-    //~| NOTE not a member of `Foo`
+    //~| NOTE not a member of trait `Foo`
 }
 
 fn main() {
diff --git a/src/test/compile-fail/E0438.rs b/src/test/compile-fail/E0438.rs
index f549d62aebf..2e2df4bee5a 100644
--- a/src/test/compile-fail/E0438.rs
+++ b/src/test/compile-fail/E0438.rs
@@ -10,11 +10,11 @@
 
 #![feature(associated_consts)]
 
-trait Foo {}
+trait Bar {}
 
-impl Foo for i32 {
+impl Bar for i32 {
     const BAR: bool = true; //~ ERROR E0438
-        //~| NOTE not a member of trait `Foo`
+        //~| NOTE not a member of trait `Bar`
 }
 
 fn main () {
diff --git a/src/test/compile-fail/borrowck/borrowck-union-borrow-nested.rs b/src/test/compile-fail/borrowck/borrowck-union-borrow-nested.rs
index 19975d79b60..8b6b8d9ecb0 100644
--- a/src/test/compile-fail/borrowck/borrowck-union-borrow-nested.rs
+++ b/src/test/compile-fail/borrowck/borrowck-union-borrow-nested.rs
@@ -18,16 +18,12 @@ struct S {
     b: u16,
 }
 
+#[derive(Clone, Copy)]
 union U {
     s: S,
     c: u32,
 }
 
-impl Clone for U {
-    fn clone(&self) -> Self { *self }
-}
-impl Copy for U {}
-
 fn main() {
     unsafe {
         {
diff --git a/src/test/compile-fail/borrowck/borrowck-union-borrow.rs b/src/test/compile-fail/borrowck/borrowck-union-borrow.rs
index e8989a3c2d4..ecc698acc31 100644
--- a/src/test/compile-fail/borrowck/borrowck-union-borrow.rs
+++ b/src/test/compile-fail/borrowck/borrowck-union-borrow.rs
@@ -12,16 +12,12 @@
 
 #![feature(untagged_unions)]
 
+#[derive(Clone, Copy)]
 union U {
     a: u8,
     b: u64,
 }
 
-impl Clone for U {
-    fn clone(&self) -> Self { *self }
-}
-impl Copy for U {}
-
 fn main() {
     unsafe {
         let mut u = U { b: 0 };
diff --git a/src/test/compile-fail/issue-36053-2.rs b/src/test/compile-fail/issue-36053-2.rs
new file mode 100644
index 00000000000..7da529487aa
--- /dev/null
+++ b/src/test/compile-fail/issue-36053-2.rs
@@ -0,0 +1,21 @@
+// Copyright 2016 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 #36053. ICE was caused due to obligations
+// being added to a special, dedicated fulfillment cx during
+// a probe.
+
+use std::iter::once;
+fn main() {
+    once::<&str>("str").fuse().filter(|a: &str| true).count();
+    //~^ ERROR no method named `count`
+    //~| ERROR E0281
+    //~| ERROR E0281
+}
diff --git a/src/test/compile-fail/macro-expansion-tests.rs b/src/test/compile-fail/macro-expansion-tests.rs
new file mode 100644
index 00000000000..a064e69bc6d
--- /dev/null
+++ b/src/test/compile-fail/macro-expansion-tests.rs
@@ -0,0 +1,46 @@
+// Copyright 2016 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 macros_cant_escape_fns {
+    fn f() {
+        macro_rules! m { () => { 3 + 4 } }
+    }
+    fn g() -> i32 { m!() } //~ ERROR macro undefined
+}
+
+mod macros_cant_escape_mods {
+    mod f {
+        macro_rules! m { () => { 3 + 4 } }
+    }
+    fn g() -> i32 { m!() } //~ ERROR macro undefined
+}
+
+mod macros_can_escape_flattened_mods_test {
+    #[macro_use]
+    mod f {
+        macro_rules! m { () => { 3 + 4 } }
+    }
+    fn g() -> i32 { m!() }
+}
+
+fn macro_tokens_should_match() {
+    macro_rules! m { (a) => { 13 } }
+    m!(a);
+}
+
+// should be able to use a bound identifier as a literal in a macro definition:
+fn self_macro_parsing() {
+    macro_rules! foo { (zz) => { 287; } }
+    fn f(zz: i32) {
+        foo!(zz);
+    }
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/union/union-copy.rs b/src/test/compile-fail/union/union-copy.rs
index 6e08ae0074d..9014b3f2956 100644
--- a/src/test/compile-fail/union/union-copy.rs
+++ b/src/test/compile-fail/union/union-copy.rs
@@ -10,16 +10,16 @@
 
 #![feature(untagged_unions)]
 
+#[derive(Clone)]
 union U {
     a: u8
 }
 
+#[derive(Clone)]
 union W {
     a: String
 }
 
-impl Clone for U { fn clone(&self) { panic!(); } }
-impl Clone for W { fn clone(&self) { panic!(); } }
 impl Copy for U {} // OK
 impl Copy for W {} //~ ERROR the trait `Copy` may not be implemented for this type
 
diff --git a/src/test/compile-fail/union/union-derive-clone.rs b/src/test/compile-fail/union/union-derive-clone.rs
new file mode 100644
index 00000000000..6e226d7d79f
--- /dev/null
+++ b/src/test/compile-fail/union/union-derive-clone.rs
@@ -0,0 +1,41 @@
+// Copyright 2016 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(untagged_unions)]
+
+#[derive(Clone)] //~ ERROR the trait bound `U1: std::marker::Copy` is not satisfied
+union U1 {
+    a: u8,
+}
+
+#[derive(Clone)]
+union U2 {
+    a: u8, // OK
+}
+
+impl Copy for U2 {}
+
+#[derive(Clone, Copy)]
+union U3 {
+    a: u8, // OK
+}
+
+#[derive(Clone, Copy)]
+union U4<T> {
+    a: T, // OK
+}
+
+#[derive(Clone)]
+struct CloneNoCopy;
+
+fn main() {
+    let u = U4 { a: CloneNoCopy };
+    let w = u.clone(); //~ ERROR no method named `clone` found for type `U4<CloneNoCopy>`
+}
diff --git a/src/test/compile-fail/union/union-derive-eq.rs b/src/test/compile-fail/union/union-derive-eq.rs
new file mode 100644
index 00000000000..9dfec288c15
--- /dev/null
+++ b/src/test/compile-fail/union/union-derive-eq.rs
@@ -0,0 +1,30 @@
+// Copyright 2016 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(untagged_unions)]
+
+#[derive(Eq)] // OK
+union U1 {
+    a: u8,
+}
+
+impl PartialEq for U1 { fn eq(&self, rhs: &Self) -> bool { true } }
+
+#[derive(PartialEq)]
+struct PartialEqNotEq;
+
+#[derive(Eq)]
+union U2 {
+    a: PartialEqNotEq, //~ ERROR the trait bound `PartialEqNotEq: std::cmp::Eq` is not satisfied
+}
+
+impl PartialEq for U2 { fn eq(&self, rhs: &Self) -> bool { true } }
+
+fn main() {}
diff --git a/src/test/compile-fail/union/union-derive.rs b/src/test/compile-fail/union/union-derive.rs
index 0f78e96f640..26dbdfd0b41 100644
--- a/src/test/compile-fail/union/union-derive.rs
+++ b/src/test/compile-fail/union/union-derive.rs
@@ -13,9 +13,7 @@
 #![feature(untagged_unions)]
 
 #[derive(
-    Clone, //~ ERROR this trait cannot be derived for unions
     PartialEq, //~ ERROR this trait cannot be derived for unions
-    Eq, //~ ERROR this trait cannot be derived for unions
     PartialOrd, //~ ERROR this trait cannot be derived for unions
     Ord, //~ ERROR this trait cannot be derived for unions
     Hash, //~ ERROR this trait cannot be derived for unions
diff --git a/src/test/run-fail-fulldeps/qquote.rs b/src/test/run-fail-fulldeps/qquote.rs
index 47e97abbbaa..1458583ff58 100644
--- a/src/test/run-fail-fulldeps/qquote.rs
+++ b/src/test/run-fail-fulldeps/qquote.rs
@@ -25,11 +25,11 @@ use syntax_pos::DUMMY_SP;
 
 fn main() {
     let ps = syntax::parse::ParseSess::new();
-    let mut loader = syntax::ext::base::DummyMacroLoader;
+    let mut resolver = syntax::ext::base::DummyResolver;
     let mut cx = syntax::ext::base::ExtCtxt::new(
         &ps, vec![],
         syntax::ext::expand::ExpansionConfig::default("qquote".to_string()),
-        &mut loader);
+        &mut resolver);
     cx.bt_push(syntax::codemap::ExpnInfo {
         call_site: DUMMY_SP,
         callee: syntax::codemap::NameAndSpan {
diff --git a/src/test/run-fail/bounds-check-no-overflow.rs b/src/test/run-fail/bounds-check-no-overflow.rs
index 4d502cb2106..3d1cbb446e8 100644
--- a/src/test/run-fail/bounds-check-no-overflow.rs
+++ b/src/test/run-fail/bounds-check-no-overflow.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:assertion failed: index < self.len()
+// error-pattern:index out of bounds
 
 use std::usize;
 use std::mem::size_of;
diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs
index a4f0e35cc5a..2a53a62a5ab 100644
--- a/src/test/run-pass-fulldeps/qquote.rs
+++ b/src/test/run-pass-fulldeps/qquote.rs
@@ -21,11 +21,11 @@ use syntax_pos::DUMMY_SP;
 
 fn main() {
     let ps = syntax::parse::ParseSess::new();
-    let mut loader = syntax::ext::base::DummyMacroLoader;
+    let mut resolver = syntax::ext::base::DummyResolver;
     let mut cx = syntax::ext::base::ExtCtxt::new(
         &ps, vec![],
         syntax::ext::expand::ExpansionConfig::default("qquote".to_string()),
-        &mut loader);
+        &mut resolver);
     cx.bt_push(syntax::codemap::ExpnInfo {
         call_site: DUMMY_SP,
         callee: syntax::codemap::NameAndSpan {
diff --git a/src/test/run-pass/auxiliary/typeid-intrinsic-aux1.rs b/src/test/run-pass/auxiliary/typeid-intrinsic-aux1.rs
index 42c0da6286b..10e315f269f 100644
--- a/src/test/run-pass/auxiliary/typeid-intrinsic-aux1.rs
+++ b/src/test/run-pass/auxiliary/typeid-intrinsic-aux1.rs
@@ -22,6 +22,8 @@ pub type F = Option<isize>;
 pub type G = usize;
 pub type H = &'static str;
 pub type I = Box<Fn()>;
+pub type I32Iterator = Iterator<Item=i32>;
+pub type U32Iterator = Iterator<Item=u32>;
 
 pub fn id_A() -> TypeId { TypeId::of::<A>() }
 pub fn id_B() -> TypeId { TypeId::of::<B>() }
@@ -34,3 +36,6 @@ pub fn id_H() -> TypeId { TypeId::of::<H>() }
 pub fn id_I() -> TypeId { TypeId::of::<I>() }
 
 pub fn foo<T: Any>() -> TypeId { TypeId::of::<T>() }
+
+pub fn id_i32_iterator() -> TypeId { TypeId::of::<I32Iterator>() }
+pub fn id_u32_iterator() -> TypeId { TypeId::of::<U32Iterator>() }
diff --git a/src/test/run-pass/auxiliary/typeid-intrinsic-aux2.rs b/src/test/run-pass/auxiliary/typeid-intrinsic-aux2.rs
index 42c0da6286b..10e315f269f 100644
--- a/src/test/run-pass/auxiliary/typeid-intrinsic-aux2.rs
+++ b/src/test/run-pass/auxiliary/typeid-intrinsic-aux2.rs
@@ -22,6 +22,8 @@ pub type F = Option<isize>;
 pub type G = usize;
 pub type H = &'static str;
 pub type I = Box<Fn()>;
+pub type I32Iterator = Iterator<Item=i32>;
+pub type U32Iterator = Iterator<Item=u32>;
 
 pub fn id_A() -> TypeId { TypeId::of::<A>() }
 pub fn id_B() -> TypeId { TypeId::of::<B>() }
@@ -34,3 +36,6 @@ pub fn id_H() -> TypeId { TypeId::of::<H>() }
 pub fn id_I() -> TypeId { TypeId::of::<I>() }
 
 pub fn foo<T: Any>() -> TypeId { TypeId::of::<T>() }
+
+pub fn id_i32_iterator() -> TypeId { TypeId::of::<I32Iterator>() }
+pub fn id_u32_iterator() -> TypeId { TypeId::of::<U32Iterator>() }
diff --git a/src/test/run-pass/issue-35546.rs b/src/test/run-pass/issue-35546.rs
new file mode 100644
index 00000000000..e8d14f1d421
--- /dev/null
+++ b/src/test/run-pass/issue-35546.rs
@@ -0,0 +1,28 @@
+// Copyright 2016 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 #35546. Check that we are able to codegen
+// this. Before we had problems because of the drop glue signature
+// around dropping a trait object (specifically, when dropping the
+// `value` field of `Node<Send>`).
+
+struct Node<T: ?Sized + Send> {
+    next: Option<Box<Node<Send>>>,
+    value: T,
+}
+
+fn clear(head: &mut Option<Box<Node<Send>>>) {
+    match head.take() {
+        Some(node) => *head = node.next,
+        None => (),
+    }
+}
+
+fn main() {}
diff --git a/src/test/run-pass/issue-36053.rs b/src/test/run-pass/issue-36053.rs
new file mode 100644
index 00000000000..2411996cf05
--- /dev/null
+++ b/src/test/run-pass/issue-36053.rs
@@ -0,0 +1,32 @@
+// Copyright 2016 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 #36053. ICE was caused due to obligations being
+// added to a special, dedicated fulfillment cx during a
+// probe. Problem seems to be related to the particular definition of
+// `FusedIterator` in std but I was not able to isolate that into an
+// external crate.
+
+#![feature(fused)]
+use std::iter::FusedIterator;
+
+struct Thing<'a>(&'a str);
+impl<'a> Iterator for Thing<'a> {
+    type Item = &'a str;
+    fn next(&mut self) -> Option<&'a str> {
+        None
+    }
+}
+
+impl<'a> FusedIterator for Thing<'a> {}
+
+fn main() {
+    Thing("test").fuse().filter(|_| true).count();
+}
diff --git a/src/test/run-pass/typeid-intrinsic.rs b/src/test/run-pass/typeid-intrinsic.rs
index e99a5f69af4..36650368d57 100644
--- a/src/test/run-pass/typeid-intrinsic.rs
+++ b/src/test/run-pass/typeid-intrinsic.rs
@@ -78,4 +78,13 @@ pub fn main() {
     b.hash(&mut s2);
 
     assert_eq!(s1.finish(), s2.finish());
+
+    // Check projections
+
+    assert_eq!(TypeId::of::<other1::I32Iterator>(), other1::id_i32_iterator());
+    assert_eq!(TypeId::of::<other1::U32Iterator>(), other1::id_u32_iterator());
+    assert_eq!(other1::id_i32_iterator(), other2::id_i32_iterator());
+    assert_eq!(other1::id_u32_iterator(), other2::id_u32_iterator());
+    assert!(other1::id_i32_iterator() != other1::id_u32_iterator());
+    assert!(TypeId::of::<other1::I32Iterator>() != TypeId::of::<other1::U32Iterator>());
 }
diff --git a/src/test/run-pass/union/union-c-interop.rs b/src/test/run-pass/union/union-c-interop.rs
index a9f97620ebd..bea4d5f923e 100644
--- a/src/test/run-pass/union/union-c-interop.rs
+++ b/src/test/run-pass/union/union-c-interop.rs
@@ -10,14 +10,14 @@
 
 #![feature(untagged_unions)]
 
-#[derive(Copy)]
+#[derive(Clone, Copy)]
 #[repr(C)]
 struct LARGE_INTEGER_U {
     LowPart: u32,
     HighPart: u32,
 }
 
-#[derive(Copy)]
+#[derive(Clone, Copy)]
 #[repr(C)]
 union LARGE_INTEGER {
   __unnamed__: LARGE_INTEGER_U,
@@ -25,9 +25,6 @@ union LARGE_INTEGER {
   QuadPart: u64,
 }
 
-impl Clone for LARGE_INTEGER_U { fn clone(&self) -> Self { *self } }
-impl Clone for LARGE_INTEGER { fn clone(&self) -> Self { *self } }
-
 #[link(name = "rust_test_helpers")]
 extern "C" {
     fn increment_all_parts(_: LARGE_INTEGER) -> LARGE_INTEGER;
diff --git a/src/test/run-pass/union/union-derive.rs b/src/test/run-pass/union/union-derive.rs
index b71c23990a4..8ff6f17394f 100644
--- a/src/test/run-pass/union/union-derive.rs
+++ b/src/test/run-pass/union/union-derive.rs
@@ -14,18 +14,34 @@
 
 #[derive(
     Copy,
+    Clone,
+    Eq,
 )]
 union U {
     a: u8,
     b: u16,
 }
 
-impl Clone for U {
-    fn clone(&self) -> Self { *self }
+impl PartialEq for U { fn eq(&self, rhs: &Self) -> bool { true } }
+
+#[derive(
+    Clone,
+    Copy,
+    Eq
+)]
+union W<T> {
+    a: T,
 }
 
+impl<T> PartialEq for W<T> { fn eq(&self, rhs: &Self) -> bool { true } }
+
 fn main() {
     let u = U { b: 0 };
     let u1 = u;
     let u2 = u.clone();
+    assert!(u1 == u2);
+
+    let w = W { a: 0 };
+    let w1 = w.clone();
+    assert!(w == w1);
 }