From e887acec497fb3ac919e4769c1cd20118cf8536a Mon Sep 17 00:00:00 2001 From: Jake Merdich Date: Thu, 3 Feb 2022 11:02:30 -0500 Subject: [PATCH] Allow fully-qualified derives Adding a custom derive like "serde::Deserialize" results in a panic complaining that it is not a valid Ident. Derive params are not identifiers, so treat it as a token stream instead. --- bindgen-integration/build.rs | 2 +- src/codegen/helpers.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bindgen-integration/build.rs b/bindgen-integration/build.rs index 77ea64b581..d0ec3bc0dd 100644 --- a/bindgen-integration/build.rs +++ b/bindgen-integration/build.rs @@ -128,7 +128,7 @@ impl ParseCallbacks for MacroCallback { ] } else if name == "MyOrderedEnum" { vec![ - "PartialOrd".into(), + "std::cmp::PartialOrd".into(), ] } else { vec![] diff --git a/src/codegen/helpers.rs b/src/codegen/helpers.rs index 2ce6894fb2..75c169c67d 100644 --- a/src/codegen/helpers.rs +++ b/src/codegen/helpers.rs @@ -30,7 +30,7 @@ pub mod attributes { let which_ones = which_ones .iter() .cloned() - .map(|one| Ident::new(one, Span::call_site())); + .map(|one| TokenStream::from_str(one).expect("derive to be valid")); quote! { #[derive( #( #which_ones ),* )] }