]> git.lizzy.rs Git - rust.git/blob - src/test/ui/c-variadic/variadic-ffi-4.rs
Merge commit 'f2cdd4a78d89c009342197cf5844a21f8aa813df' into sync_cg_clif-2022-04-22
[rust.git] / src / test / ui / c-variadic / variadic-ffi-4.rs
1 #![crate_type = "lib"]
2 #![no_std]
3 #![feature(c_variadic)]
4
5 use core::ffi::{VaList, VaListImpl};
6
7 pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaListImpl<'f> {
8     ap
9     //~^ ERROR: lifetime may not live long enough
10     //~| ERROR: lifetime may not live long enough
11 }
12
13 pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaListImpl<'static> {
14     ap //~ ERROR: lifetime may not live long enough
15 }
16
17 pub unsafe extern "C" fn no_escape2(_: usize, ap: ...) {
18     let _ = ap.with_copy(|ap| ap); //~ ERROR: lifetime may not live long enough
19 }
20
21 pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
22     *ap0 = ap1;
23     //~^ ERROR: lifetime may not live long enough
24     //~| ERROR: lifetime may not live long enough
25 }
26
27 pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
28     ap0 = &mut ap1;
29     //~^ ERROR: `ap1` does not live long enough
30     //~| ERROR: lifetime may not live long enough
31     //~| ERROR: lifetime may not live long enough
32 }
33
34 pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
35     *ap0 = ap1.clone();
36     //~^ ERROR: lifetime may not live long enough
37     //~| ERROR: lifetime may not live long enough
38 }