Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Upgrade proc-macro-crate to v1
  • Loading branch information
dvdplm committed Mar 11, 2021
commit c76a62dfa823c9000170fe68e4cabf954a300550
2 changes: 1 addition & 1 deletion derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ proc-macro = true
quote = "1.0"
syn = { version = "1.0", features = ["derive", "visit", "visit-mut", "extra-traits"] }
proc-macro2 = "1.0"
proc-macro-crate = "0.1.5"
proc-macro-crate = "1"
8 changes: 7 additions & 1 deletion derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ fn generate_type(input: TokenStream2) -> Result<TokenStream2> {
/// Get the name of a crate, to be robust against renamed dependencies.
fn crate_name_ident(name: &str) -> Result<Ident> {
proc_macro_crate::crate_name(name)
.map(|crate_name| Ident::new(&crate_name, Span::call_site()))
.map(|crate_name| {
use proc_macro_crate::FoundCrate::*;
match crate_name {
Itself => Ident::new("self", Span::call_site()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Itself => Ident::new("self", Span::call_site()),
Itself => Ident::new("crate", Span::call_site()),

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't crate the right keyword then? Actually I wonder if crate as Ident is allowed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not, which is why I switched to a token stream in the other PR.

My plan was to merge this change here and then merge it into the other and sort out the Itself-case there.

Name(name) => Ident::new(&name, Span::call_site()),
}
})
.map_err(|e| syn::Error::new(Span::call_site(), &e))
}

Expand Down