Remove calls to unwrap() in respan! macro

Previously, `proc_macro2::Span::resolved_at` was gated behind
cfg(procmacro2_semver_exempt). This gate has been removed in the latest
version of proc-macro2, allowing us to avoid using `unwrap()` to use the
underling method on `proc_macro::Span`
This commit is contained in:
Aaron Hill
2020-08-02 17:21:07 -04:00
committed by Michael Vines
parent 0bc9bcc8b9
commit 8bcc8edf47
4 changed files with 987 additions and 992 deletions

View File

@ -13,7 +13,7 @@ proc-macro = true
[dependencies]
bs58 = "0.3.0"
proc-macro2 = "1.0"
proc-macro2 = "1.0.19"
quote = "1.0"
syn = { version = "1.0", features = ["full", "extra-traits"] }
rustversion = "1.0.3"

View File

@ -121,10 +121,7 @@ pub fn respan(input: TokenStream) -> TokenStream {
.into_iter()
.map(|mut t| {
// Combine the location of the token with the resolution behavior of `respan_using`
// Note: `proc_macro2::Span::resolved_at` is currently gated with cfg(procmacro2_semver_exempt)
// Once this gate is removed, we will no longer need to use 'unwrap()' to call
// the underling `proc_macro::Span::resolved_at` method.
let new_span: Span = t.span().unwrap().resolved_at(respan_using.unwrap()).into();
let new_span: Span = t.span().resolved_at(respan_using);
t.set_span(new_span);
t
})