fix(napi-derive): proc-macro crash on enum (#1870)
This commit is contained in:
parent
85807ad790
commit
84f3092d70
2 changed files with 20 additions and 14 deletions
|
@ -273,20 +273,25 @@ fn extract_doc_comments(attrs: &[syn::Attribute]) -> Vec<String> {
|
||||||
.filter_map(|a| {
|
.filter_map(|a| {
|
||||||
// if the path segments include an ident of "doc" we know this
|
// if the path segments include an ident of "doc" we know this
|
||||||
// this is a doc comment
|
// this is a doc comment
|
||||||
if a.path().is_ident("doc") {
|
let name_value = a.meta.require_name_value();
|
||||||
Some(
|
if let Ok(name) = name_value {
|
||||||
// We want to filter out any Puncts so just grab the Literals
|
if a.path().is_ident("doc") {
|
||||||
match &a.meta.require_name_value().unwrap().value {
|
Some(
|
||||||
syn::Expr::Lit(ExprLit {
|
// We want to filter out any Puncts so just grab the Literals
|
||||||
lit: syn::Lit::Str(str),
|
match &name.value {
|
||||||
..
|
syn::Expr::Lit(ExprLit {
|
||||||
}) => {
|
lit: syn::Lit::Str(str),
|
||||||
let quoted = str.token().to_string();
|
..
|
||||||
Some(try_unescape("ed).unwrap_or(quoted))
|
}) => {
|
||||||
}
|
let quoted = str.token().to_string();
|
||||||
_ => None,
|
Some(try_unescape("ed).unwrap_or(quoted))
|
||||||
},
|
}
|
||||||
)
|
_ => None,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ pub enum CustomNumEnum {
|
||||||
Two,
|
Two,
|
||||||
Three = 3,
|
Three = 3,
|
||||||
Four,
|
Four,
|
||||||
|
#[doc(hidden)]
|
||||||
Six = 6,
|
Six = 6,
|
||||||
Eight = 8,
|
Eight = 8,
|
||||||
Nine, // would be 9
|
Nine, // would be 9
|
||||||
|
|
Loading…
Reference in a new issue