4130 Commits

Author SHA1 Message Date
David Tolnay
1a3cf4b3c1
Update PR 2562 ui tests 2024-11-10 23:46:31 -08:00
David Tolnay
7d96352e96
Merge pull request #2857 from dtolnay/collide
Revert the colliding aliases hard error (PRs #2562 & #2853)
2024-11-10 23:37:01 -08:00
David Tolnay
111ecc5d8c
Update ui tests for warning on colliding aliases 2024-11-10 23:31:55 -08:00
David Tolnay
edd6fe954b
Revert "Add checks for conflicts for aliases"
This reverts commit 5f9fffa53e8a48d9e1f32b1735542207c42f3ead.
2024-11-10 23:31:55 -08:00
David Tolnay
a20e9249c5
Revert "pacify clippy"
This reverts commit 951ca5ace0ca0abf9b44e0d6c76005fbd3b77c5c.
2024-11-10 23:31:55 -08:00
David Tolnay
b1353a99cd
Merge pull request #2856 from dtolnay/dename
Produce a separate warning for every colliding name
2024-11-10 23:31:44 -08:00
David Tolnay
c59e876bb3
Produce a separate warning for every colliding name 2024-11-10 23:23:09 -08:00
David Tolnay
7f1e697c0d
Merge pull request #2855 from dtolnay/namespan
Produce unreachable_patterns warning when deserialization names collide
2024-11-10 23:21:46 -08:00
David Tolnay
373edcd055
Keep track of a span for alias strings 2024-11-10 23:08:40 -08:00
David Tolnay
f0b5c4f857
Move MultiName to a new module 2024-11-10 22:32:49 -08:00
David Tolnay
3035d4fa34
Rename Name -> MultiName 2024-11-10 22:32:49 -08:00
David Tolnay
60ac737439
Prevent upload-artifact step from causing CI failure
This step has been failing way more than reasonable across my various repos.

    With the provided path, there will be 1 file uploaded
    Artifact name is valid!
    Root directory input is valid!
    Attempt 1 of 5 failed with error: Request timeout: /twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact. Retrying request in 3000 ms...
    Attempt 2 of 5 failed with error: Request timeout: /twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact. Retrying request in 6029 ms...
    Attempt 3 of 5 failed with error: Request timeout: /twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact. Retrying request in 8270 ms...
    Attempt 4 of 5 failed with error: Request timeout: /twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact. Retrying request in 12577 ms...
    Error: Failed to CreateArtifact: Failed to make request after 5 attempts: Request timeout: /twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact
2024-11-08 21:45:52 -05:00
Oli Scherer
a95b0d301e
Merge pull request #2853 from serde-rs/oli-obk-patch-1
pacify clippy
2024-11-01 15:25:08 +01:00
Oli Scherer
951ca5ace0
pacify clippy 2024-11-01 15:20:51 +01:00
Oli Scherer
adf05a5bf6
Merge pull request #2562 from Mingun/alias-check
Add checks for conflicts for aliases
2024-11-01 15:14:15 +01:00
David Tolnay
418062165f
Release 1.0.214 2024-10-28 09:41:44 -07:00
David Tolnay
210373b3b6
Merge pull request #2568 from Mingun/into_deserializer-for-deserializers
Implement `IntoDeserializer` for all `Deserializer`s in `serde:🇩🇪:value` module
2024-10-28 09:40:57 -07:00
Mingun
5f9fffa53e Add checks for conflicts for aliases
- Check that alias is not the same as name of other field (it still can be the name of owning field/variant)
- Check that aliases are unique, i. e. two different fields does not use the same alias
2024-10-25 19:18:31 +05:00
Mingun
9cda015733 Implement IntoDeserializer for all Deserializers in serde:🇩🇪:value module
Unfortunately, blanket implementation IntoDeserializer for Deserializer is impossible
right now because this would be a breaking change. External crates may have this
such implementation (and serde_json actually have it for Value)
2024-10-25 19:17:50 +05:00
David Tolnay
58a8d22931
Release 1.0.213 2024-10-22 11:14:58 -07:00
David Tolnay
ef0ed22593
Merge pull request #2847 from dtolnay/newtypewith
Hygiene for macro-generated newtype struct deserialization with `with` attr
2024-10-22 11:14:18 -07:00
David Tolnay
79925ac394
Ignore dead_code warning in regression test
warning: field `0` is never read
      --> test_suite/tests/regression/issue2846.rs:8:45
       |
    8  |         pub struct S(#[serde(with = $with)] i32);
       |                    - field in this struct   ^^^
    ...
    12 | declare_in_macro!("with");
       | ------------------------- in this macro invocation
       |
       = help: consider removing this field
       = note: `#[warn(dead_code)]` on by default
       = note: this warning originates in the macro `declare_in_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
2024-10-22 11:10:52 -07:00
David Tolnay
b60e4092ec
Hygiene for macro-generated newtype struct deserialization with 'with' attr 2024-10-22 11:10:40 -07:00
David Tolnay
fdc36e5c06
Add regression test for issue 2846
error[E0425]: cannot find value `__e` in this scope
      --> test_suite/tests/regression/issue2846.rs:12:19
       |
    12 | declare_in_macro!("with");
       |                   ^^^^^^ not found in this scope
2024-10-22 11:08:22 -07:00
David Tolnay
49e11ce1ba
Ignore trivially_copy_pass_by_ref pedantic clippy lint in test
warning: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
      --> test_suite/tests/regression/issue2844.rs:18:28
       |
    18 |     pub fn serialize<S>(_: &i32, _: S) -> Result<S::Ok, S::Error>
       |                            ^^^^ help: consider passing by value instead: `i32`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref
       = note: `-W clippy::trivially-copy-pass-by-ref` implied by `-W clippy::pedantic`
       = help: to override `-W clippy::pedantic` add `#[allow(clippy::trivially_copy_pass_by_ref)]`
2024-10-22 09:56:12 -07:00
David Tolnay
7ae1b5f8f3
Release 1.0.212 2024-10-22 09:41:55 -07:00
David Tolnay
1ac054b34a
Merge pull request #2845 from dtolnay/withlocal
Fix hygiene of macro-generated local variable accesses in serde(with) wrappers
2024-10-22 09:41:27 -07:00
David Tolnay
1e36ef551d
Fix hygiene of macro-generated local variable accesses in serde(with) wrappers 2024-10-22 09:38:06 -07:00
David Tolnay
0058c7226e
Add regression test for issue 2844
error[E0424]: expected value, found module `self`
      --> test_suite/tests/regression/issue2844.rs:13:19
       |
    5  |         #[derive(Serialize, Deserialize)]
       |                  --------- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
    ...
    13 | declare_in_macro!("with");
       |                   ^^^^^^ `self` value is a keyword only available in methods with a `self` parameter

    error[E0425]: cannot find value `__s` in this scope
      --> test_suite/tests/regression/issue2844.rs:13:19
       |
    13 | declare_in_macro!("with");
       |                   ^^^^^^ not found in this scope

    error[E0425]: cannot find value `__deserializer` in this scope
      --> test_suite/tests/regression/issue2844.rs:13:19
       |
    13 | declare_in_macro!("with");
       |                   ^^^^^^ not found in this scope
2024-10-22 09:37:58 -07:00
David Tolnay
29d4f3e887
Format regression tests with rustfmt 2024-10-22 09:28:10 -07:00
David Tolnay
1b8310d98a
Release 1.0.211 2024-10-21 23:27:57 -07:00
David Tolnay
af4c388dff
Merge pull request #2843 from dtolnay/fieldwithaliases
Collect field ident and aliases into a struct
2024-10-21 23:23:28 -07:00
David Tolnay
09f6d9361d
Collect field ident and aliases into a struct 2024-10-21 23:16:05 -07:00
David Tolnay
1f9eb8300f
Merge pull request #2842 from dtolnay/identsaliases
Rename field_names_idents -> field_idents_aliases
2024-10-21 23:13:23 -07:00
David Tolnay
c6a5be7f6a
Rename variant_names_idents -> variant_idents_aliases 2024-10-21 22:56:07 -07:00
David Tolnay
0a06af8d21
Rename field_names_idents -> field_idents_aliases 2024-10-21 22:48:02 -07:00
David Tolnay
3393ad6760
Make most of prepare_enum_variant_enum independent of variant_names_idents item type 2024-10-21 22:47:42 -07:00
David Tolnay
830309fcb5
Merge pull request #2841 from dtolnay/serializewith
Reduce scope of quote_spanned on SerializeWith wrapper
2024-10-21 21:56:51 -07:00
David Tolnay
ab4f3f3111
Reduce scope of quote_spanned on SerializeWith wrapper 2024-10-21 21:09:18 -07:00
David Tolnay
00460b8dee
Fix wording in comments from PR 2558 2024-10-21 21:07:13 -07:00
David Tolnay
d4486be2b9
Format all ui tests from PR 2558 using rustfmt 2024-10-21 19:43:45 -07:00
David Tolnay
991e344804
Raise required compiler for serde_derive to 1.61
This is the rust-version declared by recent versions of Syn.
2024-10-21 19:30:51 -07:00
David Tolnay
6a7de26e5a
Ignore uninlined_format_args pedantic clippy lint
warning: variables can be used directly in the `format!` string
       --> serde_derive/src/internals/attr.rs:546:36
        |
    546 |                         meta.error(format_args!("unknown serde container attribute `{}`", path))
        |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        = note: `-W clippy::uninlined-format-args` implied by `-W clippy::pedantic`
        = help: to override `-W clippy::pedantic` add `#[allow(clippy::uninlined_format_args)]`
    help: change this to
        |
    546 -                         meta.error(format_args!("unknown serde container attribute `{}`", path))
    546 +                         meta.error(format_args!("unknown serde container attribute `{path}`"))
        |

    warning: variables can be used directly in the `format!` string
       --> serde_derive/src/internals/attr.rs:940:36
        |
    940 |                         meta.error(format_args!("unknown serde variant attribute `{}`", path))
        |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
        |
    940 -                         meta.error(format_args!("unknown serde variant attribute `{}`", path))
    940 +                         meta.error(format_args!("unknown serde variant attribute `{path}`"))
        |

    warning: variables can be used directly in the `format!` string
        --> serde_derive/src/internals/attr.rs:1095:33
         |
    1095 | ...                   format!("field `{}` does not have lifetime {}", ident, lifetime);
         |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
         |
    1095 -                                 format!("field `{}` does not have lifetime {}", ident, lifetime);
    1095 +                                 format!("field `{ident}` does not have lifetime {lifetime}");
         |

    warning: variables can be used directly in the `format!` string
        --> serde_derive/src/internals/attr.rs:1196:47
         |
    1196 |   ...                   let msg = format!(
         |  _________________________________^
    1197 | | ...                       "field `{}` does not have lifetime {}",
    1198 | | ...                       ident, lifetime,
    1199 | | ...                   );
         | |_______________________^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args

    warning: variables can be used directly in the `format!` string
        --> serde_derive/src/internals/attr.rs:1222:36
         |
    1222 |                         meta.error(format_args!("unknown serde field attribute `{}`", path))
         |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
         |
    1222 -                         meta.error(format_args!("unknown serde field attribute `{}`", path))
    1222 +                         meta.error(format_args!("unknown serde field attribute `{path}`"))
         |

    warning: variables can be used directly in the `format!` string
        --> serde_derive/src/internals/attr.rs:1415:39
         |
    1415 |                   return Err(meta.error(format_args!(
         |  _______________________________________^
    1416 | |                     "malformed {0} attribute, expected `{0}(serialize = ..., deserialize = ...)`",
    1417 | |                     attr_name,
    1418 | |                 )));
         | |_________________^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args

    warning: variables can be used directly in the `format!` string
        --> serde_derive/src/internals/attr.rs:1482:17
         |
    1482 |                 format!("unexpected suffix `{}` on string literal", suffix),
         |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
         |
    1482 -                 format!("unexpected suffix `{}` on string literal", suffix),
    1482 +                 format!("unexpected suffix `{suffix}` on string literal"),
         |

    warning: variables can be used directly in the `format!` string
        --> serde_derive/src/internals/attr.rs:1489:13
         |
    1489 | /             format!(
    1490 | |                 "expected serde {} attribute to be a string: `{} = \"...\"`",
    1491 | |                 attr_name, meta_item_name
    1492 | |             ),
         | |_____________^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args

    warning: variables can be used directly in the `format!` string
        --> serde_derive/src/internals/attr.rs:1604:21
         |
    1604 |                     format!("duplicate borrowed lifetime `{}`", lifetime),
         |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
         |
    1604 -                     format!("duplicate borrowed lifetime `{}`", lifetime),
    1604 +                     format!("duplicate borrowed lifetime `{lifetime}`"),
         |

    warning: variables can be used directly in the `format!` string
        --> serde_derive/src/internals/attr.rs:1778:19
         |
    1778 |         let msg = format!("field `{}` has no lifetimes to borrow", name);
         |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
         |
    1778 -         let msg = format!("field `{}` has no lifetimes to borrow", name);
    1778 +         let msg = format!("field `{name}` has no lifetimes to borrow");
         |

    warning: variables can be used directly in the `format!` string
      --> serde_derive/src/internals/check.rs:41:29
       |
    41 | ...   format!("field must have #[serde(default)] because previous field {} has #[serde(default)]", first),
       |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
       |
    41 -                             format!("field must have #[serde(default)] because previous field {} has #[serde(default)]", first),
    41 +                             format!("field must have #[serde(default)] because previous field {first} has #[serde(default)]"),
       |

    warning: variables can be used directly in the `format!` string
       --> serde_derive/src/internals/check.rs:314:13
        |
    314 |             format!("variant field name `{}` conflicts with internal tag", tag),
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
        |
    314 -             format!("variant field name `{}` conflicts with internal tag", tag),
    314 +             format!("variant field name `{tag}` conflicts with internal tag"),
        |

    warning: variables can be used directly in the `format!` string
       --> serde_derive/src/internals/check.rs:361:13
        |
    361 | /             format!(
    362 | |                 "enum tags `{}` for type and content conflict with each other",
    363 | |                 type_tag
    364 | |             ),
        | |_____________^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args

    warning: variables can be used directly in the `format!` string
       --> serde_derive/src/internals/check.rs:450:33
        |
    450 |         Member::Named(ident) => format!("`{}`", ident),
        |                                 ^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
        |
    450 -         Member::Named(ident) => format!("`{}`", ident),
    450 +         Member::Named(ident) => format!("`{ident}`"),
        |

    warning: variables can be used directly in the `format!` string
       --> serde_derive/src/de.rs:697:9
        |
    697 |         format!("{} with 1 element", expecting)
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
        |
    697 -         format!("{} with 1 element", expecting)
    697 +         format!("{expecting} with 1 element")
        |

    warning: variables can be used directly in the `format!` string
       --> serde_derive/src/de.rs:699:9
        |
    699 |         format!("{} with {} elements", expecting, deserialized_count)
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
        |
    699 -         format!("{} with {} elements", expecting, deserialized_count)
    699 +         format!("{expecting} with {deserialized_count} elements")
        |

    warning: variables can be used directly in the `format!` string
        --> serde_derive/src/de.rs:1442:21
         |
    1442 |     let expecting = format!("adjacently tagged enum {}", rust_name);
         |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
         |
    1442 -     let expecting = format!("adjacently tagged enum {}", rust_name);
    1442 +     let expecting = format!("adjacently tagged enum {rust_name}");
         |

    warning: variables can be used directly in the `format!` string
        --> serde_derive/src/de.rs:2842:17
         |
    2842 |     Ident::new(&format!("__field{}", i), Span::call_site())
         |                 ^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
         |
    2842 -     Ident::new(&format!("__field{}", i), Span::call_site())
    2842 +     Ident::new(&format!("__field{i}"), Span::call_site())
         |

    warning: variables can be used directly in the `format!` string
       --> serde_derive/src/ser.rs:457:42
        |
    457 |                     .map(|i| Ident::new(&format!("__field{}", i), Span::call_site()));
        |                                          ^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
        |
    457 -                     .map(|i| Ident::new(&format!("__field{}", i), Span::call_site()));
    457 +                     .map(|i| Ident::new(&format!("__field{i}"), Span::call_site()));
        |

    warning: variables can be used directly in the `format!` string
       --> serde_derive/src/ser.rs:714:48
        |
    714 |             .map(|i| Member::Named(Ident::new(&format!("__field{}", i), Span::call_site())))
        |                                                ^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
        |
    714 -             .map(|i| Member::Named(Ident::new(&format!("__field{}", i), Span::call_site())))
    714 +             .map(|i| Member::Named(Ident::new(&format!("__field{i}"), Span::call_site())))
        |

    warning: variables can be used directly in the `format!` string
       --> serde_derive/src/ser.rs:832:46
        |
    832 |                 let field_expr = Ident::new(&format!("__field{}", i), Span::call_site());
        |                                              ^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
        |
    832 -                 let field_expr = Ident::new(&format!("__field{}", i), Span::call_site());
    832 +                 let field_expr = Ident::new(&format!("__field{i}"), Span::call_site());
        |

    warning: variables can be used directly in the `format!` string
        --> serde_derive/src/ser.rs:1062:38
         |
    1062 |                 let id = Ident::new(&format!("__field{}", i), Span::call_site());
         |                                      ^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    help: change this to
         |
    1062 -                 let id = Ident::new(&format!("__field{}", i), Span::call_site());
    1062 +                 let id = Ident::new(&format!("__field{i}"), Span::call_site());
         |
2024-10-21 19:30:51 -07:00
David Tolnay
5382ef3b0b
Merge pull request #2840 from dtolnay/needlesslifetimes
Ignore needless_lifetimes clippy lint in generated code
2024-10-21 19:25:40 -07:00
David Tolnay
a8cbc9184e
Ignore needless_lifetimes clippy lint in generated code 2024-10-21 19:12:52 -07:00
David Tolnay
966e9ccf0c
Merge pull request #2839 from dtolnay/pr2558
Update ui tests from PR 2558
2024-10-21 18:58:21 -07:00
David Tolnay
53ade10137
Update ui tests from PR 2558 2024-10-21 18:52:49 -07:00
David Tolnay
422c719352
Temporarily disable 1.56 CI
While fixing other errors from recently merged PRs.
2024-10-21 18:47:54 -07:00
Oli Scherer
3415619bfd
Merge pull request #2566 from Mingun/variant-aliases
Show variant aliases in error message
2024-10-21 21:40:57 +02:00
Oli Scherer
04bb76bc00
Merge pull request #2558 from Mingun/correct-span
Improve error reporting about mismatched signature in `with` and `default` attributes
2024-10-21 21:38:09 +02:00