-
Notifications
You must be signed in to change notification settings - Fork 13.9k
error on non-rustic ABIs using unsized parameters #148302
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
Merged
+228
−4
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| //@ add-minicore | ||
| //@ build-fail | ||
| #![no_core] | ||
| #![crate_type = "lib"] | ||
| #![feature(no_core, unsized_fn_params)] | ||
| #![allow(improper_ctypes_definitions, improper_ctypes)] | ||
|
|
||
| extern crate minicore; | ||
| use minicore::*; | ||
|
|
||
| fn rust(_: [u8]) {} | ||
| extern "C" fn c(_: [u8]) {} | ||
| //~^ ERROR this function definition uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| extern "system" fn system(_: [u8]) {} | ||
| //~^ ERROR this function definition uses unsized type `[u8]` which is not supported with the chosen ABI | ||
|
|
||
| #[repr(C)] | ||
| struct CustomUnsized { | ||
| a: i64, | ||
| b: [u8], | ||
| } | ||
|
|
||
| extern "C" fn c_custom_unsized(x: CustomUnsized) {} | ||
| //~^ ERROR this function definition uses unsized type `CustomUnsized` which is not supported with the chosen ABI | ||
|
|
||
| #[unsafe(no_mangle)] | ||
| fn entry(x: [u8], y: [u8], z: [u8], w: CustomUnsized) { | ||
| rust(x); | ||
| c(y); | ||
| //~^ ERROR this function call uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| system(z); | ||
| //~^ ERROR this function call uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| c_custom_unsized(w); | ||
| //~^ ERROR this function call uses unsized type `CustomUnsized` which is not supported with the chosen ABI | ||
| } | ||
|
|
||
| #[unsafe(no_mangle)] | ||
| fn test_fn_ptr(rust: extern "Rust" fn(_: [u8]), c: extern "C" fn(_: [u8]), x: [u8], y: [u8]) { | ||
| rust(x); | ||
| c(y); | ||
| //~^ ERROR this function call uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| } | ||
|
|
||
| #[unsafe(no_mangle)] | ||
| fn test_extern(x: [u8], y: [u8]) { | ||
| unsafe extern "Rust" { | ||
| safe fn rust(_: [u8]); | ||
| } | ||
|
|
||
| unsafe extern "system" { | ||
| safe fn system(_: [u8]); | ||
| } | ||
|
|
||
| rust(x); | ||
| system(y); | ||
| //~^ ERROR this function call uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| } | ||
|
|
||
| extern "C" fn c_polymorphic<T: ?Sized>(_: T) {} | ||
| //~^ ERROR this function definition uses unsized type `[u8]` which is not supported with the chosen ABI | ||
|
|
||
| #[unsafe(no_mangle)] | ||
| fn test_polymorphic(x: [u8]) { | ||
| c_polymorphic(x); | ||
| //~^ ERROR this function call uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| } | ||
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,88 @@ | ||
| error: this function call uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| --> $DIR/non-rustic-unsized.rs:29:5 | ||
| | | ||
| LL | c(y); | ||
| | ^^^^ function called here | ||
| | | ||
| = help: only rustic ABIs support unsized parameters | ||
|
|
||
| error: this function call uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| --> $DIR/non-rustic-unsized.rs:31:5 | ||
| | | ||
| LL | system(z); | ||
| | ^^^^^^^^^ function called here | ||
| | | ||
| = help: only rustic ABIs support unsized parameters | ||
|
|
||
| error: this function call uses unsized type `CustomUnsized` which is not supported with the chosen ABI | ||
| --> $DIR/non-rustic-unsized.rs:33:5 | ||
| | | ||
| LL | c_custom_unsized(w); | ||
| | ^^^^^^^^^^^^^^^^^^^ function called here | ||
| | | ||
| = help: only rustic ABIs support unsized parameters | ||
|
|
||
| error: this function definition uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| --> $DIR/non-rustic-unsized.rs:12:1 | ||
| | | ||
| LL | extern "C" fn c(_: [u8]) {} | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^ function defined here | ||
| | | ||
| = help: only rustic ABIs support unsized parameters | ||
|
|
||
| error: this function definition uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| --> $DIR/non-rustic-unsized.rs:14:1 | ||
| | | ||
| LL | extern "system" fn system(_: [u8]) {} | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here | ||
| | | ||
| = help: only rustic ABIs support unsized parameters | ||
|
|
||
| error: this function definition uses unsized type `CustomUnsized` which is not supported with the chosen ABI | ||
| --> $DIR/non-rustic-unsized.rs:23:1 | ||
| | | ||
| LL | extern "C" fn c_custom_unsized(x: CustomUnsized) {} | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here | ||
| | | ||
| = help: only rustic ABIs support unsized parameters | ||
|
|
||
| error: this function call uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| --> $DIR/non-rustic-unsized.rs:40:5 | ||
| | | ||
| LL | c(y); | ||
| | ^^^^ function called here | ||
| | | ||
| = help: only rustic ABIs support unsized parameters | ||
|
|
||
| error: this function call uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| --> $DIR/non-rustic-unsized.rs:55:5 | ||
| | | ||
| LL | system(y); | ||
| | ^^^^^^^^^ function called here | ||
| | | ||
| = help: only rustic ABIs support unsized parameters | ||
|
|
||
| error: this function call uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| --> $DIR/non-rustic-unsized.rs:64:5 | ||
| | | ||
| LL | c_polymorphic(x); | ||
| | ^^^^^^^^^^^^^^^^ function called here | ||
| | | ||
| = help: only rustic ABIs support unsized parameters | ||
|
|
||
| error: this function definition uses unsized type `[u8]` which is not supported with the chosen ABI | ||
| --> $DIR/non-rustic-unsized.rs:59:1 | ||
| | | ||
| LL | extern "C" fn c_polymorphic<T: ?Sized>(_: T) {} | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here | ||
| | | ||
| = help: only rustic ABIs support unsized parameters | ||
|
|
||
| note: the above error was encountered while instantiating `fn c_polymorphic::<[u8]>` | ||
| --> $DIR/non-rustic-unsized.rs:64:5 | ||
| | | ||
| LL | c_polymorphic(x); | ||
| | ^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: aborting due to 10 previous errors | ||
|
|
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.
The mention of
[u8]here is a bit unfortunate, but I think it's the best we can do.