summary refs log tree commit diff
path: root/src/test/ui/c-variadic/variadic-ffi-4.rs
blob: 1c77479d02f4055ff120e5be72e1758a0a65e5fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#![crate_type="lib"]
#![no_std]
#![feature(c_variadic)]

use core::ffi::VaList;

pub unsafe extern "C" fn no_escape0<'a>(_: usize, ap: ...) -> VaList<'a> {
    ap //~ ERROR: explicit lifetime required
}

pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> {
    ap //~ ERROR: explicit lifetime required
}

pub unsafe extern "C" fn no_escape2(_: usize, ap: ...) {
    let _ = ap.with_copy(|ap| { ap }); //~ ERROR: cannot infer an appropriate lifetime
}

pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
    *ap0 = ap1; //~ ERROR: mismatched types
}

pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
    ap0 = &mut ap1;
    //~^ ERROR: a value of type `core::ffi::VaList<'_>` is borrowed for too long
    //~^^ ERROR: mismatched types
    //~^^^ ERROR: mismatched types
    //~^^^^ ERROR: cannot infer an appropriate lifetime
}