Skip to content

Commit e3867bd

Browse files
committed
Mark missing_abi lint as an edition migration lint
1 parent 327aa1e commit e3867bd

16 files changed

+74
-31
lines changed

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3544,9 +3544,15 @@ declare_lint! {
35443544
/// easily makes code review easier.
35453545
///
35463546
/// [Other ABIs]: https://doc.rust-lang.org/reference/items/external-blocks.html#abi
3547+
/// [issue #134986]: https://github.com/rust-lang/rust/issues/134986
3548+
/// [`cargo fix`]: https://doc.rust-lang.org/cargo/commands/cargo-fix.html
35473549
pub MISSING_ABI,
35483550
Warn,
3549-
"No declared ABI for extern declaration"
3551+
"No declared ABI for extern declaration",
3552+
@future_incompatible = FutureIncompatibleInfo {
3553+
reason: FutureIncompatibilityReason::EditionError(Edition::EditionFuture),
3554+
reference: "issue #134986 <https://github.com/rust-lang/rust/issues/134986>",
3555+
};
35503556
}
35513557

35523558
declare_lint! {

src/tools/lint-docs/src/groups.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static GROUP_DESCRIPTIONS: &[(&str, &str)] = &[
2626
"Lints that detect identifiers which will be come keywords in later editions",
2727
),
2828
("deprecated-safe", "Lints for functions which were erroneously marked as safe in the past"),
29+
("missing_abi", "Lint detects cases where the ABI is omitted from `extern` declarations"),
2930
];
3031

3132
type LintGroups = BTreeMap<String, BTreeSet<String>>;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ run-pass
2+
//@ run-rustfix
3+
4+
extern "C" fn _foo() {}
5+
//~^ WARN extern declarations without an explicit ABI are deprecated
6+
//~^^ WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust future!
7+
8+
fn main() {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ run-pass
2+
//@ run-rustfix
23

34
extern fn _foo() {}
45
//~^ WARN extern declarations without an explicit ABI are deprecated
6+
//~^^ WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust future!
57

68
fn main() {}

tests/ui/feature-gates/feature-gate-explicit-extern-abis.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
warning: extern declarations without an explicit ABI are deprecated
2-
--> $DIR/feature-gate-explicit-extern-abis.rs:3:1
2+
--> $DIR/feature-gate-explicit-extern-abis.rs:4:1
33
|
44
LL | extern fn _foo() {}
55
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
66
|
7+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust future!
8+
= note: for more information, see issue #134986 <https://github.com/rust-lang/rust/issues/134986>
79
= note: `#[warn(missing_abi)]` on by default
810

911
warning: 1 warning emitted

tests/ui/link-native-libs/suggest-libname-only-1.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ warning: extern declarations without an explicit ABI are deprecated
44
LL | extern { }
55
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
66
|
7+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust future!
8+
= note: for more information, see issue #134986 <https://github.com/rust-lang/rust/issues/134986>
79
= note: `#[warn(missing_abi)]` on by default
810

911
error: could not find native static library `libfoo.a`, perhaps an -L flag is missing?

tests/ui/link-native-libs/suggest-libname-only-2.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ warning: extern declarations without an explicit ABI are deprecated
44
LL | extern { }
55
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
66
|
7+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust future!
8+
= note: for more information, see issue #134986 <https://github.com/rust-lang/rust/issues/134986>
79
= note: `#[warn(missing_abi)]` on by default
810

911
error: could not find native static library `bar.lib`, perhaps an -L flag is missing?

tests/ui/lint/cli-lint-override.forbid_warn.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
error: extern declarations without an explicit ABI are deprecated
2-
--> $DIR/cli-lint-override.rs:12:1
2+
--> $DIR/cli-lint-override.rs:11:1
33
|
44
LL | extern fn foo() {}
55
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
66
|
7+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust future!
8+
= note: for more information, see issue #134986 <https://github.com/rust-lang/rust/issues/134986>
79
= note: requested on the command line with `-F missing-abi`
810

911
error: aborting due to 1 previous error

tests/ui/lint/cli-lint-override.force_warn_deny.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
warning: extern declarations without an explicit ABI are deprecated
2-
--> $DIR/cli-lint-override.rs:12:1
2+
--> $DIR/cli-lint-override.rs:11:1
33
|
44
LL | extern fn foo() {}
55
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
66
|
7+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust future!
8+
= note: for more information, see issue #134986 <https://github.com/rust-lang/rust/issues/134986>
79
= note: requested on the command line with `--force-warn missing-abi`
810

911
warning: 1 warning emitted

tests/ui/lint/cli-lint-override.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
//@[force_warn_deny] compile-flags: --force-warn missing_abi --allow missing_abi
99
//@[force_warn_deny] check-pass
1010

11-
1211
extern fn foo() {}
1312
//[warn_deny]~^ ERROR extern declarations without an explicit ABI are deprecated
14-
//[forbid_warn]~^^ ERROR extern declarations without an explicit ABI are deprecated
15-
//[force_warn_deny]~^^^ WARN extern declarations without an explicit ABI are deprecated
13+
//[warn_deny]~^^ WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust future!
14+
//[forbid_warn]~^^^ ERROR extern declarations without an explicit ABI are deprecated
15+
//[forbid_warn]~^^^^ WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust future!
16+
//[force_warn_deny]~^^^^^ WARN extern declarations without an explicit ABI are deprecated
17+
//[force_warn_deny]~^^^^^^ WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust future!
1618

1719
fn main() {}

0 commit comments

Comments
 (0)