Skip to content

Conversation

@folkertdev
Copy link
Contributor

tracking issue: #48055

This came up in #144529 (comment).

The idea is that the layout of an unsized type is unstable (following the rust layout rules), and hence stable ABIs should not use unsized types. On stable, unsized types (or generics with a ?Sized bound) are not accepted as parameters, so the errors introduced by this PR can only be observed when the unstable unsized_fn_params feature is enabled.

r? @bjorn3
cc @RalfJung

@folkertdev folkertdev added the F-unsized_fn_params `#![feature(unsized_fn_params)]` label Oct 30, 2025
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 30, 2025
Comment on lines +59 to +60
extern "C" fn c_polymorphic<T: ?Sized>(_: T) {}
//~^ ERROR this function definition uses unsized type `[u8]` which is not supported with the chosen ABI
Copy link
Contributor Author

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.

@bjorn3
Copy link
Member

bjorn3 commented Oct 30, 2025

Would have been nice if we could also get rid of the checks for unsized params in the call conv calculation code, but alas this checks runs after the call conv calculation code, so removing those checks would probably cause issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-unsized_fn_params `#![feature(unsized_fn_params)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants