diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2020-09-01 17:12:52 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2021-01-13 07:49:16 -0500 |
| commit | 8a3edb1d661ed5ce685bd5dcfa600b6e02897b86 (patch) | |
| tree | 5615826fc30a674b49dcc89fc09ff84a1fced008 /compiler/rustc_error_codes | |
| parent | c4a8d7f86a5d54a2f3b3875e703d06acd12ae7cc (diff) | |
| download | rust-8a3edb1d661ed5ce685bd5dcfa600b6e02897b86.tar.gz rust-8a3edb1d661ed5ce685bd5dcfa600b6e02897b86.zip | |
Update tests for extern block linting
Diffstat (limited to 'compiler/rustc_error_codes')
8 files changed, 16 insertions, 16 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0044.md b/compiler/rustc_error_codes/src/error_codes/E0044.md index 635ff953290..ed7daf8ddd9 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0044.md +++ b/compiler/rustc_error_codes/src/error_codes/E0044.md @@ -3,13 +3,13 @@ You cannot use type or const parameters on foreign items. Example of erroneous code: ```compile_fail,E0044 -extern { fn some_func<T>(x: T); } +extern "C" { fn some_func<T>(x: T); } ``` To fix this, replace the generic parameter with the specializations that you need: ``` -extern { fn some_func_i32(x: i32); } -extern { fn some_func_i64(x: i64); } +extern "C" { fn some_func_i32(x: i32); } +extern "C" { fn some_func_i64(x: i64); } ``` diff --git a/compiler/rustc_error_codes/src/error_codes/E0130.md b/compiler/rustc_error_codes/src/error_codes/E0130.md index a270feaf58c..2cd27b5ec05 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0130.md +++ b/compiler/rustc_error_codes/src/error_codes/E0130.md @@ -3,7 +3,7 @@ A pattern was declared as an argument in a foreign function declaration. Erroneous code example: ```compile_fail,E0130 -extern { +extern "C" { fn foo((a, b): (u32, u32)); // error: patterns aren't allowed in foreign // function declarations } @@ -17,7 +17,7 @@ struct SomeStruct { b: u32, } -extern { +extern "C" { fn foo(s: SomeStruct); // ok! } ``` @@ -25,7 +25,7 @@ extern { Or: ``` -extern { +extern "C" { fn foo(a: (u32, u32)); // ok! } ``` diff --git a/compiler/rustc_error_codes/src/error_codes/E0454.md b/compiler/rustc_error_codes/src/error_codes/E0454.md index 23ca6c7824d..95a22b92e36 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0454.md +++ b/compiler/rustc_error_codes/src/error_codes/E0454.md @@ -3,7 +3,7 @@ A link name was given with an empty name. Erroneous code example: ```compile_fail,E0454 -#[link(name = "")] extern {} +#[link(name = "")] extern "C" {} // error: `#[link(name = "")]` given with empty name ``` @@ -11,5 +11,5 @@ The rust compiler cannot link to an external library if you don't give it its name. Example: ```no_run -#[link(name = "some_lib")] extern {} // ok! +#[link(name = "some_lib")] extern "C" {} // ok! ``` diff --git a/compiler/rustc_error_codes/src/error_codes/E0455.md b/compiler/rustc_error_codes/src/error_codes/E0455.md index 2f80c34b889..84689b3ece6 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0455.md +++ b/compiler/rustc_error_codes/src/error_codes/E0455.md @@ -4,7 +4,7 @@ as frameworks are specific to that operating system. Erroneous code example: ```ignore (should-compile_fail-but-cannot-doctest-conditionally-without-macos) -#[link(name = "FooCoreServices", kind = "framework")] extern {} +#[link(name = "FooCoreServices", kind = "framework")] extern "C" {} // OS used to compile is Linux for example ``` @@ -12,7 +12,7 @@ To solve this error you can use conditional compilation: ``` #[cfg_attr(target="macos", link(name = "FooCoreServices", kind = "framework"))] -extern {} +extern "C" {} ``` Learn more in the [Conditional Compilation][conditional-compilation] section diff --git a/compiler/rustc_error_codes/src/error_codes/E0458.md b/compiler/rustc_error_codes/src/error_codes/E0458.md index 075226ac98b..359aeb6fd9a 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0458.md +++ b/compiler/rustc_error_codes/src/error_codes/E0458.md @@ -3,7 +3,7 @@ An unknown "kind" was specified for a link attribute. Erroneous code example: ```compile_fail,E0458 -#[link(kind = "wonderful_unicorn")] extern {} +#[link(kind = "wonderful_unicorn")] extern "C" {} // error: unknown kind: `wonderful_unicorn` ``` diff --git a/compiler/rustc_error_codes/src/error_codes/E0459.md b/compiler/rustc_error_codes/src/error_codes/E0459.md index 6f75f2a99a5..4a49a765445 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0459.md +++ b/compiler/rustc_error_codes/src/error_codes/E0459.md @@ -3,7 +3,7 @@ A link was used without a name parameter. Erroneous code example: ```compile_fail,E0459 -#[link(kind = "dylib")] extern {} +#[link(kind = "dylib")] extern "C" {} // error: `#[link(...)]` specified without `name = "foo"` ``` @@ -11,5 +11,5 @@ Please add the name parameter to allow the rust compiler to find the library you want. Example: ```no_run -#[link(kind = "dylib", name = "some_lib")] extern {} // ok! +#[link(kind = "dylib", name = "some_lib")] extern "C" {} // ok! ``` diff --git a/compiler/rustc_error_codes/src/error_codes/E0617.md b/compiler/rustc_error_codes/src/error_codes/E0617.md index 61b56766c26..1c5d1f87b91 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0617.md +++ b/compiler/rustc_error_codes/src/error_codes/E0617.md @@ -3,7 +3,7 @@ Attempted to pass an invalid type of variable into a variadic function. Erroneous code example: ```compile_fail,E0617 -extern { +extern "C" { fn printf(c: *const i8, ...); } @@ -21,7 +21,7 @@ to import from `std::os::raw`). In this case, `c_double` has the same size as `f64` so we can use it directly: ```no_run -# extern { +# extern "C" { # fn printf(c: *const i8, ...); # } unsafe { diff --git a/compiler/rustc_error_codes/src/error_codes/E0724.md b/compiler/rustc_error_codes/src/error_codes/E0724.md index e8f84d0fc7d..70578acbe0d 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0724.md +++ b/compiler/rustc_error_codes/src/error_codes/E0724.md @@ -18,7 +18,7 @@ the function inside of an `extern` block. ``` #![feature(ffi_returns_twice)] -extern { +extern "C" { #[ffi_returns_twice] // ok! pub fn foo(); } |
