Skip to content

Commit a780e84

Browse files
tests: split out invalid-in-impl-positions test
1 parent 5eb2c1d commit a780e84

9 files changed

+66
-174
lines changed

tests/ui/abi/unsupported-in-impls.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Test for https://github.com/rust-lang/rust/issues/86232
2+
// Due to AST-to-HIR lowering nuances, we used to allow unsupported ABIs to "leak" into the HIR
3+
// without being checked, as we would check after generating the ExternAbi.
4+
//
5+
// Here we test that an unsupported ABI in various impl-related positions will be rejected,
6+
// both in the original declarations and the actual implementations.
7+
8+
#![feature(rustc_attrs)]
9+
//@ compile-flags: --crate-type lib
10+
11+
pub struct FnPtrBearer {
12+
pub ptr: extern "rust-invalid" fn(),
13+
//~^ ERROR: is not a supported ABI
14+
}
15+
16+
impl FnPtrBearer {
17+
pub extern "rust-invalid" fn inherent_fn(self) {
18+
//~^ ERROR: is not a supported ABI
19+
(self.ptr)()
20+
}
21+
}
22+
23+
pub trait Trait {
24+
extern "rust-invalid" fn trait_fn(self);
25+
//~^ ERROR: is not a supported ABI
26+
}
27+
28+
impl Trait for FnPtrBearer {
29+
extern "rust-invalid" fn trait_fn(self) {
30+
//~^ ERROR: is not a supported ABI
31+
self.inherent_fn()
32+
}
33+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0570]: "invalid" is not a supported ABI for the current target
2+
--> $DIR/unsupported-in-impls.rs:15:21
3+
|
4+
LL | pub ptr: extern "invalid" fn(),
5+
| ^^^^^^^^^
6+
7+
error[E0570]: "invalid" is not a supported ABI for the current target
8+
--> $DIR/unsupported-in-impls.rs:20:16
9+
|
10+
LL | pub extern "invalid" fn inherent_fn(self) {
11+
| ^^^^^^^^^
12+
13+
error[E0570]: "invalid" is not a supported ABI for the current target
14+
--> $DIR/unsupported-in-impls.rs:27:12
15+
|
16+
LL | extern "invalid" fn trait_fn(self);
17+
| ^^^^^^^^^
18+
19+
error[E0570]: "invalid" is not a supported ABI for the current target
20+
--> $DIR/unsupported-in-impls.rs:32:12
21+
|
22+
LL | extern "invalid" fn trait_fn(self) {
23+
| ^^^^^^^^^
24+
25+
error: aborting due to 4 previous errors
26+
27+
For more information about this error, try `rustc --explain E0570`.

tests/ui/abi/unsupported.aarch64.stderr

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -156,30 +156,6 @@ error[E0570]: "C-cmse-nonsecure-entry" is not a supported ABI for the current ta
156156
LL | extern "C-cmse-nonsecure-entry" {}
157157
| ^^^^^^^^^^^^^^^^^^^^^^^^
158158

159-
error[E0570]: "thiscall" is not a supported ABI for the current target
160-
--> $DIR/unsupported.rs:141:17
161-
|
162-
LL | ptr: extern "thiscall" fn(),
163-
| ^^^^^^^^^^
164-
165-
error[E0570]: "thiscall" is not a supported ABI for the current target
166-
--> $DIR/unsupported.rs:146:16
167-
|
168-
LL | pub extern "thiscall" fn inherent_fn(self) {
169-
| ^^^^^^^^^^
170-
171-
error[E0570]: "thiscall" is not a supported ABI for the current target
172-
--> $DIR/unsupported.rs:153:12
173-
|
174-
LL | extern "thiscall" fn trait_fn(self);
175-
| ^^^^^^^^^^
176-
177-
error[E0570]: "thiscall" is not a supported ABI for the current target
178-
--> $DIR/unsupported.rs:158:12
179-
|
180-
LL | extern "thiscall" fn trait_fn(self) {
181-
| ^^^^^^^^^^
182-
183159
warning: "cdecl" is not a supported ABI for the current target
184160
--> $DIR/unsupported.rs:99:17
185161
|
@@ -221,6 +197,6 @@ LL | extern "cdecl" fn cdecl() {}
221197
= note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
222198
= help: use `extern "C"` instead
223199

224-
error: aborting due to 29 previous errors; 4 warnings emitted
200+
error: aborting due to 25 previous errors; 4 warnings emitted
225201

226202
For more information about this error, try `rustc --explain E0570`.

tests/ui/abi/unsupported.arm.stderr

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -138,30 +138,6 @@ error[E0570]: "C-cmse-nonsecure-entry" is not a supported ABI for the current ta
138138
LL | extern "C-cmse-nonsecure-entry" {}
139139
| ^^^^^^^^^^^^^^^^^^^^^^^^
140140

141-
error[E0570]: "thiscall" is not a supported ABI for the current target
142-
--> $DIR/unsupported.rs:141:17
143-
|
144-
LL | ptr: extern "thiscall" fn(),
145-
| ^^^^^^^^^^
146-
147-
error[E0570]: "thiscall" is not a supported ABI for the current target
148-
--> $DIR/unsupported.rs:146:16
149-
|
150-
LL | pub extern "thiscall" fn inherent_fn(self) {
151-
| ^^^^^^^^^^
152-
153-
error[E0570]: "thiscall" is not a supported ABI for the current target
154-
--> $DIR/unsupported.rs:153:12
155-
|
156-
LL | extern "thiscall" fn trait_fn(self);
157-
| ^^^^^^^^^^
158-
159-
error[E0570]: "thiscall" is not a supported ABI for the current target
160-
--> $DIR/unsupported.rs:158:12
161-
|
162-
LL | extern "thiscall" fn trait_fn(self) {
163-
| ^^^^^^^^^^
164-
165141
warning: "cdecl" is not a supported ABI for the current target
166142
--> $DIR/unsupported.rs:99:17
167143
|
@@ -203,6 +179,6 @@ LL | extern "cdecl" fn cdecl() {}
203179
= note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
204180
= help: use `extern "C"` instead
205181

206-
error: aborting due to 26 previous errors; 4 warnings emitted
182+
error: aborting due to 22 previous errors; 4 warnings emitted
207183

208184
For more information about this error, try `rustc --explain E0570`.

tests/ui/abi/unsupported.riscv32.stderr

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -150,30 +150,6 @@ error[E0570]: "C-cmse-nonsecure-entry" is not a supported ABI for the current ta
150150
LL | extern "C-cmse-nonsecure-entry" {}
151151
| ^^^^^^^^^^^^^^^^^^^^^^^^
152152

153-
error[E0570]: "thiscall" is not a supported ABI for the current target
154-
--> $DIR/unsupported.rs:141:17
155-
|
156-
LL | ptr: extern "thiscall" fn(),
157-
| ^^^^^^^^^^
158-
159-
error[E0570]: "thiscall" is not a supported ABI for the current target
160-
--> $DIR/unsupported.rs:146:16
161-
|
162-
LL | pub extern "thiscall" fn inherent_fn(self) {
163-
| ^^^^^^^^^^
164-
165-
error[E0570]: "thiscall" is not a supported ABI for the current target
166-
--> $DIR/unsupported.rs:153:12
167-
|
168-
LL | extern "thiscall" fn trait_fn(self);
169-
| ^^^^^^^^^^
170-
171-
error[E0570]: "thiscall" is not a supported ABI for the current target
172-
--> $DIR/unsupported.rs:158:12
173-
|
174-
LL | extern "thiscall" fn trait_fn(self) {
175-
| ^^^^^^^^^^
176-
177153
warning: "cdecl" is not a supported ABI for the current target
178154
--> $DIR/unsupported.rs:99:17
179155
|
@@ -215,6 +191,6 @@ LL | extern "cdecl" fn cdecl() {}
215191
= note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
216192
= help: use `extern "C"` instead
217193

218-
error: aborting due to 28 previous errors; 4 warnings emitted
194+
error: aborting due to 24 previous errors; 4 warnings emitted
219195

220196
For more information about this error, try `rustc --explain E0570`.

tests/ui/abi/unsupported.riscv64.stderr

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -150,30 +150,6 @@ error[E0570]: "C-cmse-nonsecure-entry" is not a supported ABI for the current ta
150150
LL | extern "C-cmse-nonsecure-entry" {}
151151
| ^^^^^^^^^^^^^^^^^^^^^^^^
152152

153-
error[E0570]: "thiscall" is not a supported ABI for the current target
154-
--> $DIR/unsupported.rs:141:17
155-
|
156-
LL | ptr: extern "thiscall" fn(),
157-
| ^^^^^^^^^^
158-
159-
error[E0570]: "thiscall" is not a supported ABI for the current target
160-
--> $DIR/unsupported.rs:146:16
161-
|
162-
LL | pub extern "thiscall" fn inherent_fn(self) {
163-
| ^^^^^^^^^^
164-
165-
error[E0570]: "thiscall" is not a supported ABI for the current target
166-
--> $DIR/unsupported.rs:153:12
167-
|
168-
LL | extern "thiscall" fn trait_fn(self);
169-
| ^^^^^^^^^^
170-
171-
error[E0570]: "thiscall" is not a supported ABI for the current target
172-
--> $DIR/unsupported.rs:158:12
173-
|
174-
LL | extern "thiscall" fn trait_fn(self) {
175-
| ^^^^^^^^^^
176-
177153
warning: "cdecl" is not a supported ABI for the current target
178154
--> $DIR/unsupported.rs:99:17
179155
|
@@ -215,6 +191,6 @@ LL | extern "cdecl" fn cdecl() {}
215191
= note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
216192
= help: use `extern "C"` instead
217193

218-
error: aborting due to 28 previous errors; 4 warnings emitted
194+
error: aborting due to 24 previous errors; 4 warnings emitted
219195

220196
For more information about this error, try `rustc --explain E0570`.

tests/ui/abi/unsupported.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,3 @@ extern "C-cmse-nonsecure-entry" {}
136136
extern "cdecl" {}
137137
//[x64_win]~^ WARN unsupported_calling_conventions
138138
//[x64_win]~^^ WARN this was previously accepted
139-
140-
struct FnPtrBearer {
141-
ptr: extern "thiscall" fn(),
142-
//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR: is not a supported ABI
143-
}
144-
145-
impl FnPtrBearer {
146-
pub extern "thiscall" fn inherent_fn(self) {
147-
//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR: is not a supported ABI
148-
(self.ptr)()
149-
}
150-
}
151-
152-
trait Trait {
153-
extern "thiscall" fn trait_fn(self);
154-
//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR: is not a supported ABI
155-
}
156-
157-
impl Trait for FnPtrBearer {
158-
extern "thiscall" fn trait_fn(self) {
159-
//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR: is not a supported ABI
160-
self.inherent_fn()
161-
}
162-
}

tests/ui/abi/unsupported.x64.stderr

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -132,30 +132,6 @@ error[E0570]: "C-cmse-nonsecure-entry" is not a supported ABI for the current ta
132132
LL | extern "C-cmse-nonsecure-entry" {}
133133
| ^^^^^^^^^^^^^^^^^^^^^^^^
134134

135-
error[E0570]: "thiscall" is not a supported ABI for the current target
136-
--> $DIR/unsupported.rs:141:17
137-
|
138-
LL | ptr: extern "thiscall" fn(),
139-
| ^^^^^^^^^^
140-
141-
error[E0570]: "thiscall" is not a supported ABI for the current target
142-
--> $DIR/unsupported.rs:146:16
143-
|
144-
LL | pub extern "thiscall" fn inherent_fn(self) {
145-
| ^^^^^^^^^^
146-
147-
error[E0570]: "thiscall" is not a supported ABI for the current target
148-
--> $DIR/unsupported.rs:153:12
149-
|
150-
LL | extern "thiscall" fn trait_fn(self);
151-
| ^^^^^^^^^^
152-
153-
error[E0570]: "thiscall" is not a supported ABI for the current target
154-
--> $DIR/unsupported.rs:158:12
155-
|
156-
LL | extern "thiscall" fn trait_fn(self) {
157-
| ^^^^^^^^^^
158-
159135
warning: "cdecl" is not a supported ABI for the current target
160136
--> $DIR/unsupported.rs:99:17
161137
|
@@ -197,6 +173,6 @@ LL | extern "cdecl" fn cdecl() {}
197173
= note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
198174
= help: use `extern "C"` instead
199175

200-
error: aborting due to 25 previous errors; 4 warnings emitted
176+
error: aborting due to 21 previous errors; 4 warnings emitted
201177

202178
For more information about this error, try `rustc --explain E0570`.

tests/ui/abi/unsupported.x64_win.stderr

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -100,30 +100,6 @@ error[E0570]: "C-cmse-nonsecure-entry" is not a supported ABI for the current ta
100100
LL | extern "C-cmse-nonsecure-entry" {}
101101
| ^^^^^^^^^^^^^^^^^^^^^^^^
102102

103-
error[E0570]: "thiscall" is not a supported ABI for the current target
104-
--> $DIR/unsupported.rs:141:17
105-
|
106-
LL | ptr: extern "thiscall" fn(),
107-
| ^^^^^^^^^^
108-
109-
error[E0570]: "thiscall" is not a supported ABI for the current target
110-
--> $DIR/unsupported.rs:146:16
111-
|
112-
LL | pub extern "thiscall" fn inherent_fn(self) {
113-
| ^^^^^^^^^^
114-
115-
error[E0570]: "thiscall" is not a supported ABI for the current target
116-
--> $DIR/unsupported.rs:153:12
117-
|
118-
LL | extern "thiscall" fn trait_fn(self);
119-
| ^^^^^^^^^^
120-
121-
error[E0570]: "thiscall" is not a supported ABI for the current target
122-
--> $DIR/unsupported.rs:158:12
123-
|
124-
LL | extern "thiscall" fn trait_fn(self) {
125-
| ^^^^^^^^^^
126-
127103
warning: "stdcall" is not a supported ABI for the current target
128104
--> $DIR/unsupported.rs:81:19
129105
|
@@ -215,6 +191,6 @@ LL | extern "cdecl" fn cdecl() {}
215191
= note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
216192
= help: use `extern "C"` instead
217193

218-
error: aborting due to 21 previous errors; 9 warnings emitted
194+
error: aborting due to 17 previous errors; 9 warnings emitted
219195

220196
For more information about this error, try `rustc --explain E0570`.

0 commit comments

Comments
 (0)