Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vic1707 committed Jul 9, 2024
1 parent 28a0922 commit 0925e7d
Show file tree
Hide file tree
Showing 17 changed files with 126 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ jobs:
- run: cargo docs-rs -p serde
- run: cargo docs-rs -p serde_derive
- run: cargo docs-rs -p serde_derive_internals
- run: cargo docs-rs -p serde_derive_implementation

clippy:
name: Clippy
Expand All @@ -146,6 +147,7 @@ jobs:
- run: cd serde && cargo clippy --features rc,unstable -- -Dclippy::all -Dclippy::pedantic
- run: cd serde_derive && cargo clippy -- -Dclippy::all -Dclippy::pedantic
- run: cd serde_derive_internals && cargo clippy -- -Dclippy::all -Dclippy::pedantic
- run: cd serde_derive_implementation && cargo clippy -- -Dclippy::all -Dclippy::pedantic
- run: cd test_suite && cargo clippy --tests --features unstable -- -Dclippy::all -Dclippy::pedantic
- run: cd test_suite/no_std && cargo clippy -- -Dclippy::all -Dclippy::pedantic

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"serde",
"serde_derive",
"serde_derive_implementation",
"serde_derive_internals",
"test_suite",
]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::fragment::{Expr, Fragment, Match, Stmts};
use crate::implementation::fragment::{Expr, Fragment, Match, Stmts};
use crate::implementation::{bound, dummy, pretend, this};
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::{quote, quote_spanned, ToTokens};
use std::collections::BTreeSet;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ pub enum Fragment {

macro_rules! quote_expr {
($($tt:tt)*) => {
$crate::fragment::Fragment::Expr(quote!($($tt)*))
$crate::implementation::fragment::Fragment::Expr(quote!($($tt)*))
}
}

macro_rules! quote_block {
($($tt:tt)*) => {
$crate::fragment::Fragment::Block(quote!($($tt)*))
$crate::implementation::fragment::Fragment::Block(quote!($($tt)*))
}
}

Expand Down
10 changes: 10 additions & 0 deletions serde_derive/src/implementation/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#[macro_use]
mod bound;
#[macro_use]
mod fragment;

pub mod de;
mod dummy;
mod pretend;
pub mod ser;
mod this;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::fragment::{Fragment, Match, Stmts};
use crate::implementation::fragment::{Fragment, Match, Stmts};
use crate::implementation::{bound, dummy, pretend, this};
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;
Expand Down
File renamed without changes.
12 changes: 2 additions & 10 deletions serde_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,14 @@ extern crate syn;

extern crate proc_macro;

mod implementation;
mod internals;

use proc_macro::TokenStream;
use syn::parse_macro_input;
use syn::DeriveInput;

#[macro_use]
mod bound;
#[macro_use]
mod fragment;

mod de;
mod dummy;
mod pretend;
mod ser;
mod this;
use implementation::{de, ser};

#[proc_macro_derive(Serialize, attributes(serde))]
pub fn derive_serialize(input: TokenStream) -> TokenStream {
Expand Down
26 changes: 26 additions & 0 deletions serde_derive_implementation/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "serde_derive_implementation"
version = "0.29.1"
authors = ["Erick Tryzelaar <[email protected]>", "David Tolnay <[email protected]>"]
description = "Serde derive macros implementations."
documentation = "https://docs.rs/serde_derive_implementation"
edition = "2015"
exclude = ["build.rs"]
homepage = "https://serde.rs"
keywords = ["serde", "serialization"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/serde-rs/serde"
rust-version = "1.56"

[lib]
path = "lib.rs"

[dependencies]
proc-macro2 = { workspace = true }
quote = { workspace = true }
syn = { workspace = true, features = ["clone-impls", "derive", "parsing", "printing"] }
serde_derive_internals = { path = "../serde_derive_internals" }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = ["--generate-link-to-definition"]
1 change: 1 addition & 0 deletions serde_derive_implementation/LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../LICENSE-APACHE
1 change: 1 addition & 0 deletions serde_derive_implementation/LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../LICENSE-MIT
23 changes: 23 additions & 0 deletions serde_derive_implementation/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use std::path::Path;

fn main() {
// Warning: build.rs is not published to crates.io.

println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=src/mod.rs");

println!("cargo:rustc-cfg=check_cfg");
println!("cargo:rustc-check-cfg=cfg(check_cfg)");
println!("cargo:rustc-check-cfg=cfg(exhaustive)");
println!("cargo:rustc-check-cfg=cfg(serde_build_from_git)");
println!("cargo:rustc-check-cfg=cfg(feature, values(\"deserialize_in_place\"))");

// Sometimes on Windows the git checkout does not correctly wire up the
// symlink from serde_derive_implementation/src to serde_derive/src/internals.
// When this happens we'll just build based on relative paths within the git
// repo.
let mod_behind_symlink = Path::new("src/mod.rs");
if !mod_behind_symlink.exists() {
println!("cargo:rustc-cfg=serde_build_from_git");
}
}
53 changes: 53 additions & 0 deletions serde_derive_implementation/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#![doc(html_root_url = "https://docs.rs/serde_derive_impl/0.29.1")]
#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
// Ignored clippy lints
#![allow(
clippy::cognitive_complexity,
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/7575
clippy::collapsible_match,
clippy::derive_partial_eq_without_eq,
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/6797
clippy::manual_map,
clippy::missing_panics_doc,
clippy::redundant_field_names,
clippy::result_unit_err,
clippy::should_implement_trait,
clippy::trivially_copy_pass_by_ref,
clippy::wildcard_in_or_patterns,
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704
clippy::unnested_or_patterns,
)]
// Ignored clippy_pedantic lints
#![allow(
clippy::doc_markdown,
clippy::enum_glob_use,
clippy::items_after_statements,
clippy::let_underscore_untyped,
clippy::manual_assert,
clippy::match_same_arms,
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/6984
clippy::match_wildcard_for_single_variants,
clippy::missing_errors_doc,
clippy::module_name_repetitions,
clippy::must_use_candidate,
clippy::return_self_not_must_use,
clippy::similar_names,
clippy::single_match_else,
clippy::struct_excessive_bools,
clippy::too_many_lines,
clippy::unused_self,
clippy::wildcard_imports
)]

extern crate proc_macro2;
extern crate quote;
extern crate syn;
extern crate serde_derive_internals;

use serde_derive_internals as internals;

#[cfg_attr(serde_build_from_git, path = "../serde_derive/src/implementation/mod.rs")]
#[cfg_attr(not(serde_build_from_git), path = "src/mod.rs")]
mod implementation;

pub use implementation::*;
1 change: 1 addition & 0 deletions serde_derive_implementation/src
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../serde_derive/src/implementation/

0 comments on commit 0925e7d

Please sign in to comment.