Adjust diagnostics, bless tests

This commit is contained in:
Michael Goulet 2022-07-30 05:37:48 +00:00
parent 99b3454d37
commit 2257ba92db
31 changed files with 280 additions and 158 deletions

View File

@ -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",
);
}
}
}

View File

@ -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)
}
}

View File

@ -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()
{

View File

@ -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();
<Foo as Tr>::a();
<Foo as Tr>::b();
}

View File

@ -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`.

View File

@ -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>(_: T) {}
extern "rust-call" fn foo<T: std::marker::Tuple>(_: T) {}
fn main() {
foo(());

View File

@ -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<A, F: Fn<A>>(f: F) -> F {
fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
f
}
fn to_fn_mut<A, F: FnMut<A>>(f: F) -> F {
fn to_fn_mut<A: std::marker::Tuple, F: FnMut<A>>(f: F) -> F {
f
}

View File

@ -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<A, F: Fn<A>>(f: F) -> F {
| - change this to accept `FnMut` instead of `Fn`
LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(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<A, F: Fn<A>>(f: F) -> F {
| - change this to accept `FnMut` instead of `Fn`
LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(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<A, F: Fn<A>>(f: F) -> F {
| - change this to accept `FnMut` instead of `Fn`
LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(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<A, F: Fn<A>>(f: F) -> F {
| - change this to accept `FnMut` instead of `Fn`
LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(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<A, F: Fn<A>>(f: F) -> F {
| - change this to accept `FnMut` instead of `Fn`
LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(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<A, F: Fn<A>>(f: F) -> F {
| - change this to accept `FnMut` instead of `Fn`
LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
| - change this to accept `FnMut` instead of `Fn`
...
LL | to_fn(move || z = 42);
| ----- ------- ^^^^^^ cannot assign

View File

@ -1,7 +1,7 @@
#![feature(unboxed_closures)]
#![feature(unboxed_closures, tuple_trait)]
fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f }
fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f }
fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f }
fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f }
pub fn main() {
let bar: Box<_> = Box::new(3);

View File

@ -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<Args>: FnMut<Args> {
| ------------------------------- similarly named trait `Fn` defined here
LL | pub trait Fn<Args: Tuple>: FnMut<Args> {
| -------------------------------------- similarly named trait `Fn` defined here
|
help: a trait with a similar name exists
|

View File

@ -1,8 +1,8 @@
#![feature(unboxed_closures)]
#![feature(unboxed_closures, tuple_trait)]
use std::io::Read;
fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f }
fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f }
fn main() {
let x = 1;

View File

@ -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`.

View File

@ -12,8 +12,8 @@ LL | _func: F,
|
::: $SRC_DIR/core/src/ops/function.rs:LL:COL
|
LL | pub trait Fn<Args>: FnMut<Args> {
| ------------------------------- similarly named trait `Fn` defined here
LL | pub trait Fn<Args: Tuple>: FnMut<Args> {
| -------------------------------------- similarly named trait `Fn` defined here
|
help: a trait with a similar name exists
|

View File

@ -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: Fn<i32>>(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<Args: Tuple>: FnMut<Args> {
| ^^^^^ required by this bound in `Fn`
error: aborting due to previous error

View File

@ -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

View File

@ -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() {}
| ^^

View File

@ -1,6 +1,6 @@
#![feature(unboxed_closures)]
#![feature(unboxed_closures, tuple_trait)]
fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f }
fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f }
fn do_it(x: &isize) { }
fn main() {

View File

@ -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<Args>: FnMut<Args> {
LL | pub trait Fn<Args: Tuple>: FnMut<Args> {
| ^^ ----
help: add missing generic argument
|

View File

@ -6,8 +6,8 @@ LL | impl Fo {
|
::: $SRC_DIR/core/src/ops/function.rs:LL:COL
|
LL | pub trait Fn<Args>: FnMut<Args> {
| ------------------------------- similarly named trait `Fn` defined here
LL | pub trait Fn<Args: Tuple>: FnMut<Args> {
| -------------------------------------- similarly named trait `Fn` defined here
error: aborting due to previous error

View File

@ -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<Args> {
pub trait FnOnce<Args: Tuple> {
type Output;
extern "rust-call" fn call_once(self, args: Args) -> Self::Output;

View File

@ -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`.

View File

@ -1,8 +1,8 @@
#![feature(unboxed_closures)]
#![feature(unboxed_closures,tuple_trait)]
use std::ops::FnMut;
fn to_fn_mut<A, F: FnMut<A>>(f: F) -> F { f }
fn to_fn_mut<A:std::marker::Tuple, F:FnMut<A>>(f: F) -> F { f }
fn call_it<F: FnMut(isize, isize) -> isize>(y: isize, mut f: F) -> isize {
//~^ NOTE required by this bound in `call_it`

View File

@ -1,6 +1,6 @@
#![feature(unboxed_closures)]
#![feature(unboxed_closures, tuple_trait)]
fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f }
fn test(_x: Box<usize>) {}

View File

@ -8,22 +8,23 @@ struct S {
}
impl FnMut<isize> 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<isize> 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))
}

View File

@ -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<isize> 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<Args: Tuple>: FnOnce<Args> {
| ^^^^^ 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<isize> 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<Args: Tuple> {
| ^^^^^ 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`.

View File

@ -1,6 +1,6 @@
#![feature(unboxed_closures)]
#![feature(unboxed_closures, tuple_trait)]
fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f }
fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f }
fn main() {
let r = {

View File

@ -6,8 +6,8 @@ LL | impl F {
|
::: $SRC_DIR/core/src/ops/function.rs:LL:COL
|
LL | pub trait Fn<Args>: FnMut<Args> {
| ------------------------------- similarly named trait `Fn` defined here
LL | pub trait Fn<Args: Tuple>: FnMut<Args> {
| -------------------------------------- similarly named trait `Fn` defined here
error[E0412]: cannot find type `TestResult` in this scope
--> $DIR/issue-83693.rs:9:22

View File

@ -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<A,F:Fn<A>>(f: F) -> F { f }
fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f }
fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f }
fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f }
fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f }
fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f }
fn main() {
// By-ref cases

View File

@ -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<A,F:Fn<A>>(f: F) -> F { f }
fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f }
fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f }
fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f }
fn a() {
let n = 0;

View File

@ -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<A,F:Fn<A>>(f: F) -> F { f }
| - change this to accept `FnMut` instead of `Fn`
LL | fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f }
| - change this to accept `FnMut` instead of `Fn`
...
LL | let mut f = to_fn(move || {
| ----- ------- in this closure

View File

@ -1,6 +1,6 @@
#![feature(unboxed_closures)]
#![feature(unboxed_closures, tuple_trait)]
fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f }
fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f }
fn main() {
let mut_ = to_fn_mut(|x| x);