mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-01 13:18:20 +00:00
api-macro: drop ToTokens for SimpleIdent
The user must be explicit about whether the ident or string is required. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
b7ecf3a597
commit
f3f15c2893
@ -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<str> 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<Self> {
|
||||
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user