11

lint/ctypes: fix `()` return type checks by davidtwco · Pull Request #113457 · r...

 1 year ago
source link: https://github.com/rust-lang/rust/pull/113457
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conversation

Member

Fixes #113436.

() is normally FFI-unsafe, but is FFI-safe when used as a return type. It is also desirable that a transparent newtype for () is FFI-safe when used as a return type.

In order to support this, when a type was deemed FFI-unsafe, because of a () type, and was used in return type - then the type was considered FFI-safe. However, this was the wrong approach - it didn't check that the () was part of a transparent newtype! The consequence of this is that the presence of a () type in a more complex return type would make it the entire type be considered safe (as long as the () type was the first that the lint found) - which is obviously incorrect.

Instead, this logic is removed, and after consultation with t-lang, I've fixed the bugs and inconsistencies and made () FFI-safe within types.

I also refactor a function, but that's not too exciting.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK