Input C/C++ Header
struct S {
int x;
int operator()(int t) const;
};
Bindgen Invocation
$ bindgen input.h --represent-cxx-operators -- -x c++ -std=c++17
Actual Results
bindgen aborts:
panicked at bindgen/ir/context.rs:903:9:
"S_operator()" is not a valid Ident
Without the flag, operators are skipped. With --represent-cxx-operators, FunctionSig::from_ty keeps operator(), then codegen does rust_ident("S_operator()"). rust_mangle only rewrites @, ?, $, and keywords, so the parentheses reach Ident::new.
Same panic for operator[], operator+, operator==. operator int does not panic (that spelling is already a valid Ident).
The rustdoc for the flag says the names are not valid Rust and you need ParseCallbacks::generated_name_override. The CLI has no callback, so bindgen panics instead of emitting something or skipping. #3142 added the flag for post-processors that rename; it did not document an abort.
rust_mangle has the same hole for clang-accepted non-XID names, e.g. gnu11 struct 🐶 { int x; }; → "🐶" is not a valid Ident. CJK struct 测试 is fine (XID).
Expected Results
Do not abort. Mangle operator() to a valid Ident (or skip with a diagnostic). Callers can still rename via generated_name_override.
Environment
bindgen: 0.73.1 (rust-lang/rust-bindgen 77cbc723)
clang/libclang: Homebrew clang 21.1.8
rustc: 1.97.1
target: aarch64-apple-darwin
OS: macOS
Input C/C++ Header
Bindgen Invocation
$ bindgen input.h --represent-cxx-operators -- -x c++ -std=c++17Actual Results
bindgen aborts:
Without the flag, operators are skipped. With
--represent-cxx-operators,FunctionSig::from_tykeepsoperator(), then codegen doesrust_ident("S_operator()").rust_mangleonly rewrites@,?,$, and keywords, so the parentheses reachIdent::new.Same panic for
operator[],operator+,operator==.operator intdoes not panic (that spelling is already a valid Ident).The rustdoc for the flag says the names are not valid Rust and you need
ParseCallbacks::generated_name_override. The CLI has no callback, so bindgen panics instead of emitting something or skipping. #3142 added the flag for post-processors that rename; it did not document an abort.rust_manglehas the same hole for clang-accepted non-XID names, e.g. gnu11struct 🐶 { int x; };→"🐶" is not a valid Ident. CJKstruct 测试is fine (XID).Expected Results
Do not abort. Mangle
operator()to a valid Ident (or skip with a diagnostic). Callers can still rename viagenerated_name_override.Environment