Skip to content

Commit e769d61

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 241d111 commit e769d61

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

Lines changed: 9 additions & 3 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 23 additions & 3 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ struct Shower<T> {
1616
x: T
1717
}
1818

19-
impl<T: fmt::Show> ops::Fn<(), ()> for Shower<T> {
19+
impl<T: fmt::Show> ops::Fn<(),> for Shower<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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 1 deletion
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() {

0 commit comments

Comments
 (0)