From f3f15c2893d31fb90b1b142df9d4c35e0982a102 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 3 Dec 2019 11:58:35 +0100 Subject: [PATCH] api-macro: drop ToTokens for SimpleIdent The user must be explicit about whether the ident or string is required. Signed-off-by: Wolfgang Bumiller --- proxmox-api-macro/src/util.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/proxmox-api-macro/src/util.rs b/proxmox-api-macro/src/util.rs index 088deaba..4821c34c 100644 --- a/proxmox-api-macro/src/util.rs +++ b/proxmox-api-macro/src/util.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use std::convert::TryFrom; use std::fmt; -use proc_macro2::{Ident, Span, TokenStream}; +use proc_macro2::{Ident, Span}; use syn::parse::{Parse, ParseStream}; use syn::punctuated::Punctuated; use syn::spanned::Spanned; @@ -43,10 +43,10 @@ impl SimpleIdent { Ok(unsafe { self.into_ident_unchecked() }) } - //#[inline] - //pub fn span(&self) -> Span { - // self.0.span() - //} + #[inline] + pub fn span(&self) -> Span { + self.0.span() + } } impl Eq for SimpleIdent {} @@ -83,12 +83,6 @@ impl Borrow for SimpleIdent { } } -impl quote::ToTokens for SimpleIdent { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.0.to_tokens(tokens) - } -} - /// Note that the 'type' keyword is handled separately in `syn`. It's not an `Ident`: impl Parse for SimpleIdent { fn parse(input: ParseStream) -> syn::Result { @@ -276,7 +270,7 @@ impl JSONObject { let mut elems = HashMap::with_capacity(map_elems.len()); for c in map_elems { if elems.insert(c.key.clone().into(), c.value).is_some() { - bail!(&c.key => "duplicate '{}' in schema", c.key); + bail!(c.key.span(), "duplicate '{}' in schema", c.key); } } Ok(elems)