Skip to content

Commit 1a01c06

Browse files
committed
Add test for extern without explicit ABI
1 parent b5d3cb7 commit 1a01c06

20 files changed

+237
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// The purpose of this feature gate is to make something into a hard error in a
2+
// future edition. Consequently, this test differs from most other feature gate
3+
// tests. Instead of verifying that an error occurs when the feature gate is
4+
// missing, it ensures that the hard error is only produced with the feature
5+
// gate is present in the `future` edition -- and otherwise that only a warning
6+
// is emitted.
7+
8+
//@ revisions: current current_feature future future_feature
9+
10+
//@ [current] run-rustfix
11+
//@ [current] check-pass
12+
13+
//@ [current_feature] run-rustfix
14+
//@ [current_feature] check-pass
15+
16+
//@ [future] edition: future
17+
//@ [future] compile-flags: -Z unstable-options
18+
//@ [future] run-rustfix
19+
//@ [future] check-pass
20+
21+
//@ [future_feature] edition: future
22+
//@ [future_feature] compile-flags: -Z unstable-options
23+
24+
#![cfg_attr(future_feature, feature(explicit_extern_abis))]
25+
#![cfg_attr(current_feature, feature(explicit_extern_abis))]
26+
27+
extern "C" fn _foo() {}
28+
//[current]~^ WARN `extern` declarations without an explicit ABI are deprecated
29+
//[current_feature]~^^ WARN `extern` declarations without an explicit ABI are deprecated
30+
//[future]~^^^ WARN `extern` declarations without an explicit ABI are deprecated
31+
//[future_feature]~^^^^ ERROR `extern` declarations without an explicit ABI are disallowed
32+
33+
unsafe extern "C" fn _bar() {}
34+
//[current]~^ WARN `extern` declarations without an explicit ABI are deprecated
35+
//[current_feature]~^^ WARN `extern` declarations without an explicit ABI are deprecated
36+
//[future]~^^^ WARN `extern` declarations without an explicit ABI are deprecated
37+
//[future_feature]~^^^^ ERROR `extern` declarations without an explicit ABI are disallowed
38+
39+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
warning: `extern` declarations without an explicit ABI are deprecated
2+
--> $DIR/feature-gate-explicit-extern-abis.rs:27:1
3+
|
4+
LL | extern fn _foo() {}
5+
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
6+
|
7+
= note: `#[warn(missing_abi)]` on by default
8+
9+
warning: `extern` declarations without an explicit ABI are deprecated
10+
--> $DIR/feature-gate-explicit-extern-abis.rs:33:8
11+
|
12+
LL | unsafe extern fn _bar() {}
13+
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
14+
15+
warning: 2 warnings emitted
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// The purpose of this feature gate is to make something into a hard error in a
2+
// future edition. Consequently, this test differs from most other feature gate
3+
// tests. Instead of verifying that an error occurs when the feature gate is
4+
// missing, it ensures that the hard error is only produced with the feature
5+
// gate is present in the `future` edition -- and otherwise that only a warning
6+
// is emitted.
7+
8+
//@ revisions: current current_feature future future_feature
9+
10+
//@ [current] run-rustfix
11+
//@ [current] check-pass
12+
13+
//@ [current_feature] run-rustfix
14+
//@ [current_feature] check-pass
15+
16+
//@ [future] edition: future
17+
//@ [future] compile-flags: -Z unstable-options
18+
//@ [future] run-rustfix
19+
//@ [future] check-pass
20+
21+
//@ [future_feature] edition: future
22+
//@ [future_feature] compile-flags: -Z unstable-options
23+
24+
#![cfg_attr(future_feature, feature(explicit_extern_abis))]
25+
#![cfg_attr(current_feature, feature(explicit_extern_abis))]
26+
27+
extern "C" fn _foo() {}
28+
//[current]~^ WARN `extern` declarations without an explicit ABI are deprecated
29+
//[current_feature]~^^ WARN `extern` declarations without an explicit ABI are deprecated
30+
//[future]~^^^ WARN `extern` declarations without an explicit ABI are deprecated
31+
//[future_feature]~^^^^ ERROR `extern` declarations without an explicit ABI are disallowed
32+
33+
unsafe extern "C" fn _bar() {}
34+
//[current]~^ WARN `extern` declarations without an explicit ABI are deprecated
35+
//[current_feature]~^^ WARN `extern` declarations without an explicit ABI are deprecated
36+
//[future]~^^^ WARN `extern` declarations without an explicit ABI are deprecated
37+
//[future_feature]~^^^^ ERROR `extern` declarations without an explicit ABI are disallowed
38+
39+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
warning: `extern` declarations without an explicit ABI are deprecated
2+
--> $DIR/feature-gate-explicit-extern-abis.rs:27:1
3+
|
4+
LL | extern fn _foo() {}
5+
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
6+
|
7+
= note: `#[warn(missing_abi)]` on by default
8+
9+
warning: `extern` declarations without an explicit ABI are deprecated
10+
--> $DIR/feature-gate-explicit-extern-abis.rs:33:8
11+
|
12+
LL | unsafe extern fn _bar() {}
13+
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
14+
15+
warning: 2 warnings emitted
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// The purpose of this feature gate is to make something into a hard error in a
2+
// future edition. Consequently, this test differs from most other feature gate
3+
// tests. Instead of verifying that an error occurs when the feature gate is
4+
// missing, it ensures that the hard error is only produced with the feature
5+
// gate is present in the `future` edition -- and otherwise that only a warning
6+
// is emitted.
7+
8+
//@ revisions: current current_feature future future_feature
9+
10+
//@ [current] run-rustfix
11+
//@ [current] check-pass
12+
13+
//@ [current_feature] run-rustfix
14+
//@ [current_feature] check-pass
15+
16+
//@ [future] edition: future
17+
//@ [future] compile-flags: -Z unstable-options
18+
//@ [future] run-rustfix
19+
//@ [future] check-pass
20+
21+
//@ [future_feature] edition: future
22+
//@ [future_feature] compile-flags: -Z unstable-options
23+
24+
#![cfg_attr(future_feature, feature(explicit_extern_abis))]
25+
#![cfg_attr(current_feature, feature(explicit_extern_abis))]
26+
27+
extern "C" fn _foo() {}
28+
//[current]~^ WARN `extern` declarations without an explicit ABI are deprecated
29+
//[current_feature]~^^ WARN `extern` declarations without an explicit ABI are deprecated
30+
//[future]~^^^ WARN `extern` declarations without an explicit ABI are deprecated
31+
//[future_feature]~^^^^ ERROR `extern` declarations without an explicit ABI are disallowed
32+
33+
unsafe extern "C" fn _bar() {}
34+
//[current]~^ WARN `extern` declarations without an explicit ABI are deprecated
35+
//[current_feature]~^^ WARN `extern` declarations without an explicit ABI are deprecated
36+
//[future]~^^^ WARN `extern` declarations without an explicit ABI are deprecated
37+
//[future_feature]~^^^^ ERROR `extern` declarations without an explicit ABI are disallowed
38+
39+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
warning: `extern` declarations without an explicit ABI are deprecated
2+
--> $DIR/feature-gate-explicit-extern-abis.rs:27:1
3+
|
4+
LL | extern fn _foo() {}
5+
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
6+
|
7+
= note: `#[warn(missing_abi)]` on by default
8+
9+
warning: `extern` declarations without an explicit ABI are deprecated
10+
--> $DIR/feature-gate-explicit-extern-abis.rs:33:8
11+
|
12+
LL | unsafe extern fn _bar() {}
13+
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
14+
15+
warning: 2 warnings emitted
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error: `extern` declarations without an explicit ABI are disallowed
2+
--> $DIR/feature-gate-explicit-extern-abis.rs:27:1
3+
|
4+
LL | extern fn _foo() {}
5+
| ^^^^^^ help: `extern` declarations require an explicit ABI: `extern { <ABI> }`
6+
|
7+
= help: previously, a default was inferred, but you must now specify one
8+
9+
error: `extern` declarations without an explicit ABI are disallowed
10+
--> $DIR/feature-gate-explicit-extern-abis.rs:33:8
11+
|
12+
LL | unsafe extern fn _bar() {}
13+
| ^^^^^^ help: `extern` declarations require an explicit ABI: `extern { <ABI> }`
14+
|
15+
= help: previously, a default was inferred, but you must now specify one
16+
17+
error: aborting due to 2 previous errors
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// The purpose of this feature gate is to make something into a hard error in a
2+
// future edition. Consequently, this test differs from most other feature gate
3+
// tests. Instead of verifying that an error occurs when the feature gate is
4+
// missing, it ensures that the hard error is only produced with the feature
5+
// gate is present in the `future` edition -- and otherwise that only a warning
6+
// is emitted.
7+
8+
//@ revisions: current current_feature future future_feature
9+
10+
//@ [current] run-rustfix
11+
//@ [current] check-pass
12+
13+
//@ [current_feature] run-rustfix
14+
//@ [current_feature] check-pass
15+
16+
//@ [future] edition: future
17+
//@ [future] compile-flags: -Z unstable-options
18+
//@ [future] run-rustfix
19+
//@ [future] check-pass
20+
21+
//@ [future_feature] edition: future
22+
//@ [future_feature] compile-flags: -Z unstable-options
23+
24+
#![cfg_attr(future_feature, feature(explicit_extern_abis))]
25+
#![cfg_attr(current_feature, feature(explicit_extern_abis))]
26+
27+
extern fn _foo() {}
28+
//[current]~^ WARN `extern` declarations without an explicit ABI are deprecated
29+
//[current_feature]~^^ WARN `extern` declarations without an explicit ABI are deprecated
30+
//[future]~^^^ WARN `extern` declarations without an explicit ABI are deprecated
31+
//[future_feature]~^^^^ ERROR `extern` declarations without an explicit ABI are disallowed
32+
33+
unsafe extern fn _bar() {}
34+
//[current]~^ WARN `extern` declarations without an explicit ABI are deprecated
35+
//[current_feature]~^^ WARN `extern` declarations without an explicit ABI are deprecated
36+
//[future]~^^^ WARN `extern` declarations without an explicit ABI are deprecated
37+
//[future_feature]~^^^^ ERROR `extern` declarations without an explicit ABI are disallowed
38+
39+
fn main() {}

Diff for: tests/ui/link-native-libs/suggest-libname-only-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@ compile-flags: --crate-type rlib
33

44
#[link(name = "libfoo.a", kind = "static")]
5-
extern { } //~ WARN extern declarations without an explicit ABI are deprecated
5+
extern { } //~ WARN `extern` declarations without an explicit ABI are deprecated
66
//~| HELP explicitly specify the "C" ABI
77

88
pub fn main() { }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
warning: extern declarations without an explicit ABI are deprecated
1+
warning: `extern` declarations without an explicit ABI are deprecated
22
--> $DIR/suggest-libname-only-1.rs:5:1
33
|
44
LL | extern { }

Diff for: tests/ui/link-native-libs/suggest-libname-only-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@ compile-flags: --crate-type rlib
33

44
#[link(name = "bar.lib", kind = "static")]
5-
extern { } //~ WARN extern declarations without an explicit ABI are deprecated
5+
extern { } //~ WARN `extern` declarations without an explicit ABI are deprecated
66
//~| HELP explicitly specify the "C" ABI
77

88
pub fn main() { }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
warning: extern declarations without an explicit ABI are deprecated
1+
warning: `extern` declarations without an explicit ABI are deprecated
22
--> $DIR/suggest-libname-only-2.rs:5:1
33
|
44
LL | extern { }

Diff for: tests/ui/lint/cli-lint-override.forbid_warn.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: extern declarations without an explicit ABI are deprecated
1+
error: `extern` declarations without an explicit ABI are deprecated
22
--> $DIR/cli-lint-override.rs:12:1
33
|
44
LL | extern fn foo() {}

Diff for: tests/ui/lint/cli-lint-override.force_warn_deny.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
warning: extern declarations without an explicit ABI are deprecated
1+
warning: `extern` declarations without an explicit ABI are deprecated
22
--> $DIR/cli-lint-override.rs:12:1
33
|
44
LL | extern fn foo() {}

Diff for: tests/ui/lint/cli-lint-override.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111

1212
extern fn foo() {}
13-
//[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]~^ 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
1616

1717
fn main() {}

Diff for: tests/ui/lint/cli-lint-override.warn_deny.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: extern declarations without an explicit ABI are deprecated
1+
error: `extern` declarations without an explicit ABI are deprecated
22
--> $DIR/cli-lint-override.rs:12:1
33
|
44
LL | extern fn foo() {}

Diff for: tests/ui/parser/bad-lit-suffixes.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ LL | #[rustc_layout_scalar_valid_range_start(0suffix)]
5151
|
5252
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
5353

54-
warning: extern declarations without an explicit ABI are deprecated
54+
warning: `extern` declarations without an explicit ABI are deprecated
5555
--> $DIR/bad-lit-suffixes.rs:3:1
5656
|
5757
LL | extern
5858
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
5959
|
6060
= note: `#[warn(missing_abi)]` on by default
6161

62-
warning: extern declarations without an explicit ABI are deprecated
62+
warning: `extern` declarations without an explicit ABI are deprecated
6363
--> $DIR/bad-lit-suffixes.rs:7:1
6464
|
6565
LL | extern

Diff for: tests/ui/parser/lit-err-in-macro.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: suffixes on string literals are invalid
44
LL | f!("Foo"__);
55
| ^^^^^^^ invalid suffix `__`
66

7-
warning: extern declarations without an explicit ABI are deprecated
7+
warning: `extern` declarations without an explicit ABI are deprecated
88
--> $DIR/lit-err-in-macro.rs:3:9
99
|
1010
LL | extern $abi fn f() {}

Diff for: tests/ui/proc-macro/inner-attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn bar() {
8282
}
8383

8484

85-
extern { //~ WARN extern declarations without an explicit ABI are deprecated
85+
extern { //~ WARN `extern` declarations without an explicit ABI are deprecated
8686
fn weird_extern() {
8787
#![print_target_and_args_consume(tenth)]
8888
}

Diff for: tests/ui/proc-macro/inner-attrs.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ error: expected non-macro inner attribute, found attribute macro `print_attr`
2222
LL | #![print_attr]
2323
| ^^^^^^^^^^ not a non-macro inner attribute
2424

25-
warning: extern declarations without an explicit ABI are deprecated
25+
warning: `extern` declarations without an explicit ABI are deprecated
2626
--> $DIR/inner-attrs.rs:85:1
2727
|
2828
LL | extern {

0 commit comments

Comments
 (0)