Skip to content

Commit

Permalink
ndk-macro: Update proc-macro-crate to 1.0, update darling to 0.13 (#163)
Browse files Browse the repository at this point in the history
proc-macro-crate 1.0 released, and [num_enum] bumped to that recently in
a patch release causing a duplicate dependency in `Cargo.lock`.  We can
upgrade to it too.

[num_enum]: illicitonion/num_enum@8385dc9
  • Loading branch information
MarijnS95 authored Jul 27, 2021
1 parent 8021a8a commit edba2c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ndk-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ proc-macro = true

[dependencies]
proc-macro2 = "1.0.24"
proc-macro-crate = "0.1.5"
proc-macro-crate = "1.0"
quote = "1.0.8"
syn = { version = "1.0.60", features = ["full"] }
darling = "0.12.0"
darling = "0.13"

[features]
default = []
Expand Down
11 changes: 8 additions & 3 deletions ndk-macro/src/helper.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use core::ops::Deref;
use proc_macro2::{Ident, Span};
use proc_macro_crate::FoundCrate;
use syn::{
parse::{Parse, ParseStream, Result},
Path, Token,
Expand Down Expand Up @@ -42,8 +43,8 @@ impl Parse for AttributeArgs {
use proc_macro_crate::crate_name;

#[cfg(test)]
fn crate_name(name: &str) -> Result<String> {
Ok(name.replace('-', "_"))
fn crate_name(name: &str) -> Result<FoundCrate> {
Ok(FoundCrate::Name(name.replace('-', "_")))
}

pub fn crate_path(name: &str, overridden_path: &Option<Path>) -> Path {
Expand All @@ -53,7 +54,11 @@ pub fn crate_path(name: &str, overridden_path: &Option<Path>) -> Path {
// try to determine crate name from Cargo.toml
crate_name(name)
.ok()
.as_deref()
.as_ref()
.map(|name| match name {
FoundCrate::Itself => "ndk_macro",
FoundCrate::Name(n) => n.as_str(),
})
// or use default crate name
// (this may cause compilation error when crate is not found)
.unwrap_or_else(|| name),
Expand Down

0 comments on commit edba2c0

Please sign in to comment.