Skip to content

Commit 594e21f

Browse files
committed
Correct various compile-fail tests. Most of the changes are because we
now don't print duplicate errors within one context, so I sometimes had to break functions into two functions.
1 parent d85ff16 commit 594e21f

14 files changed

+72
-24
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn test<T: Sync>() {}
12+
13+
fn main() {
14+
test::<Receiver<int>>(); //~ ERROR: `core::kinds::Sync` is not implemented
15+
}

src/test/compile-fail/comm-not-freeze.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,5 @@
1111
fn test<T: Sync>() {}
1212

1313
fn main() {
14-
test::<Sender<int>>(); //~ ERROR: `core::kinds::Sync` is not implemented
15-
test::<Receiver<int>>(); //~ ERROR: `core::kinds::Sync` is not implemented
16-
test::<Sender<int>>(); //~ ERROR: `core::kinds::Sync` is not implemented
14+
test::<Sender<int>>(); //~ ERROR: `core::kinds::Sync` is not implemented
1715
}

src/test/compile-fail/issue-5883.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ fn new_struct(r: A+'static)
1818
-> Struct { //~^ ERROR the trait `core::kinds::Sized` is not implemented
1919
//~^ ERROR the trait `core::kinds::Sized` is not implemented
2020
Struct { r: r }
21-
//~^ ERROR the trait `core::kinds::Sized` is not implemented
2221
}
2322

2423
trait Curve {}

src/test/compile-fail/issue-7013.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ struct A {
3232

3333
fn main() {
3434
let a = A {v: box B{v: None} as Box<Foo+Send>};
35-
//~^ ERROR the trait `core::kinds::Send` is not implemented for the type `B`
35+
//~^ ERROR the trait `core::kinds::Send` is not implemented
3636
}

src/test/compile-fail/issue-8727.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// error-pattern:reached the recursion limit during monomorphization
12+
1113
// Verify the compiler fails with an error on infinite function
1214
// recursions.
1315

14-
1516
struct Data(Box<Option<Data>>);
1617

1718
fn generic<T>( _ : Vec<(Data,T)> ) {
18-
//~^ ERROR reached the recursion limit during monomorphization
1919
let rec : Vec<(Data,(bool,T))> = Vec::new();
2020
generic( rec );
2121
}

src/test/compile-fail/kindck-copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct MyStruct {
2222
}
2323

2424
struct MyNoncopyStruct {
25-
x: Box<int>,
25+
x: Box<char>,
2626
}
2727

2828
fn test<'a,T,U:Copy>(_: &'a int) {

src/test/compile-fail/kindck-destructor-owned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct Foo {
1616
}
1717

1818
impl Drop for Foo {
19-
//~^ ERROR the trait `core::kinds::Send` is not implemented for the type `Foo`
19+
//~^ ERROR the trait `core::kinds::Send` is not implemented
2020
//~^^ NOTE cannot implement a destructor on a structure or enumeration that does not satisfy Send
2121
fn drop(&mut self) {
2222
}

src/test/compile-fail/kindck-impl-type-params.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ fn f<T>(val: T) {
2222
let a = &t as &Gettable<T>;
2323
//~^ ERROR the trait `core::kinds::Send` is not implemented
2424
//~^^ ERROR the trait `core::kinds::Copy` is not implemented
25+
}
26+
27+
fn g<T>(val: T) {
28+
let t: S<T> = S;
2529
let a: &Gettable<T> = &t;
2630
//~^ ERROR the trait `core::kinds::Send` is not implemented
2731
//~^^ ERROR the trait `core::kinds::Copy` is not implemented
@@ -30,9 +34,15 @@ fn f<T>(val: T) {
3034
fn foo<'a>() {
3135
let t: S<&'a int> = S;
3236
let a = &t as &Gettable<&'a int>;
37+
}
38+
39+
fn foo2<'a>() {
3340
let t: Box<S<String>> = box S;
3441
let a = t as Box<Gettable<String>>;
3542
//~^ ERROR the trait `core::kinds::Copy` is not implemented
43+
}
44+
45+
fn foo3<'a>() {
3646
let t: Box<S<String>> = box S;
3747
let a: Box<Gettable<String>> = t;
3848
//~^ ERROR the trait `core::kinds::Copy` is not implemented

src/test/compile-fail/kindck-nonsendable-1.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ use std::rc::Rc;
1313

1414
fn foo(_x: Rc<uint>) {}
1515

16-
fn main() {
16+
fn bar() {
1717
let x = Rc::new(3u);
1818
let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented
19-
let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented
20-
let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented
19+
}
20+
21+
fn bar2() {
22+
let x = Rc::new(3u);
2123
let _: proc() = proc() foo(x);
2224
}
25+
26+
fn main() { }

src/test/compile-fail/unsendable-class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ fn foo(i:int, j: Rc<String>) -> foo {
2929
fn main() {
3030
let cat = "kitty".to_string();
3131
let (tx, _) = channel(); //~ ERROR `core::kinds::Send` is not implemented
32-
tx.send(foo(42, Rc::new(cat))); //~ ERROR `core::kinds::Send` is not implemented
32+
tx.send(foo(42, Rc::new(cat)));
3333
}

src/test/compile-fail/unsized-enum.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
enum Foo<T> { FooSome(T), FooNone }
1211

13-
fn bar<T: Sized>() { }
14-
fn foo<Sized? T>() { bar::<Foo<T>>() }
12+
fn is_sized<T:Sized>() { }
13+
fn not_sized<Sized? T>() { }
14+
15+
enum Foo<U> { FooSome(U), FooNone }
16+
fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
17+
fn foo2<Sized? T>() { not_sized::<Foo<T>>() }
18+
//~^ ERROR the trait `core::kinds::Sized` is not implemented
19+
//
20+
// Not OK: `T` is not sized.
21+
22+
enum Bar<Sized? U> { BarSome(U), BarNone }
23+
fn bar1<Sized? T>() { not_sized::<Bar<T>>() }
24+
fn bar2<Sized? T>() { is_sized::<Bar<T>>() }
1525
//~^ ERROR the trait `core::kinds::Sized` is not implemented
16-
//~^^ ERROR the trait `core::kinds::Sized` is not implemented
1726
//
18-
// One error is for T being provided to Foo<T>, the other is
19-
// for Foo<T> being provided to bar.
27+
// Not OK: `Bar<T>` is not sized, but it should be.
2028

2129
fn main() { }

src/test/compile-fail/unsized-struct.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
12+
fn is_sized<T:Sized>() { }
13+
fn not_sized<Sized? T>() { }
14+
1115
struct Foo<T> { data: T }
16+
fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
17+
fn foo2<Sized? T>() { not_sized::<Foo<T>>() }
18+
//~^ ERROR the trait `core::kinds::Sized` is not implemented
19+
//
20+
// Not OK: `T` is not sized.
1221

13-
fn bar<T: Sized>() { }
14-
fn foo<Sized? T>() { bar::<Foo<T>>() }
22+
struct Bar<Sized? T> { data: T }
23+
fn bar1<Sized? T>() { not_sized::<Bar<T>>() }
24+
fn bar2<Sized? T>() { is_sized::<Bar<T>>() }
1525
//~^ ERROR the trait `core::kinds::Sized` is not implemented
16-
//~^^ ERROR the trait `core::kinds::Sized` is not implemented
17-
// One error is for the T in Foo<T>, the other is for Foo<T> as a value
18-
// for bar's type parameter.
26+
//
27+
// Not OK: `Bar<T>` is not sized, but it should be.
1928

2029
fn main() { }

src/test/compile-fail/unsized3.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ fn f8<Sized? X>(x1: &S<X>, x2: &S<X>) {
5757
fn f9<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) {
5858
f5(&(*x1, 34i));
5959
//~^ ERROR the trait `core::kinds::Sized` is not implemented
60+
}
61+
62+
fn f10<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) {
6063
f5(&(32i, *x2));
6164
//~^ ERROR the trait `core::kinds::Sized` is not implemented
6265
}

src/test/compile-fail/unsized5.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ struct S4 {
2929
}
3030
enum E<Sized? X> {
3131
V1(X, int), //~ERROR `core::kinds::Sized` is not implemented
32+
}
33+
enum F<Sized? X> {
3234
V2{f1: X, f: int}, //~ERROR `core::kinds::Sized` is not implemented
3335
}
3436

0 commit comments

Comments
 (0)