Skip to content

Commit 09783d1

Browse files
committed
Update test files; mostly the problem is that they were using the
explicit form `Fn<A,B>` and now should use `Fn(A) -> B` or `Fn<A,Output=B>`, but in some cases we get duplicate error reports. This is mildly annoying and arises because of the main error and another error from the projection. Might be worth squashing those, but seems like a separate problem.
1 parent ac94ae5 commit 09783d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+201
-126
lines changed

src/test/compile-fail/borrowck-overloaded-call.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ struct SFn {
1717
y: isize,
1818
}
1919

20-
impl Fn<(isize,),isize> for SFn {
20+
impl Fn<(isize,)> for SFn {
21+
type Output = isize;
22+
2123
extern "rust-call" fn call(&self, (z,): (isize,)) -> isize {
2224
self.x * self.y * z
2325
}
@@ -28,7 +30,9 @@ struct SFnMut {
2830
y: isize,
2931
}
3032

31-
impl FnMut<(isize,),isize> for SFnMut {
33+
impl FnMut<(isize,)> for SFnMut {
34+
type Output = isize;
35+
3236
extern "rust-call" fn call_mut(&mut self, (z,): (isize,)) -> isize {
3337
self.x * self.y * z
3438
}
@@ -38,7 +42,9 @@ struct SFnOnce {
3842
x: String,
3943
}
4044

41-
impl FnOnce<(String,),usize> for SFnOnce {
45+
impl FnOnce<(String,)> for SFnOnce {
46+
type Output = usize;
47+
4248
extern "rust-call" fn call_once(self, (z,): (String,)) -> usize {
4349
self.x.len() + z.len()
4450
}

src/test/compile-fail/extern-wrong-value-type.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ fn is_fn<F>(_: F) where F: Fn() {}
1616
fn main() {
1717
// extern functions are extern "C" fn
1818
let _x: extern "C" fn() = f; // OK
19-
is_fn(f); //~ ERROR the trait `core::ops::Fn()` is not implemented for the type `extern "C" fn()
19+
is_fn(f);
20+
//~^ ERROR the trait `core::ops::Fn<()>` is not implemented for the type `extern "C" fn()
21+
//~| ERROR the trait `core::ops::Fn<()>` is not implemented for the type `extern "C" fn()
2022
}

src/test/compile-fail/feature-gate-unboxed-closures-manual-impls.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,38 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Test that manual impls of the `Fn` traits are not possible without
12+
// a feature gate. In fact, the specialized check for these cases
13+
// never triggers (yet), because they encounter other problems around
14+
// angle bracket vs parentheses notation.
15+
1116
#![allow(dead_code)]
1217

1318
struct Foo;
14-
impl Fn() for Foo { //~ ERROR manual implementations of `Fn` are experimental
19+
impl Fn<()> for Foo {
20+
//~^ ERROR angle-bracket notation is not stable when used with the `Fn` family of traits
21+
type Output = ();
22+
23+
extern "rust-call" fn call(&self, args: ()) -> () {}
24+
}
25+
struct Foo1;
26+
impl Fn() for Foo1 {
27+
//~^ ERROR associated type bindings are not allowed here
28+
1529
extern "rust-call" fn call(&self, args: ()) -> () {}
1630
}
1731
struct Bar;
18-
impl FnMut() for Bar { //~ ERROR manual implementations of `FnMut` are experimental
32+
impl FnMut<()> for Bar {
33+
//~^ ERROR angle-bracket notation is not stable when used with the `Fn` family of traits
34+
type Output = ();
35+
1936
extern "rust-call" fn call_mut(&self, args: ()) -> () {}
2037
}
2138
struct Baz;
22-
impl FnOnce() for Baz { //~ ERROR manual implementations of `FnOnce` are experimental
39+
impl FnOnce<()> for Baz {
40+
//~^ ERROR angle-bracket notation is not stable when used with the `Fn` family of traits
41+
type Output = ();
42+
2343
extern "rust-call" fn call_once(&self, args: ()) -> () {}
2444
}
2545

src/test/compile-fail/fn-trait-formatting.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@ fn main() {
3434
//~| expected ()
3535
//~| found box
3636

37-
needs_fn(1is); //~ ERROR `core::ops::Fn(isize) -> isize`
37+
needs_fn(1is);
38+
//~^ ERROR `core::ops::Fn<(isize,)>`
39+
//~| ERROR `core::ops::Fn<(isize,)>`
3840
}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ struct Debuger<T> {
1616
x: T
1717
}
1818

19-
impl<T: fmt::Debug> ops::Fn<(), ()> for Debuger<T> {
19+
impl<T: fmt::Debug> ops::Fn<(),> for Debuger<T> {
20+
type Output = ();
21+
2022
fn call(&self, _args: ()) {
2123
//~^ ERROR `call` has an incompatible type for trait: expected "rust-call" fn, found "Rust" fn
2224
println!("{:?}", self.x);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#![feature(unboxed_closures)]
1212

13-
pub fn foo<'a, F: Fn<(&'a (),), ()>>(bar: F) {
13+
pub fn foo<'a, F: Fn(&'a ())>(bar: F) {
1414
bar.call((
1515
&(), //~ ERROR borrowed value does not live long enough
1616
));

src/test/compile-fail/overloaded-calls-bad.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ struct S {
1717
y: isize,
1818
}
1919

20-
impl FnMut<(isize,),isize> for S {
20+
impl FnMut<(isize,)> for S {
21+
type Output = isize;
22+
2123
extern "rust-call" fn call_mut(&mut self, (z,): (isize,)) -> isize {
2224
self.x * self.y * z
2325
}

src/test/compile-fail/overloaded-calls-nontuple.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ struct S {
1717
y: isize,
1818
}
1919

20-
impl FnMut<isize,isize> for S {
20+
impl FnMut<isize> for S {
21+
type Output = isize;
2122
extern "rust-call" fn call_mut(&mut self, z: isize) -> isize {
2223
self.x + self.y + z
2324
}

src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
// except according to those terms.
1010

1111

12-
struct invariant<'a> {
12+
struct Invariant<'a> {
1313
f: Box<for<'b> FnOnce() -> &'b mut &'a isize + 'static>,
1414
}
1515

16-
fn to_same_lifetime<'r>(bi: invariant<'r>) {
17-
let bj: invariant<'r> = bi;
16+
fn to_same_lifetime<'r>(bi: Invariant<'r>) {
17+
let bj: Invariant<'r> = bi;
1818
}
1919

20-
fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> {
20+
fn to_longer_lifetime<'r>(bi: Invariant<'r>) -> Invariant<'static> {
2121
bi //~ ERROR mismatched types
2222
}
2323

src/test/compile-fail/unboxed-closure-feature-gate.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
// Check that parenthetical notation is feature-gated except with the
1212
// `Fn` traits.
1313

14-
trait Foo<A,R> {
14+
trait Foo<A> {
15+
type Output;
1516
}
1617

1718
fn main() {

src/test/compile-fail/unboxed-closure-sugar-default.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
#![feature(unboxed_closures)]
1515
#![allow(dead_code)]
1616

17-
trait Foo<T,U,V=T> {
18-
fn dummy(&self, t: T, u: U, v: V);
17+
trait Foo<T,V=T> {
18+
type Output;
19+
fn dummy(&self, t: T, v: V);
1920
}
2021

2122
trait Eq<X: ?Sized> { }
@@ -24,14 +25,14 @@ fn eq<A: ?Sized,B: ?Sized>() where A : Eq<B> { }
2425

2526
fn test<'a,'b>() {
2627
// Parens are equivalent to omitting default in angle.
27-
eq::< Foo<(isize,),()>, Foo(isize) >();
28+
eq::< Foo<(isize,),Output=()>, Foo(isize) >();
2829

2930
// In angle version, we supply something other than the default
30-
eq::< Foo<(isize,),(),isize>, Foo(isize) >();
31+
eq::< Foo<(isize,),isize,Output=()>, Foo(isize) >();
3132
//~^ ERROR not implemented
3233

3334
// Supply default explicitly.
34-
eq::< Foo<(isize,),(),(isize,)>, Foo(isize) >();
35+
eq::< Foo<(isize,),(isize,),Output=()>, Foo(isize) >();
3536
}
3637

3738
fn main() { }

src/test/compile-fail/unboxed-closure-sugar-equiv.rs

+16-14
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
#![feature(unboxed_closures)]
1717
#![allow(dead_code)]
1818

19-
trait Foo<T,U> {
20-
fn dummy(&self, t: T, u: U);
19+
trait Foo<T> {
20+
type Output;
21+
fn dummy(&self, t: T, u: Self::Output);
2122
}
2223

2324
trait Eq<X: ?Sized> { }
@@ -26,31 +27,32 @@ fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
2627

2728
fn test<'a,'b>() {
2829
// No errors expected:
29-
eq::< Foo<(),()>, Foo() >();
30-
eq::< Foo<(isize,),()>, Foo(isize) >();
31-
eq::< Foo<(isize,usize),()>, Foo(isize,usize) >();
32-
eq::< Foo<(isize,usize),usize>, Foo(isize,usize) -> usize >();
33-
eq::< Foo<(&'a isize,&'b usize),usize>, Foo(&'a isize,&'b usize) -> usize >();
30+
eq::< Foo<(),Output=()>, Foo() >();
31+
eq::< Foo<(isize,),Output=()>, Foo(isize) >();
32+
eq::< Foo<(isize,usize),Output=()>, Foo(isize,usize) >();
33+
eq::< Foo<(isize,usize),Output=usize>, Foo(isize,usize) -> usize >();
34+
eq::< Foo<(&'a isize,&'b usize),Output=usize>, Foo(&'a isize,&'b usize) -> usize >();
3435

3536
// Test that anonymous regions in `()` form are equivalent
3637
// to fresh bound regions, and that we can intermingle
3738
// named and anonymous as we choose:
38-
eq::< for<'x,'y> Foo<(&'x isize,&'y usize),usize>,
39+
eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
3940
for<'x,'y> Foo(&'x isize,&'y usize) -> usize >();
40-
eq::< for<'x,'y> Foo<(&'x isize,&'y usize),usize>,
41+
eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
4142
for<'x> Foo(&'x isize,&usize) -> usize >();
42-
eq::< for<'x,'y> Foo<(&'x isize,&'y usize),usize>,
43+
eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
4344
for<'y> Foo(&isize,&'y usize) -> usize >();
44-
eq::< for<'x,'y> Foo<(&'x isize,&'y usize),usize>,
45+
eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
4546
Foo(&isize,&usize) -> usize >();
4647

4748
// lifetime elision
48-
eq::< for<'x> Foo<(&'x isize,), &'x isize>,
49+
eq::< for<'x> Foo<(&'x isize,), Output=&'x isize>,
4950
Foo(&isize) -> &isize >();
5051

5152
// Errors expected:
52-
eq::< Foo<(),()>, Foo(char) >();
53-
//~^ ERROR not implemented
53+
eq::< Foo<(),Output=()>,
54+
Foo(char) >();
55+
//~^^ ERROR not implemented
5456
}
5557

5658
fn main() { }

src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@
1616
#![feature(unboxed_closures)]
1717
#![allow(dead_code)]
1818

19-
trait Foo<T,U> {
20-
fn dummy(&self, t: T, u: U);
19+
trait Foo<T> {
20+
type Output;
21+
fn dummy(&self, t: T);
2122
}
2223

2324
trait Eq<X: ?Sized> { }
2425
impl<X: ?Sized> Eq<X> for X { }
2526
fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
2627

2728
fn main() {
28-
eq::< for<'a> Foo<(&'a isize,), &'a isize>,
29+
eq::< for<'a> Foo<(&'a isize,), Output=&'a isize>,
2930
Foo(&isize) -> &isize >();
30-
eq::< for<'a> Foo<(&'a isize,), (&'a isize, &'a isize)>,
31+
eq::< for<'a> Foo<(&'a isize,), Output=(&'a isize, &'a isize)>,
3132
Foo(&isize) -> (&isize, &isize) >();
3233

3334
let _: Foo(&isize, &usize) -> &usize; //~ ERROR missing lifetime specifier

src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
// Test that the `Fn` traits require `()` form without a feature gate.
1313

14-
fn bar1(x: &Fn<(),()>) {
14+
fn bar1(x: &Fn<()>) {
1515
//~^ ERROR angle-bracket notation is not stable when used with the `Fn` family
1616
}
1717

18-
fn bar2<T>(x: &T) where T: Fn<(),()> {
18+
fn bar2<T>(x: &T) where T: Fn<()> {
1919
//~^ ERROR angle-bracket notation is not stable when used with the `Fn` family
2020
}
2121

src/test/compile-fail/unboxed-closure-sugar-region.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717

1818
use std::marker;
1919

20-
trait Foo<'a,T,U> {
21-
fn dummy(&'a self) -> &'a (T,U);
20+
trait Foo<'a,T> {
21+
type Output;
22+
fn dummy(&'a self) -> &'a (T,Self::Output);
2223
}
2324

2425
trait Eq<X: ?Sized> { }
@@ -29,16 +30,17 @@ fn same_type<A,B:Eq<A>>(a: A, b: B) { }
2930

3031
fn test<'a,'b>() {
3132
// Parens are equivalent to omitting default in angle.
32-
eq::< Foo<(isize,),()>, Foo(isize) >();
33+
eq::< Foo<(isize,),Output=()>, Foo(isize) >();
3334

3435
// Here we specify 'static explicitly in angle-bracket version.
3536
// Parenthesized winds up getting inferred.
36-
eq::< Foo<'static, (isize,),()>, Foo(isize) >();
37+
eq::< Foo<'static, (isize,),Output=()>, Foo(isize) >();
3738
}
3839

39-
fn test2(x: &Foo<(isize,),()>, y: &Foo(isize)) {
40+
fn test2(x: &Foo<(isize,),Output=()>, y: &Foo(isize)) {
4041
// Here, the omitted lifetimes are expanded to distinct things.
4142
same_type(x, y) //~ ERROR cannot infer
43+
//~^ ERROR cannot infer
4244
}
4345

4446
fn main() { }

src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111

1212
// Test that parentheses form doesn't work with struct types appearing in local variables.
1313

14-
struct Bar<A,R> {
15-
f: A, r: R
14+
struct Bar<A> {
15+
f: A
1616
}
1717

1818
fn bar() {
1919
let x: Box<Bar()> = panic!();
2020
//~^ ERROR parenthesized parameters may only be used with a trait
21+
//~^^ ERROR associated type bindings are not allowed here
2122
}
2223

2324
fn main() { }

src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010

1111
// Test that parentheses form doesn't work with struct types appearing in argument types.
1212

13-
struct Bar<A,R> {
14-
f: A, r: R
13+
struct Bar<A> {
14+
f: A
1515
}
1616

1717
fn foo(b: Box<Bar()>) {
1818
//~^ ERROR parenthesized parameters may only be used with a trait
19+
//~^^ ERROR associated type bindings are not allowed here
1920
}
2021

2122
fn main() { }

src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
trait One<A> { fn foo(&self) -> A; }
1414

15-
fn foo(_: &One()) //~ ERROR wrong number of type arguments
15+
fn foo(_: &One()) //~ ERROR no associated type `Output` defined in `One<()>`
1616
{}
1717

1818
fn main() { }

src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
trait Trait {}
1414

1515
fn f<F:Trait(isize) -> isize>(x: F) {}
16-
//~^ ERROR wrong number of type arguments: expected 0, found 2
16+
//~^ ERROR wrong number of type arguments: expected 0, found 1
1717

1818
fn main() {}
1919

src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ use std::ops::{Fn,FnMut,FnOnce};
1818

1919
struct S;
2020

21-
impl FnMut<(isize,),isize> for S {
21+
impl FnMut<(isize,)> for S {
22+
type Output = isize;
23+
2224
extern "rust-call" fn call_mut(&mut self, (x,): (isize,)) -> isize {
2325
x * x
2426
}
@@ -29,6 +31,8 @@ fn call_it<F:Fn(isize)->isize>(f: &F, x: isize) -> isize {
2931
}
3032

3133
fn main() {
32-
let x = call_it(&S, 22); //~ ERROR not implemented
34+
let x = call_it(&S, 22);
35+
//~^ ERROR not implemented
36+
//~| ERROR not implemented
3337
}
3438

0 commit comments

Comments
 (0)