-
Notifications
You must be signed in to change notification settings - Fork 775
Closed
Description
@trobanga pointed out that PR #2059 (implementing #1089) doesn't seem to work if we try to add a custom derive to an enum instead of a struct.
I can see the problem if I try to extend the unit test from #2059 like this:
Input C/C++ Header
enum my_rustified_enum {
ELEVEN = 11,
TWELVE,
THIRTEEN,
};#[test]
fn test_custom_derive() {
use std::cmp::{PartialEq, Ordering};
let test3 = unsafe { bindings::my_rustified_enum::ELEVEN };
let test4 = unsafe { bindings::my_rustified_enum::TWELVE };
assert!(test3 < test4);
}Bindgen Invocation
I tested this using cargo test within bindgen-integration/, with the custom derives specified like this:
fn add_derives(&self, name: &str) -> Vec<String> {
if name == "my_rustified_enum" {
vec!["PartialOrd".into()]
} else {
vec![]
}
}Actual Results
$ cargo test
Compiling bindgen-integration v0.1.0 (.../rust-bindgen/bindgen-integration)
error[E0369]: binary operation `<` cannot be applied to type `root::my_rustified_enum`
--> src/lib.rs:289:19
|
289 | assert!(test3 < test4);
| ----- ^ ----- root::my_rustified_enum
| |
| root::my_rustified_enum
|
= note: an implementation of `std::cmp::PartialOrd` might be missing for `root::my_rustified_enum`Expected Results
PartialOrd should have been added to the #[derive(...) attribute, allowing this test to compile.
jfortin42
Metadata
Metadata
Assignees
Labels
No labels