Skip to content

Revamp foreign code not to consider the Rust modes. This requires #5298

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

Conversation

nikomatsakis
Copy link
Contributor

Revamp foreign code not to consider the Rust modes. This requires
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.

r? @brson

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.
@nikomatsakis
Copy link
Contributor Author

Note: I did some 'tidying up' while I was editing this code. I expected to need deeper changes than I did, in retrospect I could have this patch more targeted, but oh well.

@nikomatsakis nikomatsakis mentioned this pull request Mar 10, 2013
@nikomatsakis
Copy link
Contributor Author

I just opened pull request #5307 which obsoletes this one. @brson go review that instead. ;)

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 added a commit to rust-lang-ci/rust that referenced this pull request May 2, 2020
…ip1995,Manishearth

needless_doc_main: only check rust code

This fixes rust-lang#5280 by checking the language attribute on code blocks.

---

changelog: none
# 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.

1 participant