Skip to content
Myr

Eliminate 2015-style module system imports from serde_derive

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 89f84c2 · Browse files · 11 files+21 added−34 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+21 added−34 removed

  • other:+21 added−34 removed

11 files+21 added−34 removed

modified:serde_derive/src/internals/ast.rs+1 added-4 removed
1//! A Serde ast, parsed from the Syn ast and ready to generate Rust code.23use internals::attr;4use internals::check;5use internals::{Ctxt, Derive};6use syn;3use crate::internals::{attr, check, Ctxt, Derive};4use syn::punctuated::Punctuated;56/// A source data structure annotated with `#[derive(Serialize)]` and/or `#[derive(Deserialize)]`,7/// parsed into an internal representation.
205 unmodified lines
modified:serde_derive/src/internals/attr.rs+3 added-4 removed
1use internals::symbol::*;2use internals::{ungroup, Ctxt};1use crate::internals::symbol::*;2use crate::internals::{ungroup, Ctxt};3use proc_macro2::{Spacing, Span, TokenStream, TokenTree};4use quote::ToTokens;5use std::borrow::Cow;6use std::collections::BTreeSet;7use std::iter::FromIterator;8use syn;8use syn::meta::ParseNestedMeta;9use syn::parse::ParseStream;10use syn::punctuated::Punctuated;11use syn::{token, Ident, Lifetime};
5 unmodified lines
17// duplicated attributes result in a span_err but otherwise are ignored. The18// user will see errors simultaneously for all bad attributes in the crate19// rather than just the first.2022pub use internals::case::RenameRule;21pub use crate::internals::case::RenameRule;2223struct Attr<'c, T> {24 cx: &'c Ctxt,25 name: Symbol,
1786 unmodified lines
modified:serde_derive/src/internals/check.rs+3 added-3 removed
1use internals::ast::{Container, Data, Field, Style};2use internals::attr::{Identifier, TagType};3use internals::{ungroup, Ctxt, Derive};1use crate::internals::ast::{Container, Data, Field, Style};2use crate::internals::attr::{Identifier, TagType};3use crate::internals::{ungroup, Ctxt, Derive};4use syn::{Member, Type};56// Cross-cutting checks that require looking at more than a single attrs object.7// Simpler checks should happen when parsing and building the attrs.
431 unmodified lines
modified:serde_derive/src/internals/ctxt.rs-1 removed
1use quote::ToTokens;2use std::cell::RefCell;3use std::fmt::Display;4use std::thread;5use syn;56/// A type to collect errors together and format them.7///8/// Dropping this object will cause a panic. It must be consumed using `check`.
60 unmodified lines
modified:serde_derive/src/internals/receiver.rs+1 added-1 removed
1use internals::respan::respan;1use crate::internals::respan::respan;2use proc_macro2::Span;3use quote::ToTokens;4use std::mem;5use syn::punctuated::Punctuated;
287 unmodified lines
modified:serde_derive/src/bound.rs+2 added-3 removed
1use std::collections::HashSet;23use syn;3use syn::punctuated::{Pair, Punctuated};46use internals::ast::{Container, Data};7use internals::{attr, ungroup};5use crate::internals::ast::{Container, Data};6use crate::internals::{attr, ungroup};78use proc_macro2::Span;910// Remove the default from every type parameter because in the generated impls
403 unmodified lines
modified:serde_derive/src/de.rs+4 added-7 removed
4 unmodified lines
5use syn::punctuated::Punctuated;6use syn::spanned::Spanned;7use syn::{self, Ident, Index, Member};89use bound;10use dummy;11use fragment::{Expr, Fragment, Match, Stmts};12use internals::ast::{Container, Data, Field, Style, Variant};13use internals::{attr, replace_receiver, ungroup, Ctxt, Derive};14use pretend;9use crate::fragment::{Expr, Fragment, Match, Stmts};10use crate::internals::ast::{Container, Data, Field, Style, Variant};11use crate::internals::{attr, replace_receiver, ungroup, Ctxt, Derive};12use crate::{bound, dummy, pretend, this};15use this;1314use std::collections::BTreeSet;15use std::ptr;16
3176 unmodified lines
modified:serde_derive/src/dummy.rs+1 added-2 removed
1use proc_macro2::TokenStream;23use syn;4use try;3use crate::try;45pub fn wrap_in_const(serde_path: Option<&syn::Path>, code: TokenStream) -> TokenStream {6 let try_replacement = try::replacement();7
20 unmodified lines
modified:serde_derive/src/pretend.rs+1 added-1 removed
1use proc_macro2::TokenStream;2use quote::format_ident;34use internals::ast::{Container, Data, Field, Style, Variant};4use crate::internals::ast::{Container, Data, Field, Style, Variant};56// Suppress dead_code warnings that would otherwise appear when using a remote7// derive. Other than this pretend code, a struct annotated with remote derive8// never has its fields referenced and an enum annotated with remote derive
178 unmodified lines
modified:serde_derive/src/ser.rs+4 added-7 removed
1use proc_macro2::{Span, TokenStream};2use syn::spanned::Spanned;3use syn::{self, Ident, Index, Member};45use bound;6use dummy;7use fragment::{Fragment, Match, Stmts};8use internals::ast::{Container, Data, Field, Style, Variant};9use internals::{attr, replace_receiver, Ctxt, Derive};10use pretend;5use crate::fragment::{Fragment, Match, Stmts};6use crate::internals::ast::{Container, Data, Field, Style, Variant};7use crate::internals::{attr, replace_receiver, Ctxt, Derive};8use crate::{bound, dummy, pretend, this};11use this;910pub fn expand_derive_serialize(input: &mut syn::DeriveInput) -> syn::Result<TokenStream> {11 replace_receiver(input);12
1326 unmodified lines
modified:serde_derive/src/this.rs+1 added-1 removed
1use internals::ast::Container;1use crate::internals::ast::Container;2use syn::{Path, PathArguments, Token};34pub fn this_type(cont: &Container) -> Path {5 if let Some(remote) = cont.attrs.remote() {
27 unmodified lines