Commit Graph

3272 Commits

Author SHA1 Message Date
David Tolnay
e2f85681fe
Release 1.0.127 2021-07-30 20:59:13 -07:00
David Tolnay
8b840c3030
Resolve semicolon_in_expressions_from_macros warning in serde_test
warning: trailing semicolon in macro used in expression position
       --> serde_test/src/ser.rs:44:10
        |
    44  |         );
        |          ^
    ...
    152 |             Some(&Token::BorrowedStr(_)) => assert_next_token!(self, BorrowedStr(v)),
        |                                             ---------------------------------------- in this macro invocation
        |
        = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default
        = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
        = note: this warning originates in the macro `assert_next_token` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: trailing semicolon in macro used in expression position
       --> serde_test/src/ser.rs:36:76
        |
    36  |         assert_next_token!($ser, stringify!($actual), Token::$actual, true);
        |                                                                            ^
    ...
    386 |             Token::TupleVariantEnd => assert_next_token!(self.ser, TupleVariantEnd),
        |                                       --------------------------------------------- in this macro invocation
        |
        = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
        = note: this warning originates in the macro `assert_next_token` (in Nightly builds, run with -Z macro-backtrace for more info)
2021-07-30 20:58:07 -07:00
David Tolnay
9c39115f82
Ignore buggy nonstandard_macro_braces clippy lint
Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422

    error: use of irregular braces for `format_args!` macro
       --> test_suite/tests/test_gen.rs:528:25
        |
    528 |     #[derive(Serialize, Deserialize)]
        |                         ^^^^^^^^^^^
        |
        = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `Deserialize`
       --> test_suite/tests/test_gen.rs:528:25
        |
    528 |     #[derive(Serialize, Deserialize)]
        |                         ^^^^^^^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `format_args!` macro
        --> test_suite/tests/test_annotations.rs:1791:43
         |
    1791 |     #[derive(Debug, PartialEq, Serialize, Deserialize)]
         |                                           ^^^^^^^^^^^
         |
         = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `Deserialize`
        --> test_suite/tests/test_annotations.rs:1791:43
         |
    1791 |     #[derive(Debug, PartialEq, Serialize, Deserialize)]
         |                                           ^^^^^^^^^^^
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
         = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
2021-07-02 20:58:04 -07:00
David Tolnay
89342af71e
Merge pull request #2047 from jsoref/spelling
spelling: implicitly
2021-06-24 22:25:58 -07:00
Josh Soref
3c5e2d11f6 spelling: implicitly
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2021-06-25 00:43:23 -04:00
David Tolnay
3805c037a8
Merge pull request #2040 from dtolnay/test
Fix outdated test instructions in CONTRIBUTING.md
2021-06-12 13:43:30 -07:00
David Tolnay
7045fee260
Fix outdated test instructions in CONTRIBUTING.md 2021-06-12 13:38:40 -07:00
David Tolnay
9d81532e41
Merge pull request #2039 from dtolnay/test
Update documented test command for the serde directory
2021-06-12 13:38:34 -07:00
David Tolnay
5e47432ef0
Update documented test command for the serde directory 2021-06-12 13:34:45 -07:00
Mingun
e0fc46783d Add test with generic deserialize_with function 2021-06-12 18:47:08 +05:00
Mingun
ca772a14f9 Get rid of useless DeserializeWith wrapper 2021-06-12 18:38:03 +05:00
David Tolnay
7b840897a9
Resolve needless_borrow clippy lints
error: this expression borrows a reference (`&syn::Type`) that is immediately dereferenced by the compiler
       --> serde_derive/src/internals/check.rs:399:37
        |
    399 |     if let Type::Path(ty) = ungroup(&field.ty) {
        |                                     ^^^^^^^^^ help: change this to: `field.ty`
        |
    note: the lint level is defined here
       --> serde_derive/src/lib.rs:18:9
        |
    18  | #![deny(clippy::all, clippy::pedantic)]
        |         ^^^^^^^^^^^
        = note: `#[deny(clippy::needless_borrow)]` implied by `#[deny(clippy::all)]`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression borrows a reference (`&str`) that is immediately dereferenced by the compiler
       --> serde_derive/src/de.rs:478:52
        |
    478 |         &type_path, params, fields, false, cattrs, &expecting,
        |                                                    ^^^^^^^^^^ help: change this to: `expecting`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression borrows a reference (`&str`) that is immediately dereferenced by the compiler
       --> serde_derive/src/de.rs:564:76
        |
    564 |     let visit_seq = Stmts(deserialize_seq_in_place(params, fields, cattrs, &expecting));
        |                                                                            ^^^^^^^^^^ help: change this to: `expecting`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression borrows a reference (`&str`) that is immediately dereferenced by the compiler
       --> serde_derive/src/de.rs:925:51
        |
    925 |         &type_path, params, fields, true, cattrs, &expecting,
        |                                                   ^^^^^^^^^^ help: change this to: `expecting`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression borrows a reference (`&str`) that is immediately dereferenced by the compiler
        --> serde_derive/src/de.rs:1066:76
         |
    1066 |     let visit_seq = Stmts(deserialize_seq_in_place(params, fields, cattrs, &expecting));
         |                                                                            ^^^^^^^^^^ help: change this to: `expecting`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression borrows a reference (`&proc_macro2::TokenStream`) that is immediately dereferenced by the compiler
        --> serde_derive/src/de.rs:2288:80
         |
    2288 |         let fallthrough_borrowed_arm = fallthrough_borrowed.as_ref().unwrap_or(&fallthrough_arm);
         |                                                                                ^^^^^^^^^^^^^^^^ help: change this to: `fallthrough_arm`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression borrows a reference (`&syn::Member`) that is immediately dereferenced by the compiler
        --> serde_derive/src/ser.rs:1102:43
         |
    1102 |                 get_member(params, field, &member)
         |                                           ^^^^^^^ help: change this to: `member`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
2021-06-04 20:58:23 -07:00
David Tolnay
967795414b
Resolve semicolon_if_nothing_returned clippy lints
error: consider adding a `;` to the last statement for consistent formatting
       --> serde_derive/src/internals/attr.rs:559:25
        |
    559 |                         serde_path.set(&m.path, path)
        |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `serde_path.set(&m.path, path);`
        |
    note: the lint level is defined here
       --> serde_derive/src/lib.rs:18:22
        |
    18  | #![deny(clippy::all, clippy::pedantic)]
        |                      ^^^^^^^^^^^^^^^^
        = note: `#[deny(clippy::semicolon_if_nothing_returned)]` implied by `#[deny(clippy::pedantic)]`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned

    error: consider adding a `;` to the last statement for consistent formatting
        --> serde_derive/src/internals/attr.rs:1612:9
         |
    1612 |         cx.error_spanned_by(lit, format!("failed to parse path: {:?}", string.value()))
         |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `cx.error_spanned_by(lit, format!("failed to parse path: {:?}", string.value()));`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned

    error: consider adding a `;` to the last statement for consistent formatting
        --> serde_derive/src/internals/attr.rs:1623:9
         |
    1623 |         cx.error_spanned_by(lit, format!("failed to parse path: {:?}", string.value()))
         |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `cx.error_spanned_by(lit, format!("failed to parse path: {:?}", string.value()));`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned

    error: consider adding a `;` to the last statement for consistent formatting
        --> serde_derive/src/internals/attr.rs:1649:9
         |
    1649 | /         cx.error_spanned_by(
    1650 | |             lit,
    1651 | |             format!("failed to parse type: {} = {:?}", attr_name, string.value()),
    1652 | |         )
         | |_________^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
    help: add a `;` here
         |
    1649 |         cx.error_spanned_by(
    1650 |             lit,
    1651 |             format!("failed to parse type: {} = {:?}", attr_name, string.value()),
    1652 |         );
         |

    error: consider adding a `;` to the last statement for consistent formatting
       --> serde_derive/src/internals/check.rs:260:9
        |
    260 | /         cx.error_spanned_by(
    261 | |             cont.original,
    262 | |             format!("variant field name `{}` conflicts with internal tag", tag),
    263 | |         )
        | |_________^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
    help: add a `;` here
        |
    260 |         cx.error_spanned_by(
    261 |             cont.original,
    262 |             format!("variant field name `{}` conflicts with internal tag", tag),
    263 |         );
        |

    error: consider adding a `;` to the last statement for consistent formatting
        --> serde_derive/src/de.rs:2090:9
         |
    2090 |         flat_fields.extend(aliases.iter().map(|alias| (alias, ident)))
         |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `flat_fields.extend(aliases.iter().map(|alias| (alias, ident)));`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
2021-06-04 20:55:22 -07:00
David Tolnay
985725f820
Resolve while_let_on_iterator clippy lint
error: this loop could be written as a `for` loop
        --> serde/src/private/de.rs:2835:9
         |
    2835 |         while let Some(item) = self.iter.next() {
         |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for item in &mut self.iter`
         |
    note: the lint level is defined here
        --> serde/src/lib.rs:97:44
         |
    97   | #![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
         |                                            ^^^^^^
         = note: `#[deny(clippy::while_let_on_iterator)]` implied by `#[deny(clippy::all)]`
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator

    error: this loop could be written as a `for` loop
        --> serde/src/private/de.rs:2937:9
         |
    2937 |         while let Some(item) = self.iter.next() {
         |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for item in &mut self.iter`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator
2021-05-22 20:29:34 -07:00
David Tolnay
0c303d85d7
Merge pull request #2027 from striezel-stash/fix-typos
fix some typos
2021-05-15 10:14:13 -07:00
Dirk Stolle
f68e9e901e fix some typos 2021-05-15 16:18:05 +02:00
David Tolnay
1094e2d334
Update ui test suite to nightly-2021-05-14 2021-05-13 19:16:07 -07:00
David Tolnay
d9c338ec4a
Release 1.0.126 2021-05-12 10:18:26 -07:00
David Tolnay
699bf3a75d
Merge pull request #2026 from hyd-dev/warning
Allow only `unused_extern_crates` instead of the whole `rust_2018_idioms` lint group in `serde_derive`-generated code
2021-05-12 10:16:47 -07:00
hyd-dev
dd29825217
Allow only unused_extern_crates instead of the whole rust_2018_idioms lint group in serde_derive-generated code 2021-05-12 18:29:45 +08:00
David Tolnay
6366f17da7
Ignore clone_instead_of_copied pedantic clippy lint
Iterator::copied was introduced in Rust 1.35, whereas serde_test
currently supports a minimum compiler version of 1.13.

    error: used `cloned` where `copied` could be used instead
       --> serde_test/src/de.rs:49:29
        |
    49  |         self.tokens.first().cloned()
        |                             ^^^^^^ help: try: `copied`
        |
    note: the lint level is defined here
       --> serde_test/src/lib.rs:149:52
        |
    149 | #![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
        |                                                    ^^^^^^^^^^^^^^^
        = note: `#[deny(clippy::cloned_instead_of_copied)]` implied by `#[deny(clippy::pedantic)]`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied
2021-04-24 19:26:19 -07:00
David Tolnay
1120e5af4a
Remove suppression of removed clippy lint
warning: lint `clippy::filter_map` has been removed: this lint has been replaced by `manual_filter_map`, a more specific lint
      --> serde_derive/src/lib.rs:42:5
       |
    42 |     clippy::filter_map,
       |     ^^^^^^^^^^^^^^^^^^
       |
       = note: `#[warn(renamed_and_removed_lints)]` on by default

    warning: lint `clippy::filter_map` has been removed: this lint has been replaced by `manual_filter_map`, a more specific lint
      --> serde_derive/src/lib.rs:42:5
       |
    42 |     clippy::filter_map,
       |     ^^^^^^^^^^^^^^^^^^
2021-04-24 19:23:56 -07:00
David Tolnay
1093f7e232
Resolve flat_map_option pedantic clippy lint
error: used `flat_map` where `filter_map` could be used instead
      --> serde_derive/src/bound.rs:52:10
       |
    52 |         .flat_map(|field| from_field(&field.attrs))
       |          ^^^^^^^^ help: try: `filter_map`
       |
    note: the lint level is defined here
      --> serde_derive/src/lib.rs:18:22
       |
    18 | #![deny(clippy::all, clippy::pedantic)]
       |                      ^^^^^^^^^^^^^^^^
       = note: `#[deny(clippy::flat_map_option)]` implied by `#[deny(clippy::pedantic)]`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#flat_map_option

    error: used `flat_map` where `filter_map` could be used instead
      --> serde_derive/src/bound.rs:74:10
       |
    74 |         .flat_map(|variant| from_variant(&variant.attrs))
       |          ^^^^^^^^ help: try: `filter_map`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#flat_map_option
2021-04-24 19:23:21 -07:00
David Tolnay
2ea132b8c4
Merge pull request #2018 from dtolnay/nonascii
Remove non_ascii_idents feature gate from test suite
2021-04-19 20:24:51 -07:00
David Tolnay
2ebc771b88
Remove non_ascii_idents feature gate from test suite
error: the feature `non_ascii_idents` has been stable since 1.53.0 and no longer requires an attribute to enable
     --> test_suite/tests/test_gen.rs:6:43
      |
    6 | #![cfg_attr(feature = "unstable", feature(non_ascii_idents))]
      |                                           ^^^^^^^^^^^^^^^^
      |
    note: the lint level is defined here
     --> test_suite/tests/test_gen.rs:5:9
      |
    5 | #![deny(warnings)]
      |         ^^^^^^^^
      = note: `#[deny(stable_features)]` implied by `#[deny(warnings)]`
2021-04-19 19:55:12 -07:00
David Tolnay
c17c4eef18
Unify stable and beta CI workflow 2021-04-19 19:54:56 -07:00
David Tolnay
7aa4950504
Release serde_derive_internals 0.26.0 2021-04-09 14:23:13 -07:00
David Tolnay
47015a2727
Merge pull request #2015 from dtolnay/symlink
Build using relative path in repo if Windows lost the symlink
2021-04-09 14:20:55 -07:00
David Tolnay
dc4c31eb50
Build using relative path in repo if Windows lost symlink 2021-04-09 14:16:17 -07:00
David Tolnay
b53ebef438
Resolve safe_packed_borrows lint renamed to unaligned_references
warning: lint `safe_packed_borrows` has been renamed to `unaligned_references`
        --> test_suite/tests/test_macros.rs:1926:8
         |
    1926 | #[deny(safe_packed_borrows)]
         |        ^^^^^^^^^^^^^^^^^^^ help: use the new name: `unaligned_references`
         |
         = note: `#[warn(renamed_and_removed_lints)]` on by default
2021-04-08 20:08:42 -07:00
David Tolnay
6c3bf7a2fc
Ignore poor suggestion from branches_sharing_code lint
https://github.com/rust-lang/rust-clippy/issues/7054

    error: all if blocks contain the same code at the end
        --> serde_derive/src/de.rs:2160:5
         |
    2160 | /         &fallthrough_arm_tokens
    2161 | |     };
         | |_____^
         |
    note: the lint level is defined here
        --> serde_derive/src/lib.rs:18:9
         |
    18   | #![deny(clippy::all, clippy::pedantic)]
         |         ^^^^^^^^^^^
         = note: `#[deny(clippy::branches_sharing_code)]` implied by `#[deny(clippy::all)]`
         = note: The end suggestion probably needs some adjustments to use the expression result correctly
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#branches_sharing_code
    help: consider moving the end statements out like this
         |
    2160 |     }
    2161 |     &fallthrough_arm_tokens;
         |
2021-04-08 20:08:42 -07:00
David Tolnay
ce0844b9ec
Suppress match_wildcard_for_single_variants clippy false positive
https://github.com/rust-lang/rust-clippy/issues/6984

    error: wildcard matches only a single variant and will also match any future added variants
        --> serde_derive/src/internals/attr.rs:1918:9
         |
    1918 |         _ => {}
         |         ^ help: try this: `syn::Type::__TestExhaustive(_)`
         |
    note: the lint level is defined here
        --> serde_derive/src/lib.rs:18:22
         |
    18   | #![deny(clippy::all, clippy::pedantic)]
         |                      ^^^^^^^^^^^^^^^^
         = note: `#[deny(clippy::match_wildcard_for_single_variants)]` implied by `#[deny(clippy::pedantic)]`
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_wildcard_for_single_variants

    error: wildcard matches only a single variant and will also match any future added variants
       --> serde_derive/src/internals/receiver.rs:153:13
        |
    153 |             _ => {}
        |             ^ help: try this: `Type::__TestExhaustive(_)`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_wildcard_for_single_variants

    error: wildcard matches only a single variant and will also match any future added variants
       --> serde_derive/src/bound.rs:190:17
        |
    190 |                 _ => {}
        |                 ^ help: try this: `syn::Type::__TestExhaustive(_)`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_wildcard_for_single_variants
2021-03-26 23:30:15 -04:00
David Tolnay
e9270e59f0
Release 1.0.125 2021-03-22 16:15:57 -07:00
David Tolnay
72060b779a
Extend test_format_u8 to include u8::MAX
This is equivalent to looping 0..=u8::MAX, except that `..=` syntax is
not supported on old rustc and `...` syntax is not supported on new
rustc, so loop it is.
2021-03-22 16:09:33 -07:00
David Tolnay
1bb23ad9d1
Remove format_u8 when not used by Ipv4Addr impl 2021-03-22 16:00:58 -07:00
David Tolnay
9be4c9654a
Merge pull request 2001 from saethlin/optimize-ipaddr 2021-03-22 16:00:11 -07:00
Ben Kimock
4114e90bac Fix off-by-one mistake, explain the offset 2021-03-22 18:39:24 -04:00
Ben Kimock
8bb07b0743 skip UTF8 checking and initialize with b'.' 2021-03-22 18:15:50 -04:00
Ben Kimock
ba8c1d63c8 use the algorithm from itoa 2021-03-16 17:33:42 -04:00
Ben Kimock
857a805993 Faster Ipv4 serialization prototype 2021-03-16 10:41:13 -04:00
David Tolnay
5a8dcac2ed
Release 1.0.124 2021-03-05 19:55:40 -08:00
David Tolnay
697b082e90
Touch up PR 1997 2021-03-05 19:48:40 -08:00
David Tolnay
d91075c8d5
Merge pull request #1997 from cyang1/systemtime-panics
Prevent various panics when deserializing malformed SystemTime
2021-03-05 18:35:48 -08:00
Cary Yang
4118cec731 Prevent various panics when deserializing malformed SystemTime 2021-03-05 17:52:51 -08:00
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
bc6b2b1dee
Make json5 description capitalization consistent with other links 2021-02-10 23:13:12 -08:00
David Tolnay
beb21cb640
Ignore new missing_panics_doc pedantic clippy lint 2021-02-03 20:07:44 -08:00
David Tolnay
7cfebbcd72
Merge pull request #1974 from Mingun/new-internally-tagged-tests
New internally tagged tests
2021-02-02 15:23:10 -08:00
Mingun
b60c03ec3f Extend test_internally_tagged_newtype_variant_containing_unit_struct to cover structs and seqs 2021-02-02 09:00:04 +05:00