Skip to content

Commit

Permalink
Allow fully-qualified derives
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jmerdich authored and emilio committed Feb 18, 2022
1 parent 71fe5fd commit b3e6a98
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bindgen-integration/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl ParseCallbacks for MacroCallback {
]
} else if name == "MyOrderedEnum" {
vec![
"PartialOrd".into(),
"std::cmp::PartialOrd".into(),
]
} else {
vec![]
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),* )]
}
Expand Down

0 comments on commit b3e6a98

Please sign in to comment.