serde/test_suite/tests
David Tolnay eb4c3f16f7
Add a test of serde(bound = "") attribute
Without serde(bound = ""), serde_derive infers a bound of `T: Serialize`
for the generated Serialize impl and `T: Deserialize<'de> + Default` for
the Deserialize impl. `X` implements none of these so the generated code
would fail to compile.

    error[E0277]: the trait bound `X: Serialize` is not satisfied
       --> test_suite/tests/test_gen.rs:268:14
        |
    268 |     assert::<PhantomDataWrapper<X>>();
        |              ^^^^^^^^^^^^^^^^^^^^^ the trait `Serialize` is not implemented for `X`
        |
        = help: the following other types implement trait `Serialize`:
                  &'a T
                  &'a mut T
                  ()
                  (T0, T1)
                  (T0, T1, T2)
                  (T0, T1, T2, T3)
                  (T0, T1, T2, T3, T4)
                  (T0, T1, T2, T3, T4, T5)
                and 248 others
    note: required for `PhantomDataWrapper<X>` to implement `Serialize`
       --> test_suite/tests/test_gen.rs:262:14
        |
    262 |     #[derive(Serialize, Deserialize)]
        |              ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
    263 |     //#[serde(bound = "")]
    264 |     struct PhantomDataWrapper<T> {
        |            ^^^^^^^^^^^^^^^^^^^^^
    note: required by a bound in `assert`
       --> test_suite/tests/test_gen.rs:767:14
        |
    767 | fn assert<T: Serialize + DeserializeOwned>() {}
        |              ^^^^^^^^^ required by this bound in `assert`
        = note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)

    error[E0277]: the trait bound `X: Deserialize<'_>` is not satisfied
       --> test_suite/tests/test_gen.rs:268:14
        |
    268 |     assert::<PhantomDataWrapper<X>>();
        |              ^^^^^^^^^^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `X`
        |
        = help: the following other types implement trait `Deserialize<'de>`:
                  <&'a Path as Deserialize<'de>>
                  <&'a [u8] as Deserialize<'de>>
                  <&'a str as Deserialize<'de>>
                  <() as Deserialize<'de>>
                  <(T0, T1) as Deserialize<'de>>
                  <(T0, T1, T2) as Deserialize<'de>>
                  <(T0, T1, T2, T3) as Deserialize<'de>>
                  <(T0, T1, T2, T3, T4) as Deserialize<'de>>
                and 331 others
    note: required for `PhantomDataWrapper<X>` to implement `for<'de> Deserialize<'de>`
       --> test_suite/tests/test_gen.rs:262:25
        |
    262 |     #[derive(Serialize, Deserialize)]
        |                         ^^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
    263 |     //#[serde(bound = "")]
    264 |     struct PhantomDataWrapper<T> {
        |            ^^^^^^^^^^^^^^^^^^^^^
        = note: required for `PhantomDataWrapper<X>` to implement `DeserializeOwned`
    note: required by a bound in `assert`
       --> test_suite/tests/test_gen.rs:767:26
        |
    767 | fn assert<T: Serialize + DeserializeOwned>() {}
        |                          ^^^^^^^^^^^^^^^^ required by this bound in `assert`
        = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)

    error[E0277]: the trait bound `X: Default` is not satisfied
       --> test_suite/tests/test_gen.rs:268:14
        |
    268 |     assert::<PhantomDataWrapper<X>>();
        |              ^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `X`
        |
    note: required for `PhantomDataWrapper<X>` to implement `for<'de> Deserialize<'de>`
       --> test_suite/tests/test_gen.rs:262:25
        |
    262 |     #[derive(Serialize, Deserialize)]
        |                         ^^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
    263 |     //#[serde(bound = "")]
    264 |     struct PhantomDataWrapper<T> {
        |            ^^^^^^^^^^^^^^^^^^^^^
        = note: required for `PhantomDataWrapper<X>` to implement `DeserializeOwned`
    note: required by a bound in `assert`
       --> test_suite/tests/test_gen.rs:767:26
        |
    767 | fn assert<T: Serialize + DeserializeOwned>() {}
        |                          ^^^^^^^^^^^^^^^^ required by this bound in `assert`
        = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
    help: consider annotating `X` with `#[derive(Default)]`
        |
    779 | #[derive(Default)]
        |
2023-03-08 19:11:25 -08:00
..
bytes Replace try! macro in test suite 2018-12-31 21:46:14 -05:00
macros Ignore unused_macro_rules warning in test macros 2022-05-12 21:33:43 -07:00
regression Make a directory dedicated to regression tests 2023-03-08 19:02:42 -08:00
ui Eliminate special case on empty string passed to borrow="" 2023-03-08 18:50:19 -08:00
unstable Update test suite to 2018 edition 2018-12-31 21:53:37 -05:00
compiletest.rs Ignore unused ignore attribute warning in some configurations 2022-04-24 16:01:22 -07:00
regression.rs Make a directory dedicated to regression tests 2023-03-08 19:02:42 -08:00
test_annotations.rs Add tests for #2387 2023-03-07 08:09:01 +08:00
test_borrow.rs Ignore derive_partial_eq_without_eq clippy lint 2022-05-21 20:43:51 -07:00
test_de_error.rs Ignore derive_partial_eq_without_eq clippy lint 2022-05-21 20:43:51 -07:00
test_de.rs Ignore uninlined_format_args pedantic clippy lint false positive 2022-10-07 21:46:25 -07:00
test_gen.rs Add a test of serde(bound = "") attribute 2023-03-08 19:11:25 -08:00
test_identifier.rs Ignore derive_partial_eq_without_eq clippy lint 2022-05-21 20:43:51 -07:00
test_ignored_any.rs Ignore derive_partial_eq_without_eq clippy lint 2022-05-21 20:43:51 -07:00
test_macros.rs Delete deny(unaligned_references) from test 2023-02-01 19:06:06 -08:00
test_remote.rs Fix Into conversion involving generic remote derive with getter 2022-11-27 17:18:10 -08:00
test_roundtrip.rs Implement test suite seq macro without tt muncher 2022-01-20 19:40:58 -08:00
test_self.rs Enable pedantic lints on test suite in CI 2021-11-04 20:21:48 -07:00
test_ser.rs Serialize unsized RefCell, Mutex and RwLock 2022-09-22 09:57:55 +03:00
test_serde_path.rs Ignore extra_unused_type_parameters clippy lint in test 2023-02-10 19:14:43 -08:00
test_unstable.rs Ignore derive_partial_eq_without_eq clippy lint 2022-05-21 20:43:51 -07:00
test_value.rs Ignore derive_partial_eq_without_eq clippy lint 2022-05-21 20:43:51 -07:00