diff options
Diffstat (limited to 'tests/ui')
5 files changed, 99 insertions, 24 deletions
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs new file mode 100644 index 00000000000..9317ab5cd27 --- /dev/null +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs @@ -0,0 +1,69 @@ +//@ add-core-stubs +//@ edition: 2018 +//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib +//@ needs-llvm-components: arm +#![feature(cmse_nonsecure_entry, c_variadic, no_core, lang_items)] +#![no_core] + +extern crate minicore; +use minicore::*; + +#[lang = "va_list"] +struct VaList(*mut u8); + +unsafe extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { + //~^ ERROR `...` is not supported for `extern "cmse-nonsecure-entry"` functions +} + +// A regression test for https://github.com/rust-lang/rust/issues/132142 +async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...) { + //~^ ERROR `...` is not supported for `extern "cmse-nonsecure-entry"` functions + //~| ERROR functions cannot be both `async` and C-variadic +} + +// Below are the lang items that are required for a program that defines an `async` function. +// Without them, the ICE that is tested for here is not reached for this target. For now they are in +// this file, but they may be moved into `minicore` if/when other `#[no_core]` tests want to use +// them. + +// NOTE: in `core` this type uses `NonNull`. +#[lang = "ResumeTy"] +pub struct ResumeTy(*mut Context<'static>); + +#[lang = "future_trait"] +pub trait Future { + /// The type of value produced on completion. + #[lang = "future_output"] + type Output; + + // NOTE: misses the `poll` method. +} + +#[lang = "async_drop"] +pub trait AsyncDrop { + // NOTE: misses the `drop` method. +} + +#[lang = "Poll"] +pub enum Poll<T> { + #[lang = "Ready"] + Ready(T), + + #[lang = "Pending"] + Pending, +} + +#[lang = "Context"] +pub struct Context<'a> { + // NOTE: misses a bunch of fields. + _marker: PhantomData<fn(&'a ()) -> &'a ()>, +} + +#[lang = "get_context"] +pub unsafe fn get_context<'a, 'b>(cx: ResumeTy) -> &'a mut Context<'b> { + // NOTE: the actual implementation looks different. + mem::transmute(cx.0) +} + +#[lang = "pin"] +pub struct Pin<T>(T); diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.stderr new file mode 100644 index 00000000000..948f8f5747b --- /dev/null +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.stderr @@ -0,0 +1,28 @@ +error: `...` is not supported for `extern "cmse-nonsecure-entry"` functions + --> $DIR/c-variadic.rs:14:60 + | +LL | unsafe extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { + | ----------------------------- ^^^^^^ + | | + | `extern "cmse-nonsecure-entry"` because of this + | + = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list + +error: functions cannot be both `async` and C-variadic + --> $DIR/c-variadic.rs:19:1 + | +LL | async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...) { + | ^^^^^ `async` because of this ^^^^^^ C-variadic because of this + +error: `...` is not supported for `extern "cmse-nonsecure-entry"` functions + --> $DIR/c-variadic.rs:19:68 + | +LL | async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...) { + | ----------------------------- ^^^^^^ + | | + | `extern "cmse-nonsecure-entry"` because of this + | + = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list + +error: aborting due to 3 previous errors + diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs index eb6f4a32365..aee01e25ddc 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs @@ -1,7 +1,7 @@ //@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm -#![feature(cmse_nonsecure_entry, c_variadic, no_core, lang_items)] +#![feature(cmse_nonsecure_entry, no_core, lang_items)] #![no_core] extern crate minicore; @@ -65,8 +65,3 @@ extern "cmse-nonsecure-entry" fn wrapped_trait_object(x: WrapperTransparent) -> //~^ ERROR return value of `"cmse-nonsecure-entry"` function too large to pass via registers [E0798] x } - -unsafe extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { - //~^ ERROR `...` is not supported for `extern "cmse-nonsecure-entry"` functions - //~| ERROR requires `va_list` lang_item -} diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr index 8937def9428..df1a9107043 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr @@ -1,13 +1,3 @@ -error: `...` is not supported for `extern "cmse-nonsecure-entry"` functions - --> $DIR/generics.rs:69:60 - | -LL | unsafe extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { - | ----------------------------- ^^^^^^ - | | - | `extern "cmse-nonsecure-entry"` because of this - | - = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list - error[E0798]: functions with the `"cmse-nonsecure-entry"` ABI cannot contain generics in their type --> $DIR/generics.rs:30:1 | @@ -71,12 +61,6 @@ LL | extern "cmse-nonsecure-entry" fn wrapped_trait_object(x: WrapperTransparent = note: functions with the `"cmse-nonsecure-entry"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error: requires `va_list` lang_item - --> $DIR/generics.rs:69:60 - | -LL | unsafe extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { - | ^^^^^^ - -error: aborting due to 9 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0798`. diff --git a/tests/ui/rfcs/rfc-2091-track-caller/file-is-nul-terminated.rs b/tests/ui/rfcs/rfc-2091-track-caller/file-is-nul-terminated.rs index 7902f40b09b..698492966ad 100644 --- a/tests/ui/rfcs/rfc-2091-track-caller/file-is-nul-terminated.rs +++ b/tests/ui/rfcs/rfc-2091-track-caller/file-is-nul-terminated.rs @@ -1,5 +1,4 @@ //@ run-pass -#![feature(file_with_nul)] #[track_caller] const fn assert_file_has_trailing_zero() { |
