Merge pull request #2963 from dtolnay/diagnosticpath
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Override diagnostic::on_unimplemented message for all serde_core traits
authored by David Tolnay · committed by GitHub · parents 723fcac, 4bddf1b · Browse files · 9 files·+331 added−92 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
9 files+331 added−92 removed
- tests:+211 added−92 removed
- other:+120 added−0 removed
Provenance
- Commit
66c5d2b- Tree
3046ba1- Author
David Tolnay <dtolnay@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
723fcac- Parent 2
4bddf1b
9 files changed+331 added−92 removed
modified:serde_core/src/de/mod.rs+63 added
156 unmodified lines157 /// The [example data format] presented on the website shows an error158 /// type appropriate for a basic JSON data format.159 ///160 /// [example data format]: https://serde.rs/data-format.html161+ #[cfg_attr(162+ not(no_diagnostic_namespace),163+ diagnostic::on_unimplemented(164+ message = "the trait bound `{Self}: serde::de::Error` is not satisfied",165+ )166+ )]167 pub trait Error: Sized $(+ $($supertrait)::+)* {168 /// Raised when there is general error when deserializing a type.169 ///170 /// The message should not be capitalized and should not end with a period.305 unmodified lines476 /// &"a negative integer",477 /// ));478 /// # }479 /// ```480+#[cfg_attr(481+ not(no_diagnostic_namespace),482+ diagnostic::on_unimplemented(483+ message = "the trait bound `{Self}: serde::de::Expected` is not satisfied",484+ )485+)]486 pub trait Expected {487 /// Format an explanation of what data was being expected. Same signature as488 /// the `Display` and `Debug` traits.489 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result;55 unmodified lines545 /// [Understanding deserializer lifetimes]: https://serde.rs/lifetimes.html546 #[cfg_attr(547 not(no_diagnostic_namespace),548 diagnostic::on_unimplemented(549+ // Prevents `serde_core::de::Deserialize` appearing in the error message550+ // in projects with no direct dependency on serde_core.551+ message = "the trait bound `{Self}: serde::Deserialize<'de>` is not satisfied",552 note = "for local types consider adding `#[derive(serde::Deserialize)]` to your `{Self}` type",553 note = "for types from other crates check whether the crate offers a `serde` feature flag",554 )555 )]68 unmodified lines624 /// bounds is explained in more detail on the page [Understanding deserializer625 /// lifetimes].626 ///627 /// [Understanding deserializer lifetimes]: https://serde.rs/lifetimes.html628+#[cfg_attr(629+ not(no_diagnostic_namespace),630+ diagnostic::on_unimplemented(631+ message = "the trait bound `{Self}: serde::de::DeserializeOwned` is not satisfied",632+ )633+)]634 pub trait DeserializeOwned: for<'de> Deserialize<'de> {}635 impl<T> DeserializeOwned for T where T: for<'de> Deserialize<'de> {}636 637 /// `DeserializeSeed` is the stateful form of the `Deserialize` trait. If you157 unmodified lines795 /// let flattened: Vec<u64> = deserializer.deserialize_seq(visitor)?;796 /// # Ok(())797 /// # }798 /// ```799+#[cfg_attr(800+ not(no_diagnostic_namespace),801+ diagnostic::on_unimplemented(802+ message = "the trait bound `{Self}: serde::de::DeserializeSeed<'de>` is not satisfied",803+ )804+)]805 pub trait DeserializeSeed<'de>: Sized {806 /// The type produced by using this seed.807 type Value;808 128 unmodified lines937 /// The [example data format] presented on the website contains example code for938 /// a basic JSON `Deserializer`.939 ///940 /// [example data format]: https://serde.rs/data-format.html941+#[cfg_attr(942+ not(no_diagnostic_namespace),943+ diagnostic::on_unimplemented(944+ message = "the trait bound `{Self}: serde::de::Deserializer<'de>` is not satisfied",945+ )946+)]947 pub trait Deserializer<'de>: Sized {948 /// The error type that can be returned if some error occurs during949 /// deserialization.950 type Error: Error;348 unmodified lines1299 /// }1300 /// }1301 /// }1302 /// ```1303+#[cfg_attr(1304+ not(no_diagnostic_namespace),1305+ diagnostic::on_unimplemented(1306+ message = "the trait bound `{Self}: serde::de::Visitor<'de>` is not satisfied",1307+ )1308+)]1309 pub trait Visitor<'de>: Sized {1310 /// The value produced by this visitor.1311 type Value;1312 418 unmodified lines1731 /// The [example data format] presented on the website demonstrates an1732 /// implementation of `SeqAccess` for a basic JSON data format.1733 ///1734 /// [example data format]: https://serde.rs/data-format.html1735+#[cfg_attr(1736+ not(no_diagnostic_namespace),1737+ diagnostic::on_unimplemented(1738+ message = "the trait bound `{Self}: serde::de::SeqAccess<'de>` is not satisfied",1739+ )1740+)]1741 pub trait SeqAccess<'de> {1742 /// The error type that can be returned if some error occurs during1743 /// deserialization.1744 type Error: Error;74 unmodified lines1819 /// The [example data format] presented on the website demonstrates an1820 /// implementation of `MapAccess` for a basic JSON data format.1821 ///1822 /// [example data format]: https://serde.rs/data-format.html1823+#[cfg_attr(1824+ not(no_diagnostic_namespace),1825+ diagnostic::on_unimplemented(1826+ message = "the trait bound `{Self}: serde::de::MapAccess<'de>` is not satisfied",1827+ )1828+)]1829 pub trait MapAccess<'de> {1830 /// The error type that can be returned if some error occurs during1831 /// deserialization.1832 type Error: Error;184 unmodified lines2017 /// The [example data format] presented on the website demonstrates an2018 /// implementation of `EnumAccess` for a basic JSON data format.2019 ///2020 /// [example data format]: https://serde.rs/data-format.html2021+#[cfg_attr(2022+ not(no_diagnostic_namespace),2023+ diagnostic::on_unimplemented(2024+ message = "the trait bound `{Self}: serde::de::EnumAccess<'de>` is not satisfied",2025+ )2026+)]2027 pub trait EnumAccess<'de>: Sized {2028 /// The error type that can be returned if some error occurs during2029 /// deserialization.2030 type Error: Error;39 unmodified lines2070 /// The [example data format] presented on the website demonstrates an2071 /// implementation of `VariantAccess` for a basic JSON data format.2072 ///2073 /// [example data format]: https://serde.rs/data-format.html2074+#[cfg_attr(2075+ not(no_diagnostic_namespace),2076+ diagnostic::on_unimplemented(2077+ message = "the trait bound `{Self}: serde::de::VariantAccess<'de>` is not satisfied",2078+ )2079+)]2080 pub trait VariantAccess<'de>: Sized {2081 /// The error type that can be returned if some error occurs during2082 /// deserialization. Must match the error type of our `EnumAccess`.2083 type Error: Error;301 unmodified linesmodified:serde_core/src/ser/mod.rs+57 added
137 unmodified lines138 /// The [example data format] presented on the website shows an error139 /// type appropriate for a basic JSON data format.140 ///141 /// [example data format]: https://serde.rs/data-format.html142+ #[cfg_attr(143+ not(no_diagnostic_namespace),144+ diagnostic::on_unimplemented(145+ message = "the trait bound `{Self}: serde::ser::Error` is not satisfied",146+ )147+ )]148 pub trait Error: Sized $(+ $($supertrait)::+)* {149 /// Used when a [`Serialize`] implementation encounters any error150 /// while serializing a type.151 ///71 unmodified lines223 /// [derive section of the manual]: https://serde.rs/derive.html224 #[cfg_attr(225 not(no_diagnostic_namespace),226 diagnostic::on_unimplemented(227+ // Prevents `serde_core::ser::Serialize` appearing in the error message228+ // in projects with no direct dependency on serde_core.229+ message = "the trait bound `{Self}: serde::Serialize` is not satisfied",230 note = "for local types consider adding `#[derive(serde::Serialize)]` to your `{Self}` type",231 note = "for types from other crates check whether the crate offers a `serde` feature flag",232 )233 )]111 unmodified lines345 /// The [example data format] presented on the website contains example code for346 /// a basic JSON `Serializer`.347 ///348 /// [example data format]: https://serde.rs/data-format.html349+#[cfg_attr(350+ not(no_diagnostic_namespace),351+ diagnostic::on_unimplemented(352+ message = "the trait bound `{Self}: serde::Serializer` is not satisfied",353+ )354+)]355 pub trait Serializer: Sized {356 /// The output type produced by this `Serializer` during successful357 /// serialization. Most serializers that produce text or binary output358 /// should set `Ok = ()` and serialize into an [`io::Write`] or buffer1149 unmodified lines1508 /// The [example data format] presented on the website demonstrates an1509 /// implementation of `SerializeSeq` for a basic JSON data format.1510 ///1511 /// [example data format]: https://serde.rs/data-format.html1512+#[cfg_attr(1513+ not(no_diagnostic_namespace),1514+ diagnostic::on_unimplemented(1515+ message = "the trait bound `{Self}: serde::ser::SerializeSeq` is not satisfied",1516+ )1517+)]1518 pub trait SerializeSeq {1519 /// Must match the `Ok` type of our `Serializer`.1520 type Ok;1521 92 unmodified lines1614 /// The [example data format] presented on the website demonstrates an1615 /// implementation of `SerializeTuple` for a basic JSON data format.1616 ///1617 /// [example data format]: https://serde.rs/data-format.html1618+#[cfg_attr(1619+ not(no_diagnostic_namespace),1620+ diagnostic::on_unimplemented(1621+ message = "the trait bound `{Self}: serde::ser::SerializeTuple` is not satisfied",1622+ )1623+)]1624 pub trait SerializeTuple {1625 /// Must match the `Ok` type of our `Serializer`.1626 type Ok;1627 37 unmodified lines1665 /// The [example data format] presented on the website demonstrates an1666 /// implementation of `SerializeTupleStruct` for a basic JSON data format.1667 ///1668 /// [example data format]: https://serde.rs/data-format.html1669+#[cfg_attr(1670+ not(no_diagnostic_namespace),1671+ diagnostic::on_unimplemented(1672+ message = "the trait bound `{Self}: serde::ser::SerializeTupleStruct` is not satisfied",1673+ )1674+)]1675 pub trait SerializeTupleStruct {1676 /// Must match the `Ok` type of our `Serializer`.1677 type Ok;1678 50 unmodified lines1729 /// The [example data format] presented on the website demonstrates an1730 /// implementation of `SerializeTupleVariant` for a basic JSON data format.1731 ///1732 /// [example data format]: https://serde.rs/data-format.html1733+#[cfg_attr(1734+ not(no_diagnostic_namespace),1735+ diagnostic::on_unimplemented(1736+ message = "the trait bound `{Self}: serde::ser::SerializeTupleVariant` is not satisfied",1737+ )1738+)]1739 pub trait SerializeTupleVariant {1740 /// Must match the `Ok` type of our `Serializer`.1741 type Ok;1742 58 unmodified lines1801 /// The [example data format] presented on the website demonstrates an1802 /// implementation of `SerializeMap` for a basic JSON data format.1803 ///1804 /// [example data format]: https://serde.rs/data-format.html1805+#[cfg_attr(1806+ not(no_diagnostic_namespace),1807+ diagnostic::on_unimplemented(1808+ message = "the trait bound `{Self}: serde::ser::SerializeMap` is not satisfied",1809+ )1810+)]1811 pub trait SerializeMap {1812 /// Must match the `Ok` type of our `Serializer`.1813 type Ok;1814 82 unmodified lines1897 /// The [example data format] presented on the website demonstrates an1898 /// implementation of `SerializeStruct` for a basic JSON data format.1899 ///1900 /// [example data format]: https://serde.rs/data-format.html1901+#[cfg_attr(1902+ not(no_diagnostic_namespace),1903+ diagnostic::on_unimplemented(1904+ message = "the trait bound `{Self}: serde::ser::SerializeStruct` is not satisfied",1905+ )1906+)]1907 pub trait SerializeStruct {1908 /// Must match the `Ok` type of our `Serializer`.1909 type Ok;1910 56 unmodified lines1967 /// The [example data format] presented on the website demonstrates an1968 /// implementation of `SerializeStructVariant` for a basic JSON data format.1969 ///1970 /// [example data format]: https://serde.rs/data-format.html1971+#[cfg_attr(1972+ not(no_diagnostic_namespace),1973+ diagnostic::on_unimplemented(1974+ message = "the trait bound `{Self}: serde::ser::SerializeStructVariant` is not satisfied",1975+ )1976+)]1977 pub trait SerializeStructVariant {1978 /// Must match the `Ok` type of our `Serializer`.1979 type Ok;1980 30 unmodified linesadded:test_suite/tests/ui/unimplemented/required_by_dependency.rs+6 added
1+struct MyStruct;2+3+fn main() {4+ serde_test::assert_ser_tokens(&MyStruct, &[]);5+ serde_test::assert_de_tokens(&MyStruct, &[]);6+}added:test_suite/tests/ui/unimplemented/required_by_dependency.stderr+113 added
1+error[E0277]: the trait bound `MyStruct: serde::Serialize` is not satisfied2+ --> tests/ui/unimplemented/required_by_dependency.rs:4:353+ |4+4 | serde_test::assert_ser_tokens(&MyStruct, &[]);5+ | ----------------------------- ^^^^^^^^^ unsatisfied trait bound6+ | |7+ | required by a bound introduced by this call8+ |9+help: the trait `serde_core::ser::Serialize` is not implemented for `MyStruct`10+ --> tests/ui/unimplemented/required_by_dependency.rs:1:111+ |12+1 | struct MyStruct;13+ | ^^^^^^^^^^^^^^^14+ = note: for local types consider adding `#[derive(serde::Serialize)]` to your `MyStruct` type15+ = note: for types from other crates check whether the crate offers a `serde` feature flag16+ = help: the following other types implement trait `serde_core::ser::Serialize`:17+ &'a T18+ &'a mut T19+ ()20+ (T,)21+ (T0, T1)22+ (T0, T1, T2)23+ (T0, T1, T2, T3)24+ (T0, T1, T2, T3, T4)25+ and $N others26+note: required by a bound in `assert_ser_tokens`27+ --> $CARGO/serde_test-$VERSION/src/assert.rs28+ |29+ | pub fn assert_ser_tokens<T>(value: &T, tokens: &[Token])30+ | ----------------- required by a bound in this function31+ | where32+ | T: ?Sized + Serialize,33+ | ^^^^^^^^^ required by this bound in `assert_ser_tokens`34+35+error[E0277]: the trait bound `MyStruct: serde::Deserialize<'de>` is not satisfied36+ --> tests/ui/unimplemented/required_by_dependency.rs:5:3437+ |38+5 | serde_test::assert_de_tokens(&MyStruct, &[]);39+ | ---------------------------- ^^^^^^^^^ unsatisfied trait bound40+ | |41+ | required by a bound introduced by this call42+ |43+help: the trait `serde_core::de::Deserialize<'_>` is not implemented for `MyStruct`44+ --> tests/ui/unimplemented/required_by_dependency.rs:1:145+ |46+1 | struct MyStruct;47+ | ^^^^^^^^^^^^^^^48+ = note: for local types consider adding `#[derive(serde::Deserialize)]` to your `MyStruct` type49+ = note: for types from other crates check whether the crate offers a `serde` feature flag50+ = help: the following other types implement trait `serde_core::de::Deserialize<'de>`:51+ &'a Path52+ &'a [u8]53+ &'a str54+ ()55+ (T,)56+ (T0, T1)57+ (T0, T1, T2)58+ (T0, T1, T2, T3)59+ and $N others60+note: required by a bound in `assert_de_tokens`61+ --> $CARGO/serde_test-$VERSION/src/assert.rs62+ |63+ | pub fn assert_de_tokens<'de, T>(value: &T, tokens: &'de [Token])64+ | ---------------- required by a bound in this function65+ | where66+ | T: Deserialize<'de> + PartialEq + Debug,67+ | ^^^^^^^^^^^^^^^^ required by this bound in `assert_de_tokens`68+69+error[E0277]: can't compare `MyStruct` with `MyStruct`70+ --> tests/ui/unimplemented/required_by_dependency.rs:5:3471+ |72+5 | serde_test::assert_de_tokens(&MyStruct, &[]);73+ | ---------------------------- ^^^^^^^^^ no implementation for `MyStruct == MyStruct`74+ | |75+ | required by a bound introduced by this call76+ |77+ = help: the trait `PartialEq` is not implemented for `MyStruct`78+note: required by a bound in `assert_de_tokens`79+ --> $CARGO/serde_test-$VERSION/src/assert.rs80+ |81+ | pub fn assert_de_tokens<'de, T>(value: &T, tokens: &'de [Token])82+ | ---------------- required by a bound in this function83+ | where84+ | T: Deserialize<'de> + PartialEq + Debug,85+ | ^^^^^^^^^ required by this bound in `assert_de_tokens`86+help: consider annotating `MyStruct` with `#[derive(PartialEq)]`87+ |88+ 1 + #[derive(PartialEq)]89+ 2 | struct MyStruct;90+ |91+92+error[E0277]: `MyStruct` doesn't implement `Debug`93+ --> tests/ui/unimplemented/required_by_dependency.rs:5:3494+ |95+5 | serde_test::assert_de_tokens(&MyStruct, &[]);96+ | ---------------------------- ^^^^^^^^^ the trait `Debug` is not implemented for `MyStruct`97+ | |98+ | required by a bound introduced by this call99+ |100+ = note: add `#[derive(Debug)]` to `MyStruct` or manually `impl Debug for MyStruct`101+note: required by a bound in `assert_de_tokens`102+ --> $CARGO/serde_test-$VERSION/src/assert.rs103+ |104+ | pub fn assert_de_tokens<'de, T>(value: &T, tokens: &'de [Token])105+ | ---------------- required by a bound in this function106+ | where107+ | T: Deserialize<'de> + PartialEq + Debug,108+ | ^^^^^ required by this bound in `assert_de_tokens`109+help: consider annotating `MyStruct` with `#[derive(Debug)]`110+ |111+ 1 + #[derive(Debug)]112+ 2 | struct MyStruct;113+ |added:test_suite/tests/ui/unimplemented/required_locally.rs+23 added
1+use serde::de::Deserialize;2+use serde::ser::Serialize;3+4+fn to_string<T>(_: &T) -> String5+where6+ T: Serialize,7+{8+ unimplemented!()9+}10+11+fn from_str<'de, T>(_: &'de str) -> T12+where13+ T: Deserialize<'de>,14+{15+ unimplemented!()16+}17+18+struct MyStruct;19+20+fn main() {21+ to_string(&MyStruct);22+ let _: MyStruct = from_str("");23+}added:test_suite/tests/ui/unimplemented/required_locally.stderr+65 added
1+error[E0277]: the trait bound `MyStruct: serde::Serialize` is not satisfied2+ --> tests/ui/unimplemented/required_locally.rs:21:153+ |4+21 | to_string(&MyStruct);5+ | --------- ^^^^^^^^^ unsatisfied trait bound6+ | |7+ | required by a bound introduced by this call8+ |9+help: the trait `Serialize` is not implemented for `MyStruct`10+ --> tests/ui/unimplemented/required_locally.rs:18:111+ |12+18 | struct MyStruct;13+ | ^^^^^^^^^^^^^^^14+ = note: for local types consider adding `#[derive(serde::Serialize)]` to your `MyStruct` type15+ = note: for types from other crates check whether the crate offers a `serde` feature flag16+ = help: the following other types implement trait `Serialize`:17+ &'a T18+ &'a mut T19+ ()20+ (T,)21+ (T0, T1)22+ (T0, T1, T2)23+ (T0, T1, T2, T3)24+ (T0, T1, T2, T3, T4)25+ and $N others26+note: required by a bound in `to_string`27+ --> tests/ui/unimplemented/required_locally.rs:6:828+ |29+ 4 | fn to_string<T>(_: &T) -> String30+ | --------- required by a bound in this function31+ 5 | where32+ 6 | T: Serialize,33+ | ^^^^^^^^^ required by this bound in `to_string`34+35+error[E0277]: the trait bound `MyStruct: serde::Deserialize<'de>` is not satisfied36+ --> tests/ui/unimplemented/required_locally.rs:22:2337+ |38+22 | let _: MyStruct = from_str("");39+ | ^^^^^^^^^^^^ unsatisfied trait bound40+ |41+help: the trait `Deserialize<'_>` is not implemented for `MyStruct`42+ --> tests/ui/unimplemented/required_locally.rs:18:143+ |44+18 | struct MyStruct;45+ | ^^^^^^^^^^^^^^^46+ = note: for local types consider adding `#[derive(serde::Deserialize)]` to your `MyStruct` type47+ = note: for types from other crates check whether the crate offers a `serde` feature flag48+ = help: the following other types implement trait `Deserialize<'de>`:49+ &'a Path50+ &'a [u8]51+ &'a str52+ ()53+ (T,)54+ (T0, T1)55+ (T0, T1, T2)56+ (T0, T1, T2, T3)57+ and $N others58+note: required by a bound in `from_str`59+ --> tests/ui/unimplemented/required_locally.rs:13:860+ |61+11 | fn from_str<'de, T>(_: &'de str) -> T62+ | -------- required by a bound in this function63+12 | where64+13 | T: Deserialize<'de>,65+ | ^^^^^^^^^^^^^^^^ required by this bound in `from_str`modified:test_suite/tests/ui/with/incorrect_type.stderr+4 added-4 removed
1-error[E0277]: the trait bound `&u8: Serializer` is not satisfied1+error[E0277]: the trait bound `&u8: serde::Serializer` is not satisfied2 --> tests/ui/with/incorrect_type.rs:14:103 |4 14 | #[derive(Serialize, Deserialize)]5 | ^^^^^^^^^ the trait `Serializer` is not implemented for `&u8`23 unmodified lines29 |30 9 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> {31 | ^^^^^^^^^32 33-error[E0277]: the trait bound `&u8: Serializer` is not satisfied33+error[E0277]: the trait bound `&u8: serde::Serializer` is not satisfied34 --> tests/ui/with/incorrect_type.rs:15:2535 |36 15 | struct W(#[serde(with = "w")] u8, u8);37 | ^^^ the trait `Serializer` is not implemented for `&u8`10 unmodified lines48 | ^^^ expected `u8`, found `()`49 |50 = note: `?` operator cannot convert from `()` to `u8`51 52-error[E0277]: the trait bound `&u8: Serializer` is not satisfied52+error[E0277]: the trait bound `&u8: serde::Serializer` is not satisfied53 --> tests/ui/with/incorrect_type.rs:17:1054 |55 17 | #[derive(Serialize, Deserialize)]56 | ^^^^^^^^^ the trait `Serializer` is not implemented for `&u8`23 unmodified lines80 |81 9 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> {82 | ^^^^^^^^^83 84-error[E0277]: the trait bound `&u8: Serializer` is not satisfied84+error[E0277]: the trait bound `&u8: serde::Serializer` is not satisfied85 --> tests/ui/with/incorrect_type.rs:18:3586 |87 18 | struct S(#[serde(serialize_with = "w::serialize")] u8, u8);88 | ^^^^^^^^^^^^^^ the trait `Serializer` is not implemented for `&u8`13 unmodified linesdeleted:test_suite/tests/ui/on_unimplemented.rs-23 removed
1-use serde::de::Deserialize;2-use serde::ser::Serialize;3-4-fn to_string<T>(_: &T) -> String5-where6- T: Serialize,7-{8- unimplemented!()9-}10-11-fn from_str<'de, T>(_: &'de str) -> T12-where13- T: Deserialize<'de>,14-{15- unimplemented!()16-}17-18-struct MyStruct;19-20-fn main() {21- to_string(&MyStruct);22- let _: MyStruct = from_str("");23-}deleted:test_suite/tests/ui/on_unimplemented.stderr-65 removed
1-error[E0277]: the trait bound `MyStruct: Serialize` is not satisfied2- --> tests/ui/on_unimplemented.rs:21:153- |4-21 | to_string(&MyStruct);5- | --------- ^^^^^^^^^ unsatisfied trait bound6- | |7- | required by a bound introduced by this call8- |9-help: the trait `Serialize` is not implemented for `MyStruct`10- --> tests/ui/on_unimplemented.rs:18:111- |12-18 | struct MyStruct;13- | ^^^^^^^^^^^^^^^14- = note: for local types consider adding `#[derive(serde::Serialize)]` to your `MyStruct` type15- = note: for types from other crates check whether the crate offers a `serde` feature flag16- = help: the following other types implement trait `Serialize`:17- &'a T18- &'a mut T19- ()20- (T,)21- (T0, T1)22- (T0, T1, T2)23- (T0, T1, T2, T3)24- (T0, T1, T2, T3, T4)25- and $N others26-note: required by a bound in `to_string`27- --> tests/ui/on_unimplemented.rs:6:828- |29- 4 | fn to_string<T>(_: &T) -> String30- | --------- required by a bound in this function31- 5 | where32- 6 | T: Serialize,33- | ^^^^^^^^^ required by this bound in `to_string`34-35-error[E0277]: the trait bound `MyStruct: Deserialize<'_>` is not satisfied36- --> tests/ui/on_unimplemented.rs:22:2337- |38-22 | let _: MyStruct = from_str("");39- | ^^^^^^^^^^^^ unsatisfied trait bound40- |41-help: the trait `Deserialize<'_>` is not implemented for `MyStruct`42- --> tests/ui/on_unimplemented.rs:18:143- |44-18 | struct MyStruct;45- | ^^^^^^^^^^^^^^^46- = note: for local types consider adding `#[derive(serde::Deserialize)]` to your `MyStruct` type47- = note: for types from other crates check whether the crate offers a `serde` feature flag48- = help: the following other types implement trait `Deserialize<'de>`:49- &'a Path50- &'a [u8]51- &'a str52- ()53- (T,)54- (T0, T1)55- (T0, T1, T2)56- (T0, T1, T2, T3)57- and $N others58-note: required by a bound in `from_str`59- --> tests/ui/on_unimplemented.rs:13:860- |61-11 | fn from_str<'de, T>(_: &'de str) -> T62- | -------- required by a bound in this function63-12 | where64-13 | T: Deserialize<'de>,65- | ^^^^^^^^^^^^^^^^ required by this bound in `from_str`