Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump proc-macro-crate to 1 #48

Merged
merged 3 commits into from Jul 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion num_enum_derive/Cargo.toml
Expand Up @@ -32,6 +32,6 @@ features = ["external_doc"]

[dependencies]
proc-macro2 = "1"
proc-macro-crate = { version = "0.1.4", optional = true }
proc-macro-crate = { version = "1", optional = true }
quote = "1"
syn = { version = "1", features = ["parsing"] }
13 changes: 10 additions & 3 deletions num_enum_derive/src/lib.rs
Expand Up @@ -574,10 +574,17 @@ pub fn derive_try_from_primitive(input: TokenStream) -> TokenStream {

#[cfg(feature = "proc-macro-crate")]
fn get_crate_name() -> String {
::proc_macro_crate::crate_name("num_enum").unwrap_or_else(|err| {
let found_crate = proc_macro_crate::crate_name("num_enum").unwrap_or_else(|err| {
eprintln!("Warning: {}\n => defaulting to `num_enum`", err,);
String::from("num_enum")
})
proc_macro_crate::FoundCrate::Itself
});

let crate_name = match found_crate {
proc_macro_crate::FoundCrate::Itself => String::from("num_enum"),
proc_macro_crate::FoundCrate::Name(name) => name,
};

crate_name
}

// Don't depend on proc-macro-crate in no_std environments because it causes an awkward dependency
Expand Down