diff --git a/ndk-macro/Cargo.toml b/ndk-macro/Cargo.toml index 8ff019df..bdb9db0f 100644 --- a/ndk-macro/Cargo.toml +++ b/ndk-macro/Cargo.toml @@ -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 = [] diff --git a/ndk-macro/src/helper.rs b/ndk-macro/src/helper.rs index a3e4c49a..ee1ff38f 100644 --- a/ndk-macro/src/helper.rs +++ b/ndk-macro/src/helper.rs @@ -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, @@ -42,8 +43,8 @@ impl Parse for AttributeArgs { use proc_macro_crate::crate_name; #[cfg(test)] -fn crate_name(name: &str) -> Result { - Ok(name.replace('-', "_")) +fn crate_name(name: &str) -> Result { + Ok(FoundCrate::Name(name.replace('-', "_"))) } pub fn crate_path(name: &str, overridden_path: &Option) -> Path { @@ -53,7 +54,11 @@ pub fn crate_path(name: &str, overridden_path: &Option) -> 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),