Revert parts of "Use absolute paths in generated code"
to restore compatibility with older versions of Rust.
This commit is contained in:
parent
d19c57d23d
commit
a1fc2f9fad
@ -256,17 +256,17 @@ impl Into<proc_macro2::TokenStream> for Field {
|
||||
fn into(self) -> proc_macro2::TokenStream {
|
||||
match self {
|
||||
Field::FieldString => quote! { ::std::string::String },
|
||||
Field::FieldBool => quote! { ::std::primitive::bool },
|
||||
Field::FieldI8 => quote! { ::std::primitive::i8 },
|
||||
Field::FieldU8 => quote! { ::std::primitive::u8 },
|
||||
Field::FieldI16 => quote! { ::std::primitive::i16 },
|
||||
Field::FieldU16 => quote! { ::std::primitive::u16 },
|
||||
Field::FieldI32 => quote! { ::std::primitive::i32 },
|
||||
Field::FieldU32 => quote! { ::std::primitive::u32 },
|
||||
Field::FieldI64 => quote! { ::std::primitive::i64 },
|
||||
Field::FieldU64 => quote! { ::std::primitive::u64 },
|
||||
Field::FieldF32 => quote! { ::std::primitive::f32 },
|
||||
Field::FieldF64 => quote! { ::std::primitive::f64 },
|
||||
Field::FieldBool => quote! { bool },
|
||||
Field::FieldI8 => quote! { i8 },
|
||||
Field::FieldU8 => quote! { u8 },
|
||||
Field::FieldI16 => quote! { i16 },
|
||||
Field::FieldU16 => quote! { u16 },
|
||||
Field::FieldI32 => quote! { i32 },
|
||||
Field::FieldU32 => quote! { u32 },
|
||||
Field::FieldI64 => quote! { i64 },
|
||||
Field::FieldU64 => quote! { u64 },
|
||||
Field::FieldF32 => quote! { f32 },
|
||||
Field::FieldF64 => quote! { f64 },
|
||||
_ => panic!("Not a simple type: {:?}", self),
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ fn build_unnamed_field_visitors(fields: &syn::FieldsUnnamed) -> TokenStream {
|
||||
|
||||
fn #visitor(
|
||||
self,
|
||||
v: &::std::primitive::str,
|
||||
v: &str,
|
||||
) -> ::std::result::Result<Self::Value, ::std::string::String> {
|
||||
#fn_body
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ pub fn parse(
|
||||
|
||||
fn visit_str(
|
||||
self,
|
||||
v: &::std::primitive::str,
|
||||
v: &str,
|
||||
) -> ::std::result::Result<Self::Value, ::std::string::String> {
|
||||
let content = "<".to_string() + #struct_id + ">" + v + "</" + #struct_id + ">";
|
||||
::yaserde::de::from_str(&content)
|
||||
@ -114,7 +114,7 @@ pub fn parse(
|
||||
|
||||
fn #visitor(
|
||||
self,
|
||||
v: &::std::primitive::str,
|
||||
v: &str,
|
||||
) -> ::std::result::Result<Self::Value, ::std::string::String> {
|
||||
::std::result::Result::Ok(#field_type::from_str(#map_if_bool).unwrap())
|
||||
}
|
||||
@ -363,7 +363,7 @@ pub fn parse(
|
||||
let event = reader.peek()?.to_owned();
|
||||
::log::trace!(
|
||||
"Struct {} @ {}: matching {:?}",
|
||||
::std::stringify!(#name), start_depth, event,
|
||||
stringify!(#name), start_depth, event,
|
||||
);
|
||||
match event {
|
||||
::xml::reader::XmlEvent::StartElement{ref name, ref attributes, ..} => {
|
||||
|
||||
@ -3,7 +3,7 @@ pub mod expand_enum;
|
||||
pub mod expand_struct;
|
||||
|
||||
use crate::common::YaSerdeAttribute;
|
||||
use proc_macro2::TokenStream;
|
||||
use proc_macro2::{Ident, TokenStream};
|
||||
use quote::quote;
|
||||
|
||||
pub fn expand_derive_deserialize(ast: &syn::DeriveInput) -> Result<TokenStream, String> {
|
||||
@ -29,9 +29,11 @@ pub fn expand_derive_deserialize(ast: &syn::DeriveInput) -> Result<TokenStream,
|
||||
syn::Data::Union(ref _data_union) => unimplemented!(),
|
||||
};
|
||||
|
||||
let dummy_const = Ident::new(&format!("_IMPL_YA_DESERIALIZE_FOR_{}", name), name.span());
|
||||
|
||||
Ok(quote! {
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _: () = {
|
||||
const #dummy_const: () = {
|
||||
use ::std::str::FromStr as _;
|
||||
use ::yaserde::Visitor as _;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ pub mod label;
|
||||
pub mod namespace;
|
||||
|
||||
use crate::common::YaSerdeAttribute;
|
||||
use proc_macro2::TokenStream;
|
||||
use proc_macro2::{Ident, TokenStream};
|
||||
use quote::quote;
|
||||
|
||||
pub fn expand_derive_serialize(ast: &syn::DeriveInput) -> Result<TokenStream, String> {
|
||||
@ -32,9 +32,11 @@ pub fn expand_derive_serialize(ast: &syn::DeriveInput) -> Result<TokenStream, St
|
||||
syn::Data::Union(ref _data_union) => unimplemented!(),
|
||||
};
|
||||
|
||||
let dummy_const = Ident::new(&format!("_IMPL_YA_SERIALIZE_FOR_{}", name), name.span());
|
||||
|
||||
Ok(quote! {
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _: () = {
|
||||
const #dummy_const: () = {
|
||||
use ::std::str::FromStr as _;
|
||||
|
||||
#impl_block
|
||||
|
||||
Loading…
Reference in New Issue
Block a user