Skip to content

Commit 76c779f

Browse files
committedApr 8, 2025
Add test for extern without explicit ABI
1 parent a5cb6d3 commit 76c779f

8 files changed

+170
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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: 1 warning emitted
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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: 1 warning emitted
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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: 1 warning emitted
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
| ^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
fn main() {}

0 commit comments

Comments
 (0)