-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Reject unsupported extern "{abi}"
s consistently in all positions
#142134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
workingjubilee
wants to merge
13
commits into
rust-lang:master
Choose a base branch
from
workingjubilee:reject-unsupported-abi
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,282
−1,989
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0a9d50c
compiler: plug unsupported ABI leakage from the AST
workingjubilee 8e1560f
compiler: Avoid double-errors on ABIs during hir_analysis
workingjubilee 5614e46
compiler: Remove unsupported_fn_ptr_calling_conventions lint
workingjubilee 85bc53d
tests: Bless abi_gpu_kernel feature gate test
workingjubilee 82a0ba3
tests: Upgrade unstable ABIs to errors in unsupported ABI test
workingjubilee 339a0b7
tests: Update and bless cmse-nonsecure ABI tests
workingjubilee b61f777
tests: Adopt ABI transmute tests from crashtests
workingjubilee f8811f6
tests: Adopt unsupported ABI in weird type impl test
workingjubilee bdad069
rustdoc-json: Rearrange deck chairs in ABI testing
workingjubilee eaf8932
tests: Verify varargs with unsupported fn ptr ABIs must error
workingjubilee 4036396
tests: Verify traits with unsupported ABIs must error
workingjubilee d662baa
tests: Change "fastcall" to "system" in some tests
workingjubilee fa0169e
ast_lowering: Explain why we double-error for unstable arch-specific …
workingjubilee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#![feature(abi_vectorcall)] | ||
//@ only-x86_64 | ||
|
||
//@ is "$.index[?(@.name=='AbiVectorcall')].inner.type_alias.type.function_pointer.header.abi.Other" '"\"vectorcall\""' | ||
pub type AbiVectorcall = extern "vectorcall" fn(); | ||
|
||
//@ is "$.index[?(@.name=='AbiVectorcallUnwind')].inner.type_alias.type.function_pointer.header.abi.Other" '"\"vectorcall-unwind\""' | ||
pub type AbiVectorcallUnwind = extern "vectorcall-unwind" fn(); | ||
|
||
//@ has "$.index[?(@.name=='Foo')]" | ||
pub struct Foo; | ||
|
||
impl Foo { | ||
//@ is "$.index[?(@.name=='abi_vectorcall')].inner.function.header.abi.Other" '"\"vectorcall\""' | ||
pub extern "vectorcall" fn abi_vectorcall() {} | ||
|
||
//@ is "$.index[?(@.name=='abi_vectorcall_unwind')].inner.function.header.abi.Other" '"\"vectorcall-unwind\""' | ||
pub extern "vectorcall-unwind" fn abi_vectorcall_unwind() {} | ||
} | ||
|
||
pub trait Bar { | ||
//@ is "$.index[?(@.name=='trait_abi_vectorcall')].inner.function.header.abi.Other" '"\"vectorcall\""' | ||
extern "vectorcall" fn trait_abi_vectorcall() {} | ||
|
||
//@ is "$.index[?(@.name=='trait_abi_vectorcall_unwind')].inner.function.header.abi.Other" '"\"vectorcall-unwind\""' | ||
extern "vectorcall-unwind" fn trait_abi_vectorcall_unwind() {} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#![feature(abi_gpu_kernel)] | ||
// Check we error before unsupported ABIs reach codegen stages. | ||
|
||
fn main() { | ||
let a = unsafe { core::mem::transmute::<usize, extern "gpu-kernel" fn(i32)>(4) }(2); | ||
//~^ ERROR E0570 | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target | ||
--> $DIR/unsupported-abi-transmute.rs:5:59 | ||
| | ||
LL | let a = unsafe { core::mem::transmute::<usize, extern "gpu-kernel" fn(i32)>(4) }(2); | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0570`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//@ compile-flags: --crate-type=lib | ||
//@ edition: 2018 | ||
#![feature(abi_gpu_kernel)] | ||
struct Test; | ||
|
||
impl Test { | ||
pub extern "gpu-kernel" fn test(val: &str) {} | ||
//~^ ERROR [E0570] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error codes are pretty meaningless, making the test file hard to read. IMO it'd be better to have a snippet of the error message in the test file here. |
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target | ||
--> $DIR/unsupported-extern-abi-in-type-impl.rs:7:16 | ||
| | ||
LL | pub extern "gpu-kernel" fn test(val: &str) {} | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0570`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//@ compile-flags: --crate-type=lib | ||
|
||
#![feature(abi_gpu_kernel)] | ||
|
||
trait T { | ||
extern "gpu-kernel" fn mu(); | ||
//~^ ERROR[E0570] | ||
} | ||
|
||
type TAU = extern "gpu-kernel" fn(); | ||
//~^ ERROR[E0570] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target | ||
--> $DIR/unsupported-trait-decl.rs:6:12 | ||
| | ||
LL | extern "gpu-kernel" fn mu(); | ||
| ^^^^^^^^^^^^ | ||
|
||
error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target | ||
--> $DIR/unsupported-trait-decl.rs:10:19 | ||
| | ||
LL | type TAU = extern "gpu-kernel" fn(); | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0570`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// FIXME(workingjubilee): add revisions and generalize to other platform-specific varargs ABIs, | ||
// preferably after the only-arch directive is enhanced with an "or pattern" syntax | ||
//@ only-x86_64 | ||
|
||
// We have to use this flag to force ABI computation of an invalid ABI | ||
//@ compile-flags: -Clink-dead-code | ||
|
||
#![feature(extended_varargs_abi_support)] | ||
|
||
// sometimes fn ptrs with varargs make layout and ABI computation ICE | ||
// as found in https://github.com/rust-lang/rust/issues/142107 | ||
|
||
fn aapcs(f: extern "aapcs" fn(usize, ...)) { | ||
//~^ ERROR [E0570] | ||
// Note we DO NOT have to actually make a call to trigger the ICE! | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the history of leaky checks, maybe add a delay_span_bug here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.