mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-27 13:27:56 +00:00
Compare commits
63 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f331cc257 | |||
| ef16c815f6 | |||
| c45a809d5c | |||
| f7d06cae4c | |||
| 31fe82a215 | |||
| ef6ed1d1be | |||
| 9d1251548b | |||
| c20730ee39 | |||
| afd51ef0f4 | |||
| 3167f98689 | |||
| 078b171c1b | |||
| da8d6f678e | |||
| 548eb8f667 | |||
| 1fe39043ee | |||
| c2114491ca | |||
| 9f47c47cad | |||
| d6b39fd2c1 | |||
| 4d6d0ae539 | |||
| dda070f45c | |||
| b97a183e82 | |||
| 9433004307 | |||
| 9476838264 | |||
| 172edc4cf4 | |||
| 3c97e1b9a9 | |||
| a81968af3c | |||
| ea2789df0f | |||
| b7cfe33101 | |||
| 1b8ebf6b64 | |||
| 35ad468780 | |||
| 850a29beb1 | |||
| 16bf9871cd | |||
| 6182eceed1 | |||
| 99bc52f685 | |||
| 726ff5ed31 | |||
| f63acb52dc | |||
| 36a66873cc | |||
| 63809e69c7 | |||
| f44402e224 | |||
| 099fa25b86 | |||
| c120c4518b | |||
| 115c1b4830 | |||
| 23db3a41e7 | |||
| e2ff603587 | |||
| 19a11237b8 | |||
| 732544aed6 | |||
| 65dfa607c8 | |||
| 59104bbc24 | |||
| 38ad09aeb7 | |||
| 02631cef42 | |||
| f369707dc5 | |||
| e16e924c21 | |||
| 8b52ddd5b9 | |||
| 112f2040ea | |||
| cd836eb3ca | |||
| 2b4355724e | |||
| 5534bf4df1 | |||
| 60522937af | |||
| 29be721f79 | |||
| 0c4ffad9ec | |||
| 03addbae55 | |||
| 0bab6be124 | |||
| b6def5300a | |||
| 1b35c9e27e |
@@ -0,0 +1,163 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
schedule: [cron: "40 1 * * *"]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Test suite
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: dtolnay/rust-toolchain@nightly
|
||||||
|
- run: cd test_suite && cargo test --features unstable
|
||||||
|
|
||||||
|
windows:
|
||||||
|
name: Test suite (windows)
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: dtolnay/rust-toolchain@nightly
|
||||||
|
- run: cd test_suite && cargo test --features unstable -- --skip ui --exact
|
||||||
|
|
||||||
|
stable:
|
||||||
|
name: Rust stable
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
- run: cd serde && cargo build --features rc
|
||||||
|
- run: cd serde && cargo build --no-default-features
|
||||||
|
- run: cd serde_test && cargo build
|
||||||
|
- run: cd serde_test && cargo test --features serde/derive,serde/rc
|
||||||
|
|
||||||
|
beta:
|
||||||
|
name: Rust beta
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: dtolnay/rust-toolchain@beta
|
||||||
|
- run: cd serde && cargo build --features rc
|
||||||
|
- run: cd test_suite && cargo test
|
||||||
|
|
||||||
|
nightly:
|
||||||
|
name: Rust nightly ${{matrix.os == 'windows' && '(windows)' || ''}}
|
||||||
|
runs-on: ${{matrix.os}}-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu, windows]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: dtolnay/rust-toolchain@nightly
|
||||||
|
- run: cd serde && cargo build
|
||||||
|
- run: cd serde && cargo build --no-default-features
|
||||||
|
- run: cd serde && cargo build --no-default-features --features alloc
|
||||||
|
- run: cd serde && cargo build --no-default-features --features rc,alloc
|
||||||
|
- run: cd serde && cargo test --features derive,rc,unstable
|
||||||
|
- run: cd test_suite/no_std && cargo build
|
||||||
|
if: matrix.os != 'windows'
|
||||||
|
|
||||||
|
msrv:
|
||||||
|
name: Rust 1.13.0
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: dtolnay/rust-toolchain@1.13.0
|
||||||
|
- name: Get timestamp for cache
|
||||||
|
id: date
|
||||||
|
run: echo ::set-output name=yearmo::$(date +%Y%m)
|
||||||
|
- uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.cargo/registry/index
|
||||||
|
key: cargo-registry-index-${{steps.date.outputs.yearmo}}
|
||||||
|
- run: cd serde && cargo build --features rc
|
||||||
|
- run: cd serde && cargo build --no-default-features
|
||||||
|
- run: cd serde_test && cargo build
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Rust ${{matrix.rust}}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
rust: [1.19.0, 1.20.0, 1.21.0, 1.25.0, 1.26.0, 1.34.0]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: dtolnay/rust-toolchain@master
|
||||||
|
with:
|
||||||
|
toolchain: ${{matrix.rust}}
|
||||||
|
- run: cd serde && cargo build --no-default-features
|
||||||
|
- run: cd serde && cargo build
|
||||||
|
|
||||||
|
more:
|
||||||
|
name: Rust ${{matrix.rust}}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
rust: [1.27.0, 1.28.0]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: dtolnay/rust-toolchain@master
|
||||||
|
with:
|
||||||
|
toolchain: ${{matrix.rust}}
|
||||||
|
# Work around failing to parse manifest because editions are unstable.
|
||||||
|
- run: sed -i /test_suite/d Cargo.toml
|
||||||
|
- run: cd serde && cargo build --no-default-features
|
||||||
|
- run: cd serde && cargo build
|
||||||
|
|
||||||
|
derive:
|
||||||
|
name: Rust 1.31.0
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: dtolnay/rust-toolchain@1.31.0
|
||||||
|
- run: cd serde_derive && cargo check
|
||||||
|
|
||||||
|
alloc:
|
||||||
|
name: Rust 1.36.0
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: dtolnay/rust-toolchain@1.36.0
|
||||||
|
- run: cd serde && cargo build --no-default-features --features alloc
|
||||||
|
|
||||||
|
emscripten:
|
||||||
|
name: Emscripten
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: dtolnay/rust-toolchain@nightly
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 9
|
||||||
|
- name: Install cargo-web
|
||||||
|
run: |
|
||||||
|
CARGO_WEB_RELEASE=$(curl -L -s -H Accept:application/json https://github.com/koute/cargo-web/releases/latest)
|
||||||
|
CARGO_WEB_VERSION=$(echo "${CARGO_WEB_RELEASE}" | jq -r .tag_name)
|
||||||
|
CARGO_WEB_URL="https://github.com/koute/cargo-web/releases/download/${CARGO_WEB_VERSION}/cargo-web-x86_64-unknown-linux-gnu.gz"
|
||||||
|
mkdir -p ~/.cargo/bin
|
||||||
|
curl -L "${CARGO_WEB_URL}" | gzip -d > ~/.cargo/bin/cargo-web
|
||||||
|
chmod +x ~/.cargo/bin/cargo-web
|
||||||
|
- run: cd test_suite && cargo web test --target=asmjs-unknown-emscripten --nodejs
|
||||||
|
continue-on-error: true
|
||||||
|
- run: cd test_suite && cargo web test --target=wasm32-unknown-emscripten --nodejs
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
name: Clippy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: dtolnay/rust-toolchain@clippy
|
||||||
|
# The need for -Aredundant_field_names here is a Clippy bug.
|
||||||
|
# https://github.com/rust-lang/rust-clippy/issues/5356
|
||||||
|
- run: cd serde && cargo clippy --features rc,unstable -- -D clippy::all -A clippy::redundant_field_names
|
||||||
|
- run: cd serde_derive && cargo clippy -- -D clippy::all
|
||||||
|
- run: cd serde_test && cargo clippy -- -D clippy::all -A clippy::redundant_field_names
|
||||||
|
- run: cd test_suite && cargo clippy --tests --features unstable -- -D clippy::all -A clippy::redundant_field_names
|
||||||
|
- run: cd test_suite/no_std && cargo clippy -- -D clippy::all -A clippy::redundant_field_names
|
||||||
-107
@@ -1,107 +0,0 @@
|
|||||||
language: rust
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- rust: stable
|
|
||||||
script:
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde"
|
|
||||||
- cargo build --features rc
|
|
||||||
- cargo build --no-default-features
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde_test"
|
|
||||||
- cargo build
|
|
||||||
- cargo test --features serde/derive,serde/rc
|
|
||||||
|
|
||||||
- rust: beta
|
|
||||||
script:
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde"
|
|
||||||
- cargo build --features rc
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/test_suite"
|
|
||||||
- cargo test
|
|
||||||
|
|
||||||
- rust: nightly
|
|
||||||
script:
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde"
|
|
||||||
- cargo build
|
|
||||||
- cargo build --no-default-features
|
|
||||||
- cargo build --no-default-features --features alloc
|
|
||||||
- cargo build --no-default-features --features rc,alloc
|
|
||||||
- cargo test --features derive,rc,unstable
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/test_suite"
|
|
||||||
- cargo test --features unstable
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/test_suite/no_std"
|
|
||||||
- cargo build
|
|
||||||
|
|
||||||
- rust: 1.13.0
|
|
||||||
script:
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde"
|
|
||||||
- cargo build --features rc
|
|
||||||
- cargo build --no-default-features
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde_test"
|
|
||||||
- cargo build
|
|
||||||
|
|
||||||
- rust: 1.19.0
|
|
||||||
- rust: 1.20.0
|
|
||||||
- rust: 1.21.0
|
|
||||||
- rust: 1.25.0
|
|
||||||
- rust: 1.26.0
|
|
||||||
|
|
||||||
# Work around failing to parse manifest because editions are unstable.
|
|
||||||
- rust: 1.27.0
|
|
||||||
before_script: sed -i /test_suite/d Cargo.toml
|
|
||||||
- rust: 1.28.0
|
|
||||||
before_script: sed -i /test_suite/d Cargo.toml
|
|
||||||
|
|
||||||
- rust: 1.31.0
|
|
||||||
script:
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde_derive"
|
|
||||||
- cargo build
|
|
||||||
|
|
||||||
- rust: 1.34.0
|
|
||||||
|
|
||||||
- rust: 1.36.0
|
|
||||||
script:
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde"
|
|
||||||
- cargo build --no-default-features --features alloc
|
|
||||||
|
|
||||||
- rust: nightly
|
|
||||||
name: Clippy
|
|
||||||
script:
|
|
||||||
- rustup component add clippy || travis_terminate 0
|
|
||||||
- cargo clippy -- -D clippy::all
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde"
|
|
||||||
- cargo clippy --features rc,unstable -- -D clippy::all
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde_derive"
|
|
||||||
- cargo clippy -- -D clippy::all
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde_test"
|
|
||||||
- cargo clippy -- -D clippy::all
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/test_suite"
|
|
||||||
- cargo clippy --tests --features unstable -- -D clippy::all
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/test_suite/no_std"
|
|
||||||
- cargo clippy -- -D clippy::all
|
|
||||||
|
|
||||||
- rust: nightly
|
|
||||||
name: Emscripten
|
|
||||||
script:
|
|
||||||
- CARGO_WEB_RELEASE=$(curl -L -s -H Accept:application/json https://github.com/koute/cargo-web/releases/latest)
|
|
||||||
- CARGO_WEB_VERSION=$(echo "${CARGO_WEB_RELEASE}" | jq -r .tag_name)
|
|
||||||
- CARGO_WEB_URL="https://github.com/koute/cargo-web/releases/download/${CARGO_WEB_VERSION}/cargo-web-x86_64-unknown-linux-gnu.gz"
|
|
||||||
|
|
||||||
- nvm install 9
|
|
||||||
- mkdir -p ~/.cargo/bin
|
|
||||||
- curl -L "${CARGO_WEB_URL}" | gzip -d > ~/.cargo/bin/cargo-web
|
|
||||||
- chmod +x ~/.cargo/bin/cargo-web
|
|
||||||
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/test_suite"
|
|
||||||
- cargo web test --target=asmjs-unknown-emscripten --nodejs
|
|
||||||
- cargo web test --target=wasm32-unknown-emscripten --nodejs
|
|
||||||
|
|
||||||
allow_failures:
|
|
||||||
- rust: nightly
|
|
||||||
name: Clippy
|
|
||||||
- rust: nightly
|
|
||||||
name: Emscripten
|
|
||||||
|
|
||||||
script:
|
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde"
|
|
||||||
- cargo build --no-default-features
|
|
||||||
- cargo build
|
|
||||||
@@ -4,11 +4,6 @@ Serde welcomes contribution from everyone in the form of suggestions, bug
|
|||||||
reports, pull requests, and feedback. This document gives some guidance if you
|
reports, pull requests, and feedback. This document gives some guidance if you
|
||||||
are thinking of helping us.
|
are thinking of helping us.
|
||||||
|
|
||||||
Please reach out here in a GitHub issue or in the #serde IRC channel on
|
|
||||||
[`irc.mozilla.org`] if we can do anything to help you contribute.
|
|
||||||
|
|
||||||
[`irc.mozilla.org`]: https://wiki.mozilla.org/IRC
|
|
||||||
|
|
||||||
## Submitting bug reports and feature requests
|
## Submitting bug reports and feature requests
|
||||||
|
|
||||||
Serde development is spread across lots of repositories, but this serde-rs/serde
|
Serde development is spread across lots of repositories, but this serde-rs/serde
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Serde   [![Build Status]][travis] [![Latest Version]][crates.io] [![serde: rustc 1.13+]][Rust 1.13] [![serde_derive: rustc 1.31+]][Rust 1.31]
|
# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.13+]][Rust 1.13] [![serde_derive: rustc 1.31+]][Rust 1.31]
|
||||||
|
|
||||||
[Build Status]: https://api.travis-ci.org/serde-rs/serde.svg?branch=master
|
[Build Status]: https://img.shields.io/github/workflow/status/serde-rs/serde/CI/master
|
||||||
[travis]: https://travis-ci.org/serde-rs/serde
|
[actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster
|
||||||
[Latest Version]: https://img.shields.io/crates/v/serde.svg
|
[Latest Version]: https://img.shields.io/crates/v/serde.svg
|
||||||
[crates.io]: https://crates.io/crates/serde
|
[crates.io]: https://crates.io/crates/serde
|
||||||
[serde: rustc 1.13+]: https://img.shields.io/badge/serde-rustc_1.13+-lightgray.svg
|
[serde: rustc 1.13+]: https://img.shields.io/badge/serde-rustc_1.13+-lightgray.svg
|
||||||
@@ -75,13 +75,23 @@ fn main() {
|
|||||||
|
|
||||||
## Getting help
|
## Getting help
|
||||||
|
|
||||||
Serde developers live in the #serde channel on [`irc.mozilla.org`][irc]. The
|
Serde is one of the most widely used Rust libraries so any place that Rustaceans
|
||||||
\#rust channel is also a good resource with generally faster response time but
|
congregate will be able to help you out. For chat, consider trying the
|
||||||
less specific knowledge about Serde. If IRC is not your thing or you don't get a
|
[#general] or [#beginners] channels of the unofficial community Discord, the
|
||||||
good response, we are happy to respond to [GitHub issues][issues] as well.
|
[#rust-usage] channel of the official Rust Project Discord, or the
|
||||||
|
[#general][zulip] stream in Zulip. For asynchronous, consider the [\[rust\] tag
|
||||||
|
on StackOverflow][stackoverflow], the [/r/rust] subreddit which has a pinned
|
||||||
|
weekly easy questions post, or the Rust [Discourse forum][discourse]. It's
|
||||||
|
acceptable to file a support issue in this repo but they tend not to get as many
|
||||||
|
eyes as any of the above and may get closed without a response after some time.
|
||||||
|
|
||||||
[irc]: https://wiki.mozilla.org/IRC
|
[#general]: https://discord.com/channels/273534239310479360/274215136414400513
|
||||||
[issues]: https://github.com/serde-rs/serde/issues/new/choose
|
[#beginners]: https://discord.com/channels/273534239310479360/273541522815713281
|
||||||
|
[#rust-usage]: https://discord.com/channels/442252698964721669/443150878111694848
|
||||||
|
[zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general
|
||||||
|
[stackoverflow]: https://stackoverflow.com/questions/tagged/rust
|
||||||
|
[/r/rust]: https://www.reddit.com/r/rust
|
||||||
|
[discourse]: https://users.rust-lang.org
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
environment:
|
|
||||||
matrix:
|
|
||||||
- APPVEYOR_RUST_CHANNEL: stable
|
|
||||||
- APPVEYOR_RUST_CHANNEL: nightly
|
|
||||||
|
|
||||||
install:
|
|
||||||
# Install rust, x86_64-pc-windows-msvc host
|
|
||||||
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
|
|
||||||
- rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain %APPVEYOR_RUST_CHANNEL%
|
|
||||||
- set PATH=C:\msys64\usr\bin;%PATH%;C:\Users\appveyor\.cargo\bin
|
|
||||||
- rustc -vV
|
|
||||||
- cargo -vV
|
|
||||||
|
|
||||||
build: false
|
|
||||||
|
|
||||||
for:
|
|
||||||
- matrix:
|
|
||||||
only:
|
|
||||||
- APPVEYOR_RUST_CHANNEL: stable
|
|
||||||
test_script:
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%\serde
|
|
||||||
- cargo build --features rc
|
|
||||||
- cargo build --no-default-features
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%\serde_test
|
|
||||||
- cargo build
|
|
||||||
- cargo test --features serde/derive,serde/rc
|
|
||||||
|
|
||||||
- matrix:
|
|
||||||
only:
|
|
||||||
- APPVEYOR_RUST_CHANNEL: nightly
|
|
||||||
test_script:
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%\serde
|
|
||||||
- cargo build
|
|
||||||
- cargo build --no-default-features
|
|
||||||
- cargo build --no-default-features --features alloc
|
|
||||||
- cargo build --no-default-features --features rc,alloc
|
|
||||||
- cargo test --features derive,rc,unstable
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%\test_suite
|
|
||||||
- cargo test --features unstable
|
|
||||||
+16
-6
@@ -43,10 +43,20 @@ fn main() {
|
|||||||
|
|
||||||
## Getting help
|
## Getting help
|
||||||
|
|
||||||
Serde developers live in the #serde channel on [`irc.mozilla.org`][irc]. The
|
Serde is one of the most widely used Rust libraries so any place that Rustaceans
|
||||||
\#rust channel is also a good resource with generally faster response time but
|
congregate will be able to help you out. For chat, consider trying the
|
||||||
less specific knowledge about Serde. If IRC is not your thing or you don't get a
|
[#general] or [#beginners] channels of the unofficial community Discord, the
|
||||||
good response, we are happy to respond to [GitHub issues][issues] as well.
|
[#rust-usage] channel of the official Rust Project Discord, or the
|
||||||
|
[#general][zulip] stream in Zulip. For asynchronous, consider the [\[rust\] tag
|
||||||
|
on StackOverflow][stackoverflow], the [/r/rust] subreddit which has a pinned
|
||||||
|
weekly easy questions post, or the Rust [Discourse forum][discourse]. It's
|
||||||
|
acceptable to file a support issue in this repo but they tend not to get as many
|
||||||
|
eyes as any of the above and may get closed without a response after some time.
|
||||||
|
|
||||||
[irc]: https://wiki.mozilla.org/IRC
|
[#general]: https://discord.com/channels/273534239310479360/274215136414400513
|
||||||
[issues]: https://github.com/serde-rs/serde/issues/new/choose
|
[#beginners]: https://discord.com/channels/273534239310479360/273541522815713281
|
||||||
|
[#rust-usage]: https://discord.com/channels/442252698964721669/443150878111694848
|
||||||
|
[zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general
|
||||||
|
[stackoverflow]: https://stackoverflow.com/questions/tagged/rust
|
||||||
|
[/r/rust]: https://www.reddit.com/r/rust
|
||||||
|
[discourse]: https://users.rust-lang.org
|
||||||
|
|||||||
+2
-6
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.106" # remember to update html_root_url and serde_derive dependency
|
version = "1.0.111" # remember to update html_root_url and serde_derive dependency
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "A generic serialization/deserialization framework"
|
description = "A generic serialization/deserialization framework"
|
||||||
@@ -13,12 +13,8 @@ readme = "crates-io.md"
|
|||||||
include = ["Cargo.toml", "build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
include = ["Cargo.toml", "build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[badges]
|
|
||||||
travis-ci = { repository = "serde-rs/serde" }
|
|
||||||
appveyor = { repository = "serde-rs/serde" }
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_derive = { version = "=1.0.106", optional = true, path = "../serde_derive" }
|
serde_derive = { version = "=1.0.111", optional = true, path = "../serde_derive" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_derive = { version = "1.0", path = "../serde_derive" }
|
serde_derive = { version = "1.0", path = "../serde_derive" }
|
||||||
|
|||||||
@@ -90,10 +90,13 @@ macro_rules! visit_integer_method {
|
|||||||
{
|
{
|
||||||
match FromPrimitive::$from_method(v) {
|
match FromPrimitive::$from_method(v) {
|
||||||
Some(v) => Ok(v),
|
Some(v) => Ok(v),
|
||||||
None => Err(Error::invalid_value(Unexpected::$group(v as $group_ty), &self)),
|
None => Err(Error::invalid_value(
|
||||||
|
Unexpected::$group(v as $group_ty),
|
||||||
|
&self,
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! visit_float_method {
|
macro_rules! visit_float_method {
|
||||||
@@ -105,7 +108,7 @@ macro_rules! visit_float_method {
|
|||||||
{
|
{
|
||||||
Ok(v as Self::Value)
|
Ok(v as Self::Value)
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! impl_deserialize_num {
|
macro_rules! impl_deserialize_num {
|
||||||
|
|||||||
+6
-1
@@ -53,6 +53,9 @@
|
|||||||
//! *(deserialization only)*
|
//! *(deserialization only)*
|
||||||
//! - [Envy Store], a way to deserialize [AWS Parameter Store] parameters into
|
//! - [Envy Store], a way to deserialize [AWS Parameter Store] parameters into
|
||||||
//! Rust structs. *(deserialization only)*
|
//! Rust structs. *(deserialization only)*
|
||||||
|
//! - [S-expressions], the textual representation of code and data used by the
|
||||||
|
//! Lisp language family.
|
||||||
|
//! - [D-Bus]'s binary wire format.
|
||||||
//!
|
//!
|
||||||
//! [JSON]: https://github.com/serde-rs/json
|
//! [JSON]: https://github.com/serde-rs/json
|
||||||
//! [Bincode]: https://github.com/TyOverby/bincode
|
//! [Bincode]: https://github.com/TyOverby/bincode
|
||||||
@@ -71,11 +74,13 @@
|
|||||||
//! [Envy Store]: https://github.com/softprops/envy-store
|
//! [Envy Store]: https://github.com/softprops/envy-store
|
||||||
//! [Cargo]: http://doc.crates.io/manifest.html
|
//! [Cargo]: http://doc.crates.io/manifest.html
|
||||||
//! [AWS Parameter Store]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html
|
//! [AWS Parameter Store]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html
|
||||||
|
//! [S-expressions]: https://github.com/rotty/lexpr-rs
|
||||||
|
//! [D-Bus]: https://docs.rs/zvariant
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Serde types in rustdoc of other crates get linked to here.
|
// Serde types in rustdoc of other crates get linked to here.
|
||||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.106")]
|
#![doc(html_root_url = "https://docs.rs/serde/1.0.111")]
|
||||||
// Support using Serde without the standard library!
|
// Support using Serde without the standard library!
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
// Unstable functionality only if the user asks for it. For tracking and
|
// Unstable functionality only if the user asks for it. For tracking and
|
||||||
|
|||||||
@@ -183,7 +183,9 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deserializer.deserialize_bytes(CowBytesVisitor).map(From::from)
|
deserializer
|
||||||
|
.deserialize_bytes(CowBytesVisitor)
|
||||||
|
.map(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod size_hint {
|
pub mod size_hint {
|
||||||
@@ -1560,7 +1562,7 @@ mod content {
|
|||||||
other.unexpected(),
|
other.unexpected(),
|
||||||
&"struct variant",
|
&"struct variant",
|
||||||
)),
|
)),
|
||||||
_ => Err(de::Error::invalid_type(
|
None => Err(de::Error::invalid_type(
|
||||||
de::Unexpected::UnitVariant,
|
de::Unexpected::UnitVariant,
|
||||||
&"struct variant",
|
&"struct variant",
|
||||||
)),
|
)),
|
||||||
@@ -2250,7 +2252,7 @@ mod content {
|
|||||||
other.unexpected(),
|
other.unexpected(),
|
||||||
&"struct variant",
|
&"struct variant",
|
||||||
)),
|
)),
|
||||||
_ => Err(de::Error::invalid_type(
|
None => Err(de::Error::invalid_type(
|
||||||
de::Unexpected::UnitVariant,
|
de::Unexpected::UnitVariant,
|
||||||
&"struct variant",
|
&"struct variant",
|
||||||
)),
|
)),
|
||||||
@@ -2472,7 +2474,7 @@ mod content {
|
|||||||
where
|
where
|
||||||
M: MapAccess<'de>,
|
M: MapAccess<'de>,
|
||||||
{
|
{
|
||||||
while let Some(_) = try!(access.next_entry::<IgnoredAny, IgnoredAny>()) {}
|
while try!(access.next_entry::<IgnoredAny, IgnoredAny>()).is_some() {}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,174 @@
|
|||||||
|
use lib::*;
|
||||||
|
use ser::{Error, Impossible, Serialize, Serializer};
|
||||||
|
|
||||||
|
impl Error for fmt::Error {
|
||||||
|
fn custom<T: Display>(_msg: T) -> Self {
|
||||||
|
fmt::Error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! fmt_primitives {
|
||||||
|
($($f:ident: $t:ty,)*) => {
|
||||||
|
$(
|
||||||
|
fn $f(self, v: $t) -> fmt::Result {
|
||||||
|
Display::fmt(&v, self)
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ```edition2018
|
||||||
|
/// use serde::Serialize;
|
||||||
|
/// use std::fmt::{self, Display};
|
||||||
|
///
|
||||||
|
/// #[derive(Serialize)]
|
||||||
|
/// #[serde(rename_all = "kebab-case")]
|
||||||
|
/// pub enum MessageType {
|
||||||
|
/// StartRequest,
|
||||||
|
/// EndRequest,
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// impl Display for MessageType {
|
||||||
|
/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
/// self.serialize(f)
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
|
||||||
|
type Ok = ();
|
||||||
|
type Error = fmt::Error;
|
||||||
|
type SerializeSeq = Impossible<(), fmt::Error>;
|
||||||
|
type SerializeTuple = Impossible<(), fmt::Error>;
|
||||||
|
type SerializeTupleStruct = Impossible<(), fmt::Error>;
|
||||||
|
type SerializeTupleVariant = Impossible<(), fmt::Error>;
|
||||||
|
type SerializeMap = Impossible<(), fmt::Error>;
|
||||||
|
type SerializeStruct = Impossible<(), fmt::Error>;
|
||||||
|
type SerializeStructVariant = Impossible<(), fmt::Error>;
|
||||||
|
|
||||||
|
fmt_primitives! {
|
||||||
|
serialize_bool: bool,
|
||||||
|
serialize_i8: i8,
|
||||||
|
serialize_i16: i16,
|
||||||
|
serialize_i32: i32,
|
||||||
|
serialize_i64: i64,
|
||||||
|
serialize_u8: u8,
|
||||||
|
serialize_u16: u16,
|
||||||
|
serialize_u32: u32,
|
||||||
|
serialize_u64: u64,
|
||||||
|
serialize_f32: f32,
|
||||||
|
serialize_f64: f64,
|
||||||
|
serialize_char: char,
|
||||||
|
serialize_str: &str,
|
||||||
|
serialize_unit_struct: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
serde_if_integer128! {
|
||||||
|
fmt_primitives! {
|
||||||
|
serialize_i128: i128,
|
||||||
|
serialize_u128: u128,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_unit_variant(
|
||||||
|
self,
|
||||||
|
_name: &'static str,
|
||||||
|
_variant_index: u32,
|
||||||
|
variant: &'static str,
|
||||||
|
) -> fmt::Result {
|
||||||
|
Display::fmt(variant, self)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_newtype_struct<T: ?Sized>(self, _name: &'static str, value: &T) -> fmt::Result
|
||||||
|
where
|
||||||
|
T: Serialize,
|
||||||
|
{
|
||||||
|
Serialize::serialize(value, self)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_bytes(self, _v: &[u8]) -> fmt::Result {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_none(self) -> fmt::Result {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_some<T: ?Sized>(self, _value: &T) -> fmt::Result
|
||||||
|
where
|
||||||
|
T: Serialize,
|
||||||
|
{
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_unit(self) -> fmt::Result {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_newtype_variant<T: ?Sized>(
|
||||||
|
self,
|
||||||
|
_name: &'static str,
|
||||||
|
_variant_index: u32,
|
||||||
|
_variant: &'static str,
|
||||||
|
_value: &T,
|
||||||
|
) -> fmt::Result
|
||||||
|
where
|
||||||
|
T: Serialize,
|
||||||
|
{
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_tuple_struct(
|
||||||
|
self,
|
||||||
|
_name: &'static str,
|
||||||
|
_len: usize,
|
||||||
|
) -> Result<Self::SerializeTupleStruct, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_tuple_variant(
|
||||||
|
self,
|
||||||
|
_name: &'static str,
|
||||||
|
_variant_index: u32,
|
||||||
|
_variant: &'static str,
|
||||||
|
_len: usize,
|
||||||
|
) -> Result<Self::SerializeTupleVariant, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_struct(
|
||||||
|
self,
|
||||||
|
_name: &'static str,
|
||||||
|
_len: usize,
|
||||||
|
) -> Result<Self::SerializeStruct, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_struct_variant(
|
||||||
|
self,
|
||||||
|
_name: &'static str,
|
||||||
|
_variant_index: u32,
|
||||||
|
_variant: &'static str,
|
||||||
|
_len: usize,
|
||||||
|
) -> Result<Self::SerializeStructVariant, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn collect_str<T: ?Sized>(self, value: &T) -> fmt::Result
|
||||||
|
where
|
||||||
|
T: Display,
|
||||||
|
{
|
||||||
|
Display::fmt(value, self)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -616,7 +616,7 @@ impl Serialize for SystemTime {
|
|||||||
use super::SerializeStruct;
|
use super::SerializeStruct;
|
||||||
let duration_since_epoch = self
|
let duration_since_epoch = self
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
.expect("SystemTime must be later than UNIX_EPOCH");
|
.map_err(|_| S::Error::custom("SystemTime must be later than UNIX_EPOCH"))?;
|
||||||
let mut state = try!(serializer.serialize_struct("SystemTime", 2));
|
let mut state = try!(serializer.serialize_struct("SystemTime", 2));
|
||||||
try!(state.serialize_field("secs_since_epoch", &duration_since_epoch.as_secs()));
|
try!(state.serialize_field("secs_since_epoch", &duration_since_epoch.as_secs()));
|
||||||
try!(state.serialize_field("nanos_since_epoch", &duration_since_epoch.subsec_nanos()));
|
try!(state.serialize_field("nanos_since_epoch", &duration_since_epoch.subsec_nanos()));
|
||||||
|
|||||||
@@ -109,6 +109,7 @@
|
|||||||
|
|
||||||
use lib::*;
|
use lib::*;
|
||||||
|
|
||||||
|
mod fmt;
|
||||||
mod impls;
|
mod impls;
|
||||||
mod impossible;
|
mod impossible;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.106" # remember to update html_root_url
|
version = "1.0.111" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
||||||
@@ -11,10 +11,6 @@ keywords = ["serde", "serialization", "no_std"]
|
|||||||
readme = "crates-io.md"
|
readme = "crates-io.md"
|
||||||
include = ["Cargo.toml", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
include = ["Cargo.toml", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
||||||
|
|
||||||
[badges]
|
|
||||||
travis-ci = { repository = "serde-rs/serde" }
|
|
||||||
appveyor = { repository = "serde-rs/serde" }
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
deserialize_in_place = []
|
deserialize_in_place = []
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use syn::punctuated::{Pair, Punctuated};
|
|||||||
use syn::visit::{self, Visit};
|
use syn::visit::{self, Visit};
|
||||||
|
|
||||||
use internals::ast::{Container, Data};
|
use internals::ast::{Container, Data};
|
||||||
use internals::attr;
|
use internals::{attr, ungroup};
|
||||||
|
|
||||||
use proc_macro2::Span;
|
use proc_macro2::Span;
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ pub fn with_bound(
|
|||||||
}
|
}
|
||||||
impl<'ast> Visit<'ast> for FindTyParams<'ast> {
|
impl<'ast> Visit<'ast> for FindTyParams<'ast> {
|
||||||
fn visit_field(&mut self, field: &'ast syn::Field) {
|
fn visit_field(&mut self, field: &'ast syn::Field) {
|
||||||
if let syn::Type::Path(ty) = &field.ty {
|
if let syn::Type::Path(ty) = ungroup(&field.ty) {
|
||||||
if let Some(Pair::Punctuated(t, _)) = ty.path.segments.pairs().next() {
|
if let Some(Pair::Punctuated(t, _)) = ty.path.segments.pairs().next() {
|
||||||
if self.all_type_params.contains(&t.ident) {
|
if self.all_type_params.contains(&t.ident) {
|
||||||
self.associated_type_usage.push(ty);
|
self.associated_type_usage.push(ty);
|
||||||
@@ -156,7 +156,7 @@ pub fn with_bound(
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut visitor = FindTyParams {
|
let mut visitor = FindTyParams {
|
||||||
all_type_params: all_type_params,
|
all_type_params,
|
||||||
relevant_type_params: HashSet::new(),
|
relevant_type_params: HashSet::new(),
|
||||||
associated_type_usage: Vec::new(),
|
associated_type_usage: Vec::new(),
|
||||||
};
|
};
|
||||||
@@ -271,7 +271,7 @@ pub fn with_lifetime_bound(generics: &syn::Generics, lifetime: &str) -> syn::Gen
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
syn::Generics {
|
syn::Generics {
|
||||||
params: params,
|
params,
|
||||||
..generics.clone()
|
..generics.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+45
-37
@@ -8,7 +8,7 @@ use bound;
|
|||||||
use dummy;
|
use dummy;
|
||||||
use fragment::{Expr, Fragment, Match, Stmts};
|
use fragment::{Expr, Fragment, Match, Stmts};
|
||||||
use internals::ast::{Container, Data, Field, Style, Variant};
|
use internals::ast::{Container, Data, Field, Style, Variant};
|
||||||
use internals::{attr, Ctxt, Derive};
|
use internals::{attr, ungroup, Ctxt, Derive};
|
||||||
use pretend;
|
use pretend;
|
||||||
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
@@ -77,7 +77,7 @@ fn precondition(cx: &Ctxt, cont: &Container) {
|
|||||||
fn precondition_sized(cx: &Ctxt, cont: &Container) {
|
fn precondition_sized(cx: &Ctxt, cont: &Container) {
|
||||||
if let Data::Struct(_, fields) = &cont.data {
|
if let Data::Struct(_, fields) = &cont.data {
|
||||||
if let Some(last) = fields.last() {
|
if let Some(last) = fields.last() {
|
||||||
if let syn::Type::Slice(_) = *last.ty {
|
if let syn::Type::Slice(_) = ungroup(last.ty) {
|
||||||
cx.error_spanned_by(
|
cx.error_spanned_by(
|
||||||
cont.original,
|
cont.original,
|
||||||
"cannot deserialize a dynamically sized struct",
|
"cannot deserialize a dynamically sized struct",
|
||||||
@@ -134,11 +134,11 @@ impl Parameters {
|
|||||||
let has_getter = cont.data.has_getter();
|
let has_getter = cont.data.has_getter();
|
||||||
|
|
||||||
Parameters {
|
Parameters {
|
||||||
local: local,
|
local,
|
||||||
this: this,
|
this,
|
||||||
generics: generics,
|
generics,
|
||||||
borrowed: borrowed,
|
borrowed,
|
||||||
has_getter: has_getter,
|
has_getter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1153,10 +1153,13 @@ fn prepare_enum_variant_enum(
|
|||||||
variants: &[Variant],
|
variants: &[Variant],
|
||||||
cattrs: &attr::Container,
|
cattrs: &attr::Container,
|
||||||
) -> (TokenStream, Stmts) {
|
) -> (TokenStream, Stmts) {
|
||||||
let variant_names_idents: Vec<_> = variants
|
let mut deserialized_variants = variants
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|&(_, variant)| !variant.attrs.skip_deserializing())
|
.filter(|&(_, variant)| !variant.attrs.skip_deserializing());
|
||||||
|
|
||||||
|
let variant_names_idents: Vec<_> = deserialized_variants
|
||||||
|
.clone()
|
||||||
.map(|(i, variant)| {
|
.map(|(i, variant)| {
|
||||||
(
|
(
|
||||||
variant.attrs.name().deserialize_name(),
|
variant.attrs.name().deserialize_name(),
|
||||||
@@ -1166,7 +1169,7 @@ fn prepare_enum_variant_enum(
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let other_idx = variants.iter().position(|variant| variant.attrs.other());
|
let other_idx = deserialized_variants.position(|(_, variant)| variant.attrs.other());
|
||||||
|
|
||||||
let variants_stmt = {
|
let variants_stmt = {
|
||||||
let variant_names = variant_names_idents.iter().map(|(name, _, _)| name);
|
let variant_names = variant_names_idents.iter().map(|(name, _, _)| name);
|
||||||
@@ -1374,39 +1377,44 @@ fn deserialize_adjacently_tagged_enum(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fn is_unit(variant: &Variant) -> bool {
|
|
||||||
match variant.style {
|
|
||||||
Style::Unit => true,
|
|
||||||
Style::Struct | Style::Tuple | Style::Newtype => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut missing_content = quote! {
|
let mut missing_content = quote! {
|
||||||
_serde::export::Err(<__A::Error as _serde::de::Error>::missing_field(#content))
|
_serde::export::Err(<__A::Error as _serde::de::Error>::missing_field(#content))
|
||||||
};
|
};
|
||||||
if variants.iter().any(is_unit) {
|
let mut missing_content_fallthrough = quote!();
|
||||||
let fallthrough = if variants.iter().all(is_unit) {
|
let missing_content_arms = variants
|
||||||
None
|
.iter()
|
||||||
} else {
|
.enumerate()
|
||||||
Some(quote! {
|
.filter(|&(_, variant)| !variant.attrs.skip_deserializing())
|
||||||
_ => #missing_content
|
.filter_map(|(i, variant)| {
|
||||||
})
|
let variant_index = field_i(i);
|
||||||
};
|
let variant_ident = &variant.ident;
|
||||||
let arms = variants
|
|
||||||
.iter()
|
let arm = match variant.style {
|
||||||
.enumerate()
|
Style::Unit => quote! {
|
||||||
.filter(|&(_, variant)| !variant.attrs.skip_deserializing() && is_unit(variant))
|
_serde::export::Ok(#this::#variant_ident)
|
||||||
.map(|(i, variant)| {
|
},
|
||||||
let variant_index = field_i(i);
|
Style::Newtype if variant.attrs.deserialize_with().is_none() => {
|
||||||
let variant_ident = &variant.ident;
|
let span = variant.original.span();
|
||||||
quote! {
|
let func = quote_spanned!(span=> _serde::private::de::missing_field);
|
||||||
__Field::#variant_index => _serde::export::Ok(#this::#variant_ident),
|
quote! {
|
||||||
|
#func(#content).map(#this::#variant_ident)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
_ => {
|
||||||
|
missing_content_fallthrough = quote!(_ => #missing_content);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Some(quote! {
|
||||||
|
__Field::#variant_index => #arm,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
if !missing_content_arms.is_empty() {
|
||||||
missing_content = quote! {
|
missing_content = quote! {
|
||||||
match __field {
|
match __field {
|
||||||
#(#arms)*
|
#(#missing_content_arms)*
|
||||||
#fallthrough
|
#missing_content_fallthrough
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,7 @@ pub fn wrap_in_const(
|
|||||||
use #path as _serde;
|
use #path as _serde;
|
||||||
},
|
},
|
||||||
None => quote! {
|
None => quote! {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
|
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ impl<'a> Container<'a> {
|
|||||||
|
|
||||||
let mut item = Container {
|
let mut item = Container {
|
||||||
ident: item.ident.clone(),
|
ident: item.ident.clone(),
|
||||||
attrs: attrs,
|
attrs,
|
||||||
data: data,
|
data,
|
||||||
generics: &item.generics,
|
generics: &item.generics,
|
||||||
original: item,
|
original: item,
|
||||||
};
|
};
|
||||||
@@ -148,9 +148,9 @@ fn enum_from_ast<'a>(
|
|||||||
struct_from_ast(cx, &variant.fields, Some(&attrs), container_default);
|
struct_from_ast(cx, &variant.fields, Some(&attrs), container_default);
|
||||||
Variant {
|
Variant {
|
||||||
ident: variant.ident.clone(),
|
ident: variant.ident.clone(),
|
||||||
attrs: attrs,
|
attrs,
|
||||||
style: style,
|
style,
|
||||||
fields: fields,
|
fields,
|
||||||
original: variant,
|
original: variant,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use internals::symbol::*;
|
use internals::symbol::*;
|
||||||
use internals::Ctxt;
|
use internals::{ungroup, Ctxt};
|
||||||
use proc_macro2::{Group, Span, TokenStream, TokenTree};
|
use proc_macro2::{Group, Span, TokenStream, TokenTree};
|
||||||
use quote::ToTokens;
|
use quote::ToTokens;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
@@ -32,8 +32,8 @@ struct Attr<'c, T> {
|
|||||||
impl<'c, T> Attr<'c, T> {
|
impl<'c, T> Attr<'c, T> {
|
||||||
fn none(cx: &'c Ctxt, name: Symbol) -> Self {
|
fn none(cx: &'c Ctxt, name: Symbol) -> Self {
|
||||||
Attr {
|
Attr {
|
||||||
cx: cx,
|
cx,
|
||||||
name: name,
|
name,
|
||||||
tokens: TokenStream::new(),
|
tokens: TokenStream::new(),
|
||||||
value: None,
|
value: None,
|
||||||
}
|
}
|
||||||
@@ -101,8 +101,8 @@ struct VecAttr<'c, T> {
|
|||||||
impl<'c, T> VecAttr<'c, T> {
|
impl<'c, T> VecAttr<'c, T> {
|
||||||
fn none(cx: &'c Ctxt, name: Symbol) -> Self {
|
fn none(cx: &'c Ctxt, name: Symbol) -> Self {
|
||||||
VecAttr {
|
VecAttr {
|
||||||
cx: cx,
|
cx,
|
||||||
name: name,
|
name,
|
||||||
first_dup_tokens: TokenStream::new(),
|
first_dup_tokens: TokenStream::new(),
|
||||||
values: Vec::new(),
|
values: Vec::new(),
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ impl Name {
|
|||||||
serialize_renamed: ser_renamed,
|
serialize_renamed: ser_renamed,
|
||||||
deserialize: de_name.unwrap_or(source_name),
|
deserialize: de_name.unwrap_or(source_name),
|
||||||
deserialize_renamed: de_renamed,
|
deserialize_renamed: de_renamed,
|
||||||
deserialize_aliases: deserialize_aliases,
|
deserialize_aliases,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +222,7 @@ pub struct Container {
|
|||||||
identifier: Identifier,
|
identifier: Identifier,
|
||||||
has_flatten: bool,
|
has_flatten: bool,
|
||||||
serde_path: Option<syn::Path>,
|
serde_path: Option<syn::Path>,
|
||||||
|
is_packed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Styles of representing an enum.
|
/// Styles of representing an enum.
|
||||||
@@ -592,6 +593,16 @@ impl Container {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut is_packed = false;
|
||||||
|
for attr in &item.attrs {
|
||||||
|
if attr.path.is_ident("repr") {
|
||||||
|
let _ = attr.parse_args_with(|input: ParseStream| {
|
||||||
|
is_packed |= input.parse::<Ident>()? == "packed";
|
||||||
|
Ok(())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Container {
|
Container {
|
||||||
name: Name::from_attrs(unraw(&item.ident), ser_name, de_name, None),
|
name: Name::from_attrs(unraw(&item.ident), ser_name, de_name, None),
|
||||||
transparent: transparent.get(),
|
transparent: transparent.get(),
|
||||||
@@ -611,6 +622,7 @@ impl Container {
|
|||||||
identifier: decide_identifier(cx, item, field_identifier, variant_identifier),
|
identifier: decide_identifier(cx, item, field_identifier, variant_identifier),
|
||||||
has_flatten: false,
|
has_flatten: false,
|
||||||
serde_path: serde_path.get(),
|
serde_path: serde_path.get(),
|
||||||
|
is_packed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -662,6 +674,10 @@ impl Container {
|
|||||||
self.remote.as_ref()
|
self.remote.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_packed(&self) -> bool {
|
||||||
|
self.is_packed
|
||||||
|
}
|
||||||
|
|
||||||
pub fn identifier(&self) -> Identifier {
|
pub fn identifier(&self) -> Identifier {
|
||||||
self.identifier
|
self.identifier
|
||||||
}
|
}
|
||||||
@@ -716,7 +732,7 @@ fn decide_tag(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TagType::Internal { tag: tag }
|
TagType::Internal { tag }
|
||||||
}
|
}
|
||||||
(Some((untagged_tokens, _)), Some((tag_tokens, _)), None) => {
|
(Some((untagged_tokens, _)), Some((tag_tokens, _)), None) => {
|
||||||
cx.error_spanned_by(
|
cx.error_spanned_by(
|
||||||
@@ -747,10 +763,7 @@ fn decide_tag(
|
|||||||
);
|
);
|
||||||
TagType::External
|
TagType::External
|
||||||
}
|
}
|
||||||
(None, Some((_, tag)), Some((_, content))) => TagType::Adjacent {
|
(None, Some((_, tag)), Some((_, content))) => TagType::Adjacent { tag, content },
|
||||||
tag: tag,
|
|
||||||
content: content,
|
|
||||||
},
|
|
||||||
(Some((untagged_tokens, _)), Some((tag_tokens, _)), Some((content_tokens, _))) => {
|
(Some((untagged_tokens, _)), Some((tag_tokens, _)), Some((content_tokens, _))) => {
|
||||||
cx.error_spanned_by(
|
cx.error_spanned_by(
|
||||||
untagged_tokens,
|
untagged_tokens,
|
||||||
@@ -1383,7 +1396,7 @@ impl Field {
|
|||||||
let expr = syn::ExprPath {
|
let expr = syn::ExprPath {
|
||||||
attrs: Vec::new(),
|
attrs: Vec::new(),
|
||||||
qself: None,
|
qself: None,
|
||||||
path: path,
|
path,
|
||||||
};
|
};
|
||||||
deserialize_with.set_if_none(expr);
|
deserialize_with.set_if_none(expr);
|
||||||
} else if is_cow(&field.ty, is_slice_u8) {
|
} else if is_cow(&field.ty, is_slice_u8) {
|
||||||
@@ -1400,7 +1413,7 @@ impl Field {
|
|||||||
let expr = syn::ExprPath {
|
let expr = syn::ExprPath {
|
||||||
attrs: Vec::new(),
|
attrs: Vec::new(),
|
||||||
qself: None,
|
qself: None,
|
||||||
path: path,
|
path,
|
||||||
};
|
};
|
||||||
deserialize_with.set_if_none(expr);
|
deserialize_with.set_if_none(expr);
|
||||||
}
|
}
|
||||||
@@ -1420,7 +1433,7 @@ impl Field {
|
|||||||
deserialize_with: deserialize_with.get(),
|
deserialize_with: deserialize_with.get(),
|
||||||
ser_bound: ser_bound.get(),
|
ser_bound: ser_bound.get(),
|
||||||
de_bound: de_bound.get(),
|
de_bound: de_bound.get(),
|
||||||
borrowed_lifetimes: borrowed_lifetimes,
|
borrowed_lifetimes,
|
||||||
getter: getter.get(),
|
getter: getter.get(),
|
||||||
flatten: flatten.get(),
|
flatten: flatten.get(),
|
||||||
transparent: false,
|
transparent: false,
|
||||||
@@ -1724,7 +1737,7 @@ fn is_implicitly_borrowed_reference(ty: &syn::Type) -> bool {
|
|||||||
// cow: Cow<'a, str>,
|
// cow: Cow<'a, str>,
|
||||||
// }
|
// }
|
||||||
fn is_cow(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
fn is_cow(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||||
let path = match ty {
|
let path = match ungroup(ty) {
|
||||||
syn::Type::Path(ty) => &ty.path,
|
syn::Type::Path(ty) => &ty.path,
|
||||||
_ => {
|
_ => {
|
||||||
return false;
|
return false;
|
||||||
@@ -1751,7 +1764,7 @@ fn is_cow(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||||
let path = match ty {
|
let path = match ungroup(ty) {
|
||||||
syn::Type::Path(ty) => &ty.path,
|
syn::Type::Path(ty) => &ty.path,
|
||||||
_ => {
|
_ => {
|
||||||
return false;
|
return false;
|
||||||
@@ -1798,7 +1811,7 @@ fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
|||||||
// r: &'a str,
|
// r: &'a str,
|
||||||
// }
|
// }
|
||||||
fn is_reference(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
fn is_reference(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||||
match ty {
|
match ungroup(ty) {
|
||||||
syn::Type::Reference(ty) => ty.mutability.is_none() && elem(&ty.elem),
|
syn::Type::Reference(ty) => ty.mutability.is_none() && elem(&ty.elem),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
@@ -1809,14 +1822,14 @@ fn is_str(ty: &syn::Type) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_slice_u8(ty: &syn::Type) -> bool {
|
fn is_slice_u8(ty: &syn::Type) -> bool {
|
||||||
match ty {
|
match ungroup(ty) {
|
||||||
syn::Type::Slice(ty) => is_primitive_type(&ty.elem, "u8"),
|
syn::Type::Slice(ty) => is_primitive_type(&ty.elem, "u8"),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_primitive_type(ty: &syn::Type, primitive: &str) -> bool {
|
fn is_primitive_type(ty: &syn::Type, primitive: &str) -> bool {
|
||||||
match ty {
|
match ungroup(ty) {
|
||||||
syn::Type::Path(ty) => ty.qself.is_none() && is_primitive_path(&ty.path, primitive),
|
syn::Type::Path(ty) => ty.qself.is_none() && is_primitive_path(&ty.path, primitive),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use internals::ast::{Container, Data, Field, Style};
|
use internals::ast::{Container, Data, Field, Style};
|
||||||
use internals::attr::{Identifier, TagType};
|
use internals::attr::{Identifier, TagType};
|
||||||
use internals::{Ctxt, Derive};
|
use internals::{ungroup, Ctxt, Derive};
|
||||||
use syn::{Member, Type};
|
use syn::{Member, Type};
|
||||||
|
|
||||||
/// Cross-cutting checks that require looking at more than a single attrs
|
/// Cross-cutting checks that require looking at more than a single attrs
|
||||||
@@ -396,7 +396,7 @@ fn member_message(member: &Member) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn allow_transparent(field: &Field, derive: Derive) -> bool {
|
fn allow_transparent(field: &Field, derive: Derive) -> bool {
|
||||||
if let Type::Path(ty) = field.ty {
|
if let Type::Path(ty) = ungroup(&field.ty) {
|
||||||
if let Some(seg) = ty.path.segments.last() {
|
if let Some(seg) = ty.path.segments.last() {
|
||||||
if seg.ident == "PhantomData" {
|
if seg.ident == "PhantomData" {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -8,8 +8,17 @@ mod case;
|
|||||||
mod check;
|
mod check;
|
||||||
mod symbol;
|
mod symbol;
|
||||||
|
|
||||||
|
use syn::Type;
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub enum Derive {
|
pub enum Derive {
|
||||||
Serialize,
|
Serialize,
|
||||||
Deserialize,
|
Deserialize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn ungroup(mut ty: &Type) -> &Type {
|
||||||
|
while let Type::Group(group) = ty {
|
||||||
|
ty = &group.elem;
|
||||||
|
}
|
||||||
|
ty
|
||||||
|
}
|
||||||
|
|||||||
+28
-36
@@ -13,46 +13,38 @@
|
|||||||
//!
|
//!
|
||||||
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.106")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.111")]
|
||||||
#![allow(unknown_lints, bare_trait_objects)]
|
#![allow(unknown_lints, bare_trait_objects)]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![deny(clippy::all, clippy::pedantic)]
|
||||||
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
#![cfg_attr(
|
#![allow(
|
||||||
feature = "cargo-clippy",
|
clippy::cognitive_complexity,
|
||||||
allow(
|
clippy::enum_variant_names,
|
||||||
cognitive_complexity,
|
clippy::needless_pass_by_value,
|
||||||
enum_variant_names,
|
clippy::too_many_arguments,
|
||||||
needless_pass_by_value,
|
clippy::trivially_copy_pass_by_ref,
|
||||||
redundant_field_names,
|
clippy::used_underscore_binding,
|
||||||
too_many_arguments,
|
clippy::wildcard_in_or_patterns
|
||||||
trivially_copy_pass_by_ref,
|
|
||||||
used_underscore_binding,
|
|
||||||
wildcard_in_or_patterns,
|
|
||||||
)
|
|
||||||
)]
|
)]
|
||||||
// Ignored clippy_pedantic lints
|
// Ignored clippy_pedantic lints
|
||||||
#![cfg_attr(
|
#![allow(
|
||||||
feature = "cargo-clippy",
|
clippy::cast_possible_truncation,
|
||||||
allow(
|
clippy::checked_conversions,
|
||||||
cast_possible_truncation,
|
clippy::doc_markdown,
|
||||||
checked_conversions,
|
clippy::enum_glob_use,
|
||||||
doc_markdown,
|
clippy::filter_map,
|
||||||
enum_glob_use,
|
clippy::indexing_slicing,
|
||||||
filter_map,
|
clippy::items_after_statements,
|
||||||
indexing_slicing,
|
clippy::match_same_arms,
|
||||||
items_after_statements,
|
clippy::module_name_repetitions,
|
||||||
match_same_arms,
|
clippy::must_use_candidate,
|
||||||
module_name_repetitions,
|
clippy::similar_names,
|
||||||
must_use_candidate,
|
clippy::single_match_else,
|
||||||
similar_names,
|
clippy::struct_excessive_bools,
|
||||||
single_match_else,
|
clippy::too_many_lines,
|
||||||
struct_excessive_bools,
|
clippy::unseparated_literal_suffix,
|
||||||
too_many_lines,
|
clippy::use_self,
|
||||||
unseparated_literal_suffix,
|
clippy::wildcard_imports
|
||||||
use_self,
|
|
||||||
wildcard_imports,
|
|
||||||
)
|
|
||||||
)]
|
)]
|
||||||
// The `quote!` macro requires deep recursion.
|
// The `quote!` macro requires deep recursion.
|
||||||
#![recursion_limit = "512"]
|
#![recursion_limit = "512"]
|
||||||
|
|||||||
+28
-15
@@ -87,6 +87,9 @@ struct Parameters {
|
|||||||
|
|
||||||
/// Type has a `serde(remote = "...")` attribute.
|
/// Type has a `serde(remote = "...")` attribute.
|
||||||
is_remote: bool,
|
is_remote: bool,
|
||||||
|
|
||||||
|
/// Type has a repr(packed) attribute.
|
||||||
|
is_packed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parameters {
|
impl Parameters {
|
||||||
@@ -103,13 +106,16 @@ impl Parameters {
|
|||||||
None => cont.ident.clone().into(),
|
None => cont.ident.clone().into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let is_packed = cont.attrs.is_packed();
|
||||||
|
|
||||||
let generics = build_generics(cont);
|
let generics = build_generics(cont);
|
||||||
|
|
||||||
Parameters {
|
Parameters {
|
||||||
self_var: self_var,
|
self_var,
|
||||||
this: this,
|
this,
|
||||||
generics: generics,
|
generics,
|
||||||
is_remote: is_remote,
|
is_remote,
|
||||||
|
is_packed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,17 +544,17 @@ fn serialize_externally_tagged_variant(
|
|||||||
}
|
}
|
||||||
Style::Tuple => serialize_tuple_variant(
|
Style::Tuple => serialize_tuple_variant(
|
||||||
TupleVariant::ExternallyTagged {
|
TupleVariant::ExternallyTagged {
|
||||||
type_name: type_name,
|
type_name,
|
||||||
variant_index: variant_index,
|
variant_index,
|
||||||
variant_name: variant_name,
|
variant_name,
|
||||||
},
|
},
|
||||||
params,
|
params,
|
||||||
&variant.fields,
|
&variant.fields,
|
||||||
),
|
),
|
||||||
Style::Struct => serialize_struct_variant(
|
Style::Struct => serialize_struct_variant(
|
||||||
StructVariant::ExternallyTagged {
|
StructVariant::ExternallyTagged {
|
||||||
variant_index: variant_index,
|
variant_index,
|
||||||
variant_name: variant_name,
|
variant_name,
|
||||||
},
|
},
|
||||||
params,
|
params,
|
||||||
&variant.fields,
|
&variant.fields,
|
||||||
@@ -614,10 +620,7 @@ fn serialize_internally_tagged_variant(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Style::Struct => serialize_struct_variant(
|
Style::Struct => serialize_struct_variant(
|
||||||
StructVariant::InternallyTagged {
|
StructVariant::InternallyTagged { tag, variant_name },
|
||||||
tag: tag,
|
|
||||||
variant_name: variant_name,
|
|
||||||
},
|
|
||||||
params,
|
params,
|
||||||
&variant.fields,
|
&variant.fields,
|
||||||
&type_name,
|
&type_name,
|
||||||
@@ -1241,9 +1244,19 @@ fn mut_if(is_mut: bool) -> Option<TokenStream> {
|
|||||||
fn get_member(params: &Parameters, field: &Field, member: &Member) -> TokenStream {
|
fn get_member(params: &Parameters, field: &Field, member: &Member) -> TokenStream {
|
||||||
let self_var = ¶ms.self_var;
|
let self_var = ¶ms.self_var;
|
||||||
match (params.is_remote, field.attrs.getter()) {
|
match (params.is_remote, field.attrs.getter()) {
|
||||||
(false, None) => quote!(&#self_var.#member),
|
(false, None) => {
|
||||||
|
if params.is_packed {
|
||||||
|
quote!(&{#self_var.#member})
|
||||||
|
} else {
|
||||||
|
quote!(&#self_var.#member)
|
||||||
|
}
|
||||||
|
}
|
||||||
(true, None) => {
|
(true, None) => {
|
||||||
let inner = quote!(&#self_var.#member);
|
let inner = if params.is_packed {
|
||||||
|
quote!(&{#self_var.#member})
|
||||||
|
} else {
|
||||||
|
quote!(&#self_var.#member)
|
||||||
|
};
|
||||||
let ty = field.ty;
|
let ty = field.ty;
|
||||||
quote!(_serde::private::ser::constrain::<#ty>(#inner))
|
quote!(_serde::private::ser::constrain::<#ty>(#inner))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,5 @@ proc-macro2 = "1.0"
|
|||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = { version = "1.0", default-features = false, features = ["derive", "parsing", "printing", "clone-impls"] }
|
syn = { version = "1.0", default-features = false, features = ["derive", "parsing", "printing", "clone-impls"] }
|
||||||
|
|
||||||
[badges]
|
|
||||||
travis-ci = { repository = "serde-rs/serde" }
|
|
||||||
appveyor = { repository = "serde-rs/serde" }
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_test"
|
name = "serde_test"
|
||||||
version = "1.0.106" # remember to update html_root_url
|
version = "1.0.111" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "Token De/Serializer for testing De/Serialize implementations"
|
description = "Token De/Serializer for testing De/Serialize implementations"
|
||||||
@@ -18,9 +18,5 @@ serde = { version = "1.0.60", path = "../serde" }
|
|||||||
serde = { version = "1.0", path = "../serde" }
|
serde = { version = "1.0", path = "../serde" }
|
||||||
serde_derive = { version = "1.0", path = "../serde_derive" }
|
serde_derive = { version = "1.0", path = "../serde_derive" }
|
||||||
|
|
||||||
[badges]
|
|
||||||
travis-ci = { repository = "serde-rs/serde" }
|
|
||||||
appveyor = { repository = "serde-rs/serde" }
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.106")]
|
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.111")]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
||||||
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
|
|||||||
@@ -7,16 +7,20 @@ publish = false
|
|||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
expandtest = []
|
||||||
unstable = ["serde/unstable"]
|
unstable = ["serde/unstable"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { path = "../serde" }
|
serde = { path = "../serde" }
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
toolchain_find = "0.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
fnv = "1.0"
|
fnv = "1.0"
|
||||||
rustversion = "0.1"
|
macrotest = "=1.0.0"
|
||||||
|
rustversion = "1.0"
|
||||||
serde = { path = "../serde", features = ["rc", "derive"] }
|
serde = { path = "../serde", features = ["rc", "derive"] }
|
||||||
serde_derive = { path = "../serde_derive", features = ["deserialize_in_place"] }
|
serde_derive = { path = "../serde_derive", features = ["deserialize_in_place"] }
|
||||||
serde_test = { path = "../serde_test" }
|
serde_test = { path = "../serde_test" }
|
||||||
trybuild = "1.0"
|
trybuild = "1.0"
|
||||||
macrotest = "0.1"
|
|
||||||
|
|||||||
+16
-9
@@ -1,13 +1,13 @@
|
|||||||
use std::process::{Command, ExitStatus, Stdio};
|
use std::process::{Command, ExitStatus, Stdio};
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
fn has_cargo_expand() -> bool {
|
||||||
const CARGO_EXPAND: &str = "cargo-expand";
|
let cargo_expand = if cfg!(windows) {
|
||||||
|
"cargo-expand.exe"
|
||||||
|
} else {
|
||||||
|
"cargo-expand"
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(windows)]
|
Command::new(cargo_expand)
|
||||||
const CARGO_EXPAND: &str = "cargo-expand.exe";
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
if Command::new(CARGO_EXPAND)
|
|
||||||
.arg("--version")
|
.arg("--version")
|
||||||
.stdin(Stdio::null())
|
.stdin(Stdio::null())
|
||||||
.stdout(Stdio::null())
|
.stdout(Stdio::null())
|
||||||
@@ -16,7 +16,14 @@ fn main() {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map(ExitStatus::success)
|
.map(ExitStatus::success)
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
{
|
}
|
||||||
println!("cargo:rustc-cfg=cargo_expand");
|
|
||||||
|
fn has_rustfmt() -> bool {
|
||||||
|
toolchain_find::find_installed_component("rustfmt").is_some()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
if cfg!(feature = "expandtest") && has_cargo_expand() && has_rustfmt() {
|
||||||
|
println!("cargo:rustc-cfg=expandtest");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ enum DeEnum<B, C, D> {
|
|||||||
_Seq2(i8, B, C, D),
|
_Seq2(i8, B, C, D),
|
||||||
_Map2 { a: i8, b: B, c: C, d: D },
|
_Map2 { a: i8, b: B, c: C, d: D },
|
||||||
}
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_DeEnum: () = {
|
const _IMPL_SERIALIZE_FOR_DeEnum: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<B, C, D> _serde::Serialize for DeEnum<B, C, D>
|
impl<B, C, D> _serde::Serialize for DeEnum<B, C, D>
|
||||||
@@ -259,10 +259,10 @@ const _IMPL_SERIALIZE_FOR_DeEnum: () = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_DeEnum: () = {
|
const _IMPL_DESERIALIZE_FOR_DeEnum: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'de, B, C, D> _serde::Deserialize<'de> for DeEnum<B, C, D>
|
impl<'de, B, C, D> _serde::Deserialize<'de> for DeEnum<B, C, D>
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ impl AssociatedType for i32 {
|
|||||||
struct DefaultTyParam<T: AssociatedType<X = i32> = i32> {
|
struct DefaultTyParam<T: AssociatedType<X = i32> = i32> {
|
||||||
phantom: PhantomData<T>,
|
phantom: PhantomData<T>,
|
||||||
}
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_DefaultTyParam: () = {
|
const _IMPL_SERIALIZE_FOR_DefaultTyParam: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<T: AssociatedType<X = i32>> _serde::Serialize for DefaultTyParam<T> {
|
impl<T: AssociatedType<X = i32>> _serde::Serialize for DefaultTyParam<T> {
|
||||||
@@ -43,10 +43,10 @@ const _IMPL_SERIALIZE_FOR_DefaultTyParam: () = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_DefaultTyParam: () = {
|
const _IMPL_DESERIALIZE_FOR_DefaultTyParam: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'de, T: AssociatedType<X = i32>> _serde::Deserialize<'de> for DefaultTyParam<T> {
|
impl<'de, T: AssociatedType<X = i32>> _serde::Deserialize<'de> for DefaultTyParam<T> {
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ pub enum GenericEnum<T, U> {
|
|||||||
Seq(T, U),
|
Seq(T, U),
|
||||||
Map { x: T, y: U },
|
Map { x: T, y: U },
|
||||||
}
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_GenericEnum: () = {
|
const _IMPL_SERIALIZE_FOR_GenericEnum: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<T, U> _serde::Serialize for GenericEnum<T, U>
|
impl<T, U> _serde::Serialize for GenericEnum<T, U>
|
||||||
@@ -108,10 +108,10 @@ const _IMPL_SERIALIZE_FOR_GenericEnum: () = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_GenericEnum: () = {
|
const _IMPL_DESERIALIZE_FOR_GenericEnum: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'de, T, U> _serde::Deserialize<'de> for GenericEnum<T, U>
|
impl<'de, T, U> _serde::Deserialize<'de> for GenericEnum<T, U>
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ use serde::{Deserialize, Serialize};
|
|||||||
pub struct GenericStruct<T> {
|
pub struct GenericStruct<T> {
|
||||||
x: T,
|
x: T,
|
||||||
}
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_GenericStruct: () = {
|
const _IMPL_SERIALIZE_FOR_GenericStruct: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<T> _serde::Serialize for GenericStruct<T>
|
impl<T> _serde::Serialize for GenericStruct<T>
|
||||||
@@ -36,10 +36,10 @@ const _IMPL_SERIALIZE_FOR_GenericStruct: () = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_GenericStruct: () = {
|
const _IMPL_DESERIALIZE_FOR_GenericStruct: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'de, T> _serde::Deserialize<'de> for GenericStruct<T>
|
impl<'de, T> _serde::Deserialize<'de> for GenericStruct<T>
|
||||||
@@ -398,10 +398,10 @@ const _IMPL_DESERIALIZE_FOR_GenericStruct: () = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
pub struct GenericNewTypeStruct<T>(T);
|
pub struct GenericNewTypeStruct<T>(T);
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_GenericNewTypeStruct: () = {
|
const _IMPL_SERIALIZE_FOR_GenericNewTypeStruct: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<T> _serde::Serialize for GenericNewTypeStruct<T>
|
impl<T> _serde::Serialize for GenericNewTypeStruct<T>
|
||||||
@@ -420,10 +420,10 @@ const _IMPL_SERIALIZE_FOR_GenericNewTypeStruct: () = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_GenericNewTypeStruct: () = {
|
const _IMPL_DESERIALIZE_FOR_GenericNewTypeStruct: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'de, T> _serde::Deserialize<'de> for GenericNewTypeStruct<T>
|
impl<'de, T> _serde::Deserialize<'de> for GenericNewTypeStruct<T>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
pub struct GenericTupleStruct<T, U>(T, U);
|
pub struct GenericTupleStruct<T, U>(T, U);
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_GenericTupleStruct: () = {
|
const _IMPL_DESERIALIZE_FOR_GenericTupleStruct: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'de, T, U> _serde::Deserialize<'de> for GenericTupleStruct<T, U>
|
impl<'de, T, U> _serde::Deserialize<'de> for GenericTupleStruct<T, U>
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ enum Lifetimes<'a> {
|
|||||||
LifetimeMap { a: &'a i32 },
|
LifetimeMap { a: &'a i32 },
|
||||||
NoLifetimeMap { a: i32 },
|
NoLifetimeMap { a: i32 },
|
||||||
}
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_Lifetimes: () = {
|
const _IMPL_SERIALIZE_FOR_Lifetimes: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'a> _serde::Serialize for Lifetimes<'a> {
|
impl<'a> _serde::Serialize for Lifetimes<'a> {
|
||||||
@@ -89,10 +89,10 @@ const _IMPL_SERIALIZE_FOR_Lifetimes: () = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_Lifetimes: () = {
|
const _IMPL_DESERIALIZE_FOR_Lifetimes: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'de, 'a> _serde::Deserialize<'de> for Lifetimes<'a> {
|
impl<'de, 'a> _serde::Deserialize<'de> for Lifetimes<'a> {
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ struct SerNamedMap<'a, 'b, A: 'a, B: 'b, C> {
|
|||||||
b: &'b mut B,
|
b: &'b mut B,
|
||||||
c: C,
|
c: C,
|
||||||
}
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_SerNamedMap: () = {
|
const _IMPL_SERIALIZE_FOR_SerNamedMap: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'a, 'b, A: 'a, B: 'b, C> _serde::Serialize for SerNamedMap<'a, 'b, A, B, C>
|
impl<'a, 'b, A: 'a, B: 'b, C> _serde::Serialize for SerNamedMap<'a, 'b, A, B, C>
|
||||||
@@ -57,10 +57,10 @@ struct DeNamedMap<A, B, C> {
|
|||||||
b: B,
|
b: B,
|
||||||
c: C,
|
c: C,
|
||||||
}
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_DeNamedMap: () = {
|
const _IMPL_DESERIALIZE_FOR_DeNamedMap: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'de, A, B, C> _serde::Deserialize<'de> for DeNamedMap<A, B, C>
|
impl<'de, A, B, C> _serde::Deserialize<'de> for DeNamedMap<A, B, C>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
struct SerNamedTuple<'a, 'b, A: 'a, B: 'b, C>(&'a A, &'b mut B, C);
|
struct SerNamedTuple<'a, 'b, A: 'a, B: 'b, C>(&'a A, &'b mut B, C);
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_SerNamedTuple: () = {
|
const _IMPL_SERIALIZE_FOR_SerNamedTuple: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'a, 'b, A: 'a, B: 'b, C> _serde::Serialize for SerNamedTuple<'a, 'b, A, B, C>
|
impl<'a, 'b, A: 'a, B: 'b, C> _serde::Serialize for SerNamedTuple<'a, 'b, A, B, C>
|
||||||
@@ -49,10 +49,10 @@ const _IMPL_SERIALIZE_FOR_SerNamedTuple: () = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct DeNamedTuple<A, B, C>(A, B, C);
|
struct DeNamedTuple<A, B, C>(A, B, C);
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_DeNamedTuple: () = {
|
const _IMPL_DESERIALIZE_FOR_DeNamedTuple: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'de, A, B, C> _serde::Deserialize<'de> for DeNamedTuple<A, B, C>
|
impl<'de, A, B, C> _serde::Deserialize<'de> for DeNamedTuple<A, B, C>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
struct NamedUnit;
|
struct NamedUnit;
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_NamedUnit: () = {
|
const _IMPL_SERIALIZE_FOR_NamedUnit: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl _serde::Serialize for NamedUnit {
|
impl _serde::Serialize for NamedUnit {
|
||||||
@@ -15,10 +15,10 @@ const _IMPL_SERIALIZE_FOR_NamedUnit: () = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_NamedUnit: () = {
|
const _IMPL_DESERIALIZE_FOR_NamedUnit: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'de> _serde::Deserialize<'de> for NamedUnit {
|
impl<'de> _serde::Deserialize<'de> for NamedUnit {
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ where
|
|||||||
_Seq2(i8, B, &'a C, &'a mut D),
|
_Seq2(i8, B, &'a C, &'a mut D),
|
||||||
_Map2 { a: i8, b: B, c: &'a C, d: &'a mut D },
|
_Map2 { a: i8, b: B, c: &'a C, d: &'a mut D },
|
||||||
}
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_SerEnum: () = {
|
const _IMPL_SERIALIZE_FOR_SerEnum: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'a, B: 'a, C: 'a, D> _serde::Serialize for SerEnum<'a, B, C, D>
|
impl<'a, B: 'a, C: 'a, D> _serde::Serialize for SerEnum<'a, B, C, D>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
enum Void {}
|
enum Void {}
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_Void: () = {
|
const _IMPL_SERIALIZE_FOR_Void: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl _serde::Serialize for Void {
|
impl _serde::Serialize for Void {
|
||||||
@@ -15,10 +15,10 @@ const _IMPL_SERIALIZE_FOR_Void: () = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_Void: () = {
|
const _IMPL_DESERIALIZE_FOR_Void: () = {
|
||||||
#[allow(unknown_lints)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
#[allow(rust_2018_idioms)]
|
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl<'de> _serde::Deserialize<'de> for Void {
|
impl<'de> _serde::Deserialize<'de> for Void {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(target_os = "emscripten", ignore)]
|
||||||
#[cfg_attr(not(cargo_expand), ignore)]
|
#[cfg_attr(not(expandtest), ignore)]
|
||||||
#[rustversion::attr(not(nightly), ignore)]
|
#[rustversion::attr(not(nightly), ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
fn expandtest() {
|
fn expandtest() {
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ fn test_gen() {
|
|||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
struct NonAsciiIdents {
|
struct NonAsciiIdents {
|
||||||
σ: f64,
|
σ: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
@@ -691,6 +691,34 @@ fn test_gen() {
|
|||||||
#[serde(flatten, skip_deserializing)]
|
#[serde(flatten, skip_deserializing)]
|
||||||
flat: T,
|
flat: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/serde-rs/serde/issues/1804
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
enum Message {
|
||||||
|
#[serde(skip)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
String(String),
|
||||||
|
#[serde(other)]
|
||||||
|
Unknown,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
#[repr(packed)]
|
||||||
|
struct Packed {
|
||||||
|
x: u8,
|
||||||
|
y: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! deriving {
|
||||||
|
($field:ty) => {
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct MacroRules<'a> {
|
||||||
|
field: $field,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
deriving!(&'a str);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -1145,6 +1145,20 @@ fn test_adjacently_tagged_enum() {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// optional newtype with no content field
|
||||||
|
assert_de_tokens(
|
||||||
|
&AdjacentlyTagged::Newtype::<Option<u8>>(None),
|
||||||
|
&[
|
||||||
|
Token::Struct {
|
||||||
|
name: "AdjacentlyTagged",
|
||||||
|
len: 1,
|
||||||
|
},
|
||||||
|
Token::Str("t"),
|
||||||
|
Token::Str("Newtype"),
|
||||||
|
Token::StructEnd,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
// tuple with tag first
|
// tuple with tag first
|
||||||
assert_tokens(
|
assert_tokens(
|
||||||
&AdjacentlyTagged::Tuple::<u8>(1, 1),
|
&AdjacentlyTagged::Tuple::<u8>(1, 1),
|
||||||
|
|||||||
Reference in New Issue
Block a user