Skip to content

Commit

Permalink
Bump proc-macro-crate to 1 (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
eclipseo authored Jul 10, 2021
1 parent 1c820e2 commit 8385dc9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion num_enum_derive/Cargo.toml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 8385dc9

Please sign in to comment.