Skip to content
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

Flows should be repr(C) #14791

Open
Ms2ger opened this issue Dec 30, 2016 · 5 comments
Open

Flows should be repr(C) #14791

Ms2ger opened this issue Dec 30, 2016 · 5 comments

Comments

@Ms2ger
Copy link
Contributor

@Ms2ger Ms2ger commented Dec 30, 2016

We have code that extracts the BaseFlow through

pub fn base<T: ?Sized + Flow>(this: &T) -> &BaseFlow {
    unsafe {
        let obj = mem::transmute::<&&T, &raw::TraitObject>(&this);
        mem::transmute::<*mut (), &BaseFlow>(obj.data)
    }
}

This relies on the BaseFlow being the first field in any Flow implementation.

(Perhaps this also means Flow should be an unsafe trait…)

@stshine
Copy link
Contributor

@stshine stshine commented Dec 31, 2016

Argh, the story of inheritence.

@DemiMarie
Copy link

@DemiMarie DemiMarie commented Feb 13, 2017

Rust really needs an object system. Perhaps one can be implemented as a compiler plugin.

@nox
Copy link
Member

@nox nox commented Oct 7, 2017

I think this is still true.

@dralley
Copy link
Contributor

@dralley dralley commented Mar 24, 2020

Does layout 2020 address this?

@nox
Copy link
Member

@nox nox commented Jun 25, 2020

Yes, but 2013 is still a thing for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.