-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch [
extern_without_abi
] to LateLintPass
Also: - Add test if inside external macro and/or proc macro - Update lint documentation - Emit `MachineApplicable` suggestion with lint
- Loading branch information
Showing
5 changed files
with
219 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//@aux-build:proc_macros.rs | ||
|
||
#![warn(clippy::extern_without_abi)] | ||
|
||
extern crate proc_macros; | ||
use proc_macros::{external, with_span}; | ||
|
||
#[rustfmt::skip] | ||
extern "C" fn foo() {} | ||
//~^ ERROR: `extern` missing explicit ABI | ||
|
||
#[rustfmt::skip] | ||
extern "C" | ||
fn foo_two() {} | ||
//~^^ ERROR: `extern` missing explicit ABI | ||
|
||
extern "C" fn bar() {} | ||
|
||
#[rustfmt::skip] | ||
extern | ||
"C" | ||
fn bar_two() {} | ||
|
||
extern "system" fn baz() {} | ||
|
||
#[rustfmt::skip] | ||
extern "C" { | ||
//~^ ERROR: `extern` missing explicit ABI | ||
fn qux(); | ||
} | ||
|
||
#[rustfmt::skip] | ||
extern "C" | ||
{ | ||
//~^^ ERROR: `extern` missing explicit ABI | ||
fn qux_two(); | ||
} | ||
|
||
#[rustfmt::skip] | ||
extern "C" {fn qux_three();} | ||
//~^ ERROR: `extern` missing explicit ABI | ||
|
||
extern "C" { | ||
fn grault(); | ||
} | ||
|
||
extern "system" { | ||
fn grault_two(); | ||
} | ||
|
||
external! { | ||
extern fn waldo() {} | ||
} | ||
|
||
with_span! { | ||
span | ||
extern fn waldo_two() {} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,60 @@ | ||
//@aux-build:proc_macros.rs | ||
|
||
#![warn(clippy::extern_without_abi)] | ||
|
||
fn main() {} | ||
extern crate proc_macros; | ||
use proc_macros::{external, with_span}; | ||
|
||
#[rustfmt::skip] | ||
extern fn foo() {} | ||
//~^ ERROR: `extern` missing explicit ABI | ||
|
||
#[rustfmt::skip] | ||
extern | ||
fn foo_two() {} | ||
//~^^ ERROR: `extern` missing explicit ABI | ||
|
||
extern "C" fn bar() {} | ||
|
||
#[rustfmt::skip] | ||
extern | ||
"C" | ||
fn bar_two() {} | ||
|
||
extern "system" fn baz() {} | ||
|
||
#[rustfmt::skip] | ||
extern { | ||
//~^ ERROR: `extern` missing explicit ABI | ||
static QUX: std::ffi::c_int; | ||
fn qux(); | ||
} | ||
|
||
fn quux(); | ||
#[rustfmt::skip] | ||
extern | ||
{ | ||
//~^^ ERROR: `extern` missing explicit ABI | ||
fn qux_two(); | ||
} | ||
|
||
extern "C" { | ||
static CORGE: std::ffi::c_int; | ||
#[rustfmt::skip] | ||
extern {fn qux_three();} | ||
//~^ ERROR: `extern` missing explicit ABI | ||
|
||
extern "C" { | ||
fn grault(); | ||
} | ||
|
||
extern "system" { | ||
static GARPLY: std::ffi::c_int; | ||
fn grault_two(); | ||
} | ||
|
||
fn waldo(); | ||
external! { | ||
extern fn waldo() {} | ||
} | ||
|
||
with_span! { | ||
span | ||
extern fn waldo_two() {} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,66 @@ | ||
error: `extern` missing explicit ABI | ||
--> tests/ui/extern_without_abi.rs:6:1 | ||
--> tests/ui/extern_without_abi.rs:9:1 | ||
| | ||
LL | extern fn foo() {} | ||
| ^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^ help: consider using: `extern "C" fn foo() {}` | ||
| | ||
= note: `-D clippy::extern-without-abi` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::extern_without_abi)]` | ||
|
||
error: `extern` missing explicit ABI | ||
--> tests/ui/extern_without_abi.rs:14:1 | ||
--> tests/ui/extern_without_abi.rs:13:1 | ||
| | ||
LL | / extern | ||
LL | | fn foo_two() {} | ||
| |_______________^ | ||
| | ||
help: consider using | ||
| | ||
LL ~ extern "C" | ||
LL + fn foo_two() {} | ||
| | ||
|
||
error: `extern` missing explicit ABI | ||
--> tests/ui/extern_without_abi.rs:27:1 | ||
| | ||
LL | / extern { | ||
LL | | | ||
LL | | static QUX: std::ffi::c_int; | ||
... | | ||
LL | | fn qux(); | ||
LL | | } | ||
| |_^ | ||
| | ||
help: consider using | ||
| | ||
LL + extern "C" { | ||
LL + | ||
LL + fn qux(); | ||
LL + } | ||
| | ||
|
||
error: `extern` missing explicit ABI | ||
--> tests/ui/extern_without_abi.rs:33:1 | ||
| | ||
LL | / extern | ||
LL | | { | ||
LL | | | ||
LL | | fn qux_two(); | ||
LL | | } | ||
| |_^ | ||
| | ||
help: consider using | ||
| | ||
LL ~ extern "C" | ||
LL + { | ||
LL + | ||
LL + fn qux_two(); | ||
LL + } | ||
| | ||
|
||
error: `extern` missing explicit ABI | ||
--> tests/ui/extern_without_abi.rs:40:1 | ||
| | ||
LL | extern {fn qux_three();} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `extern "C" {fn qux_three();}` | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to 5 previous errors | ||
|