diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-4f9fe856a25ab29345b90e7725509e9ee38a37be.tar.xz rustc-4f9fe856a25ab29345b90e7725509e9ee38a37be.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs index 52bd8136d..757c6538d 100644 --- a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs +++ b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs @@ -1,27 +1,49 @@ -// Make sure that an error is reported if the `call` function of the -// `fn`/`fn_mut` lang item is grossly ill-formed. +// revisions: fn_once_bad_item fn_once_bad_sig fn_mut_bad_item fn_mut_bad_sig fn_bad_item fn_bad_sig #![feature(lang_items)] #![feature(no_core)] #![no_core] +#[lang = "sized"] +trait Sized {} + +#[cfg(any(fn_bad_item, fn_bad_sig))] #[lang = "fn"] trait MyFn<T> { + #[cfg(fn_bad_sig)] + fn call(i: i32) -> i32 { 0 } + + #[cfg(fn_bad_item)] const call: i32 = 42; - //~^ ERROR: `call` trait item in `fn` lang item must be a function } +#[cfg(any(fn_mut_bad_item, fn_mut_bad_sig))] #[lang = "fn_mut"] trait MyFnMut<T> { - fn call(i: i32, j: i32) -> i32 { i + j } - //~^ ERROR: first argument of `call` in `fn_mut` lang item must be a reference + #[cfg(fn_mut_bad_sig)] + fn call_mut(i: i32) -> i32 { 0 } + + #[cfg(fn_mut_bad_item)] + const call_mut: i32 = 42; +} + +#[cfg(any(fn_once_bad_item, fn_once_bad_sig))] +#[lang = "fn_once"] +trait MyFnOnce<T> { + #[cfg(fn_once_bad_sig)] + fn call_once(i: i32) -> i32 { 0 } + + #[cfg(fn_once_bad_item)] + const call_once: i32 = 42; } fn main() { let a = || 42; a(); + //~^ ERROR failed to find an overloaded call trait for closure call let mut i = 0; - let mut b = || { i += 1; }; + let mut b = || { }; b(); + //~^ ERROR failed to find an overloaded call trait for closure call } |