rust/src/test/ui/parser/no-const-fn-in-extern-block.stderr
Aaron Hill 73b50d211b
Add support for 'extern const fn'
This works just as you might expect - an 'extern const fn' is a 'const
fn' that is callable from foreign code.

Currently, panicking is not allowed in consts. When RFC 2345 is
stabilized, then panicking in an 'extern const fn' will produce a
compile-time error when invoked at compile time, and an abort when
invoked at runtime.

Since this is extending the language (we're allowing the `const` keyword
in a new context), I believe that this will need an FCP. However, it's a
very minor change, so I didn't think that filing an RFC was necessary.

This will allow libc (and other FFI crates) to make many functions
`const`, without having to give up on making them `extern` as well.
2019-10-02 00:38:52 -04:00

15 lines
309 B
Plaintext

error: extern items cannot be `const`
--> $DIR/no-const-fn-in-extern-block.rs:2:5
|
LL | const fn foo();
| ^^^^^
error: extern items cannot be `const`
--> $DIR/no-const-fn-in-extern-block.rs:4:5
|
LL | const unsafe fn bar();
| ^^^^^
error: aborting due to 2 previous errors