Commit Graph

624 Commits

Author SHA1 Message Date
David Tolnay
c261015325
Ignore incorrect suggestion from manual_map lint
https://github.com/rust-lang/rust-clippy/issues/6797

    error[E0382]: use of partially moved value: `self`
       --> serde_derive/src/internals/attr.rs:71:24
        |
    71  |         self.value.map(|value| (self.tokens, value))
        |                    ----^^^^^^^----------------------
        |                    |   |        |
        |                    |   |        use occurs due to use in closure
        |                    |   value used here after partial move
        |                    `self.value` partially moved due to this method call
        |
    note: this function takes ownership of the receiver `self`, which moves `self.value`
       --> /home/david/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:485:38
        |
    485 |     pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Option<U> {
        |                                      ^^^^
        = note: partial move occurs because `self.value` has type `std::option::Option<T>`, which does not implement the `Copy` trait
2021-02-25 20:53:45 -08:00
David Tolnay
6b5e5a83d0
Ignore let_underscore_drop pedantic clippy lint 2021-02-18 19:31:39 -08:00
David Tolnay
3d6c4149b1
Release 1.0.123 2021-01-25 13:43:11 -08:00
David Tolnay
2ba97394fb
Substitute Self in output of Serialize derive 2021-01-25 13:34:09 -08:00
David Tolnay
e5efb6ad93
Remove dependency on syn/visit-mut feature 2021-01-24 23:56:57 -08:00
David Tolnay
1f423580a5
Deduplicate token stream respanner 2021-01-24 23:06:08 -08:00
David Tolnay
033114a4ae
Touch up PR 1830 2021-01-24 23:06:07 -08:00
David Tolnay
7cec99c7fd
Pare down PR 1830
Unlike expr macros, macros in type position in a derive input are rare
enough that it's not worth supporting for an issue that has such an easy
workaround (just replace `Self` in the macro input with your type name).
2021-01-24 23:06:06 -08:00
David Tolnay
6c5bf701be
Merge pull request 1830 from taiki-e/self 2021-01-24 23:05:51 -08:00
David Tolnay
6e800ff826
Test exhaustiveness of type match in collect_lifetimes 2021-01-24 23:04:01 -08:00
David Tolnay
aeee73fe92
Merge pull request #1831 from taiki-e/borrow-macro
Collect lifetimes inside macro invocations
2021-01-24 19:08:20 -08:00
David Tolnay
ffed19243d
Release 1.0.122 2021-01-24 16:17:29 -08:00
David Tolnay
6ea446fb4b
Suppress clippy unused_self pedantic lint
This usage is fine. It's mirroring trait signatures in syn::visit::Visit.

    error: unused `self` argument
       --> serde_derive/src/bound.rs:241:24
        |
    241 |         fn visit_macro(&mut self, _mac: &'ast syn::Macro) {}
        |                        ^^^^^^^^^
        |
    note: the lint level is defined here
       --> serde_derive/src/lib.rs:18:22
        |
    18  | #![deny(clippy::all, clippy::pedantic)]
        |                      ^^^^^^^^^^^^^^^^
        = note: `#[deny(clippy::unused_self)]` implied by `#[deny(clippy::pedantic)]`
        = help: consider refactoring to a associated function
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_self
2021-01-24 16:01:05 -08:00
David Tolnay
85c6904a93
Remove dependency on syn/visit feature
The builtin visitor is fairly expensive to compile (3700 lines of code),
particularly if something else in the dependency graph also enables
syn/full. For the usage in serde_derive, it turns out to be easy to
replace.
2021-01-24 15:50:41 -08:00
Taiki Endo
e81f54fbc8 Make AST borrow checker happy 2021-01-24 15:23:54 +09:00
Taiki Endo
c67017d466 Fix handling of Self keyword in type definition 2021-01-24 15:23:51 +09:00
David Tolnay
e24dbc418d
Skip another clone of the fallthrough arm 2021-01-23 20:52:03 -08:00
David Tolnay
3728d3c67a
Eliminate duplicated borrowed and non-borrowed identifier deserialization 2021-01-23 20:32:38 -08:00
David Tolnay
b6a2d07f26
Return IdentifierDeserializer to just one associated type
The BorrowedDeserializer was added in #1917, but only makes sense for
&str and &[u8], not for u64 which also needs to be have an
IdentifierDeserializer impl.
2021-01-23 20:04:58 -08:00
David Tolnay
e6b6602a42
Merge pull request 1914 from Mingun/seq-other 2021-01-23 19:50:39 -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
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
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
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
398fba9b1e
Release 1.0.120 2021-01-18 22:55:13 -08:00
David Tolnay
4c89cf89fd
Release 1.0.119 2021-01-11 12:13:57 -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
e797431268
Release 1.0.118 2020-12-05 13:45:47 -08:00
David Tolnay
0d5b6c180c
Resolve ptr_eq clippy lint
error: use `std::ptr::eq` when comparing raw pointers
       --> serde_derive/src/de.rs:362:12
        |
    362 |         if field as *const Field == transparent_field as *const Field {
        |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(field, transparent_field)`
        |
    note: the lint level is defined here
       --> serde_derive/src/lib.rs:18:9
        |
    18  | #![deny(clippy::all, clippy::pedantic)]
        |         ^^^^^^^^^^^
        = note: `#[deny(clippy::ptr_eq)]` implied by `#[deny(clippy::all)]`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_eq
2020-10-27 19:18:29 -07:00
Taiki Endo
a227a87865 Collect lifetimes inside macro invocations 2020-10-24 05:29:47 +09:00
Mingun
7a7a182ab6 Allow borrow for field identifiers 2020-10-23 19:03:18 +05:00
Mingun
104ad9a7dd Allow to define custom expectation message for type with #[serde(expecting = "...")]
Closes #1883
2020-10-23 01:23:01 +05:00
Mingun
0737474640 Allow field identifiers be any numbers if #[serde(other)] is used
Thus behavior synchronized between string/bytes identifiers and numeric identifiers
2020-10-22 16:35:28 +05:00
David Tolnay
fc3f104c4a
Release 1.0.117 2020-10-15 09:49:03 -07:00
David Tolnay
be7d0e7eb2
Ignore map_err_ignore Clippy pedantic lint 2020-09-25 21:55:59 -04:00
David Tolnay
b539cb45d7
Release 1.0.116 2020-09-11 11:56:19 -07:00
David Tolnay
2ef60b62ac
Release 1.0.115 2020-08-10 15:51:19 -07:00
David Tolnay
53b9871b17
Quote no longer requires high recursion 2020-07-16 10:49:16 -07:00
David Tolnay
f8787c3ca8
Suppress match_like_matches_macro clippy lint 2020-07-14 18:57:26 -07:00
David Tolnay
3022064f84
Suppress option_if_let_else clippy pedantic lint 2020-07-14 18:57:24 -07:00
David Tolnay
9c6f0c3a0e
Release 1.0.114 2020-06-21 17:31:02 -07:00
David Tolnay
a9f8ea0a1e
Simplify search for packed repr attr 2020-06-21 17:22:07 -07:00
Tanner Rogalsky
1cd10a7d09 Improved packed repr matching. 2020-06-21 16:46:27 -07:00
David Tolnay
7350b58f5c
Release 1.0.113 2020-06-19 13:31:38 -07:00
David Tolnay
7351e0e55a
Link to feature announcements where available 2020-06-19 13:30:14 -07:00
Taiki Endo
a50e1c20e9 Use underscore consts on Rust 1.37+ 2020-06-19 15:55:43 +09:00
David Tolnay
f3520e526b
Release 1.0.112 2020-06-14 11:16:04 -07:00
David Tolnay
95b1a5d3d9
Ignore unnested_or_patterns suggesting unstable code
Clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704
2020-06-10 19:41:16 -07:00
David Tolnay
0856a2c101
No need to specify Cargo.toml in package.include
Cargo.toml is always included in the published crate.
2020-06-10 01:21:19 -07:00
David Tolnay
9f331cc257
Release 1.0.111 2020-05-29 18:53:07 -07:00
David Tolnay
c45a809d5c
Look inside of None-delimited groups when examining types 2020-05-29 17:58:34 -07:00
David Tolnay
078b171c1b
Release 1.0.110 2020-05-09 23:06:56 -07:00
David Tolnay
da8d6f678e
Simplify finding of repr(packed) attributes 2020-05-09 23:02:49 -07:00
David Tolnay
548eb8f667
Format PR 1791 with rustfmt 2020-05-09 22:54:42 -07:00
David Tolnay
1fe39043ee
Simplify access of packed struct fields in derived Serialize impls 2020-05-09 22:53:38 -07:00
alvardes
9f47c47cad Add support for packed structs. 2020-05-09 22:45:44 -07:00
David Tolnay
dda070f45c
Fix borrow error on pre-NLL compilers
error[E0506]: cannot assign to `missing_content` because it is borrowed
        --> serde_derive/src/de.rs:1414:9
         |
    1388 |           .filter_map(|(i, variant)| {
         |                       -------------- borrow of `missing_content` occurs here
    ...
    1414 | /         missing_content = quote! {
    1415 | |             match __field {
    1416 | |                 #(#missing_content_arms)*
    1417 | |                 #missing_content_fallthrough
    1418 | |             }
    1419 | |         };
         | |_________^ assignment to borrowed `missing_content` occurs here

    error[E0502]: cannot borrow `missing_content_fallthrough` as immutable because it is also borrowed as mutable
        --> serde_derive/src/de.rs:1414:27
         |
    1388 |           .filter_map(|(i, variant)| {
         |                       -------------- mutable borrow occurs here
    ...
    1404 |                       missing_content_fallthrough = quote!(_ => #missing_content);
         |                       --------------------------- previous borrow occurs due to use of `missing_content_fallthrough` in closure
    ...
    1414 |           missing_content = quote! {
         |  ___________________________^
    1415 | |             match __field {
    1416 | |                 #(#missing_content_arms)*
    1417 | |                 #missing_content_fallthrough
    1418 | |             }
    1419 | |         };
         | |_________^ immutable borrow occurs here
    ...
    1622 |   }
         |   - mutable borrow ends here
         |
         = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
2020-05-09 22:37:31 -07:00
David Tolnay
b97a183e82
Release 1.0.109 2020-05-09 21:00:51 -07:00
David Tolnay
9433004307
Omit missing content match if not needed 2020-05-09 20:59:01 -07:00
David Tolnay
9476838264
Omit missing content fallthrough arm if not needed 2020-05-09 20:59:00 -07:00
asdsad
172edc4cf4
Allow optional content field for adjacently tagged newtype variants
* Deserialize adjacently tagged newtype variants with optional content as None instead of erroring when content field is missing

* refactor to remove duplicate code and remove panic
2020-05-09 20:58:28 -07:00
David Tolnay
ea2789df0f
Release 1.0.108 2020-05-09 17:53:23 -07:00
David Tolnay
f63acb52dc
Release 1.0.107 2020-05-08 15:45:36 -07:00
David Tolnay
63809e69c7
Fix indexing bug when skip and other are combined 2020-05-08 15:39:07 -07:00
David Tolnay
60522937af
Remove CI badge from Cargo.toml
Support for badges has been deprecated by crates.io.
2020-05-01 21:11:02 -07:00
David Tolnay
b6def5300a
Resolve redundant_field_names lint in serde_derive 2020-04-05 21:07:52 -07:00
David Tolnay
1b35c9e27e
Update serde_derive to tool attrs 2020-04-05 21:00:58 -07:00
David Tolnay
d1564525ad
Release 1.0.106 2020-04-03 14:26:42 -07:00
robo9k
a135199ab1 Hide generated dummy const in rustdoc 2020-04-03 22:21:38 +02:00
David Tolnay
69653a762d
Release 1.0.105 2020-03-18 11:42:51 -07:00
David Tolnay
078e88b223
Select a single docs.rs build target 2020-03-17 13:31:35 -07:00
David Tolnay
1894cb703f
Resolve clippy question_mark lint 2020-03-05 19:48:07 -08:00
David Tolnay
27c283ab53
Suppress wildcard import pedantic lints 2020-02-26 21:00:12 -08:00
David Tolnay
142955b109
Ignore struct_excessive_bools pedantic lint 2020-02-12 19:34:14 -08:00
David Tolnay
cb1632e957
Fix unused_parens lint
These are left over from a series of unfortunate rustfmt interactions.
ee75e6c0e9 (diff-c052b162f01a664f8184ef1855d1f1cfL767-R735)
cc2558b0dc (diff-c052b162f01a664f8184ef1855d1f1cfL733-R738)
9f38ca032e (diff-c052b162f01a664f8184ef1855d1f1cfL779-R782)
2020-01-25 00:05:15 -08:00
David Tolnay
dfa321a1dd
Ignore wildcard_in_or_patterns lint 2020-01-14 20:31:03 -08:00
David Tolnay
234fbfd7e3
Release 1.0.104 2019-12-15 20:01:04 -08:00
David Tolnay
d540e72fc7
Format with rustfmt 2019-10-07 2019-11-26 00:02:11 -08:00
David Tolnay
43a9f59c18
Release 1.0.103 2019-11-24 16:15:13 -08:00
David Tolnay
2ceabad360
Release 1.0.102 2019-10-27 13:39:27 -07:00
David Tolnay
5db72b8ad9
Ignore must_use_candidate pedantic lint 2019-10-17 11:05:28 -04:00
David Tolnay
d4d737de8d
Resolve redundant_clone lint 2019-10-08 21:16:45 -07:00
David Tolnay
4aba6fae78
Release 1.0.101 2019-09-16 00:32:28 -07:00
David Tolnay
fe06bc2f88
More concise explanation of allow(unused_variables) 2019-09-16 00:31:23 -07:00
David Tolnay
8dfb4cd02f
Merge pull request #1617 from arilotter/master
Fix unused variable warning when field of adjacently tagged enum is skipped
2019-09-15 23:51:39 -07:00
David Tolnay
d1ade37827
Ignore new too_many_lines lint 2019-09-10 23:15:59 -07:00
Ari Lotter
9de49241fb Bug fix for #1610
Allow unused variables in tuple in AdjacentlyTagged serializer
2019-09-09 10:43:05 -04:00
David Tolnay
b24d50160a
Remove use of ref keyword from serde_derive 2019-09-07 23:16:02 -07:00
David Tolnay
a3157c9572
Produce errors on attr that fails to parse as Meta 2019-09-07 22:46:50 -07:00
David Tolnay
0d4722680a
Use flatten() to iterate serde meta items 2019-09-07 22:44:25 -07:00
David Tolnay
7ab12597bb
Un-wrap error message strings for better grepping 2019-09-07 22:40:24 -07:00
David Tolnay
b86a46c83c
Factor skipping in newtype variants into effective_style 2019-09-07 22:16:56 -07:00