diff options
| author | bors <bors@rust-lang.org> | 2021-10-03 00:41:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-03 00:41:49 +0000 |
| commit | c70b35efd8ed4d2e85a468c6519300c16609cdab (patch) | |
| tree | 00bb25b0a64bd85ee9e66c0b9b492b311d45905d /compiler/rustc_plugin_impl/src | |
| parent | 2801a770ce3a21a53769180d9815240ac555cbef (diff) | |
| parent | abfad74ec6326b806509a676b6527e8d645d4fdf (diff) | |
| download | rust-c70b35efd8ed4d2e85a468c6519300c16609cdab.tar.gz rust-c70b35efd8ed4d2e85a468c6519300c16609cdab.zip | |
Auto merge of #84267 - dtolnay:ptrunit, r=nagisa
Make *const (), *mut () okay for FFI
Pointer-to-() is used occasionally in the standard library to mean "pointer to none-of-your-business". Examples:
- `RawWakerVTable::new` https://doc.rust-lang.org/1.51.0/std/task/struct.RawWakerVTable.html#method.new
- `<*const T>::to_raw_parts` https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.to_raw_parts
I believe it's useful for the same purpose in FFI signatures, even while `()` itself is not FFI safe. The following should be allowed:
```rust
extern "C" {
fn demo(pc: *const (), pm: *mut ());
}
```
Prior to this PR, those pointers were not considered okay for an extern signature.
```console
warning: `extern` block uses type `()`, which is not FFI-safe
--> src/main.rs:2:17
|
2 | fn demo(pc: *const (), pm: *mut ());
| ^^^^^^^^^ not FFI-safe
|
= note: `#[warn(improper_ctypes)]` on by default
= help: consider using a struct instead
= note: tuples have unspecified layout
warning: `extern` block uses type `()`, which is not FFI-safe
--> src/main.rs:2:32
|
2 | fn demo(pc: *const (), pm: *mut ());
| ^^^^^^^ not FFI-safe
|
= help: consider using a struct instead
= note: tuples have unspecified layout
```
Diffstat (limited to 'compiler/rustc_plugin_impl/src')
0 files changed, 0 insertions, 0 deletions
