Bug 1440207 - Part 5: Disable UniqueFileHandle for RUST_BINDGEN, r=emilio,glandium
Apparently rust bindgen uses a hack which assumes all specializations of `UniquePtr` have the basic layout and use a pointer member with an empty deleter. This incorrect assumption unfortunately comes up for UniqueFileHandle, which replaces the pointer type using the deleter with a file handle helper type. As this fails to build with RUST_BINDGEN, this patch takes the same approach as bug 1802320, and just disables building these types when building headers for bindgen. This does not fix the general issue of bindgen making incorrect assumptions about the layout of UniquePtr with non-default deleters. Ideally, all non-default deleters should be made opaque. Differential Revision: https://phabricator.services.mozilla.com/D223628
This commit is contained in:
@@ -93,6 +93,7 @@ struct FreePolicy {
|
|||||||
void operator()(const void* ptr) { free(const_cast<void*>(ptr)); }
|
void operator()(const void* ptr) { free(const_cast<void*>(ptr)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined(RUST_BINDGEN)
|
||||||
# if defined(XP_WIN)
|
# if defined(XP_WIN)
|
||||||
// Can't include <windows.h> to get the actual definition of HANDLE
|
// Can't include <windows.h> to get the actual definition of HANDLE
|
||||||
// because of namespace pollution.
|
// because of namespace pollution.
|
||||||
@@ -162,6 +163,7 @@ struct FileHandleDeleter {
|
|||||||
using receiver = FileHandleType;
|
using receiver = FileHandleType;
|
||||||
MFBT_API void operator()(FileHandleHelper aHelper);
|
MFBT_API void operator()(FileHandleHelper aHelper);
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(XP_DARWIN) && !defined(RUST_BINDGEN)
|
#if defined(XP_DARWIN) && !defined(RUST_BINDGEN)
|
||||||
struct MachPortHelper {
|
struct MachPortHelper {
|
||||||
@@ -215,6 +217,7 @@ struct MachPortSetDeleter {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
using UniqueFreePtr = UniquePtr<T, detail::FreePolicy<T>>;
|
using UniqueFreePtr = UniquePtr<T, detail::FreePolicy<T>>;
|
||||||
|
|
||||||
|
#if !defined(RUST_BINDGEN)
|
||||||
// A RAII class for the OS construct used for open files and similar
|
// A RAII class for the OS construct used for open files and similar
|
||||||
// objects: a file descriptor on Unix or a handle on Windows.
|
// objects: a file descriptor on Unix or a handle on Windows.
|
||||||
using UniqueFileHandle =
|
using UniqueFileHandle =
|
||||||
@@ -227,6 +230,7 @@ inline UniqueFileHandle DuplicateFileHandle(const UniqueFileHandle& aFile) {
|
|||||||
return DuplicateFileHandle(aFile.get());
|
return DuplicateFileHandle(aFile.get());
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(XP_DARWIN) && !defined(RUST_BINDGEN)
|
#if defined(XP_DARWIN) && !defined(RUST_BINDGEN)
|
||||||
// A RAII class for a Mach port that names a send right.
|
// A RAII class for a Mach port that names a send right.
|
||||||
|
|||||||
Reference in New Issue
Block a user