Commit Graph

3110 Commits

Author SHA1 Message Date
David Tolnay
fa6712d2bf
Merge pull request #1918 from Mingun/fix-serde-test
Fix incorrect message in serializer tokens and correctly implement next_entry_seed
2021-01-23 15:02:32 -08:00
David Tolnay
012ea8eb84
Keep conditional compilation cfg naming consistent with serde crate
The serde crate's build.rs uses names like `core_duration` or
`integer128`, not `has_core_duration` / `has_integer128`.
2021-01-23 14:57:12 -08:00
David Tolnay
9add5812e2
Update track_caller cfg link to show what version it's in 2021-01-23 14:56:03 -08:00
David Tolnay
5fd52100b6
Merge pull request #1920 from Mingun/track_caller
Show correct location in error messages by tracking caller of utility `assert_tokens` functions
2021-01-23 14:54:24 -08:00
David Tolnay
6670a309ca
Merge pull request #1961 from serde-rs/renamerule
Provide list of recognized rename rules on parse error
2021-01-23 14:50:02 -08:00
David Tolnay
b7bad3a165
Restore compatibility with rustc 1.31 in RenameRule error
str::escape_debug wasn't stabilized until 1.34, whereas serde_derive
currently supports an oldest version of 1.31.
2021-01-23 14:40:44 -08:00
David Tolnay
4e002ece07
Provide list of recognized rename rules on parse error 2021-01-23 14:38:20 -08:00
David Tolnay
eaccae2c46
Fix UPPERCASE rename rule variant to follow idiomatic variant naming
This shouldn't have been named this way in PR #1132.
2021-01-23 14:27:33 -08:00
David Tolnay
990a502c39
Parse rename rules based on table of rules
This will make it possible to reuse the same table of recognized rules
in the parse error message.
2021-01-23 14:24:21 -08:00
David Tolnay
661206d885
Merge pull request #1960 from serde-rs/renamerule
Deduplicate RenameRule parse error message generation
2021-01-23 14:23:09 -08:00
David Tolnay
51d4563ed1
Move RenameRule parse error message to a Display impl 2021-01-23 14:13:47 -08:00
David Tolnay
7db0982e58
Add error type to use for RenameRule parsing 2021-01-23 14:09:58 -08:00
David Tolnay
ed04824f10
Move RenameRule parse from trait fn to associated
This will allow updating it to return an Err that borrows the input
string, which is not possible with FromStr.
2021-01-23 14:07:59 -08:00
David Tolnay
88ee470a1c
Format PR #1916 with rustfmt 1.4.32 2021-01-23 13:39:12 -08:00
David Tolnay
a5ecbdb4f4
Merge pull request 1916 from Mingun/expecting-customize 2021-01-23 13:38:45 -08:00
David Tolnay
bd588db067
Release 1.0.121 2021-01-23 13:17:08 -08:00
David Tolnay
8f09aeacdd
Merge pull request #1959 from serde-rs/1917
Touch up borrowed field identifiers PR
2021-01-23 13:15:30 -08:00
David Tolnay
0b5c56b0db
Touch up documentation from PR #1917 2021-01-23 13:09:37 -08:00
David Tolnay
85de92e6f7
Inline forward_deserializer for bytes deserializers 2021-01-23 13:08:08 -08:00
David Tolnay
c858a1fa77
Clean up unnecessary macro_use from PR #1917 2021-01-23 12:59:12 -08:00
David Tolnay
d02eb22557
Inline some unnecessary constructor functions from PR #1917 2021-01-23 12:58:42 -08:00
David Tolnay
034fe25d5b
Remove redundant unused trait impls from private types from PR #1917 2021-01-23 12:58:42 -08:00
David Tolnay
0a230e8598
Inline forward_deserializer into private::de for Str deserializers
We shouldn't try to use the same macro for public and private types. The
API for a private type can usually be pared much further down to save
compile time, such as Debug and Copy and Clone impls.
2021-01-23 12:57:35 -08:00
David Tolnay
b20214d4a0
Undo macro exports from PR #1917
All of these macros are only used internally within the serde crate.
There is no need for them to have #[macro_export] and need to be hidden
from docs.
2021-01-23 12:40:01 -08:00
David Tolnay
34f4b68f77
Fix unneeded clone from PR #1917 2021-01-23 12:40:00 -08:00
David Tolnay
60e08f9545
Format PR #1917 with rustfmt 1.4.32 2021-01-23 12:39:59 -08:00
David Tolnay
ba46f45dc5
Merge pull request 1917 from Mingun/borrow-identifier 2021-01-23 12:39:28 -08:00
David Tolnay
44b9567e21
Merge pull request #1958 from jonasbb/duration-panic
Prevent panic when deserializing malformed Duration
2021-01-23 00:45:39 -08:00
Jonas Bushart
b276849ce1 Prevent panic when deserializing malformed Duration
std::time::Duration::new can panic. There is no alternative non-panicing constructor.
Check the panic condition beforehand and return an error instead of panicing.

Fixes #1933
2021-01-20 20:41:45 +01:00
David Tolnay
398fba9b1e
Release 1.0.120 2021-01-18 22:55:13 -08:00
David Tolnay
cd6697b0e4
Merge pull request #1955 from TheJokr/patch-1
Add 128-bit integer support to de::IgnoredAny
2021-01-18 22:54:43 -08:00
Leo Blöcher
c162d51866
Add 128-bit integer support to de::IgnoredAny
This fixes the errors that occur when IgnoredAny is deserialized
from anything containing a 128-bit integer somewhere. As IgnoredAny
is used in serde_derive to skip ignored fields in structs, these
errors currently prevent parsing of structs with an ignored field
containing a 128-bit integer in the serialization.
2021-01-19 02:32:26 +01:00
David Tolnay
78a9dbc57e
Merge pull request #1948 from Marwes/from_str
refactor: Merge multiple FromStr visitors to a single FromStrVisitor
2021-01-12 13:12:54 -08:00
David Tolnay
391d3ababf
Touch up PR 1948 2021-01-12 13:08:50 -08:00
Markus Westerlind
99d9151ce9 refactor: Merge multiple FromStr visitors to a single FromStrVisitor
Only refactors, doesn't actually expose this visitor
2021-01-12 11:32:16 +01:00
David Tolnay
4c89cf89fd
Release 1.0.119 2021-01-11 12:13:57 -08:00
David Tolnay
b0c99ed761
Restore compatibility with rustc 1.13.0
error[E0432]: unresolved import `private:🇩🇪:size_hint`
      --> src/de/value.rs:28:5
       |
    28 | use private:🇩🇪:size_hint;
       |     ^^^^^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate private`?
2021-01-08 20:01:30 -08:00
David Tolnay
dd1f4b483e
Make it clearer that the private implementation details are private
Both of these modules are doc(hidden) and commented "Not public API",
but incorrect downstream code sometimes still references them. Naming
the module __private will make it more likely to be noticed in code
review.
2021-01-08 19:55:31 -08:00
David Tolnay
91bfa8f947
Refresh expandtest files with most recent rustfmt 2021-01-08 19:54:21 -08:00
David Tolnay
8847800ce2
Ignore from_over_into clippy lint in test suite 2021-01-03 19:05:43 -08:00
David Tolnay
3c9fa1ccdf
Switch to short form for serde.rs link in rustdoc
Fixes a rustdoc warning:

    warning: unneeded long form for URL
      --> serde/src/lib.rs:12:27
       |
    12 | //! See the Serde website [https://serde.rs/] for additional documentation and
       |                           ^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://serde.rs/>`
       |
       = note: `#[warn(non_autolinks)]` on by default
2020-12-21 10:35:28 -08:00
David Tolnay
3c29a8857f
Merge pull request #1936 from bryanburgers/add-serde-dynamo
Add serde_dynamo to the list of data formats
2020-12-21 10:33:45 -08:00
Bryan Burgers
a5da27e16d Add serde_dynamo to the list of data formats 2020-12-21 10:51:56 -06:00
David Tolnay
e797431268
Release 1.0.118 2020-12-05 13:45:47 -08:00
David Tolnay
4a335f8933
Merge pull request #1926 from attente/core-num-wrapping
Allow serializing of Wrapping without std
2020-12-05 13:43:20 -08:00
David Tolnay
84721920fd
Resolve clippy items_after_statements lint
error: adding items after statements is confusing, since items exist from the start of the scope
        --> serde/src/de/impls.rs:1876:9
         |
    1876 | /         impl<'de> Deserialize<'de> for Field {
    1877 | |             fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    1878 | |             where
    1879 | |                 D: Deserializer<'de>,
    ...    |
    1917 | |             }
    1918 | |         }
         | |_________^
         |
    note: the lint level is defined here
        --> serde/src/lib.rs:95:52
         |
    95   | #![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
         |                                                    ^^^^^^^^^^^^^^^
         = note: `#[deny(clippy::items_after_statements)]` implied by `#[deny(clippy::pedantic)]`
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements

    error: adding items after statements is confusing, since items exist from the start of the scope
        --> serde/src/de/impls.rs:1920:9
         |
    1920 |         struct DurationVisitor;
         |         ^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements

    error: adding items after statements is confusing, since items exist from the start of the scope
        --> serde/src/de/impls.rs:1922:9
         |
    1922 | /         impl<'de> Visitor<'de> for DurationVisitor {
    1923 | |             type Value = Duration;
    1924 | |
    1925 | |             fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
    ...    |
    1979 | |             }
    1980 | |         }
         | |_________^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements

    error: adding items after statements is confusing, since items exist from the start of the scope
        --> serde/src/de/impls.rs:1982:9
         |
    1982 |         const FIELDS: &'static [&'static str] = &["secs", "nanos"];
         |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements

    error: adding items after statements is confusing, since items exist from the start of the scope
        --> serde/src/de/impls.rs:2001:9
         |
    2001 | /         impl<'de> Deserialize<'de> for Field {
    2002 | |             fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    2003 | |             where
    2004 | |                 D: Deserializer<'de>,
    ...    |
    2042 | |             }
    2043 | |         }
         | |_________^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements

    error: adding items after statements is confusing, since items exist from the start of the scope
        --> serde/src/de/impls.rs:2045:9
         |
    2045 |         struct DurationVisitor;
         |         ^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements

    error: adding items after statements is confusing, since items exist from the start of the scope
        --> serde/src/de/impls.rs:2047:9
         |
    2047 | /         impl<'de> Visitor<'de> for DurationVisitor {
    2048 | |             type Value = Duration;
    2049 | |
    2050 | |             fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
    ...    |
    2108 | |             }
    2109 | |         }
         | |_________^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements

    error: adding items after statements is confusing, since items exist from the start of the scope
        --> serde/src/de/impls.rs:2111:9
         |
    2111 |         const FIELDS: &'static [&'static str] = &["secs_since_epoch", "nanos_since_epoch"];
         |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
2020-11-28 19:08:41 -08:00
David Tolnay
192c7819ee
Format with rustfmt 1.4.25-beta 2020-11-28 19:06:37 -08:00
William Hua
ede40bdfaa Allow serializing of Wrapping without std 2020-11-24 00:56:10 -05:00
David Tolnay
e3d871ff7b
Opt in to experimental trybuild diffs 2020-10-31 13:28:19 -07:00
Mingun
5cbc8439ea Show correct location in error messages by tracking caller of utility assert_tokens functions 2020-10-28 09:11:54 +05:00