Skip to content

Commit 7c51363

Browse files
committed
Add test for extern without explicit ABI
1 parent 74f4426 commit 7c51363

20 files changed

+287
-15
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
unsafe extern "C" {}
40+
//[current]~^ WARN `extern` declarations without an explicit ABI are deprecated
41+
//[current_feature]~^^ WARN `extern` declarations without an explicit ABI are deprecated
42+
//[future]~^^^ WARN `extern` declarations without an explicit ABI are deprecated
43+
//[future_feature]~^^^^ ERROR `extern` declarations without an explicit ABI are disallowed
44+
45+
fn main() {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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: `extern` declarations without an explicit ABI are deprecated
16+
--> $DIR/feature-gate-explicit-extern-abis.rs:39:8
17+
|
18+
LL | unsafe extern {}
19+
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
20+
21+
warning: 3 warnings emitted
22+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
unsafe extern "C" {}
40+
//[current]~^ WARN `extern` declarations without an explicit ABI are deprecated
41+
//[current_feature]~^^ WARN `extern` declarations without an explicit ABI are deprecated
42+
//[future]~^^^ WARN `extern` declarations without an explicit ABI are deprecated
43+
//[future_feature]~^^^^ ERROR `extern` declarations without an explicit ABI are disallowed
44+
45+
fn main() {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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: `extern` declarations without an explicit ABI are deprecated
16+
--> $DIR/feature-gate-explicit-extern-abis.rs:39:8
17+
|
18+
LL | unsafe extern {}
19+
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
20+
21+
warning: 3 warnings emitted
22+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
unsafe extern "C" {}
40+
//[current]~^ WARN `extern` declarations without an explicit ABI are deprecated
41+
//[current_feature]~^^ WARN `extern` declarations without an explicit ABI are deprecated
42+
//[future]~^^^ WARN `extern` declarations without an explicit ABI are deprecated
43+
//[future_feature]~^^^^ ERROR `extern` declarations without an explicit ABI are disallowed
44+
45+
fn main() {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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: `extern` declarations without an explicit ABI are deprecated
16+
--> $DIR/feature-gate-explicit-extern-abis.rs:39:8
17+
|
18+
LL | unsafe extern {}
19+
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
20+
21+
warning: 3 warnings emitted
22+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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: specify an ABI: `extern <abi>`
6+
|
7+
= help: prior to Rust 2024, a default ABI was inferred
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: specify an ABI: `extern <abi>`
14+
|
15+
= help: prior to Rust 2024, a default ABI was inferred
16+
17+
error: `extern` declarations without an explicit ABI are disallowed
18+
--> $DIR/feature-gate-explicit-extern-abis.rs:39:8
19+
|
20+
LL | unsafe extern {}
21+
| ^^^^^^ help: specify an ABI: `extern <abi>`
22+
|
23+
= help: prior to Rust 2024, a default ABI was inferred
24+
25+
error: aborting due to 3 previous errors
26+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
unsafe extern {}
40+
//[current]~^ WARN `extern` declarations without an explicit ABI are deprecated
41+
//[current_feature]~^^ WARN `extern` declarations without an explicit ABI are deprecated
42+
//[future]~^^^ WARN `extern` declarations without an explicit ABI are deprecated
43+
//[future_feature]~^^^^ ERROR `extern` declarations without an explicit ABI are disallowed
44+
45+
fn main() {}

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

Lines changed: 1 addition & 1 deletion
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() { }

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

Lines changed: 1 addition & 1 deletion
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 { }

0 commit comments

Comments
 (0)