Skip to content

Remove by val mode #5307

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Mar 13, 2013
Merged

Remove by val mode #5307

merged 2 commits into from
Mar 13, 2013

Conversation

nikomatsakis
Copy link
Contributor

This is done in two steps:

First, we make foreign functions not consider modes at all. This is because previously ++ mode was the only way to pass structs to foreign functions and so forth. We also add a lint mode warning if you use && mode in a foreign function, since the semantics of that change (it used to pass a pointer to the C function, now it doesn't).

Then, we remove by value and make it equivalent to + mode. At the same time, we stop parsing - mode and convert all uses of it to + mode (it was already being parsed to + mode anyhow).

This obsoletes pull request #5298.

r? @brson

@nikomatsakis
Copy link
Contributor Author

As I said before, I also did some minor cleanup and reorganization while revamping the foreign code. I ought to have separately that into its own commit and also separate out the conversion of - to +, but I didn't think it worth the trouble to back and sort the patches out now.

@pcwalton
Copy link
Contributor

Yay!

@brson
Copy link
Contributor

brson commented Mar 10, 2013

Great work and great documentation, as always.

@brson
Copy link
Contributor

brson commented Mar 11, 2013

Doing some work here on #2064 (returning structs from C functions on x86) and it seems like on your branch it works as expected. Did you fix that purposefully (I didn't see a test)? If so, thanks.

@brson
Copy link
Contributor

brson commented Mar 11, 2013

Oh I see rust_dbg_extern_identity_TwoU64s is testing the return value. Awesome.

adjusting a few foreign functions that were declared with by-ref
mode.  This also allows us to remove by-val mode in the near future.

With copy mode, though, we have to be careful because Rust will implicitly pass
somethings by pointer but this may not be the C ABI rules.  For example, rust
will pass a struct Foo as a Foo*.  So I added some code into the adapters to
fix this (though the C ABI rules may put the pointer back, oh well).

This patch also includes a lint mode for the use of by-ref mode
in foreign functions as the semantics of this have changed.
and obsolete `-` mode altogether (it *was* parsed as `+` mode).
bors added a commit that referenced this pull request Mar 13, 2013
This is done in two steps:

First, we make foreign functions not consider modes at all.  This is because previously ++ mode was the only way to pass structs to foreign functions and so forth.  We also add a lint mode warning if you use `&&` mode in a foreign function, since the semantics of that change (it used to pass a pointer to the C function, now it doesn't).

Then, we remove by value and make it equivalent to `+` mode.  At the same time, we stop parsing `-` mode and convert all uses of it to `+` mode (it was already being parsed to `+` mode anyhow).

This obsoletes pull request #5298.

r? @brson
@bors bors closed this Mar 13, 2013
@bors bors merged commit 852619d into rust-lang:incoming Mar 13, 2013
@nikomatsakis nikomatsakis deleted the remove-by-val branch March 30, 2016 16:17
bors added a commit to rust-lang-ci/rust that referenced this pull request May 2, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants