diff --git a/precompiled/serde_derive/src/lib_from_source.rs b/precompiled/serde_derive/src/lib_from_source.rs index 7dd89e04..2427a574 100644 --- a/precompiled/serde_derive/src/lib_from_source.rs +++ b/precompiled/serde_derive/src/lib_from_source.rs @@ -1,9 +1,7 @@ -#[macro_use] -extern crate quote; -#[macro_use] -extern crate syn; extern crate proc_macro; extern crate proc_macro2; +extern crate quote; +extern crate syn; #[macro_use] mod bound; @@ -19,7 +17,7 @@ mod this; mod try; use proc_macro::TokenStream; -use syn::DeriveInput; +use syn::{parse_macro_input, DeriveInput}; #[proc_macro_derive(Serialize, attributes(serde))] pub fn derive_serialize(input: TokenStream) -> TokenStream { diff --git a/serde_derive/src/bound.rs b/serde_derive/src/bound.rs index 65bc984e..dd51e689 100644 --- a/serde_derive/src/bound.rs +++ b/serde_derive/src/bound.rs @@ -3,6 +3,7 @@ use crate::internals::{attr, ungroup}; use proc_macro2::Span; use std::collections::HashSet; use syn::punctuated::{Pair, Punctuated}; +use syn::Token; // Remove the default from every type parameter because in the generated impls // they look like associated types: "error: associated type bindings are not diff --git a/serde_derive/src/de.rs b/serde_derive/src/de.rs index 7052d363..305a14d9 100644 --- a/serde_derive/src/de.rs +++ b/serde_derive/src/de.rs @@ -3,14 +3,14 @@ use crate::internals::ast::{Container, Data, Field, Style, Variant}; use crate::internals::{attr, replace_receiver, ungroup, Ctxt, Derive}; use crate::{bound, dummy, pretend, this}; use proc_macro2::{Literal, Span, TokenStream}; -use quote::ToTokens; +use quote::{quote, quote_spanned, ToTokens}; use std::collections::BTreeSet; use std::ptr; #[cfg(precompiled)] use std::sync::atomic::Ordering; use syn::punctuated::Punctuated; use syn::spanned::Spanned; -use syn::{self, Ident, Index, Member}; +use syn::{parse_quote, Ident, Index, Member}; pub fn expand_derive_deserialize(input: &mut syn::DeriveInput) -> syn::Result { replace_receiver(input); diff --git a/serde_derive/src/dummy.rs b/serde_derive/src/dummy.rs index 5b888208..646da540 100644 --- a/serde_derive/src/dummy.rs +++ b/serde_derive/src/dummy.rs @@ -1,5 +1,6 @@ use crate::try; use proc_macro2::TokenStream; +use quote::quote; pub fn wrap_in_const(serde_path: Option<&syn::Path>, code: TokenStream) -> TokenStream { let try_replacement = try::replacement(); diff --git a/serde_derive/src/fragment.rs b/serde_derive/src/fragment.rs index 324504aa..6627c266 100644 --- a/serde_derive/src/fragment.rs +++ b/serde_derive/src/fragment.rs @@ -1,6 +1,6 @@ use proc_macro2::TokenStream; use quote::ToTokens; -use syn::token; +use syn::{token, Token}; pub enum Fragment { /// Tokens that can be used as an expression. diff --git a/serde_derive/src/internals/ast.rs b/serde_derive/src/internals/ast.rs index b9f14bc5..5a9ee4e6 100644 --- a/serde_derive/src/internals/ast.rs +++ b/serde_derive/src/internals/ast.rs @@ -2,6 +2,7 @@ use crate::internals::{attr, check, Ctxt, Derive}; use syn::punctuated::Punctuated; +use syn::Token; /// A source data structure annotated with `#[derive(Serialize)]` and/or `#[derive(Deserialize)]`, /// parsed into an internal representation. diff --git a/serde_derive/src/internals/attr.rs b/serde_derive/src/internals/attr.rs index 7adba5fb..87cf45ad 100644 --- a/serde_derive/src/internals/attr.rs +++ b/serde_derive/src/internals/attr.rs @@ -8,7 +8,7 @@ use std::iter::FromIterator; use syn::meta::ParseNestedMeta; use syn::parse::ParseStream; use syn::punctuated::Punctuated; -use syn::{token, Ident, Lifetime}; +use syn::{parse_quote, token, Ident, Lifetime, Token}; // This module handles parsing of `#[serde(...)]` attributes. The entrypoints // are `attr::Container::from_ast`, `attr::Variant::from_ast`, and diff --git a/serde_derive/src/internals/receiver.rs b/serde_derive/src/internals/receiver.rs index 7fb8b388..6273dfec 100644 --- a/serde_derive/src/internals/receiver.rs +++ b/serde_derive/src/internals/receiver.rs @@ -5,7 +5,7 @@ use std::mem; use syn::punctuated::Punctuated; use syn::{ parse_quote, Data, DeriveInput, Expr, ExprPath, GenericArgument, GenericParam, Generics, Macro, - Path, PathArguments, QSelf, ReturnType, Type, TypeParamBound, TypePath, WherePredicate, + Path, PathArguments, QSelf, ReturnType, Token, Type, TypeParamBound, TypePath, WherePredicate, }; pub fn replace_receiver(input: &mut DeriveInput) { diff --git a/serde_derive/src/lib.rs b/serde_derive/src/lib.rs index 8eb1e072..208604d2 100644 --- a/serde_derive/src/lib.rs +++ b/serde_derive/src/lib.rs @@ -63,15 +63,12 @@ )] #![cfg_attr(all(test, exhaustive), feature(non_exhaustive_omitted_patterns_lint))] -#[macro_use] +extern crate proc_macro2; extern crate quote; -#[macro_use] extern crate syn; #[cfg(not(precompiled))] extern crate proc_macro; -extern crate proc_macro2; - #[cfg(precompiled)] extern crate proc_macro2 as proc_macro; @@ -80,7 +77,7 @@ mod internals; use proc_macro::TokenStream; #[cfg(precompiled)] use std::sync::atomic::AtomicBool; -use syn::DeriveInput; +use syn::{parse_macro_input, DeriveInput}; #[macro_use] mod bound; diff --git a/serde_derive/src/pretend.rs b/serde_derive/src/pretend.rs index 7d99dfa7..04868753 100644 --- a/serde_derive/src/pretend.rs +++ b/serde_derive/src/pretend.rs @@ -1,6 +1,6 @@ use crate::internals::ast::{Container, Data, Field, Style, Variant}; use proc_macro2::TokenStream; -use quote::format_ident; +use quote::{format_ident, quote}; // Suppress dead_code warnings that would otherwise appear when using a remote // derive. Other than this pretend code, a struct annotated with remote derive diff --git a/serde_derive/src/ser.rs b/serde_derive/src/ser.rs index 942a4ada..951573ca 100644 --- a/serde_derive/src/ser.rs +++ b/serde_derive/src/ser.rs @@ -3,8 +3,9 @@ use crate::internals::ast::{Container, Data, Field, Style, Variant}; use crate::internals::{attr, replace_receiver, Ctxt, Derive}; use crate::{bound, dummy, pretend, this}; use proc_macro2::{Span, TokenStream}; +use quote::{quote, quote_spanned}; use syn::spanned::Spanned; -use syn::{self, Ident, Index, Member}; +use syn::{parse_quote, Ident, Index, Member}; pub fn expand_derive_serialize(input: &mut syn::DeriveInput) -> syn::Result { replace_receiver(input); diff --git a/serde_derive/src/try.rs b/serde_derive/src/try.rs index 48cceeba..d15d503e 100644 --- a/serde_derive/src/try.rs +++ b/serde_derive/src/try.rs @@ -1,4 +1,5 @@ use proc_macro2::{Punct, Spacing, TokenStream}; +use quote::quote; // None of our generated code requires the `From::from` error conversion // performed by the standard library's `try!` macro. With this simplified macro diff --git a/serde_derive_internals/lib.rs b/serde_derive_internals/lib.rs index f9362e2d..9842b39b 100644 --- a/serde_derive_internals/lib.rs +++ b/serde_derive_internals/lib.rs @@ -38,11 +38,9 @@ clippy::wildcard_imports )] -#[macro_use] -extern crate syn; - extern crate proc_macro2; extern crate quote; +extern crate syn; #[cfg_attr(serde_build_from_git, path = "../serde_derive/src/internals/mod.rs")] #[cfg_attr(not(serde_build_from_git), path = "src/mod.rs")]