From 09783d1dab5817b9c0202ce2fa2b0e5e78e79d44 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Jan 2015 10:27:25 -0500 Subject: [PATCH] Update test files; mostly the problem is that they were using the explicit form `Fn` and now should use `Fn(A) -> B` or `Fn`, 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. --- .../compile-fail/borrowck-overloaded-call.rs | 12 ++++++-- .../compile-fail/extern-wrong-value-type.rs | 4 ++- ...ture-gate-unboxed-closures-manual-impls.rs | 26 ++++++++++++++-- src/test/compile-fail/fn-trait-formatting.rs | 4 ++- src/test/compile-fail/issue-15094.rs | 4 ++- src/test/compile-fail/issue-17545.rs | 2 +- src/test/compile-fail/overloaded-calls-bad.rs | 4 ++- .../compile-fail/overloaded-calls-nontuple.rs | 3 +- ...ns-infer-invariance-due-to-mutability-4.rs | 8 ++--- .../unboxed-closure-feature-gate.rs | 3 +- .../unboxed-closure-sugar-default.rs | 11 +++---- .../unboxed-closure-sugar-equiv.rs | 30 ++++++++++--------- .../unboxed-closure-sugar-lifetime-elision.rs | 9 +++--- .../unboxed-closure-sugar-not-used-on-fn.rs | 4 +-- .../unboxed-closure-sugar-region.rs | 12 ++++---- .../unboxed-closure-sugar-used-on-struct-1.rs | 5 ++-- .../unboxed-closure-sugar-used-on-struct.rs | 5 ++-- ...r-wrong-number-number-type-parameters-1.rs | 2 +- .../unboxed-closure-sugar-wrong-trait.rs | 2 +- .../unboxed-closures-fnmut-as-fn.rs | 8 +++-- .../unboxed-closures-unsafe-extern-fn.rs | 4 ++- .../unboxed-closures-vtable-mismatch.rs | 6 ++-- .../unboxed-closures-wrong-abi.rs | 4 ++- ...boxed-closures-wrong-arg-type-extern-fn.rs | 4 ++- .../unboxed-closures-wrong-trait.rs | 1 + .../run-pass/bare-fn-implements-fn-mut.rs | 4 +-- src/test/run-pass/hrtb-parse.rs | 16 +++++----- .../hrtb-trait-object-paren-notation.rs | 2 +- src/test/run-pass/issue-13655.rs | 3 +- src/test/run-pass/issue-14958.rs | 3 +- src/test/run-pass/issue-14959.rs | 4 ++- src/test/run-pass/issue-16668.rs | 2 +- src/test/run-pass/issue-16739.rs | 23 +++++++------- .../overloaded-calls-param-vtables.rs | 8 +++-- src/test/run-pass/overloaded-calls-simple.rs | 27 +++++++++-------- .../run-pass/overloaded-calls-zero-args.rs | 9 +++--- src/test/run-pass/unboxed-closures-boxed.rs | 6 ++-- ...unboxed-closures-fn-as-fnmut-and-fnonce.rs | 11 +++---- .../unboxed-closures-fnmut-as-fnonce.rs | 10 ++++--- src/test/run-pass/unboxed-closures-generic.rs | 4 +-- .../run-pass/unboxed-closures-manual-impl.rs | 10 ++++--- .../unboxed-closures-monomorphization.rs | 6 ++-- .../run-pass/unboxed-closures-sugar-object.rs | 2 +- 43 files changed, 201 insertions(+), 126 deletions(-) diff --git a/src/test/compile-fail/borrowck-overloaded-call.rs b/src/test/compile-fail/borrowck-overloaded-call.rs index 7d35a27c0ae2..04d73cc36f04 100644 --- a/src/test/compile-fail/borrowck-overloaded-call.rs +++ b/src/test/compile-fail/borrowck-overloaded-call.rs @@ -17,7 +17,9 @@ struct SFn { y: isize, } -impl Fn<(isize,),isize> for SFn { +impl Fn<(isize,)> for SFn { + type Output = isize; + extern "rust-call" fn call(&self, (z,): (isize,)) -> isize { self.x * self.y * z } @@ -28,7 +30,9 @@ struct SFnMut { y: isize, } -impl FnMut<(isize,),isize> for SFnMut { +impl FnMut<(isize,)> for SFnMut { + type Output = isize; + extern "rust-call" fn call_mut(&mut self, (z,): (isize,)) -> isize { self.x * self.y * z } @@ -38,7 +42,9 @@ struct SFnOnce { x: String, } -impl FnOnce<(String,),usize> for SFnOnce { +impl FnOnce<(String,)> for SFnOnce { + type Output = usize; + extern "rust-call" fn call_once(self, (z,): (String,)) -> usize { self.x.len() + z.len() } diff --git a/src/test/compile-fail/extern-wrong-value-type.rs b/src/test/compile-fail/extern-wrong-value-type.rs index d7586af291e8..db3373ea0277 100644 --- a/src/test/compile-fail/extern-wrong-value-type.rs +++ b/src/test/compile-fail/extern-wrong-value-type.rs @@ -16,5 +16,7 @@ fn is_fn(_: F) where F: Fn() {} fn main() { // extern functions are extern "C" fn let _x: extern "C" fn() = f; // OK - is_fn(f); //~ ERROR the trait `core::ops::Fn()` is not implemented for the type `extern "C" fn() + is_fn(f); + //~^ ERROR the trait `core::ops::Fn<()>` is not implemented for the type `extern "C" fn() + //~| ERROR the trait `core::ops::Fn<()>` is not implemented for the type `extern "C" fn() } diff --git a/src/test/compile-fail/feature-gate-unboxed-closures-manual-impls.rs b/src/test/compile-fail/feature-gate-unboxed-closures-manual-impls.rs index cdb207f705f5..e5e5ddadafcc 100644 --- a/src/test/compile-fail/feature-gate-unboxed-closures-manual-impls.rs +++ b/src/test/compile-fail/feature-gate-unboxed-closures-manual-impls.rs @@ -8,18 +8,38 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// Test that manual impls of the `Fn` traits are not possible without +// a feature gate. In fact, the specialized check for these cases +// never triggers (yet), because they encounter other problems around +// angle bracket vs parentheses notation. + #![allow(dead_code)] struct Foo; -impl Fn() for Foo { //~ ERROR manual implementations of `Fn` are experimental +impl Fn<()> for Foo { + //~^ ERROR angle-bracket notation is not stable when used with the `Fn` family of traits + type Output = (); + + extern "rust-call" fn call(&self, args: ()) -> () {} +} +struct Foo1; +impl Fn() for Foo1 { + //~^ ERROR associated type bindings are not allowed here + extern "rust-call" fn call(&self, args: ()) -> () {} } struct Bar; -impl FnMut() for Bar { //~ ERROR manual implementations of `FnMut` are experimental +impl FnMut<()> for Bar { + //~^ ERROR angle-bracket notation is not stable when used with the `Fn` family of traits + type Output = (); + extern "rust-call" fn call_mut(&self, args: ()) -> () {} } struct Baz; -impl FnOnce() for Baz { //~ ERROR manual implementations of `FnOnce` are experimental +impl FnOnce<()> for Baz { + //~^ ERROR angle-bracket notation is not stable when used with the `Fn` family of traits + type Output = (); + extern "rust-call" fn call_once(&self, args: ()) -> () {} } diff --git a/src/test/compile-fail/fn-trait-formatting.rs b/src/test/compile-fail/fn-trait-formatting.rs index f19e27640cbc..460e05c8438c 100644 --- a/src/test/compile-fail/fn-trait-formatting.rs +++ b/src/test/compile-fail/fn-trait-formatting.rs @@ -34,5 +34,7 @@ fn main() { //~| expected () //~| found box - needs_fn(1is); //~ ERROR `core::ops::Fn(isize) -> isize` + needs_fn(1is); + //~^ ERROR `core::ops::Fn<(isize,)>` + //~| ERROR `core::ops::Fn<(isize,)>` } diff --git a/src/test/compile-fail/issue-15094.rs b/src/test/compile-fail/issue-15094.rs index 2c03a9e07332..977586483b03 100644 --- a/src/test/compile-fail/issue-15094.rs +++ b/src/test/compile-fail/issue-15094.rs @@ -16,7 +16,9 @@ struct Debuger { x: T } -impl ops::Fn<(), ()> for Debuger { +impl ops::Fn<(),> for Debuger { + type Output = (); + fn call(&self, _args: ()) { //~^ ERROR `call` has an incompatible type for trait: expected "rust-call" fn, found "Rust" fn println!("{:?}", self.x); diff --git a/src/test/compile-fail/issue-17545.rs b/src/test/compile-fail/issue-17545.rs index 0501a3013ccd..84800218efc9 100644 --- a/src/test/compile-fail/issue-17545.rs +++ b/src/test/compile-fail/issue-17545.rs @@ -10,7 +10,7 @@ #![feature(unboxed_closures)] -pub fn foo<'a, F: Fn<(&'a (),), ()>>(bar: F) { +pub fn foo<'a, F: Fn(&'a ())>(bar: F) { bar.call(( &(), //~ ERROR borrowed value does not live long enough )); diff --git a/src/test/compile-fail/overloaded-calls-bad.rs b/src/test/compile-fail/overloaded-calls-bad.rs index d784ba2d0d6b..61752e62abde 100644 --- a/src/test/compile-fail/overloaded-calls-bad.rs +++ b/src/test/compile-fail/overloaded-calls-bad.rs @@ -17,7 +17,9 @@ struct S { y: isize, } -impl FnMut<(isize,),isize> for S { +impl FnMut<(isize,)> for S { + type Output = isize; + extern "rust-call" fn call_mut(&mut self, (z,): (isize,)) -> isize { self.x * self.y * z } diff --git a/src/test/compile-fail/overloaded-calls-nontuple.rs b/src/test/compile-fail/overloaded-calls-nontuple.rs index c06ab04cd849..41ecf7146138 100644 --- a/src/test/compile-fail/overloaded-calls-nontuple.rs +++ b/src/test/compile-fail/overloaded-calls-nontuple.rs @@ -17,7 +17,8 @@ struct S { y: isize, } -impl FnMut for S { +impl FnMut for S { + type Output = isize; extern "rust-call" fn call_mut(&mut self, z: isize) -> isize { self.x + self.y + z } diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs index 2e634dfe3eb6..2a246124f6f9 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs @@ -9,15 +9,15 @@ // except according to those terms. -struct invariant<'a> { +struct Invariant<'a> { f: Box FnOnce() -> &'b mut &'a isize + 'static>, } -fn to_same_lifetime<'r>(bi: invariant<'r>) { - let bj: invariant<'r> = bi; +fn to_same_lifetime<'r>(bi: Invariant<'r>) { + let bj: Invariant<'r> = bi; } -fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> { +fn to_longer_lifetime<'r>(bi: Invariant<'r>) -> Invariant<'static> { bi //~ ERROR mismatched types } diff --git a/src/test/compile-fail/unboxed-closure-feature-gate.rs b/src/test/compile-fail/unboxed-closure-feature-gate.rs index 5eb67a9bb71d..3536244f0116 100644 --- a/src/test/compile-fail/unboxed-closure-feature-gate.rs +++ b/src/test/compile-fail/unboxed-closure-feature-gate.rs @@ -11,7 +11,8 @@ // Check that parenthetical notation is feature-gated except with the // `Fn` traits. -trait Foo { +trait Foo { + type Output; } fn main() { diff --git a/src/test/compile-fail/unboxed-closure-sugar-default.rs b/src/test/compile-fail/unboxed-closure-sugar-default.rs index 0d9e406b0867..870377bc1add 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-default.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-default.rs @@ -14,8 +14,9 @@ #![feature(unboxed_closures)] #![allow(dead_code)] -trait Foo { - fn dummy(&self, t: T, u: U, v: V); +trait Foo { + type Output; + fn dummy(&self, t: T, v: V); } trait Eq { } @@ -24,14 +25,14 @@ fn eq() where A : Eq { } fn test<'a,'b>() { // Parens are equivalent to omitting default in angle. - eq::< Foo<(isize,),()>, Foo(isize) >(); + eq::< Foo<(isize,),Output=()>, Foo(isize) >(); // In angle version, we supply something other than the default - eq::< Foo<(isize,),(),isize>, Foo(isize) >(); + eq::< Foo<(isize,),isize,Output=()>, Foo(isize) >(); //~^ ERROR not implemented // Supply default explicitly. - eq::< Foo<(isize,),(),(isize,)>, Foo(isize) >(); + eq::< Foo<(isize,),(isize,),Output=()>, Foo(isize) >(); } fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs index 9dff0e9e01e3..dc5576aee650 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs @@ -16,8 +16,9 @@ #![feature(unboxed_closures)] #![allow(dead_code)] -trait Foo { - fn dummy(&self, t: T, u: U); +trait Foo { + type Output; + fn dummy(&self, t: T, u: Self::Output); } trait Eq { } @@ -26,31 +27,32 @@ fn eq>() { } fn test<'a,'b>() { // No errors expected: - eq::< Foo<(),()>, Foo() >(); - eq::< Foo<(isize,),()>, Foo(isize) >(); - eq::< Foo<(isize,usize),()>, Foo(isize,usize) >(); - eq::< Foo<(isize,usize),usize>, Foo(isize,usize) -> usize >(); - eq::< Foo<(&'a isize,&'b usize),usize>, Foo(&'a isize,&'b usize) -> usize >(); + eq::< Foo<(),Output=()>, Foo() >(); + eq::< Foo<(isize,),Output=()>, Foo(isize) >(); + eq::< Foo<(isize,usize),Output=()>, Foo(isize,usize) >(); + eq::< Foo<(isize,usize),Output=usize>, Foo(isize,usize) -> usize >(); + eq::< Foo<(&'a isize,&'b usize),Output=usize>, Foo(&'a isize,&'b usize) -> usize >(); // Test that anonymous regions in `()` form are equivalent // to fresh bound regions, and that we can intermingle // named and anonymous as we choose: - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),usize>, + eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, for<'x,'y> Foo(&'x isize,&'y usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),usize>, + eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, for<'x> Foo(&'x isize,&usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),usize>, + eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, for<'y> Foo(&isize,&'y usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),usize>, + eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, Foo(&isize,&usize) -> usize >(); // lifetime elision - eq::< for<'x> Foo<(&'x isize,), &'x isize>, + eq::< for<'x> Foo<(&'x isize,), Output=&'x isize>, Foo(&isize) -> &isize >(); // Errors expected: - eq::< Foo<(),()>, Foo(char) >(); - //~^ ERROR not implemented + eq::< Foo<(),Output=()>, + Foo(char) >(); + //~^^ ERROR not implemented } fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs b/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs index 29429c708d25..d2f781bba11e 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs @@ -16,8 +16,9 @@ #![feature(unboxed_closures)] #![allow(dead_code)] -trait Foo { - fn dummy(&self, t: T, u: U); +trait Foo { + type Output; + fn dummy(&self, t: T); } trait Eq { } @@ -25,9 +26,9 @@ impl Eq for X { } fn eq>() { } fn main() { - eq::< for<'a> Foo<(&'a isize,), &'a isize>, + eq::< for<'a> Foo<(&'a isize,), Output=&'a isize>, Foo(&isize) -> &isize >(); - eq::< for<'a> Foo<(&'a isize,), (&'a isize, &'a isize)>, + eq::< for<'a> Foo<(&'a isize,), Output=(&'a isize, &'a isize)>, Foo(&isize) -> (&isize, &isize) >(); let _: Foo(&isize, &usize) -> &usize; //~ ERROR missing lifetime specifier diff --git a/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs b/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs index 21844e5b986c..1f0d5aae36db 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs @@ -11,11 +11,11 @@ // Test that the `Fn` traits require `()` form without a feature gate. -fn bar1(x: &Fn<(),()>) { +fn bar1(x: &Fn<()>) { //~^ ERROR angle-bracket notation is not stable when used with the `Fn` family } -fn bar2(x: &T) where T: Fn<(),()> { +fn bar2(x: &T) where T: Fn<()> { //~^ ERROR angle-bracket notation is not stable when used with the `Fn` family } diff --git a/src/test/compile-fail/unboxed-closure-sugar-region.rs b/src/test/compile-fail/unboxed-closure-sugar-region.rs index c8dd33c11fd3..75688e44e807 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-region.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-region.rs @@ -17,8 +17,9 @@ use std::marker; -trait Foo<'a,T,U> { - fn dummy(&'a self) -> &'a (T,U); +trait Foo<'a,T> { + type Output; + fn dummy(&'a self) -> &'a (T,Self::Output); } trait Eq { } @@ -29,16 +30,17 @@ fn same_type>(a: A, b: B) { } fn test<'a,'b>() { // Parens are equivalent to omitting default in angle. - eq::< Foo<(isize,),()>, Foo(isize) >(); + eq::< Foo<(isize,),Output=()>, Foo(isize) >(); // Here we specify 'static explicitly in angle-bracket version. // Parenthesized winds up getting inferred. - eq::< Foo<'static, (isize,),()>, Foo(isize) >(); + eq::< Foo<'static, (isize,),Output=()>, Foo(isize) >(); } -fn test2(x: &Foo<(isize,),()>, y: &Foo(isize)) { +fn test2(x: &Foo<(isize,),Output=()>, y: &Foo(isize)) { // Here, the omitted lifetimes are expanded to distinct things. same_type(x, y) //~ ERROR cannot infer + //~^ ERROR cannot infer } fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs index a6184caf68b1..a3991a87b78f 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs @@ -11,13 +11,14 @@ // Test that parentheses form doesn't work with struct types appearing in local variables. -struct Bar { - f: A, r: R +struct Bar { + f: A } fn bar() { let x: Box = panic!(); //~^ ERROR parenthesized parameters may only be used with a trait + //~^^ ERROR associated type bindings are not allowed here } fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs index d5fb505715e9..ad85cdcaa03a 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs @@ -10,12 +10,13 @@ // Test that parentheses form doesn't work with struct types appearing in argument types. -struct Bar { - f: A, r: R +struct Bar { + f: A } fn foo(b: Box) { //~^ ERROR parenthesized parameters may only be used with a trait + //~^^ ERROR associated type bindings are not allowed here } fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs b/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs index d9efab974d83..c9837da58e75 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs @@ -12,7 +12,7 @@ trait One { fn foo(&self) -> A; } -fn foo(_: &One()) //~ ERROR wrong number of type arguments +fn foo(_: &One()) //~ ERROR no associated type `Output` defined in `One<()>` {} fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs b/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs index b58e08355c11..e63f510b890d 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs @@ -13,7 +13,7 @@ trait Trait {} fn f isize>(x: F) {} -//~^ ERROR wrong number of type arguments: expected 0, found 2 +//~^ ERROR wrong number of type arguments: expected 0, found 1 fn main() {} diff --git a/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs b/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs index fc87ec9f9598..bbafd5109edf 100644 --- a/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs +++ b/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs @@ -18,7 +18,9 @@ use std::ops::{Fn,FnMut,FnOnce}; struct S; -impl FnMut<(isize,),isize> for S { +impl FnMut<(isize,)> for S { + type Output = isize; + extern "rust-call" fn call_mut(&mut self, (x,): (isize,)) -> isize { x * x } @@ -29,6 +31,8 @@ fn call_itisize>(f: &F, x: isize) -> isize { } fn main() { - let x = call_it(&S, 22); //~ ERROR not implemented + let x = call_it(&S, 22); + //~^ ERROR not implemented + //~| ERROR not implemented } diff --git a/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs b/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs index ab909717cab6..23f7ee2b0101 100644 --- a/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs +++ b/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs @@ -21,7 +21,9 @@ fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } fn a() { - let x = call_it(&square, 22); //~ ERROR not implemented + let x = call_it(&square, 22); + //~^ ERROR not implemented + //~| ERROR not implemented } fn b() { diff --git a/src/test/compile-fail/unboxed-closures-vtable-mismatch.rs b/src/test/compile-fail/unboxed-closures-vtable-mismatch.rs index 95673a513190..305dd33e5a05 100644 --- a/src/test/compile-fail/unboxed-closures-vtable-mismatch.rs +++ b/src/test/compile-fail/unboxed-closures-vtable-mismatch.rs @@ -12,13 +12,15 @@ use std::ops::FnMut; -fn call_it>(y: isize, mut f: F) -> isize { +fn call_itisize>(y: isize, mut f: F) -> isize { f(2, y) } pub fn main() { let f = |&mut: x: usize, y: isize| -> isize { (x as isize) + y }; - let z = call_it(3, f); //~ ERROR type mismatch + let z = call_it(3, f); + //~^ ERROR type mismatch + //~| ERROR type mismatch println!("{}", z); } diff --git a/src/test/compile-fail/unboxed-closures-wrong-abi.rs b/src/test/compile-fail/unboxed-closures-wrong-abi.rs index 4a0b55558c04..96619bef36fd 100644 --- a/src/test/compile-fail/unboxed-closures-wrong-abi.rs +++ b/src/test/compile-fail/unboxed-closures-wrong-abi.rs @@ -21,7 +21,9 @@ fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } fn a() { - let x = call_it(&square, 22); //~ ERROR not implemented + let x = call_it(&square, 22); + //~^ ERROR not implemented + //~| ERROR not implemented } fn b() { diff --git a/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs b/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs index b2fdf7926301..ebcbdbbc006d 100644 --- a/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs +++ b/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs @@ -22,7 +22,9 @@ fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } fn a() { - let x = call_it(&square, 22); //~ ERROR not implemented + let x = call_it(&square, 22); + //~^ ERROR not implemented + //~| ERROR not implemented } fn b() { diff --git a/src/test/compile-fail/unboxed-closures-wrong-trait.rs b/src/test/compile-fail/unboxed-closures-wrong-trait.rs index e4255d0024fe..2ada0dd22e75 100644 --- a/src/test/compile-fail/unboxed-closures-wrong-trait.rs +++ b/src/test/compile-fail/unboxed-closures-wrong-trait.rs @@ -18,5 +18,6 @@ fn main() { let z: isize = 7; assert_eq!(c(|&mut: x: isize, y| x + y + z), 10); //~^ ERROR not implemented + //~| ERROR not implemented } diff --git a/src/test/run-pass/bare-fn-implements-fn-mut.rs b/src/test/run-pass/bare-fn-implements-fn-mut.rs index 9d104afd6464..fae83d4aa656 100644 --- a/src/test/run-pass/bare-fn-implements-fn-mut.rs +++ b/src/test/run-pass/bare-fn-implements-fn-mut.rs @@ -12,7 +12,7 @@ use std::ops::FnMut; -fn call_f>(mut f: F) { +fn call_f(mut f: F) { f(); } @@ -20,7 +20,7 @@ fn f() { println!("hello"); } -fn call_g>(mut g: G, x: String, y: String) +fn call_g String>(mut g: G, x: String, y: String) -> String { g(x, y) } diff --git a/src/test/run-pass/hrtb-parse.rs b/src/test/run-pass/hrtb-parse.rs index 41b7c0fae074..d5307c09103a 100644 --- a/src/test/run-pass/hrtb-parse.rs +++ b/src/test/run-pass/hrtb-parse.rs @@ -22,23 +22,23 @@ trait Get { // Parse HRTB with explicit `for` in a where-clause: fn foo00(t: T) - where T : for<'a> Get<&'a int, &'a int> + where T : for<'a> Get<&'a i32, &'a i32> { } -fn foo01 Get<&'a int, &'a int>>(t: T) +fn foo01 Get<&'a i32, &'a i32>>(t: T) { } // Parse HRTB with explicit `for` in various sorts of types: -fn foo10(t: Box Get>) { } -fn foo11(t: Box Get(int) -> int>) { } +fn foo10(t: Box Get>) { } +fn foo11(t: Box Fn(i32) -> i32>) { } -fn foo20(t: for<'a> fn(int) -> int) { } -fn foo21(t: for<'a> unsafe fn(int) -> int) { } -fn foo22(t: for<'a> extern "C" fn(int) -> int) { } -fn foo23(t: for<'a> unsafe extern "C" fn(int) -> int) { } +fn foo20(t: for<'a> fn(i32) -> i32) { } +fn foo21(t: for<'a> unsafe fn(i32) -> i32) { } +fn foo22(t: for<'a> extern "C" fn(i32) -> i32) { } +fn foo23(t: for<'a> unsafe extern "C" fn(i32) -> i32) { } fn main() { } diff --git a/src/test/run-pass/hrtb-trait-object-paren-notation.rs b/src/test/run-pass/hrtb-trait-object-paren-notation.rs index e17e0ae2189d..1b62a8e809c8 100644 --- a/src/test/run-pass/hrtb-trait-object-paren-notation.rs +++ b/src/test/run-pass/hrtb-trait-object-paren-notation.rs @@ -16,7 +16,7 @@ trait FnLike { fn call(&self, arg: A) -> R; } -type FnObject<'b> = for<'a> FnLike(&'a int) -> (&'a int) + 'b; +type FnObject<'b> = for<'a> FnLike<(&'a i32,), &'a i32> + 'b; struct Identity; diff --git a/src/test/run-pass/issue-13655.rs b/src/test/run-pass/issue-13655.rs index 6fdaac992047..81a8b29461c7 100644 --- a/src/test/run-pass/issue-13655.rs +++ b/src/test/run-pass/issue-13655.rs @@ -13,7 +13,8 @@ use std::ops::Fn; struct Foo(T); -impl Fn<(), T> for Foo { +impl Fn<()> for Foo { + type Output = T; extern "rust-call" fn call(&self, _: ()) -> T { match *self { Foo(t) => t diff --git a/src/test/run-pass/issue-14958.rs b/src/test/run-pass/issue-14958.rs index 1ffd349a6538..814a743648d3 100644 --- a/src/test/run-pass/issue-14958.rs +++ b/src/test/run-pass/issue-14958.rs @@ -14,7 +14,8 @@ trait Foo {} struct Bar; -impl<'a> std::ops::Fn<(&'a (Foo+'a),), ()> for Bar { +impl<'a> std::ops::Fn<(&'a (Foo+'a),)> for Bar { + type Output = (); extern "rust-call" fn call(&self, _: (&'a Foo,)) {} } diff --git a/src/test/run-pass/issue-14959.rs b/src/test/run-pass/issue-14959.rs index 99472bb3610f..33281d7d78ff 100644 --- a/src/test/run-pass/issue-14959.rs +++ b/src/test/run-pass/issue-14959.rs @@ -33,7 +33,9 @@ impl Alloy { } } -impl<'a, 'b> Fn<(&'b mut (Response+'b),),()> for SendFile<'a> { +impl<'a, 'b> Fn<(&'b mut (Response+'b),)> for SendFile<'a> { + type Output = (); + extern "rust-call" fn call(&self, (_res,): (&'b mut (Response+'b),)) {} } diff --git a/src/test/run-pass/issue-16668.rs b/src/test/run-pass/issue-16668.rs index 75b1e11ddc1e..e82add61aa3b 100644 --- a/src/test/run-pass/issue-16668.rs +++ b/src/test/run-pass/issue-16668.rs @@ -15,7 +15,7 @@ #![feature(unboxed_closures)] struct Parser<'a, I, O> { - parse: Box> + 'a> + parse: Box Result + 'a> } impl<'a, I, O: 'a> Parser<'a, I, O> { diff --git a/src/test/run-pass/issue-16739.rs b/src/test/run-pass/issue-16739.rs index cb6f068cf45b..389baecafd14 100644 --- a/src/test/run-pass/issue-16739.rs +++ b/src/test/run-pass/issue-16739.rs @@ -15,27 +15,30 @@ // Test that unboxing shim for calling rust-call ABI methods through a // trait box works and does not cause an ICE. -struct Foo { foo: uint } +struct Foo { foo: u32 } -impl FnMut<(), uint> for Foo { - extern "rust-call" fn call_mut(&mut self, _: ()) -> uint { self.foo } +impl FnMut<()> for Foo { + type Output = u32; + extern "rust-call" fn call_mut(&mut self, _: ()) -> u32 { self.foo } } -impl FnMut<(uint,), uint> for Foo { - extern "rust-call" fn call_mut(&mut self, (x,): (uint,)) -> uint { self.foo + x } +impl FnMut<(u32,)> for Foo { + type Output = u32; + extern "rust-call" fn call_mut(&mut self, (x,): (u32,)) -> u32 { self.foo + x } } -impl FnMut<(uint, uint), uint> for Foo { - extern "rust-call" fn call_mut(&mut self, (x, y): (uint, uint)) -> uint { self.foo + x + y } +impl FnMut<(u32,u32)> for Foo { + type Output = u32; + extern "rust-call" fn call_mut(&mut self, (x, y): (u32, u32)) -> u32 { self.foo + x + y } } fn main() { - let mut f = box Foo { foo: 42 } as Box>; + let mut f = box Foo { foo: 42 } as Box u32>; assert_eq!(f.call_mut(()), 42); - let mut f = box Foo { foo: 40 } as Box>; + let mut f = box Foo { foo: 40 } as Box u32>; assert_eq!(f.call_mut((2,)), 42); - let mut f = box Foo { foo: 40 } as Box>; + let mut f = box Foo { foo: 40 } as Box u32>; assert_eq!(f.call_mut((1, 1)), 42); } diff --git a/src/test/run-pass/overloaded-calls-param-vtables.rs b/src/test/run-pass/overloaded-calls-param-vtables.rs index 56887636d5df..2838909c1be6 100644 --- a/src/test/run-pass/overloaded-calls-param-vtables.rs +++ b/src/test/run-pass/overloaded-calls-param-vtables.rs @@ -17,13 +17,15 @@ use std::ops::Add; struct G; -impl<'a, A: Add> Fn<(A,), int> for G { - extern "rust-call" fn call(&self, (arg,): (A,)) -> int { +impl<'a, A: Add> Fn<(A,)> for G { + type Output = i32; + + extern "rust-call" fn call(&self, (arg,): (A,)) -> i32 { arg.add(1) } } fn main() { // ICE trigger - G(1i); + G(1_i32); } diff --git a/src/test/run-pass/overloaded-calls-simple.rs b/src/test/run-pass/overloaded-calls-simple.rs index bb5b88d3674a..f9e838d9b3d3 100644 --- a/src/test/run-pass/overloaded-calls-simple.rs +++ b/src/test/run-pass/overloaded-calls-simple.rs @@ -13,34 +13,37 @@ use std::ops::{Fn, FnMut, FnOnce}; struct S1 { - x: int, - y: int, + x: i32, + y: i32, } -impl FnMut<(int,),int> for S1 { - extern "rust-call" fn call_mut(&mut self, (z,): (int,)) -> int { +impl FnMut<(i32,)> for S1 { + type Output = i32; + extern "rust-call" fn call_mut(&mut self, (z,): (i32,)) -> i32 { self.x * self.y * z } } struct S2 { - x: int, - y: int, + x: i32, + y: i32, } -impl Fn<(int,),int> for S2 { - extern "rust-call" fn call(&self, (z,): (int,)) -> int { +impl Fn<(i32,)> for S2 { + type Output = i32; + extern "rust-call" fn call(&self, (z,): (i32,)) -> i32 { self.x * self.y * z } } struct S3 { - x: int, - y: int, + x: i32, + y: i32, } -impl FnOnce<(int,int),int> for S3 { - extern "rust-call" fn call_once(self, (z,zz): (int,int)) -> int { +impl FnOnce<(i32,i32)> for S3 { + type Output = i32; + extern "rust-call" fn call_once(self, (z,zz): (i32,i32)) -> i32 { self.x * self.y * z * zz } } diff --git a/src/test/run-pass/overloaded-calls-zero-args.rs b/src/test/run-pass/overloaded-calls-zero-args.rs index 809a251fe805..ce7395673b39 100644 --- a/src/test/run-pass/overloaded-calls-zero-args.rs +++ b/src/test/run-pass/overloaded-calls-zero-args.rs @@ -13,12 +13,13 @@ use std::ops::{FnMut}; struct S { - x: int, - y: int, + x: i32, + y: i32, } -impl FnMut<(),int> for S { - extern "rust-call" fn call_mut(&mut self, (): ()) -> int { +impl FnMut<()> for S { + type Output = i32; + extern "rust-call" fn call_mut(&mut self, (): ()) -> i32 { self.x * self.y } } diff --git a/src/test/run-pass/unboxed-closures-boxed.rs b/src/test/run-pass/unboxed-closures-boxed.rs index dc35d5bf2cac..27528ca5d566 100644 --- a/src/test/run-pass/unboxed-closures-boxed.rs +++ b/src/test/run-pass/unboxed-closures-boxed.rs @@ -14,9 +14,9 @@ use std::ops::FnMut; - fn make_adder(x: int) -> Box+'static> { - (box move |&mut: y: int| -> int { x + y }) as - Box+'static> + fn make_adder(x: i32) -> Boxi32+'static> { + (box move |&mut: y: i32| -> i32 { x + y }) as + Boxi32+'static> } pub fn main() { diff --git a/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs b/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs index 8af0547e5e57..5d6029e703b8 100644 --- a/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs +++ b/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs @@ -18,21 +18,22 @@ use std::ops::{Fn,FnMut,FnOnce}; struct S; -impl Fn<(int,),int> for S { - extern "rust-call" fn call(&self, (x,): (int,)) -> int { +impl Fn<(i32,)> for S { + type Output = i32; + extern "rust-call" fn call(&self, (x,): (i32,)) -> i32 { x * x } } -fn call_itint>(f: &F, x: int) -> int { +fn call_iti32>(f: &F, x: i32) -> i32 { f(x) } -fn call_it_mutint>(f: &mut F, x: int) -> int { +fn call_it_muti32>(f: &mut F, x: i32) -> i32 { f(x) } -fn call_it_onceint>(f: F, x: int) -> int { +fn call_it_oncei32>(f: F, x: i32) -> i32 { f(x) } diff --git a/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs b/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs index 068080e256db..95dae41c6840 100644 --- a/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs +++ b/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs @@ -18,17 +18,19 @@ use std::ops::{FnMut,FnOnce}; struct S; -impl FnMut<(int,),int> for S { - extern "rust-call" fn call_mut(&mut self, (x,): (int,)) -> int { +impl FnMut<(i32,)> for S { + type Output = i32; + + extern "rust-call" fn call_mut(&mut self, (x,): (i32,)) -> i32 { x * x } } -fn call_it_mutint>(f: &mut F, x: int) -> int { +fn call_it_muti32>(f: &mut F, x: i32) -> i32 { f(x) } -fn call_it_onceint>(f: F, x: int) -> int { +fn call_it_oncei32>(f: F, x: i32) -> i32 { f(x) } diff --git a/src/test/run-pass/unboxed-closures-generic.rs b/src/test/run-pass/unboxed-closures-generic.rs index 0edeeb8d198d..04c124946c9a 100644 --- a/src/test/run-pass/unboxed-closures-generic.rs +++ b/src/test/run-pass/unboxed-closures-generic.rs @@ -12,12 +12,12 @@ use std::ops::FnMut; -fn call_it>(y: int, mut f: F) -> int { +fn call_iti32>(y: i32, mut f: F) -> i32 { f(2, y) } pub fn main() { - let f = |&mut: x: int, y: int| -> int { x + y }; + let f = |&mut: x: i32, y: i32| -> i32 { x + y }; let z = call_it(3, f); println!("{}", z); assert_eq!(z, 5); diff --git a/src/test/run-pass/unboxed-closures-manual-impl.rs b/src/test/run-pass/unboxed-closures-manual-impl.rs index 88c9ceae4a12..37075de0405a 100644 --- a/src/test/run-pass/unboxed-closures-manual-impl.rs +++ b/src/test/run-pass/unboxed-closures-manual-impl.rs @@ -15,17 +15,19 @@ use std::ops::FnMut; struct S; -impl FnMut<(int,),int> for S { - extern "rust-call" fn call_mut(&mut self, (x,): (int,)) -> int { +impl FnMut<(i32,)> for S { + type Output = i32; + + extern "rust-call" fn call_mut(&mut self, (x,): (i32,)) -> i32 { x * x } } -fn call_itint>(mut f: F, x: int) -> int { +fn call_iti32>(mut f: F, x: i32) -> i32 { f(x) + 3 } -fn call_box(f: &mut FnMut(int) -> int, x: int) -> int { +fn call_box(f: &mut FnMut(i32) -> i32, x: i32) -> i32 { f(x) + 3 } diff --git a/src/test/run-pass/unboxed-closures-monomorphization.rs b/src/test/run-pass/unboxed-closures-monomorphization.rs index 6701f879e4f2..6dfa4c124e24 100644 --- a/src/test/run-pass/unboxed-closures-monomorphization.rs +++ b/src/test/run-pass/unboxed-closures-monomorphization.rs @@ -16,17 +16,17 @@ #![feature(unboxed_closures)] fn main(){ - fn bar<'a, T:Clone+'a> (t: T) -> Box + 'a> { + fn bar<'a, T:Clone+'a> (t: T) -> BoxT + 'a> { box move |&mut:| t.clone() } - let mut f = bar(42u); + let mut f = bar(42_u32); assert_eq!(f.call_mut(()), 42); let mut f = bar("forty-two"); assert_eq!(f.call_mut(()), "forty-two"); - let x = 42u; + let x = 42_u32; let mut f = bar(&x); assert_eq!(f.call_mut(()), &x); diff --git a/src/test/run-pass/unboxed-closures-sugar-object.rs b/src/test/run-pass/unboxed-closures-sugar-object.rs index d65de438514f..fff841a2f052 100644 --- a/src/test/run-pass/unboxed-closures-sugar-object.rs +++ b/src/test/run-pass/unboxed-closures-sugar-object.rs @@ -29,7 +29,7 @@ impl Getter for Identity { } fn main() { - let x: &Getter(int) -> (int,) = &Identity; + let x: &Getter<(i32,), (i32,)> = &Identity; let (y,) = x.get((22,)); assert_eq!(y, 22); }