Update tests.

This commit is contained in:
Mara Bos 2024-10-31 11:39:45 +01:00
parent e7bd340ba4
commit 585c9765a2
63 changed files with 197 additions and 142 deletions

View file

@ -681,7 +681,7 @@ impl<T> Index<usize> for [T] {
} }
} }
extern { extern "C" {
type VaListImpl; type VaListImpl;
} }

View file

@ -258,13 +258,13 @@ fn main() {
assert_eq!(((|()| 42u8) as fn(()) -> u8)(()), 42); assert_eq!(((|()| 42u8) as fn(()) -> u8)(()), 42);
extern { extern "C" {
#[linkage = "weak"] #[linkage = "weak"]
static ABC: *const u8; static ABC: *const u8;
} }
{ {
extern { extern "C" {
#[linkage = "weak"] #[linkage = "weak"]
static ABC: *const u8; static ABC: *const u8;
} }

View file

@ -3,7 +3,7 @@
#![allow(internal_features)] #![allow(internal_features)]
#[link(name = "c")] #[link(name = "c")]
extern {} extern "C" {}
#[panic_handler] #[panic_handler]
fn panic_handler(_: &core::panic::PanicInfo<'_>) -> ! { fn panic_handler(_: &core::panic::PanicInfo<'_>) -> ! {

View file

@ -7,7 +7,7 @@ use std::arch::x86_64::*;
use std::io::Write; use std::io::Write;
use std::ops::Coroutine; use std::ops::Coroutine;
extern { extern "C" {
pub fn printf(format: *const i8, ...) -> i32; pub fn printf(format: *const i8, ...) -> i32;
} }

View file

@ -173,6 +173,7 @@ mod issue_3739 {
/// This shouldn't warn for `boxed_local` as it is intended to called from non-Rust code. /// This shouldn't warn for `boxed_local` as it is intended to called from non-Rust code.
pub extern "C" fn do_not_warn_me(_c_pointer: Box<String>) -> () {} pub extern "C" fn do_not_warn_me(_c_pointer: Box<String>) -> () {}
#[allow(missing_abi)]
#[rustfmt::skip] // Forces rustfmt to not add ABI #[rustfmt::skip] // Forces rustfmt to not add ABI
pub extern fn do_not_warn_me_no_abi(_c_pointer: Box<String>) -> () {} pub extern fn do_not_warn_me_no_abi(_c_pointer: Box<String>) -> () {}

View file

@ -14,13 +14,13 @@ LL | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
| ^^^^^^^^^^^ | ^^^^^^^^^^^
error: local variable doesn't need to be boxed here error: local variable doesn't need to be boxed here
--> tests/ui/boxed_local.rs:188:44 --> tests/ui/boxed_local.rs:189:44
| |
LL | fn default_impl_x(self: Box<Self>, x: Box<u32>) -> u32 { LL | fn default_impl_x(self: Box<Self>, x: Box<u32>) -> u32 {
| ^ | ^
error: local variable doesn't need to be boxed here error: local variable doesn't need to be boxed here
--> tests/ui/boxed_local.rs:196:16 --> tests/ui/boxed_local.rs:197:16
| |
LL | fn foo(x: Box<u32>) {} LL | fn foo(x: Box<u32>) {}
| ^ | ^

View file

@ -240,7 +240,7 @@ fn parenthesized_word() {}
/// UXes /// UXes
fn plural_acronym_test() {} fn plural_acronym_test() {}
extern { extern "C" {
/// `foo()` /// `foo()`
fn in_extern(); fn in_extern();
} }

View file

@ -240,7 +240,7 @@ fn parenthesized_word() {}
/// UXes /// UXes
fn plural_acronym_test() {} fn plural_acronym_test() {}
extern { extern "C" {
/// foo() /// foo()
fn in_extern(); fn in_extern();
} }

View file

@ -149,6 +149,7 @@ mod msrv {
//~^ ERROR: this could be a `const fn` //~^ ERROR: this could be a `const fn`
#[rustfmt::skip] #[rustfmt::skip]
#[allow(missing_abi)]
const extern fn implicit_c() {} const extern fn implicit_c() {}
//~^ ERROR: this could be a `const fn` //~^ ERROR: this could be a `const fn`

View file

@ -149,6 +149,7 @@ mod msrv {
//~^ ERROR: this could be a `const fn` //~^ ERROR: this could be a `const fn`
#[rustfmt::skip] #[rustfmt::skip]
#[allow(missing_abi)]
extern fn implicit_c() {} extern fn implicit_c() {}
//~^ ERROR: this could be a `const fn` //~^ ERROR: this could be a `const fn`

View file

@ -222,7 +222,7 @@ LL | const extern "C" fn c() {}
| +++++ | +++++
error: this could be a `const fn` error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:152:9 --> tests/ui/missing_const_for_fn/could_be_const.rs:153:9
| |
LL | extern fn implicit_c() {} LL | extern fn implicit_c() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -233,7 +233,7 @@ LL | const extern fn implicit_c() {}
| +++++ | +++++
error: this could be a `const fn` error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:169:9 --> tests/ui/missing_const_for_fn/could_be_const.rs:170:9
| |
LL | / pub fn new(strings: Vec<String>) -> Self { LL | / pub fn new(strings: Vec<String>) -> Self {
LL | | Self { strings } LL | | Self { strings }
@ -246,7 +246,7 @@ LL | pub const fn new(strings: Vec<String>) -> Self {
| +++++ | +++++
error: this could be a `const fn` error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:174:9 --> tests/ui/missing_const_for_fn/could_be_const.rs:175:9
| |
LL | / pub fn empty() -> Self { LL | / pub fn empty() -> Self {
LL | | Self { strings: Vec::new() } LL | | Self { strings: Vec::new() }
@ -259,7 +259,7 @@ LL | pub const fn empty() -> Self {
| +++++ | +++++
error: this could be a `const fn` error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:185:9 --> tests/ui/missing_const_for_fn/could_be_const.rs:186:9
| |
LL | / pub fn new(text: String) -> Self { LL | / pub fn new(text: String) -> Self {
LL | | let vec = Vec::new(); LL | | let vec = Vec::new();
@ -273,7 +273,7 @@ LL | pub const fn new(text: String) -> Self {
| +++++ | +++++
error: this could be a `const fn` error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:204:5 --> tests/ui/missing_const_for_fn/could_be_const.rs:205:5
| |
LL | fn alias_ty_is_projection(bar: <() as FooTrait>::Foo) {} LL | fn alias_ty_is_projection(bar: <() as FooTrait>::Foo) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -284,7 +284,7 @@ LL | const fn alias_ty_is_projection(bar: <() as FooTrait>::Foo) {}
| +++++ | +++++
error: this could be a `const fn` error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:208:5 --> tests/ui/missing_const_for_fn/could_be_const.rs:209:5
| |
LL | extern "C-unwind" fn c_unwind() {} LL | extern "C-unwind" fn c_unwind() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -295,7 +295,7 @@ LL | const extern "C-unwind" fn c_unwind() {}
| +++++ | +++++
error: this could be a `const fn` error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:210:5 --> tests/ui/missing_const_for_fn/could_be_const.rs:211:5
| |
LL | extern "system" fn system() {} LL | extern "system" fn system() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -306,7 +306,7 @@ LL | const extern "system" fn system() {}
| +++++ | +++++
error: this could be a `const fn` error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:212:5 --> tests/ui/missing_const_for_fn/could_be_const.rs:213:5
| |
LL | extern "system-unwind" fn system_unwind() {} LL | extern "system-unwind" fn system_unwind() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -3,7 +3,7 @@
#![feature(extern_types)] #![feature(extern_types)]
#![allow(dead_code)] #![allow(dead_code)]
extern { extern "C" {
type Extern; type Extern;
} }

View file

@ -39,7 +39,7 @@ bug!();
macro_rules! doc_comment { macro_rules! doc_comment {
($x:expr) => { ($x:expr) => {
#[doc = $x] #[doc = $x]
extern {} extern "C" {}
}; };
} }

View file

@ -5,7 +5,7 @@
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
#[link(name = "c")] #[link(name = "c")]
extern {} extern "C" {}
#[lang = "start"] #[lang = "start"]
fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize { fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize {

View file

@ -18,7 +18,7 @@ impl !Copy for WithDrop {}
struct Type; struct Type;
trait Trait {} trait Trait {}
extern { extern "C" {
type ExternType; type ExternType;
} }

View file

@ -63,7 +63,7 @@ const B: bool = true;
// ForeignType::unresolved - error // ForeignType::unresolved - error
extern { extern "C" {
type ForeignType; type ForeignType;
} }

View file

@ -1,6 +1,6 @@
#![feature(extern_types)] #![feature(extern_types)]
extern { extern "C" {
type Opaque; type Opaque;
} }

View file

@ -11,7 +11,7 @@ trait OtherTrait {
reuse Trait::*; //~ ERROR glob delegation is only supported in impls reuse Trait::*; //~ ERROR glob delegation is only supported in impls
} }
extern { extern "C" {
reuse Trait::*; //~ ERROR delegation is not supported in `extern` blocks reuse Trait::*; //~ ERROR delegation is not supported in `extern` blocks
} }

View file

@ -4,11 +4,11 @@
// because they are both extern types. // because they are both extern types.
#![feature(extern_types)] #![feature(extern_types)]
extern { extern "C" {
type ShouldNotBeMentioned; type ShouldNotBeMentioned;
} }
extern { extern "C" {
type Foo; type Foo;
} }

View file

@ -1,5 +1,5 @@
//@ run-pass //@ run-pass
#![allow(dead_code)] #![allow(dead_code, missing_abi)]
unsafe extern fn foo() {} unsafe extern fn foo() {}
unsafe extern "C" fn bar() {} unsafe extern "C" fn bar() {}

View file

@ -1,6 +1,6 @@
//@ edition:2018 //@ edition:2018
extern { extern "C" {
async fn L() { //~ ERROR: incorrect function inside `extern` block async fn L() { //~ ERROR: incorrect function inside `extern` block
//~^ ERROR: functions in `extern` blocks cannot have `async` qualifier //~^ ERROR: functions in `extern` blocks cannot have `async` qualifier
async fn M() {} async fn M() {}

View file

@ -1,8 +1,8 @@
error: incorrect function inside `extern` block error: incorrect function inside `extern` block
--> $DIR/issue-95829.rs:4:14 --> $DIR/issue-95829.rs:4:14
| |
LL | extern { LL | extern "C" {
| ------ `extern` blocks define existing foreign functions and functions inside of them cannot have a body | ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body
LL | async fn L() { LL | async fn L() {
| ______________^___- | ______________^___-
| | | | | |
@ -18,8 +18,8 @@ LL | | }
error: functions in `extern` blocks cannot have `async` qualifier error: functions in `extern` blocks cannot have `async` qualifier
--> $DIR/issue-95829.rs:4:5 --> $DIR/issue-95829.rs:4:5
| |
LL | extern { LL | extern "C" {
| ------ in this `extern` block | ---------- in this `extern` block
LL | async fn L() { LL | async fn L() {
| ^^^^^ help: remove the `async` qualifier | ^^^^^ help: remove the `async` qualifier

View file

@ -1,4 +1,5 @@
#![crate_type = "lib"] #![crate_type = "lib"]
#![allow(missing_abi)]
extern fn none_fn(x: bool) -> i32; extern fn none_fn(x: bool) -> i32;
//~^ ERROR free function without a body //~^ ERROR free function without a body

View file

@ -1,5 +1,5 @@
error: free function without a body error: free function without a body
--> $DIR/not-in-block.rs:3:1 --> $DIR/not-in-block.rs:4:1
| |
LL | extern fn none_fn(x: bool) -> i32; LL | extern fn none_fn(x: bool) -> i32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -14,7 +14,7 @@ LL | extern { fn none_fn(x: bool) -> i32; }
| ~~~~~~~~ + | ~~~~~~~~ +
error: free function without a body error: free function without a body
--> $DIR/not-in-block.rs:5:1 --> $DIR/not-in-block.rs:6:1
| |
LL | extern "C" fn c_fn(x: bool) -> i32; LL | extern "C" fn c_fn(x: bool) -> i32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,6 +1,6 @@
// Regression test for issue #91370. // Regression test for issue #91370.
extern { extern "C" {
//~^ `extern` blocks define existing foreign functions //~^ `extern` blocks define existing foreign functions
fn f() { fn f() {
//~^ incorrect function inside `extern` block //~^ incorrect function inside `extern` block

View file

@ -1,8 +1,8 @@
error: incorrect function inside `extern` block error: incorrect function inside `extern` block
--> $DIR/issue-91370-foreign-fn-block-impl.rs:5:8 --> $DIR/issue-91370-foreign-fn-block-impl.rs:5:8
| |
LL | extern { LL | extern "C" {
| ------ `extern` blocks define existing foreign functions and functions inside of them cannot have a body | ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body
LL | LL |
LL | fn f() { LL | fn f() {
| ________^___- | ________^___-

View file

@ -21,7 +21,7 @@ struct S;
#[rustc_legacy_const_generics(0usize)] //~ ERROR suffixed literals are not allowed in attributes #[rustc_legacy_const_generics(0usize)] //~ ERROR suffixed literals are not allowed in attributes
fn foo6<const X: usize>() {} fn foo6<const X: usize>() {}
extern { extern "C" {
#[rustc_legacy_const_generics(1)] //~ ERROR attribute should be applied to a function #[rustc_legacy_const_generics(1)] //~ ERROR attribute should be applied to a function
fn foo7<const X: usize>(); //~ ERROR foreign items may not have const parameters fn foo7<const X: usize>(); //~ ERROR foreign items may not have const parameters
} }

View file

@ -1,4 +1,4 @@
#![crate_type = "lib"] #![crate_type = "lib"]
#[link(kind = "static", modifiers = "+whole-archive,+bundle")] #[link(kind = "static", modifiers = "+whole-archive,+bundle")]
//~^ ERROR `#[link]` attribute requires a `name = "string"` argument //~^ ERROR `#[link]` attribute requires a `name = "string"` argument
extern {} extern "C" {}

View file

@ -1,6 +1,14 @@
warning: extern declarations without an explicit ABI are deprecated
--> $DIR/suggest-libname-only-1.rs:7:1
|
LL | extern { }
| ^^^^^^ help: explicitly specify the C ABI: `extern "C"`
|
= note: `#[warn(missing_abi)]` on by default
error: could not find native static library `libfoo.a`, perhaps an -L flag is missing? error: could not find native static library `libfoo.a`, perhaps an -L flag is missing?
| |
= help: only provide the library name `foo`, not the full filename = help: only provide the library name `foo`, not the full filename
error: aborting due to 1 previous error error: aborting due to 1 previous error; 1 warning emitted

View file

@ -1,6 +1,14 @@
warning: extern declarations without an explicit ABI are deprecated
--> $DIR/suggest-libname-only-2.rs:7:1
|
LL | extern { }
| ^^^^^^ help: explicitly specify the C ABI: `extern "C"`
|
= note: `#[warn(missing_abi)]` on by default
error: could not find native static library `bar.lib`, perhaps an -L flag is missing? error: could not find native static library `bar.lib`, perhaps an -L flag is missing?
| |
= help: only provide the library name `bar`, not the full filename = help: only provide the library name `bar`, not the full filename
error: aborting due to 1 previous error error: aborting due to 1 previous error; 1 warning emitted

View file

@ -11,7 +11,7 @@ fn baz(x: u32, y: u32) -> u32 { x + y }
unsafe fn unsafe_fn() { } unsafe fn unsafe_fn() { }
extern "C" fn c_fn() { } extern "C" fn c_fn() { }
unsafe extern "C" fn unsafe_c_fn() { } unsafe extern "C" fn unsafe_c_fn() { }
unsafe extern fn variadic(_x: u32, _args: ...) { } unsafe extern "C" fn variadic(_x: u32, _args: ...) { }
fn take_generic_ref<'a, T>(_x: &'a T) { } fn take_generic_ref<'a, T>(_x: &'a T) { }
fn take_generic_array<T, const N: usize>(_x: [T; N]) { } fn take_generic_array<T, const N: usize>(_x: [T; N]) { }
fn multiple_generic<T, U>(_x: T, _y: U) { } fn multiple_generic<T, U>(_x: T, _y: U) { }

View file

@ -72,7 +72,7 @@ extern "C" {
pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: uses type `Box<u32>` pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: uses type `Box<u32>`
pub fn raw_array(arr: [u8; 8]); //~ ERROR: uses type `[u8; 8]` pub fn raw_array(arr: [u8; 8]); //~ ERROR: uses type `[u8; 8]`
pub fn no_niche_a(a: Option<UnsafeCell<extern fn()>>); pub fn no_niche_a(a: Option<UnsafeCell<extern "C" fn()>>);
//~^ ERROR: uses type `Option<UnsafeCell<extern "C" fn()>>` //~^ ERROR: uses type `Option<UnsafeCell<extern "C" fn()>>`
pub fn no_niche_b(b: Option<UnsafeCell<&i32>>); pub fn no_niche_b(b: Option<UnsafeCell<&i32>>);
//~^ ERROR: uses type `Option<UnsafeCell<&i32>>` //~^ ERROR: uses type `Option<UnsafeCell<&i32>>`

View file

@ -227,8 +227,8 @@ LL | pub fn raw_array(arr: [u8; 8]);
error: `extern` block uses type `Option<UnsafeCell<extern "C" fn()>>`, which is not FFI-safe error: `extern` block uses type `Option<UnsafeCell<extern "C" fn()>>`, which is not FFI-safe
--> $DIR/lint-ctypes.rs:75:26 --> $DIR/lint-ctypes.rs:75:26
| |
LL | pub fn no_niche_a(a: Option<UnsafeCell<extern fn()>>); LL | pub fn no_niche_a(a: Option<UnsafeCell<extern "C" fn()>>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
| |
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
= note: enum has no representation hint = note: enum has no representation hint

View file

@ -16,7 +16,7 @@ struct Beta {
z: dyn Trait, z: dyn Trait,
} }
extern { extern "C" {
type Extern; type Extern;
} }

View file

@ -4,9 +4,9 @@
pub type T0 = fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T0 = fn(); //~ ERROR an `fn` pointer type cannot be `const`
pub type T1 = extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T1 = extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const`
pub type T2 = unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T2 = unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const`
pub type T3 = fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T3 = fn(); //~ ERROR an `fn` pointer type cannot be `async`
pub type T4 = extern fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T4 = extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async`
pub type T5 = unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T5 = unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async`
pub type T6 = unsafe extern "C" fn(); pub type T6 = unsafe extern "C" fn();
//~^ ERROR an `fn` pointer type cannot be `const` //~^ ERROR an `fn` pointer type cannot be `const`
@ -14,9 +14,9 @@ pub type T6 = unsafe extern "C" fn();
pub type FTT0 = for<'a> fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT0 = for<'a> fn(); //~ ERROR an `fn` pointer type cannot be `const`
pub type FTT1 = for<'a> extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT1 = for<'a> extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const`
pub type FTT2 = for<'a> unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT2 = for<'a> unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const`
pub type FTT3 = for<'a> fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type FTT3 = for<'a> fn(); //~ ERROR an `fn` pointer type cannot be `async`
pub type FTT4 = for<'a> extern fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type FTT4 = for<'a> extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async`
pub type FTT5 = for<'a> unsafe extern "C" fn(); pub type FTT5 = for<'a> unsafe extern "C" fn();
//~^ ERROR an `fn` pointer type cannot be `async` //~^ ERROR an `fn` pointer type cannot be `async`
pub type FTT6 = for<'a> unsafe extern "C" fn(); pub type FTT6 = for<'a> unsafe extern "C" fn();

View file

@ -4,9 +4,9 @@
pub type T0 = const fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T0 = const fn(); //~ ERROR an `fn` pointer type cannot be `const`
pub type T1 = const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T1 = const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const`
pub type T2 = const unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T2 = const unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const`
pub type T3 = async fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T3 = async fn(); //~ ERROR an `fn` pointer type cannot be `async`
pub type T4 = async extern fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T4 = async extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async`
pub type T5 = async unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T5 = async unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async`
pub type T6 = const async unsafe extern "C" fn(); pub type T6 = const async unsafe extern "C" fn();
//~^ ERROR an `fn` pointer type cannot be `const` //~^ ERROR an `fn` pointer type cannot be `const`
@ -14,9 +14,9 @@ pub type T6 = const async unsafe extern "C" fn();
pub type FTT0 = for<'a> const fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT0 = for<'a> const fn(); //~ ERROR an `fn` pointer type cannot be `const`
pub type FTT1 = for<'a> const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT1 = for<'a> const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const`
pub type FTT2 = for<'a> const unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT2 = for<'a> const unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const`
pub type FTT3 = for<'a> async fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type FTT3 = for<'a> async fn(); //~ ERROR an `fn` pointer type cannot be `async`
pub type FTT4 = for<'a> async extern fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type FTT4 = for<'a> async extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async`
pub type FTT5 = for<'a> async unsafe extern "C" fn(); pub type FTT5 = for<'a> async unsafe extern "C" fn();
//~^ ERROR an `fn` pointer type cannot be `async` //~^ ERROR an `fn` pointer type cannot be `async`
pub type FTT6 = for<'a> const async unsafe extern "C" fn(); pub type FTT6 = for<'a> const async unsafe extern "C" fn();

View file

@ -29,15 +29,15 @@ LL + pub type T1 = extern "C" fn();
error: an `fn` pointer type cannot be `const` error: an `fn` pointer type cannot be `const`
--> $DIR/bad-fn-ptr-qualifier.rs:7:15 --> $DIR/bad-fn-ptr-qualifier.rs:7:15
| |
LL | pub type T2 = const unsafe extern fn(); LL | pub type T2 = const unsafe extern "C" fn();
| -----^^^^^^^^^^^^^^^^^^^ | -----^^^^^^^^^^^^^^^^^^^^^^^
| | | |
| `const` because of this | `const` because of this
| |
help: remove the `const` qualifier help: remove the `const` qualifier
| |
LL - pub type T2 = const unsafe extern fn(); LL - pub type T2 = const unsafe extern "C" fn();
LL + pub type T2 = unsafe extern fn(); LL + pub type T2 = unsafe extern "C" fn();
| |
error: an `fn` pointer type cannot be `async` error: an `fn` pointer type cannot be `async`
@ -57,15 +57,15 @@ LL + pub type T3 = fn();
error: an `fn` pointer type cannot be `async` error: an `fn` pointer type cannot be `async`
--> $DIR/bad-fn-ptr-qualifier.rs:9:15 --> $DIR/bad-fn-ptr-qualifier.rs:9:15
| |
LL | pub type T4 = async extern fn(); LL | pub type T4 = async extern "C" fn();
| -----^^^^^^^^^^^^ | -----^^^^^^^^^^^^^^^^
| | | |
| `async` because of this | `async` because of this
| |
help: remove the `async` qualifier help: remove the `async` qualifier
| |
LL - pub type T4 = async extern fn(); LL - pub type T4 = async extern "C" fn();
LL + pub type T4 = extern fn(); LL + pub type T4 = extern "C" fn();
| |
error: an `fn` pointer type cannot be `async` error: an `fn` pointer type cannot be `async`
@ -141,15 +141,15 @@ LL + pub type FTT1 = for<'a> extern "C" fn();
error: an `fn` pointer type cannot be `const` error: an `fn` pointer type cannot be `const`
--> $DIR/bad-fn-ptr-qualifier.rs:17:17 --> $DIR/bad-fn-ptr-qualifier.rs:17:17
| |
LL | pub type FTT2 = for<'a> const unsafe extern fn(); LL | pub type FTT2 = for<'a> const unsafe extern "C" fn();
| ^^^^^^^^-----^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^
| | | |
| `const` because of this | `const` because of this
| |
help: remove the `const` qualifier help: remove the `const` qualifier
| |
LL - pub type FTT2 = for<'a> const unsafe extern fn(); LL - pub type FTT2 = for<'a> const unsafe extern "C" fn();
LL + pub type FTT2 = for<'a> unsafe extern fn(); LL + pub type FTT2 = for<'a> unsafe extern "C" fn();
| |
error: an `fn` pointer type cannot be `async` error: an `fn` pointer type cannot be `async`
@ -169,15 +169,15 @@ LL + pub type FTT3 = for<'a> fn();
error: an `fn` pointer type cannot be `async` error: an `fn` pointer type cannot be `async`
--> $DIR/bad-fn-ptr-qualifier.rs:19:17 --> $DIR/bad-fn-ptr-qualifier.rs:19:17
| |
LL | pub type FTT4 = for<'a> async extern fn(); LL | pub type FTT4 = for<'a> async extern "C" fn();
| ^^^^^^^^-----^^^^^^^^^^^^ | ^^^^^^^^-----^^^^^^^^^^^^^^^^
| | | |
| `async` because of this | `async` because of this
| |
help: remove the `async` qualifier help: remove the `async` qualifier
| |
LL - pub type FTT4 = for<'a> async extern fn(); LL - pub type FTT4 = for<'a> async extern "C" fn();
LL + pub type FTT4 = for<'a> extern fn(); LL + pub type FTT4 = for<'a> extern "C" fn();
| |
error: an `fn` pointer type cannot be `async` error: an `fn` pointer type cannot be `async`

View file

@ -1,10 +1,10 @@
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
extern extern //~ WARN missing_abi
"C"suffix //~ ERROR suffixes on string literals are invalid "C"suffix //~ ERROR suffixes on string literals are invalid
fn foo() {} fn foo() {}
extern extern //~ WARN missing_abi
"C"suffix //~ ERROR suffixes on string literals are invalid "C"suffix //~ ERROR suffixes on string literals are invalid
{} {}

View file

@ -49,6 +49,20 @@ LL | #[rustc_layout_scalar_valid_range_start(0suffix)]
| |
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
warning: extern declarations without an explicit ABI are deprecated
--> $DIR/bad-lit-suffixes.rs:3:1
|
LL | extern
| ^^^^^^ help: explicitly specify the C ABI: `extern "C"`
|
= note: `#[warn(missing_abi)]` on by default
warning: extern declarations without an explicit ABI are deprecated
--> $DIR/bad-lit-suffixes.rs:7:1
|
LL | extern
| ^^^^^^ help: explicitly specify the C ABI: `extern "C"`
error: suffixes on string literals are invalid error: suffixes on string literals are invalid
--> $DIR/bad-lit-suffixes.rs:12:5 --> $DIR/bad-lit-suffixes.rs:12:5
| |
@ -149,5 +163,5 @@ LL | 1.0e10suffix;
| |
= help: valid suffixes are `f32` and `f64` = help: valid suffixes are `f32` and `f64`
error: aborting due to 21 previous errors error: aborting due to 21 previous errors; 2 warnings emitted

View file

@ -1,4 +1,5 @@
//@ edition:2018 //@ edition:2018
#![allow(missing_abi)]
// There is an order to respect for keywords before a function: // There is an order to respect for keywords before a function:
// `<visibility>, const, async, unsafe, extern, "<ABI>"` // `<visibility>, const, async, unsafe, extern, "<ABI>"`

View file

@ -1,5 +1,5 @@
error: expected `fn`, found keyword `unsafe` error: expected `fn`, found keyword `unsafe`
--> $DIR/wrong-unsafe.rs:9:8 --> $DIR/wrong-unsafe.rs:10:8
| |
LL | extern unsafe fn test() {} LL | extern unsafe fn test() {}
| -------^^^^^^ | -------^^^^^^

View file

@ -25,7 +25,7 @@ const unsafe fn _e() {}
//~| ERROR keyword `unsafe` is written in the wrong case //~| ERROR keyword `unsafe` is written in the wrong case
//~| ERROR keyword `fn` is written in the wrong case //~| ERROR keyword `fn` is written in the wrong case
unsafe extern fn _f() {} unsafe extern "C" fn _f() {}
//~^ ERROR keyword `unsafe` is written in the wrong case //~^ ERROR keyword `unsafe` is written in the wrong case
//~| ERROR keyword `extern` is written in the wrong case //~| ERROR keyword `extern` is written in the wrong case

View file

@ -25,7 +25,7 @@ CONST UNSAFE FN _e() {}
//~| ERROR keyword `unsafe` is written in the wrong case //~| ERROR keyword `unsafe` is written in the wrong case
//~| ERROR keyword `fn` is written in the wrong case //~| ERROR keyword `fn` is written in the wrong case
unSAFE EXTern fn _f() {} unSAFE EXTern "C" fn _f() {}
//~^ ERROR keyword `unsafe` is written in the wrong case //~^ ERROR keyword `unsafe` is written in the wrong case
//~| ERROR keyword `extern` is written in the wrong case //~| ERROR keyword `extern` is written in the wrong case

View file

@ -111,23 +111,23 @@ LL | CONST UNSAFE fn _e() {}
error: keyword `unsafe` is written in the wrong case error: keyword `unsafe` is written in the wrong case
--> $DIR/item-kw-case-mismatch.rs:28:1 --> $DIR/item-kw-case-mismatch.rs:28:1
| |
LL | unSAFE EXTern fn _f() {} LL | unSAFE EXTern "C" fn _f() {}
| ^^^^^^ | ^^^^^^
| |
help: write it in the correct case help: write it in the correct case
| |
LL | unsafe EXTern fn _f() {} LL | unsafe EXTern "C" fn _f() {}
| ~~~~~~ | ~~~~~~
error: keyword `extern` is written in the wrong case error: keyword `extern` is written in the wrong case
--> $DIR/item-kw-case-mismatch.rs:28:8 --> $DIR/item-kw-case-mismatch.rs:28:8
| |
LL | unSAFE EXTern fn _f() {} LL | unSAFE EXTern "C" fn _f() {}
| ^^^^^^ | ^^^^^^
| |
help: write it in the correct case help: write it in the correct case
| |
LL | unSAFE extern fn _f() {} LL | unSAFE extern "C" fn _f() {}
| ~~~~~~ | ~~~~~~
error: keyword `extern` is written in the wrong case error: keyword `extern` is written in the wrong case

View file

@ -1,6 +1,6 @@
macro_rules! f { macro_rules! f {
($abi:literal) => { ($abi:literal) => {
extern $abi fn f() {} extern $abi fn f() {} //~ WARN missing_abi
} }
} }

View file

@ -4,5 +4,17 @@ error: suffixes on string literals are invalid
LL | f!("Foo"__); LL | f!("Foo"__);
| ^^^^^^^ invalid suffix `__` | ^^^^^^^ invalid suffix `__`
error: aborting due to 1 previous error warning: extern declarations without an explicit ABI are deprecated
--> $DIR/lit-err-in-macro.rs:3:9
|
LL | extern $abi fn f() {}
| ^^^^^^ help: explicitly specify the C ABI: `extern "C"`
...
LL | f!("Foo"__);
| ----------- in this macro invocation
|
= note: `#[warn(missing_abi)]` on by default
= note: this warning originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error; 1 warning emitted

View file

@ -2,9 +2,9 @@
type T0 = const fn(); //~ ERROR an `fn` pointer type cannot be `const` type T0 = const fn(); //~ ERROR an `fn` pointer type cannot be `const`
type T1 = const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` type T1 = const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const`
type T2 = const unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` type T2 = const unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const`
type T3 = async fn(); //~ ERROR an `fn` pointer type cannot be `async` type T3 = async fn(); //~ ERROR an `fn` pointer type cannot be `async`
type T4 = async extern fn(); //~ ERROR an `fn` pointer type cannot be `async` type T4 = async extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async`
type T5 = async unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` type T5 = async unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async`
type T6 = const async unsafe extern "C" fn(); type T6 = const async unsafe extern "C" fn();
//~^ ERROR an `fn` pointer type cannot be `const` //~^ ERROR an `fn` pointer type cannot be `const`
@ -12,9 +12,9 @@ type T6 = const async unsafe extern "C" fn();
type FT0 = for<'a> const fn(); //~ ERROR an `fn` pointer type cannot be `const` type FT0 = for<'a> const fn(); //~ ERROR an `fn` pointer type cannot be `const`
type FT1 = for<'a> const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` type FT1 = for<'a> const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const`
type FT2 = for<'a> const unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` type FT2 = for<'a> const unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const`
type FT3 = for<'a> async fn(); //~ ERROR an `fn` pointer type cannot be `async` type FT3 = for<'a> async fn(); //~ ERROR an `fn` pointer type cannot be `async`
type FT4 = for<'a> async extern fn(); //~ ERROR an `fn` pointer type cannot be `async` type FT4 = for<'a> async extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async`
type FT5 = for<'a> async unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` type FT5 = for<'a> async unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async`
type FT6 = for<'a> const async unsafe extern "C" fn(); type FT6 = for<'a> const async unsafe extern "C" fn();
//~^ ERROR an `fn` pointer type cannot be `const` //~^ ERROR an `fn` pointer type cannot be `const`

View file

@ -29,15 +29,15 @@ LL + type T1 = extern "C" fn();
error: an `fn` pointer type cannot be `const` error: an `fn` pointer type cannot be `const`
--> $DIR/recover-const-async-fn-ptr.rs:5:11 --> $DIR/recover-const-async-fn-ptr.rs:5:11
| |
LL | type T2 = const unsafe extern fn(); LL | type T2 = const unsafe extern "C" fn();
| -----^^^^^^^^^^^^^^^^^^^ | -----^^^^^^^^^^^^^^^^^^^^^^^
| | | |
| `const` because of this | `const` because of this
| |
help: remove the `const` qualifier help: remove the `const` qualifier
| |
LL - type T2 = const unsafe extern fn(); LL - type T2 = const unsafe extern "C" fn();
LL + type T2 = unsafe extern fn(); LL + type T2 = unsafe extern "C" fn();
| |
error: an `fn` pointer type cannot be `async` error: an `fn` pointer type cannot be `async`
@ -57,15 +57,15 @@ LL + type T3 = fn();
error: an `fn` pointer type cannot be `async` error: an `fn` pointer type cannot be `async`
--> $DIR/recover-const-async-fn-ptr.rs:7:11 --> $DIR/recover-const-async-fn-ptr.rs:7:11
| |
LL | type T4 = async extern fn(); LL | type T4 = async extern "C" fn();
| -----^^^^^^^^^^^^ | -----^^^^^^^^^^^^^^^^
| | | |
| `async` because of this | `async` because of this
| |
help: remove the `async` qualifier help: remove the `async` qualifier
| |
LL - type T4 = async extern fn(); LL - type T4 = async extern "C" fn();
LL + type T4 = extern fn(); LL + type T4 = extern "C" fn();
| |
error: an `fn` pointer type cannot be `async` error: an `fn` pointer type cannot be `async`
@ -141,15 +141,15 @@ LL + type FT1 = for<'a> extern "C" fn();
error: an `fn` pointer type cannot be `const` error: an `fn` pointer type cannot be `const`
--> $DIR/recover-const-async-fn-ptr.rs:15:12 --> $DIR/recover-const-async-fn-ptr.rs:15:12
| |
LL | type FT2 = for<'a> const unsafe extern fn(); LL | type FT2 = for<'a> const unsafe extern "C" fn();
| ^^^^^^^^-----^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^
| | | |
| `const` because of this | `const` because of this
| |
help: remove the `const` qualifier help: remove the `const` qualifier
| |
LL - type FT2 = for<'a> const unsafe extern fn(); LL - type FT2 = for<'a> const unsafe extern "C" fn();
LL + type FT2 = for<'a> unsafe extern fn(); LL + type FT2 = for<'a> unsafe extern "C" fn();
| |
error: an `fn` pointer type cannot be `async` error: an `fn` pointer type cannot be `async`
@ -169,15 +169,15 @@ LL + type FT3 = for<'a> fn();
error: an `fn` pointer type cannot be `async` error: an `fn` pointer type cannot be `async`
--> $DIR/recover-const-async-fn-ptr.rs:17:12 --> $DIR/recover-const-async-fn-ptr.rs:17:12
| |
LL | type FT4 = for<'a> async extern fn(); LL | type FT4 = for<'a> async extern "C" fn();
| ^^^^^^^^-----^^^^^^^^^^^^ | ^^^^^^^^-----^^^^^^^^^^^^^^^^
| | | |
| `async` because of this | `async` because of this
| |
help: remove the `async` qualifier help: remove the `async` qualifier
| |
LL - type FT4 = for<'a> async extern fn(); LL - type FT4 = for<'a> async extern "C" fn();
LL + type FT4 = for<'a> extern fn(); LL + type FT4 = for<'a> extern "C" fn();
| |
error: an `fn` pointer type cannot be `async` error: an `fn` pointer type cannot be `async`

View file

@ -19,7 +19,7 @@ fn main() {
type Hmm = fn<>(); type Hmm = fn<>();
//~^ ERROR function pointer types may not have generic parameters //~^ ERROR function pointer types may not have generic parameters
let _: extern fn<'a: 'static>(); let _: extern "C" fn<'a: 'static>();
//~^ ERROR function pointer types may not have generic parameters //~^ ERROR function pointer types may not have generic parameters
//~| ERROR bounds cannot be used in this context //~| ERROR bounds cannot be used in this context

View file

@ -59,15 +59,15 @@ LL | type Hmm = fn<>();
| ^^ | ^^
error: function pointer types may not have generic parameters error: function pointer types may not have generic parameters
--> $DIR/recover-fn-ptr-with-generics.rs:22:21 --> $DIR/recover-fn-ptr-with-generics.rs:22:25
| |
LL | let _: extern fn<'a: 'static>(); LL | let _: extern "C" fn<'a: 'static>();
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
| |
help: consider moving the lifetime parameter to a `for` parameter list help: consider moving the lifetime parameter to a `for` parameter list
| |
LL - let _: extern fn<'a: 'static>(); LL - let _: extern "C" fn<'a: 'static>();
LL + let _: for<'a> extern fn(); LL + let _: for<'a> extern "C" fn();
| |
error: function pointer types may not have generic parameters error: function pointer types may not have generic parameters
@ -101,9 +101,9 @@ LL | type Identity = fn<T>(T) -> T;
| ^ not found in this scope | ^ not found in this scope
error: bounds cannot be used in this context error: bounds cannot be used in this context
--> $DIR/recover-fn-ptr-with-generics.rs:22:26 --> $DIR/recover-fn-ptr-with-generics.rs:22:30
| |
LL | let _: extern fn<'a: 'static>(); LL | let _: extern "C" fn<'a: 'static>();
| ^^^^^^^ | ^^^^^^^
error: aborting due to 12 previous errors error: aborting due to 12 previous errors

View file

@ -28,7 +28,7 @@ fn for_fn() {
fn for_extern() { fn for_extern() {
let foo = 3; //~ ERROR expected `;`, found keyword `extern` let foo = 3; //~ ERROR expected `;`, found keyword `extern`
extern fn foo() {} extern "C" fn foo() {}
} }
fn for_impl() { fn for_impl() {

View file

@ -28,7 +28,7 @@ fn for_fn() {
fn for_extern() { fn for_extern() {
let foo = 3 //~ ERROR expected `;`, found keyword `extern` let foo = 3 //~ ERROR expected `;`, found keyword `extern`
extern fn foo() {} extern "C" fn foo() {}
} }
fn for_impl() { fn for_impl() {

View file

@ -35,7 +35,7 @@ error: expected `;`, found keyword `extern`
| |
LL | let foo = 3 LL | let foo = 3
| ^ help: add `;` here | ^ help: add `;` here
LL | extern fn foo() {} LL | extern "C" fn foo() {}
| ------ unexpected token | ------ unexpected token
error: expected `;`, found keyword `impl` error: expected `;`, found keyword `impl`

View file

@ -22,5 +22,13 @@ error: expected non-macro inner attribute, found attribute macro `print_attr`
LL | #![print_attr] LL | #![print_attr]
| ^^^^^^^^^^ not a non-macro inner attribute | ^^^^^^^^^^ not a non-macro inner attribute
error: aborting due to 4 previous errors warning: extern declarations without an explicit ABI are deprecated
--> $DIR/inner-attrs.rs:82:1
|
LL | extern {
| ^^^^^^ help: explicitly specify the C ABI: `extern "C"`
|
= note: `#[warn(missing_abi)]` on by default
error: aborting due to 4 previous errors; 1 warning emitted

View file

@ -5,7 +5,7 @@
extern crate issue_66286; extern crate issue_66286;
#[issue_66286::vec_ice] #[issue_66286::vec_ice]
pub extern fn foo(_: Vec(u32)) -> u32 { pub extern "C" fn foo(_: Vec(u32)) -> u32 {
//~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait
0 0
} }

View file

@ -1,12 +1,12 @@
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
--> $DIR/issue-66286.rs:8:22 --> $DIR/issue-66286.rs:8:26
| |
LL | pub extern fn foo(_: Vec(u32)) -> u32 { LL | pub extern "C" fn foo(_: Vec(u32)) -> u32 {
| ^^^^^^^^ only `Fn` traits may use parentheses | ^^^^^^^^ only `Fn` traits may use parentheses
| |
help: use angle brackets instead help: use angle brackets instead
| |
LL | pub extern fn foo(_: Vec<u32>) -> u32 { LL | pub extern "C" fn foo(_: Vec<u32>) -> u32 {
| ~ ~ | ~ ~
error: aborting due to 1 previous error error: aborting due to 1 previous error

View file

@ -11,7 +11,7 @@ fn test() {}
static mut imported_val: i32 = 123; static mut imported_val: i32 = 123;
#[link(name = "exporter", kind = "raw-dylib")] #[link(name = "exporter", kind = "raw-dylib")]
extern { extern "C" {
#[link_ordinal(13)] #[link_ordinal(13)]
fn imported_function(); fn imported_function();

View file

@ -4,7 +4,7 @@
macro_rules! tt { macro_rules! tt {
($e:tt) => { ($e:tt) => {
#$e #$e
extern fn foo() {} extern "C" fn foo() {}
} }
} }
@ -13,7 +13,7 @@ macro_rules! ident {
#[unsafe($e)] #[unsafe($e)]
//~^ ERROR: unsafe attribute used without unsafe //~^ ERROR: unsafe attribute used without unsafe
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
extern fn bar() {} extern "C" fn bar() {}
} }
} }
@ -22,21 +22,21 @@ macro_rules! ident2 {
#[unsafe($e = $l)] #[unsafe($e = $l)]
//~^ ERROR: unsafe attribute used without unsafe //~^ ERROR: unsafe attribute used without unsafe
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
extern fn bars() {} extern "C" fn bars() {}
} }
} }
macro_rules! meta { macro_rules! meta {
($m:meta) => { ($m:meta) => {
#[$m] #[$m]
extern fn baz() {} extern "C" fn baz() {}
} }
} }
macro_rules! meta2 { macro_rules! meta2 {
($m:meta) => { ($m:meta) => {
#[$m] #[$m]
extern fn baw() {} extern "C" fn baw() {}
} }
} }

View file

@ -4,7 +4,7 @@
macro_rules! tt { macro_rules! tt {
($e:tt) => { ($e:tt) => {
#$e #$e
extern fn foo() {} extern "C" fn foo() {}
} }
} }
@ -13,7 +13,7 @@ macro_rules! ident {
#[$e] #[$e]
//~^ ERROR: unsafe attribute used without unsafe //~^ ERROR: unsafe attribute used without unsafe
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
extern fn bar() {} extern "C" fn bar() {}
} }
} }
@ -22,21 +22,21 @@ macro_rules! ident2 {
#[$e = $l] #[$e = $l]
//~^ ERROR: unsafe attribute used without unsafe //~^ ERROR: unsafe attribute used without unsafe
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
extern fn bars() {} extern "C" fn bars() {}
} }
} }
macro_rules! meta { macro_rules! meta {
($m:meta) => { ($m:meta) => {
#[$m] #[$m]
extern fn baz() {} extern "C" fn baz() {}
} }
} }
macro_rules! meta2 { macro_rules! meta2 {
($m:meta) => { ($m:meta) => {
#[$m] #[$m]
extern fn baw() {} extern "C" fn baw() {}
} }
} }

View file

@ -6,7 +6,7 @@
use std::ptr::NonNull; use std::ptr::NonNull;
extern { extern "C" {
type Extern; type Extern;
} }

View file

@ -2,7 +2,7 @@
#![deny(uninhabited_static)] #![deny(uninhabited_static)]
enum Void {} enum Void {}
extern { extern "C" {
static VOID: Void; //~ ERROR static of uninhabited type static VOID: Void; //~ ERROR static of uninhabited type
//~| WARN: previously accepted //~| WARN: previously accepted
static NEVER: !; //~ ERROR static of uninhabited type static NEVER: !; //~ ERROR static of uninhabited type

View file

@ -452,15 +452,15 @@ mod items {
/// ItemKind::Fn /// ItemKind::Fn
mod item_fn { mod item_fn {
pub const unsafe extern "C" fn f() {} pub const unsafe extern "C" fn f() {}
pub async unsafe extern fn g() {} pub async unsafe extern "C" fn g() {}
fn h<'a, T>() where T: 'a {} fn h<'a, T>() where T: 'a {}
trait TraitItems { trait TraitItems {
unsafe extern fn f(); unsafe extern "C" fn f();
} }
impl TraitItems for _ { impl TraitItems for _ {
default unsafe extern fn f() {} default unsafe extern "C" fn f() {}
} }
} }
@ -472,7 +472,7 @@ mod items {
/// ItemKind::ForeignMod /// ItemKind::ForeignMod
mod item_foreign_mod { mod item_foreign_mod {
unsafe extern "C++" {} unsafe extern "C++" {}
unsafe extern {} unsafe extern "C" {}
} }
/// ItemKind::GlobalAsm /// ItemKind::GlobalAsm

View file

@ -433,13 +433,13 @@ mod items {
/// ItemKind::Fn /// ItemKind::Fn
mod item_fn { mod item_fn {
pub const unsafe extern "C" fn f() {} pub const unsafe extern "C" fn f() {}
pub async unsafe extern fn g() {} pub async unsafe extern "C" fn g() {}
fn h<'a, T>() where T: 'a {} fn h<'a, T>() where T: 'a {}
trait TraitItems { trait TraitItems {
unsafe extern fn f(); unsafe extern "C" fn f();
} }
impl TraitItems for _ { impl TraitItems for _ {
default unsafe extern fn f() {} default unsafe extern "C" fn f() {}
} }
} }
/// ItemKind::Mod /// ItemKind::Mod
@ -447,7 +447,7 @@ mod items {
/// ItemKind::ForeignMod /// ItemKind::ForeignMod
mod item_foreign_mod { mod item_foreign_mod {
unsafe extern "C++" {} unsafe extern "C++" {}
unsafe extern {} unsafe extern "C" {}
} }
/// ItemKind::GlobalAsm /// ItemKind::GlobalAsm
mod item_global_asm { mod item_global_asm {