Skip to content

Remove by val mode - #5307

Merged
bors merged 2 commits into
rust-lang:incomingfrom
nikomatsakis:remove-by-val
Mar 13, 2013
Merged

Remove by val mode#5307
bors merged 2 commits into
rust-lang:incomingfrom
nikomatsakis:remove-by-val

Conversation

@nikomatsakis

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Yay!

@brson

brson commented Mar 10, 2013

Copy link
Copy Markdown
Contributor

Great work and great documentation, as always.

@brson

brson commented Mar 11, 2013

Copy link
Copy Markdown
Contributor

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

brson commented Mar 11, 2013

Copy link
Copy Markdown
Contributor

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
U007D pushed a commit to U007D/rust-mos that referenced this pull request Aug 21, 2026
5307: disable profiling r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
RalfJung added a commit to RalfJung/rust that referenced this pull request Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants