diff options
| author | bors <bors@rust-lang.org> | 2021-01-13 13:56:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-13 13:56:15 +0000 |
| commit | fd2df74902fa98bcb71f85fd548c3eb399e6a96a (patch) | |
| tree | d88a7bde6091f82bd2ae5d492c66088ef705600d /library/std/src | |
| parent | 116d1a7056830ccf649f74f823de4333ed329392 (diff) | |
| parent | 4614671cae99ff35e61708ab64e9ba7850711750 (diff) | |
| download | rust-fd2df74902fa98bcb71f85fd548c3eb399e6a96a.tar.gz rust-fd2df74902fa98bcb71f85fd548c3eb399e6a96a.zip | |
Auto merge of #76219 - Mark-Simulacrum:extern-require-abi, r=estebank
Add allow-by-default lint on implicit ABI in extern function pointers and items This adds a new lint, missing_abi, which lints on omitted ABIs on extern blocks, function declarations, and function pointers. It is currently not emitting the best possible diagnostics -- we need to track the span of "extern" at least or do some heuristic searching based on the available spans -- but seems good enough for an initial pass than can be expanded in future PRs. This is a pretty large PR, but mostly due to updating a large number of tests to include ABIs; I can split that into a separate PR if it would be helpful, but test updates are already in dedicated commits.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/ffi/c_str.rs | 14 | ||||
| -rw-r--r-- | library/std/src/keyword_docs.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/unix/weak.rs | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/library/std/src/ffi/c_str.rs b/library/std/src/ffi/c_str.rs index 60b642a6dba..230ef0b23db 100644 --- a/library/std/src/ffi/c_str.rs +++ b/library/std/src/ffi/c_str.rs @@ -86,7 +86,7 @@ use crate::sys; /// use std::ffi::CString; /// use std::os::raw::c_char; /// -/// extern { +/// extern "C" { /// fn my_printer(s: *const c_char); /// } /// @@ -144,7 +144,7 @@ pub struct CString { /// use std::ffi::CStr; /// use std::os::raw::c_char; /// -/// extern { fn my_string() -> *const c_char; } +/// extern "C" { fn my_string() -> *const c_char; } /// /// unsafe { /// let slice = CStr::from_ptr(my_string()); @@ -159,7 +159,7 @@ pub struct CString { /// use std::os::raw::c_char; /// /// fn work(data: &CStr) { -/// extern { fn work_with(data: *const c_char); } +/// extern "C" { fn work_with(data: *const c_char); } /// /// unsafe { work_with(data.as_ptr()) } /// } @@ -174,7 +174,7 @@ pub struct CString { /// use std::ffi::CStr; /// use std::os::raw::c_char; /// -/// extern { fn my_string() -> *const c_char; } +/// extern "C" { fn my_string() -> *const c_char; } /// /// fn my_string_safe() -> String { /// unsafe { @@ -359,7 +359,7 @@ impl CString { /// use std::ffi::CString; /// use std::os::raw::c_char; /// - /// extern { fn puts(s: *const c_char); } + /// extern "C" { fn puts(s: *const c_char); } /// /// let to_print = CString::new("Hello!").expect("CString::new failed"); /// unsafe { @@ -465,7 +465,7 @@ impl CString { /// use std::ffi::CString; /// use std::os::raw::c_char; /// - /// extern { + /// extern "C" { /// fn some_extern_function(s: *mut c_char); /// } /// @@ -1147,7 +1147,7 @@ impl CStr { /// use std::ffi::CStr; /// use std::os::raw::c_char; /// - /// extern { + /// extern "C" { /// fn my_string() -> *const c_char; /// } /// diff --git a/library/std/src/keyword_docs.rs b/library/std/src/keyword_docs.rs index 417a54e9dff..6b06539a094 100644 --- a/library/std/src/keyword_docs.rs +++ b/library/std/src/keyword_docs.rs @@ -401,7 +401,7 @@ mod enum_keyword {} /// /// ```rust /// #[no_mangle] -/// pub extern fn callable_from_c(x: i32) -> bool { +/// pub extern "C" fn callable_from_c(x: i32) -> bool { /// x % 3 == 0 /// } /// ``` diff --git a/library/std/src/sys/unix/weak.rs b/library/std/src/sys/unix/weak.rs index e93a4972caa..432fe4c33bc 100644 --- a/library/std/src/sys/unix/weak.rs +++ b/library/std/src/sys/unix/weak.rs @@ -28,7 +28,7 @@ use crate::sync::atomic::{self, AtomicUsize, Ordering}; macro_rules! weak { (fn $name:ident($($t:ty),*) -> $ret:ty) => ( - static $name: crate::sys::weak::Weak<unsafe extern fn($($t),*) -> $ret> = + static $name: crate::sys::weak::Weak<unsafe extern "C" fn($($t),*) -> $ret> = crate::sys::weak::Weak::new(concat!(stringify!($name), '\0')); ) } |
