rust-lang / rust-lang/rust-bindgen
Bindgen generates missing `type` generic on `Option` for internal class function pointer `typedef`
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
template< class T, class P >
class CCallResult : private CCallbackBase
{
public:
typedef void (T::*func_t)( P*, bool );
CCallResult();
~CCallResult();
void Set( SteamAPICall_t hAPICall, T *p, func_t func );
bool IsActive() const;
void Cancel();
void SetGameserverFlag() { m_nCallbackFlags |= k_ECallbackFlagsGameServer; }
private:
virtual void Run( void *pvParam );
virtual void Run( void *pvParam, bool bIOFailure, SteamAPICall_t hSteamAPICall );
virtual int GetCallbackSizeBytes() { return sizeof( P ); }
SteamAPICall_t m_hAPICall;
T *m_pObj;
func_t m_Func;
};
Bindgen Invocation
let bindings = bindgen::Builder::default()
.header(sdk_loc.join("public/steam/steam_api_flat.h").to_string_lossy())
.header(sdk_loc.join("public/steam/steam_gameserver.h").to_string_lossy())
.clang_arg("-xc++")
.clang_arg("-std=c++11")
.clang_arg(format!("-I{}", sdk_loc.join("public").display()))
.rustfmt_bindings(true)
.default_enum_style(bindgen::EnumVariation::Rust {
non_exhaustive: true
})
.generate()
.expect("Unable to generate bindings");
Actual Results
#[repr(C)]
pub struct CCallResult<T, P> {
pub _base: CCallbackBase,
pub m_hAPICall: SteamAPICall_t,
pub m_pObj: *mut T,
pub m_Func: CCallResult_func_t<P>,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell<P>>,
}
pub type CCallResult_func_t<P> = ::std::option::Option;
pub type CCallback_func_t<P> = ::std::option::Option;
error[E0107]: missing generics for enum `Option`
--> steamworks-rs\steamworks-sys\src\bindings_win32.rs:1455:47
|
1455 | pub type CCallback_func_t<P> = ::std::option::Option;
| ^^^^^^ expected 1 generic argument
Expected Results
#[repr(C)]
pub struct CCallResult<T, P> {
pub _base: CCallbackBase,
pub m_hAPICall: SteamAPICall_t,
pub m_pObj: *mut T,
pub m_Func: CCallResult_func_t<P>,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell<P>>,
}
pub type CCallResult_func_t<P> = ::std::option::Option<P>;
pub type CCallback_func_t<P> = ::std::option::Option<P>;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the C++ header and bindgen::Builder invocation shown in the report, then inspect how bindgen represents the internal class function-pointer typedef. Compare the generated aliases with the expected Option
output and confirm the fix by regenerating bindings and compiling them without the missing-generic error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100