Uh oh!
There was an error while loading. Please reload this page.
Added a unsafe_ffi_drop_implementations lint. - #22078
Conversation
rust-highfive
commented
Feb 8, 2015
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
alexcrichton
commented
Feb 9, 2015
cc #21761 |
nikomatsakis
commented
Feb 10, 2015
The code certainly looks good. The need for this lint is probably somewhat time-limited, but in the meantime it can't hurt. |
This detects cases where a struct or enum are annotated with `#[repr(C)]`, and *do not* have `#[unsafe_no_drop_flag]`, whereby it warns the user that the type may not have the expected size or layout. Also includes tests to ensure the lint is triggered by FFI+Drop structs and enums, *not* triggered by FFI+Drop+unsafe_no_drop_flag structs and enums, and *not* triggered by FFI+!Drop structs and enums. It also contains a tangential change to libstd/sys/windows/backtrace.rs. Specifically, the `Cleanup` type had `#[repr(C)]` and Drop, but was never passed to any FFI function.
c0ea937 to
26fcbd7CompareDanielKeep
commented
Feb 10, 2015
@nikomatsakis Added a struct and enum with |
kornelski
commented
Apr 11, 2015
I think I've ran into this problem and this lint would have saved me some hair-pulling :) |
alexcrichton
commented
May 1, 2015
Gah sorry for letting this fall by the wayside! This was actually recently reimplemented in #24935, so I'm going to close this. Thanks regardless though! |
…xmypz perf: optimize allocation strategies of output/parser/event
This detects cases where a struct or enum are annotated with
#[repr(C)],and do not have
#[unsafe_no_drop_flag], whereby it warns the user thatthe type may not have the expected size or layout.
The lint was set to "Warn" by default as I wasn't sure if "Deny" would be too strong.
A tangential change was to remove
#[repr(C)]fromCleanupinsrc/libstd/sys/windows/backtrace.rs. I believe this to be justified in thatCleanupis only ever used exactly once as an RAII handle, and is never passed to any FFI function.Two tests including to ensure the lint triggers when
#[unsafe_no_drop_flag]is missing, and does not trigger if it is present.Addresses #18380.