2020-01-29 17:18:54 -06:00
|
|
|
// Ensures that all `fn` forms can have all the function qualifiers syntactically.
|
|
|
|
|
|
|
|
// edition:2018
|
|
|
|
|
|
|
|
#![feature(const_extern_fn)]
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
async fn ff1() {} // OK.
|
|
|
|
unsafe fn ff2() {} // OK.
|
|
|
|
const fn ff3() {} // OK.
|
|
|
|
extern "C" fn ff4() {} // OK.
|
2022-02-14 10:10:22 -06:00
|
|
|
const async unsafe extern "C" fn ff5() {}
|
2020-01-30 06:02:06 -06:00
|
|
|
//~^ ERROR functions cannot be both `const` and `async`
|
2020-01-29 17:18:54 -06:00
|
|
|
|
|
|
|
trait X {
|
2020-02-11 01:19:21 -06:00
|
|
|
async fn ft1(); //~ ERROR functions in traits cannot be declared `async`
|
2020-01-29 17:18:54 -06:00
|
|
|
unsafe fn ft2(); // OK.
|
2020-02-11 01:19:21 -06:00
|
|
|
const fn ft3(); //~ ERROR functions in traits cannot be declared const
|
2020-01-29 17:18:54 -06:00
|
|
|
extern "C" fn ft4(); // OK.
|
2020-01-30 01:31:31 -06:00
|
|
|
const async unsafe extern "C" fn ft5();
|
2020-02-11 01:19:21 -06:00
|
|
|
//~^ ERROR functions in traits cannot be declared `async`
|
|
|
|
//~| ERROR functions in traits cannot be declared const
|
2020-01-30 06:02:06 -06:00
|
|
|
//~| ERROR functions cannot be both `const` and `async`
|
2020-01-29 17:18:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Y;
|
|
|
|
impl X for Y {
|
2020-02-11 01:19:21 -06:00
|
|
|
async fn ft1() {} //~ ERROR functions in traits cannot be declared `async`
|
2020-01-29 17:18:54 -06:00
|
|
|
unsafe fn ft2() {} // OK.
|
2020-02-11 01:19:21 -06:00
|
|
|
const fn ft3() {} //~ ERROR functions in traits cannot be declared const
|
2020-01-29 17:18:54 -06:00
|
|
|
extern "C" fn ft4() {}
|
2020-01-30 01:31:31 -06:00
|
|
|
const async unsafe extern "C" fn ft5() {}
|
2020-02-11 01:19:21 -06:00
|
|
|
//~^ ERROR functions in traits cannot be declared `async`
|
|
|
|
//~| ERROR functions in traits cannot be declared const
|
2020-01-30 06:02:06 -06:00
|
|
|
//~| ERROR functions cannot be both `const` and `async`
|
2020-01-29 17:18:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Y {
|
|
|
|
async fn fi1() {} // OK.
|
|
|
|
unsafe fn fi2() {} // OK.
|
|
|
|
const fn fi3() {} // OK.
|
|
|
|
extern "C" fn fi4() {} // OK.
|
2020-01-30 06:02:06 -06:00
|
|
|
const async unsafe extern "C" fn fi5() {}
|
|
|
|
//~^ ERROR functions cannot be both `const` and `async`
|
2020-01-29 17:18:54 -06:00
|
|
|
}
|
|
|
|
|
2020-09-01 16:12:52 -05:00
|
|
|
extern "C" {
|
2020-01-29 17:18:54 -06:00
|
|
|
async fn fe1(); //~ ERROR functions in `extern` blocks cannot have qualifiers
|
|
|
|
unsafe fn fe2(); //~ ERROR functions in `extern` blocks cannot have qualifiers
|
|
|
|
const fn fe3(); //~ ERROR functions in `extern` blocks cannot have qualifiers
|
|
|
|
extern "C" fn fe4(); //~ ERROR functions in `extern` blocks cannot have qualifiers
|
2020-01-30 01:31:31 -06:00
|
|
|
const async unsafe extern "C" fn fe5(); //~ ERROR functions in `extern` blocks
|
2020-01-30 06:02:06 -06:00
|
|
|
//~^ ERROR functions cannot be both `const` and `async`
|
2020-01-29 17:18:54 -06:00
|
|
|
}
|
|
|
|
}
|