Skip to content

Marker types should be FFI-safe #760

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

Closed
steveklabnik opened this issue Jan 29, 2015 · 2 comments
Closed

Marker types should be FFI-safe #760

steveklabnik opened this issue Jan 29, 2015 · 2 comments
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.

Comments

@steveklabnik
Copy link
Member

Issue by mzabaluev
Wednesday Oct 01, 2014 at 09:56 GMT

For earlier discussion, see rust-lang/rust#17679

This issue was labelled with: in the Rust repository


If I get a struct by pointer from a foreign library, and I know the structure cannot safely be copied because the actual object is larger than the struct, I want to declare it as something like this:

#[repr(C)]
struct A {
    // ...
    no_copy: std::kinds::marker::NoCopy;
}

Now the compiler complains at use site that the struct is not foreign-function-safe.
As the markers are zero-sized, they have no bearing on the layout and no consequences for the structure data, so they, as long as any other zero-sized structures, should not waive FFS.

@thestinger suggests the same should apply to structures with one field as well, but I'm not so certain about that: there could be optimizations regarding alignment which would not be compatible with the (default) C ABI.

@mbrubeck mbrubeck changed the title Zero-sized structs should be FFI-safe Marker types should be FFI-safe Sep 28, 2017
@mbrubeck
Copy link
Contributor

See also #750.

@Centril Centril added the T-lang Relevant to the language team, which will review and decide on the RFC. label Feb 23, 2018
@Centril
Copy link
Contributor

Centril commented Oct 7, 2018

std::kinds::marker::NoCopy does not exist so I am closing this.

@Centril Centril closed this as completed Oct 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

4 participants