diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 3ec8f9f5d14..416b555db5c 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1557,11 +1557,17 @@ fn check_fn_or_method<'tcx>( tcx.require_lang_item(hir::LangItem::Tuple, Some(span)), ); } else { - tcx.sess.span_err(span, "functions with the \"rust-call\" ABI must take a single non-self argument that is a tuple"); + tcx.sess.span_err( + hir_decl.inputs.last().map_or(span, |input| input.span), + "functions with the \"rust-call\" ABI must take a single non-self tuple argument", + ); } // No more inputs other than the `self` type and the tuple type if inputs.next().is_some() { - tcx.sess.span_err(span, "functions with the \"rust-call\" ABI must take a single non-self argument that is a tuple"); + tcx.sess.span_err( + hir_decl.inputs.last().map_or(span, |input| input.span), + "functions with the \"rust-call\" ABI must take a single non-self tuple argument", + ); } } } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 2239a33a8e9..4066cca8a4b 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -215,7 +215,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "cannot use call notation; the first type parameter \ for the function trait is neither a tuple nor unit" ) - .emit(); + .delay_as_bug(); (self.err_args(provided_args.len()), None) } } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index dacce5cd2f6..46c03757e60 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -700,6 +700,25 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { } } + if Some(trait_ref.def_id()) == tcx.lang_items().tuple_trait() { + match obligation.cause.code().peel_derives() { + ObligationCauseCode::RustCall => { + err.set_primary_message("functions with the \"rust-call\" ABI must take a single non-self tuple argument"); + } + ObligationCauseCode::BindingObligation(def_id, _) + | ObligationCauseCode::ItemObligation(def_id) + if ty::ClosureKind::from_def_id(tcx, *def_id).is_some() => + { + err.code(rustc_errors::error_code!(E0059)); + err.set_primary_message(format!( + "type parameter to bare `{}` trait must be a tuple", + tcx.def_path_str(*def_id) + )); + } + _ => {} + } + } + if Some(trait_ref.def_id()) == tcx.lang_items().drop_trait() && predicate_is_const { @@ -848,12 +867,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ); } - let is_fn_trait = [ - self.tcx.lang_items().fn_trait(), - self.tcx.lang_items().fn_mut_trait(), - self.tcx.lang_items().fn_once_trait(), - ] - .contains(&Some(trait_ref.def_id())); + let is_fn_trait = ty::ClosureKind::from_def_id(tcx, trait_ref.def_id()).is_some(); let is_target_feature_fn = if let ty::FnDef(def_id, _) = *trait_ref.skip_binder().self_ty().kind() { diff --git a/src/test/ui/abi/issues/issue-22565-rust-call.rs b/src/test/ui/abi/issues/issue-22565-rust-call.rs index a08e0bfb5e5..a572666c888 100644 --- a/src/test/ui/abi/issues/issue-22565-rust-call.rs +++ b/src/test/ui/abi/issues/issue-22565-rust-call.rs @@ -1,32 +1,31 @@ #![feature(unboxed_closures)] extern "rust-call" fn b(_i: i32) {} -//~^ ERROR functions with the "rust-call" ABI must take a single non-self argument that is a tuple +//~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument trait Tr { extern "rust-call" fn a(); + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument extern "rust-call" fn b() {} - //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument } struct Foo; impl Foo { extern "rust-call" fn bar() {} - //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument } impl Tr for Foo { extern "rust-call" fn a() {} - //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument } -fn main () { +fn main() { b(10); - Foo::bar(); - ::a(); ::b(); } diff --git a/src/test/ui/abi/issues/issue-22565-rust-call.stderr b/src/test/ui/abi/issues/issue-22565-rust-call.stderr index 3eee10bc5e9..9d205b444fa 100644 --- a/src/test/ui/abi/issues/issue-22565-rust-call.stderr +++ b/src/test/ui/abi/issues/issue-22565-rust-call.stderr @@ -1,26 +1,33 @@ -error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple +error[E0277]: functions with the "rust-call" ABI must take a single non-self tuple argument --> $DIR/issue-22565-rust-call.rs:3:1 | LL | extern "rust-call" fn b(_i: i32) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `i32` -error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple - --> $DIR/issue-22565-rust-call.rs:9:5 - | -LL | extern "rust-call" fn b() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple - --> $DIR/issue-22565-rust-call.rs:16:5 +error: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/issue-22565-rust-call.rs:17:5 | LL | extern "rust-call" fn bar() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple - --> $DIR/issue-22565-rust-call.rs:21:5 +error: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/issue-22565-rust-call.rs:22:5 | LL | extern "rust-call" fn a() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/issue-22565-rust-call.rs:7:5 + | +LL | extern "rust-call" fn a(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/issue-22565-rust-call.rs:10:5 + | +LL | extern "rust-call" fn b() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/abi/rustcall-generic.rs b/src/test/ui/abi/rustcall-generic.rs index 411c98e1031..6eaccc436b6 100644 --- a/src/test/ui/abi/rustcall-generic.rs +++ b/src/test/ui/abi/rustcall-generic.rs @@ -2,9 +2,9 @@ // check-pass //[opt] compile-flags: -Zmir-opt-level=3 -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] -extern "rust-call" fn foo(_: T) {} +extern "rust-call" fn foo(_: T) {} fn main() { foo(()); diff --git a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.rs b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.rs index e2f016614bf..a3350024e75 100644 --- a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.rs +++ b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.rs @@ -1,4 +1,4 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] // Tests that we can't assign to or mutably borrow upvars from `Fn` // closures (issue #17780) @@ -7,10 +7,10 @@ fn set(x: &mut usize) { *x = 5; } -fn to_fn>(f: F) -> F { +fn to_fn>(f: F) -> F { f } -fn to_fn_mut>(f: F) -> F { +fn to_fn_mut>(f: F) -> F { f } diff --git a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr index 093589ed092..a0eaf1f163b 100644 --- a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr +++ b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr @@ -1,8 +1,8 @@ error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:21:27 | -LL | fn to_fn>(f: F) -> F { - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn>(f: F) -> F { + | - change this to accept `FnMut` instead of `Fn` ... LL | let _f = to_fn(|| x = 42); | ----- -- ^^^^^^ cannot assign @@ -13,8 +13,8 @@ LL | let _f = to_fn(|| x = 42); error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:24:31 | -LL | fn to_fn>(f: F) -> F { - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn>(f: F) -> F { + | - change this to accept `FnMut` instead of `Fn` ... LL | let _g = to_fn(|| set(&mut y)); | ----- -- ^^^^^^ cannot borrow as mutable @@ -25,8 +25,8 @@ LL | let _g = to_fn(|| set(&mut y)); error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:29:22 | -LL | fn to_fn>(f: F) -> F { - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn>(f: F) -> F { + | - change this to accept `FnMut` instead of `Fn` ... LL | to_fn(|| z = 42); | ----- -- ^^^^^^ cannot assign @@ -37,8 +37,8 @@ LL | to_fn(|| z = 42); error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:36:32 | -LL | fn to_fn>(f: F) -> F { - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn>(f: F) -> F { + | - change this to accept `FnMut` instead of `Fn` ... LL | let _f = to_fn(move || x = 42); | ----- ------- ^^^^^^ cannot assign @@ -49,8 +49,8 @@ LL | let _f = to_fn(move || x = 42); error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:39:36 | -LL | fn to_fn>(f: F) -> F { - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn>(f: F) -> F { + | - change this to accept `FnMut` instead of `Fn` ... LL | let _g = to_fn(move || set(&mut y)); | ----- ------- ^^^^^^ cannot borrow as mutable @@ -61,8 +61,8 @@ LL | let _g = to_fn(move || set(&mut y)); error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:44:27 | -LL | fn to_fn>(f: F) -> F { - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn>(f: F) -> F { + | - change this to accept `FnMut` instead of `Fn` ... LL | to_fn(move || z = 42); | ----- ------- ^^^^^^ cannot assign diff --git a/src/test/ui/borrowck/borrowck-move-by-capture.rs b/src/test/ui/borrowck/borrowck-move-by-capture.rs index f26edef17f3..6f0eb1870f3 100644 --- a/src/test/ui/borrowck/borrowck-move-by-capture.rs +++ b/src/test/ui/borrowck/borrowck-move-by-capture.rs @@ -1,7 +1,7 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] -fn to_fn_mut>(f: F) -> F { f } -fn to_fn_once>(f: F) -> F { f } +fn to_fn_mut>(f: F) -> F { f } +fn to_fn_once>(f: F) -> F { f } pub fn main() { let bar: Box<_> = Box::new(3); diff --git a/src/test/ui/c-variadic/issue-86053-1.stderr b/src/test/ui/c-variadic/issue-86053-1.stderr index 60b379faf4e..075bd1fc488 100644 --- a/src/test/ui/c-variadic/issue-86053-1.stderr +++ b/src/test/ui/c-variadic/issue-86053-1.stderr @@ -66,8 +66,8 @@ LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize | ::: $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn: FnMut { - | ------------------------------- similarly named trait `Fn` defined here +LL | pub trait Fn: FnMut { + | -------------------------------------- similarly named trait `Fn` defined here | help: a trait with a similar name exists | diff --git a/src/test/ui/cannot-mutate-captured-non-mut-var.rs b/src/test/ui/cannot-mutate-captured-non-mut-var.rs index a83884acb1d..952dab25bf9 100644 --- a/src/test/ui/cannot-mutate-captured-non-mut-var.rs +++ b/src/test/ui/cannot-mutate-captured-non-mut-var.rs @@ -1,8 +1,8 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] use std::io::Read; -fn to_fn_once>(f: F) -> F { f } +fn to_fn_once>(f: F) -> F { f } fn main() { let x = 1; diff --git a/src/test/ui/chalkify/closure.stderr b/src/test/ui/chalkify/closure.stderr index 515e0cf0142..ca62ad834bc 100644 --- a/src/test/ui/chalkify/closure.stderr +++ b/src/test/ui/chalkify/closure.stderr @@ -1,22 +1,80 @@ -error[E0382]: borrow of moved value: `b` +error[E0277]: `()` is not a tuple + --> $DIR/closure.rs:6:5 + | +LL | t(); + | ^^^ the trait `Tuple` is not implemented for `()` + | +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn main() -> () where (): Tuple { + | +++++++++++++++ + +error[E0277]: `()` is not a tuple + --> $DIR/closure.rs:12:5 + | +LL | b(); + | ^^^ the trait `Tuple` is not implemented for `()` + | +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn main() -> () where (): Tuple { + | +++++++++++++++ + +error[E0277]: `()` is not a tuple + --> $DIR/closure.rs:16:5 + | +LL | c(); + | ^^^ the trait `Tuple` is not implemented for `()` + | +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn main() -> () where (): Tuple { + | +++++++++++++++ + +error[E0277]: `()` is not a tuple + --> $DIR/closure.rs:17:5 + | +LL | b(); + | ^^^ the trait `Tuple` is not implemented for `()` + | +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn main() -> () where (): Tuple { + | +++++++++++++++ + +error[E0277]: `()` is not a tuple + --> $DIR/closure.rs:23:5 + | +LL | b(); + | ^^^ the trait `Tuple` is not implemented for `()` + | +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn main() -> () where (): Tuple { + | +++++++++++++++ + +error[E0277]: `()` is not a tuple + --> $DIR/closure.rs:27:5 + | +LL | c(); + | ^^^ the trait `Tuple` is not implemented for `()` + | +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn main() -> () where (): Tuple { + | +++++++++++++++ + +error[E0277]: `()` is not a tuple --> $DIR/closure.rs:28:5 | -LL | let mut c = b; - | - value moved here -... LL | b(); - | ^ value borrowed here after move + | ^^^ `()` is not a tuple | -note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment - --> $DIR/closure.rs:21:9 +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | -LL | a = 1; - | ^ -help: consider mutably borrowing `b` - | -LL | let mut c = &mut b; - | ++++ +LL | fn main() -> () where (): Tuple { + | +++++++++++++++ -error: aborting due to previous error +error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0382`. +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/closures/issue-78720.stderr b/src/test/ui/closures/issue-78720.stderr index 3dd13877298..da3f539a007 100644 --- a/src/test/ui/closures/issue-78720.stderr +++ b/src/test/ui/closures/issue-78720.stderr @@ -12,8 +12,8 @@ LL | _func: F, | ::: $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn: FnMut { - | ------------------------------- similarly named trait `Fn` defined here +LL | pub trait Fn: FnMut { + | -------------------------------------- similarly named trait `Fn` defined here | help: a trait with a similar name exists | diff --git a/src/test/ui/error-codes/E0059.stderr b/src/test/ui/error-codes/E0059.stderr index a1b8aeaedbb..f331d014226 100644 --- a/src/test/ui/error-codes/E0059.stderr +++ b/src/test/ui/error-codes/E0059.stderr @@ -1,8 +1,14 @@ -error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit - --> $DIR/E0059.rs:3:41 +error[E0059]: type parameter to bare `Fn` trait must be a tuple + --> $DIR/E0059.rs:3:11 | LL | fn foo>(f: F) -> F::Output { f(3) } - | ^^^^ + | ^^^^^^^ the trait `Tuple` is not implemented for `i32` + | +note: required by a bound in `Fn` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + | +LL | pub trait Fn: FnMut { + | ^^^^^ required by this bound in `Fn` error: aborting due to previous error diff --git a/src/test/ui/feature-gates/feature-gate-abi.rs b/src/test/ui/feature-gates/feature-gate-abi.rs index 855263595d0..15b674c62e4 100644 --- a/src/test/ui/feature-gates/feature-gate-abi.rs +++ b/src/test/ui/feature-gates/feature-gate-abi.rs @@ -9,6 +9,9 @@ #[lang="sized"] trait Sized { } +#[lang="tuple_trait"] +trait Tuple { } + // Functions extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change //~^ ERROR intrinsic must be in diff --git a/src/test/ui/feature-gates/feature-gate-abi.stderr b/src/test/ui/feature-gates/feature-gate-abi.stderr index bcca39c8fb8..33ec250f090 100644 --- a/src/test/ui/feature-gates/feature-gate-abi.stderr +++ b/src/test/ui/feature-gates/feature-gate-abi.stderr @@ -1,5 +1,5 @@ error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:13:8 + --> $DIR/feature-gate-abi.rs:16:8 | LL | extern "rust-intrinsic" fn f1() {} | ^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | extern "rust-intrinsic" fn f1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:15:8 + --> $DIR/feature-gate-abi.rs:18:8 | LL | extern "platform-intrinsic" fn f2() {} | ^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | extern "platform-intrinsic" fn f2() {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:17:8 + --> $DIR/feature-gate-abi.rs:20:8 | LL | extern "rust-call" fn f4(_: ()) {} | ^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | extern "rust-call" fn f4(_: ()) {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:18:8 + --> $DIR/feature-gate-abi.rs:21:8 | LL | extern "efiapi" fn f10() {} | ^^^^^^^^ @@ -34,7 +34,7 @@ LL | extern "efiapi" fn f10() {} = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:22:12 + --> $DIR/feature-gate-abi.rs:25:12 | LL | extern "rust-intrinsic" fn m1(); | ^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL | extern "rust-intrinsic" fn m1(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:24:12 + --> $DIR/feature-gate-abi.rs:27:12 | LL | extern "platform-intrinsic" fn m2(); | ^^^^^^^^^^^^^^^^^^^^ @@ -51,7 +51,7 @@ LL | extern "platform-intrinsic" fn m2(); = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:26:12 + --> $DIR/feature-gate-abi.rs:29:12 | LL | extern "rust-call" fn m4(_: ()); | ^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | extern "rust-call" fn m4(_: ()); = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:27:12 + --> $DIR/feature-gate-abi.rs:30:12 | LL | extern "efiapi" fn m10(); | ^^^^^^^^ @@ -69,7 +69,7 @@ LL | extern "efiapi" fn m10(); = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:29:12 + --> $DIR/feature-gate-abi.rs:32:12 | LL | extern "rust-call" fn dm4(_: ()) {} | ^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | extern "rust-call" fn dm4(_: ()) {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:30:12 + --> $DIR/feature-gate-abi.rs:33:12 | LL | extern "efiapi" fn dm10() {} | ^^^^^^^^ @@ -87,7 +87,7 @@ LL | extern "efiapi" fn dm10() {} = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:37:12 + --> $DIR/feature-gate-abi.rs:40:12 | LL | extern "rust-intrinsic" fn m1() {} | ^^^^^^^^^^^^^^^^ @@ -95,7 +95,7 @@ LL | extern "rust-intrinsic" fn m1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:39:12 + --> $DIR/feature-gate-abi.rs:42:12 | LL | extern "platform-intrinsic" fn m2() {} | ^^^^^^^^^^^^^^^^^^^^ @@ -104,7 +104,7 @@ LL | extern "platform-intrinsic" fn m2() {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:41:12 + --> $DIR/feature-gate-abi.rs:44:12 | LL | extern "rust-call" fn m4(_: ()) {} | ^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | extern "rust-call" fn m4(_: ()) {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:42:12 + --> $DIR/feature-gate-abi.rs:45:12 | LL | extern "efiapi" fn m10() {} | ^^^^^^^^ @@ -122,7 +122,7 @@ LL | extern "efiapi" fn m10() {} = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:47:12 + --> $DIR/feature-gate-abi.rs:50:12 | LL | extern "rust-intrinsic" fn im1() {} | ^^^^^^^^^^^^^^^^ @@ -130,7 +130,7 @@ LL | extern "rust-intrinsic" fn im1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:49:12 + --> $DIR/feature-gate-abi.rs:52:12 | LL | extern "platform-intrinsic" fn im2() {} | ^^^^^^^^^^^^^^^^^^^^ @@ -139,7 +139,7 @@ LL | extern "platform-intrinsic" fn im2() {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:51:12 + --> $DIR/feature-gate-abi.rs:54:12 | LL | extern "rust-call" fn im4(_: ()) {} | ^^^^^^^^^^^ @@ -148,7 +148,7 @@ LL | extern "rust-call" fn im4(_: ()) {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:52:12 + --> $DIR/feature-gate-abi.rs:55:12 | LL | extern "efiapi" fn im10() {} | ^^^^^^^^ @@ -157,7 +157,7 @@ LL | extern "efiapi" fn im10() {} = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:56:18 + --> $DIR/feature-gate-abi.rs:59:18 | LL | type A1 = extern "rust-intrinsic" fn(); | ^^^^^^^^^^^^^^^^ @@ -165,7 +165,7 @@ LL | type A1 = extern "rust-intrinsic" fn(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:57:18 + --> $DIR/feature-gate-abi.rs:60:18 | LL | type A2 = extern "platform-intrinsic" fn(); | ^^^^^^^^^^^^^^^^^^^^ @@ -174,7 +174,7 @@ LL | type A2 = extern "platform-intrinsic" fn(); = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:58:18 + --> $DIR/feature-gate-abi.rs:61:18 | LL | type A4 = extern "rust-call" fn(_: ()); | ^^^^^^^^^^^ @@ -183,7 +183,7 @@ LL | type A4 = extern "rust-call" fn(_: ()); = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:59:19 + --> $DIR/feature-gate-abi.rs:62:19 | LL | type A10 = extern "efiapi" fn(); | ^^^^^^^^ @@ -192,7 +192,7 @@ LL | type A10 = extern "efiapi" fn(); = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:62:8 + --> $DIR/feature-gate-abi.rs:65:8 | LL | extern "rust-intrinsic" {} | ^^^^^^^^^^^^^^^^ @@ -200,7 +200,7 @@ LL | extern "rust-intrinsic" {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:63:8 + --> $DIR/feature-gate-abi.rs:66:8 | LL | extern "platform-intrinsic" {} | ^^^^^^^^^^^^^^^^^^^^ @@ -209,7 +209,7 @@ LL | extern "platform-intrinsic" {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:64:8 + --> $DIR/feature-gate-abi.rs:67:8 | LL | extern "rust-call" {} | ^^^^^^^^^^^ @@ -218,7 +218,7 @@ LL | extern "rust-call" {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:65:8 + --> $DIR/feature-gate-abi.rs:68:8 | LL | extern "efiapi" {} | ^^^^^^^^ @@ -227,49 +227,49 @@ LL | extern "efiapi" {} = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:22:32 + --> $DIR/feature-gate-abi.rs:25:32 | LL | extern "rust-intrinsic" fn m1(); | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:24:36 + --> $DIR/feature-gate-abi.rs:27:36 | LL | extern "platform-intrinsic" fn m2(); | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:13:33 + --> $DIR/feature-gate-abi.rs:16:33 | LL | extern "rust-intrinsic" fn f1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:15:37 + --> $DIR/feature-gate-abi.rs:18:37 | LL | extern "platform-intrinsic" fn f2() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:37:37 + --> $DIR/feature-gate-abi.rs:40:37 | LL | extern "rust-intrinsic" fn m1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:39:41 + --> $DIR/feature-gate-abi.rs:42:41 | LL | extern "platform-intrinsic" fn m2() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:47:38 + --> $DIR/feature-gate-abi.rs:50:38 | LL | extern "rust-intrinsic" fn im1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:49:42 + --> $DIR/feature-gate-abi.rs:52:42 | LL | extern "platform-intrinsic" fn im2() {} | ^^ diff --git a/src/test/ui/issues/issue-12127.rs b/src/test/ui/issues/issue-12127.rs index 8b30ddc2de6..199d542e816 100644 --- a/src/test/ui/issues/issue-12127.rs +++ b/src/test/ui/issues/issue-12127.rs @@ -1,6 +1,6 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] -fn to_fn_once>(f: F) -> F { f } +fn to_fn_once>(f: F) -> F { f } fn do_it(x: &isize) { } fn main() { diff --git a/src/test/ui/issues/issue-23024.stderr b/src/test/ui/issues/issue-23024.stderr index 73f93c51d34..dc8b34a70c3 100644 --- a/src/test/ui/issues/issue-23024.stderr +++ b/src/test/ui/issues/issue-23024.stderr @@ -16,7 +16,7 @@ LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); note: trait defined here, with 1 generic parameter: `Args` --> $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn: FnMut { +LL | pub trait Fn: FnMut { | ^^ ---- help: add missing generic argument | diff --git a/src/test/ui/issues/issue-7607-1.stderr b/src/test/ui/issues/issue-7607-1.stderr index ecff8b42b0e..f1ab0ad26d7 100644 --- a/src/test/ui/issues/issue-7607-1.stderr +++ b/src/test/ui/issues/issue-7607-1.stderr @@ -6,8 +6,8 @@ LL | impl Fo { | ::: $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn: FnMut { - | ------------------------------- similarly named trait `Fn` defined here +LL | pub trait Fn: FnMut { + | -------------------------------------- similarly named trait `Fn` defined here error: aborting due to previous error diff --git a/src/test/ui/lang-items/lang-item-missing-generator.rs b/src/test/ui/lang-items/lang-item-missing-generator.rs index 0c329542928..9b9aff38e52 100644 --- a/src/test/ui/lang-items/lang-item-missing-generator.rs +++ b/src/test/ui/lang-items/lang-item-missing-generator.rs @@ -1,12 +1,14 @@ // error-pattern: requires `generator` lang_item -#![feature(no_core, lang_items, unboxed_closures)] +#![feature(no_core, lang_items, unboxed_closures, tuple_trait)] #![no_core] #[lang = "sized"] pub trait Sized { } +#[lang = "tuple_trait"] pub trait Tuple { } + #[lang = "fn_once"] #[rustc_paren_sugar] -pub trait FnOnce { +pub trait FnOnce { type Output; extern "rust-call" fn call_once(self, args: Args) -> Self::Output; diff --git a/src/test/ui/lang-items/lang-item-missing-generator.stderr b/src/test/ui/lang-items/lang-item-missing-generator.stderr index fa13bf0b127..a24fdb5fb65 100644 --- a/src/test/ui/lang-items/lang-item-missing-generator.stderr +++ b/src/test/ui/lang-items/lang-item-missing-generator.stderr @@ -1,8 +1,15 @@ +error[E0635]: unknown feature `tuple_trait` + --> $DIR/lang-item-missing-generator.rs:2:51 + | +LL | #![feature(no_core, lang_items, unboxed_closures, tuple_trait)] + | ^^^^^^^^^^^ + error: requires `generator` lang_item - --> $DIR/lang-item-missing-generator.rs:15:17 + --> $DIR/lang-item-missing-generator.rs:17:17 | LL | pub fn abc() -> impl FnOnce(f32) { | ^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0635`. diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs index 8dbe3472ea8..307104e47a1 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs @@ -1,8 +1,8 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures,tuple_trait)] use std::ops::FnMut; -fn to_fn_mut>(f: F) -> F { f } +fn to_fn_mut>(f: F) -> F { f } fn call_it isize>(y: isize, mut f: F) -> isize { //~^ NOTE required by this bound in `call_it` diff --git a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs index 76b7aab542d..490d91ac118 100644 --- a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs +++ b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs @@ -1,6 +1,6 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] -fn to_fn>(f: F) -> F { f } +fn to_fn>(f: F) -> F { f } fn test(_x: Box) {} diff --git a/src/test/ui/overloaded/overloaded-calls-nontuple.rs b/src/test/ui/overloaded/overloaded-calls-nontuple.rs index 07d44ff82b1..32a3b93e0a1 100644 --- a/src/test/ui/overloaded/overloaded-calls-nontuple.rs +++ b/src/test/ui/overloaded/overloaded-calls-nontuple.rs @@ -8,22 +8,23 @@ struct S { } impl FnMut for S { + //~^ ERROR type parameter to bare `FnMut` trait must be a tuple extern "rust-call" fn call_mut(&mut self, z: isize) -> isize { + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument self.x + self.y + z } - //~^^^ ERROR functions with the "rust-call" ABI must take a single non-self argument } impl FnOnce for S { + //~^ ERROR type parameter to bare `FnOnce` trait must be a tuple type Output = isize; - extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) } - //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument + extern "rust-call" fn call_once(mut self, z: isize) -> isize { + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument + self.call_mut(z) + } } fn main() { - let mut s = S { - x: 1, - y: 2, - }; - drop(s(3)) //~ ERROR cannot use call notation + let mut s = S { x: 1, y: 2 }; + drop(s(3)) } diff --git a/src/test/ui/overloaded/overloaded-calls-nontuple.stderr b/src/test/ui/overloaded/overloaded-calls-nontuple.stderr index 8f299bc9434..794535aeb11 100644 --- a/src/test/ui/overloaded/overloaded-calls-nontuple.stderr +++ b/src/test/ui/overloaded/overloaded-calls-nontuple.stderr @@ -1,21 +1,40 @@ -error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple - --> $DIR/overloaded-calls-nontuple.rs:11:5 +error[E0059]: type parameter to bare `FnMut` trait must be a tuple + --> $DIR/overloaded-calls-nontuple.rs:10:6 + | +LL | impl FnMut for S { + | ^^^^^^^^^^^^ the trait `Tuple` is not implemented for `isize` + | +note: required by a bound in `FnMut` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + | +LL | pub trait FnMut: FnOnce { + | ^^^^^ required by this bound in `FnMut` + +error[E0059]: type parameter to bare `FnOnce` trait must be a tuple + --> $DIR/overloaded-calls-nontuple.rs:18:6 + | +LL | impl FnOnce for S { + | ^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `isize` + | +note: required by a bound in `FnOnce` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + | +LL | pub trait FnOnce { + | ^^^^^ required by this bound in `FnOnce` + +error[E0277]: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/overloaded-calls-nontuple.rs:12:5 | LL | extern "rust-call" fn call_mut(&mut self, z: isize) -> isize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `isize` -error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple - --> $DIR/overloaded-calls-nontuple.rs:19:5 +error[E0277]: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/overloaded-calls-nontuple.rs:21:5 | -LL | extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "rust-call" fn call_once(mut self, z: isize) -> isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `isize` -error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit - --> $DIR/overloaded-calls-nontuple.rs:28:10 - | -LL | drop(s(3)) - | ^^^^ +error: aborting due to 4 previous errors -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0059`. +Some errors have detailed explanations: E0059, E0277. +For more information about an error, try `rustc --explain E0059`. diff --git a/src/test/ui/span/issue-11925.rs b/src/test/ui/span/issue-11925.rs index d9c08fbdd0f..cac9fd5bfb6 100644 --- a/src/test/ui/span/issue-11925.rs +++ b/src/test/ui/span/issue-11925.rs @@ -1,6 +1,6 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] -fn to_fn_once>(f: F) -> F { f } +fn to_fn_once>(f: F) -> F { f } fn main() { let r = { diff --git a/src/test/ui/typeck/issue-83693.stderr b/src/test/ui/typeck/issue-83693.stderr index 0d8bbf1ce98..1e45c2d35df 100644 --- a/src/test/ui/typeck/issue-83693.stderr +++ b/src/test/ui/typeck/issue-83693.stderr @@ -6,8 +6,8 @@ LL | impl F { | ::: $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | pub trait Fn: FnMut { - | ------------------------------- similarly named trait `Fn` defined here +LL | pub trait Fn: FnMut { + | -------------------------------------- similarly named trait `Fn` defined here error[E0412]: cannot find type `TestResult` in this scope --> $DIR/issue-83693.rs:9:22 diff --git a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.rs b/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.rs index ed8d7211461..7377359b6b0 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.rs @@ -1,12 +1,12 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] // Tests that we can't move out of an unboxed closure environment // if the upvar is captured by ref or the closure takes self by // reference. -fn to_fn>(f: F) -> F { f } -fn to_fn_mut>(f: F) -> F { f } -fn to_fn_once>(f: F) -> F { f } +fn to_fn>(f: F) -> F { f } +fn to_fn_mut>(f: F) -> F { f } +fn to_fn_once>(f: F) -> F { f } fn main() { // By-ref cases diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs index 57e6d30658c..c57312b4387 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs @@ -2,12 +2,12 @@ // as `mut` through a closure. Also test that we CAN mutate a moved copy, // unless this is a `Fn` closure. Issue #16749. -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] use std::mem; -fn to_fn>(f: F) -> F { f } -fn to_fn_mut>(f: F) -> F { f } +fn to_fn>(f: F) -> F { f } +fn to_fn_mut>(f: F) -> F { f } fn a() { let n = 0; diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr index d6e74b5b8b9..26f97b51913 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr @@ -28,8 +28,8 @@ LL | n += 1; error[E0594]: cannot assign to `n`, as it is a captured variable in a `Fn` closure --> $DIR/unboxed-closures-mutate-upvar.rs:53:9 | -LL | fn to_fn>(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn>(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... LL | let mut f = to_fn(move || { | ----- ------- in this closure diff --git a/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.rs b/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.rs index 0e727b11cd2..7289d9322d0 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.rs @@ -1,6 +1,6 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] -fn to_fn_mut>(f: F) -> F { f } +fn to_fn_mut>(f: F) -> F { f } fn main() { let mut_ = to_fn_mut(|x| x);