Fix doc tests to work whether or not serde derive feature is used

This commit is contained in:
David Tolnay 2023-07-06 15:23:54 -07:00
parent 3a1f387e69
commit 290449f19b
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
6 changed files with 21 additions and 20 deletions

View File

@ -2240,8 +2240,8 @@ pub trait VariantAccess<'de>: Sized {
/// ///
/// ```edition2021 /// ```edition2021
/// use std::str::FromStr; /// use std::str::FromStr;
/// use serde::Deserialize; /// use serde::de::{value, Deserialize, IntoDeserializer};
/// use serde::de::{value, IntoDeserializer}; /// use serde_derive::Deserialize;
/// ///
/// #[derive(Deserialize)] /// #[derive(Deserialize)]
/// enum Setting { /// enum Setting {

View File

@ -3,8 +3,8 @@
//! //!
//! ```edition2021 //! ```edition2021
//! use std::str::FromStr; //! use std::str::FromStr;
//! use serde::Deserialize; //! use serde_derive::Deserialize;
//! use serde::de::{value, IntoDeserializer}; //! use serde::de::{value, Deserialize, IntoDeserializer};
//! //!
//! #[derive(Deserialize)] //! #[derive(Deserialize)]
//! enum Setting { //! enum Setting {

View File

@ -18,7 +18,8 @@ macro_rules! fmt_primitives {
} }
/// ```edition2021 /// ```edition2021
/// use serde::Serialize; /// use serde::ser::Serialize;
/// use serde_derive::Serialize;
/// use std::fmt::{self, Display}; /// use std::fmt::{self, Display};
/// ///
/// #[derive(Serialize)] /// #[derive(Serialize)]

View File

@ -18,7 +18,7 @@ rust-version = "1.19"
serde = { version = "1.0.60", path = "../serde" } serde = { version = "1.0.60", path = "../serde" }
[dev-dependencies] [dev-dependencies]
serde = { version = "1.0", path = "../serde" } serde = { version = "1.0", path = "../serde", features = ["rc"] }
serde_derive = { version = "1.0", path = "../serde_derive" } serde_derive = { version = "1.0", path = "../serde_derive" }
[lib] [lib]

View File

@ -9,7 +9,7 @@ use std::fmt::Debug;
/// Runs both `assert_ser_tokens` and `assert_de_tokens`. /// Runs both `assert_ser_tokens` and `assert_de_tokens`.
/// ///
/// ```edition2021 /// ```edition2021
/// # use serde::{Serialize, Deserialize}; /// # use serde_derive::{Serialize, Deserialize};
/// # use serde_test::{assert_tokens, Token}; /// # use serde_test::{assert_tokens, Token};
/// # /// #
/// #[derive(Serialize, Deserialize, PartialEq, Debug)] /// #[derive(Serialize, Deserialize, PartialEq, Debug)]
@ -40,7 +40,7 @@ where
/// Asserts that `value` serializes to the given `tokens`. /// Asserts that `value` serializes to the given `tokens`.
/// ///
/// ```edition2021 /// ```edition2021
/// # use serde::{Serialize, Deserialize}; /// # use serde_derive::{Serialize, Deserialize};
/// # use serde_test::{assert_ser_tokens, Token}; /// # use serde_test::{assert_ser_tokens, Token};
/// # /// #
/// #[derive(Serialize, Deserialize, PartialEq, Debug)] /// #[derive(Serialize, Deserialize, PartialEq, Debug)]
@ -82,7 +82,7 @@ where
/// use std::sync::{Arc, Mutex}; /// use std::sync::{Arc, Mutex};
/// use std::thread; /// use std::thread;
/// ///
/// use serde::Serialize; /// use serde_derive::Serialize;
/// use serde_test::{assert_ser_tokens_error, Token}; /// use serde_test::{assert_ser_tokens_error, Token};
/// ///
/// #[derive(Serialize)] /// #[derive(Serialize)]
@ -131,7 +131,7 @@ where
/// Asserts that the given `tokens` deserialize into `value`. /// Asserts that the given `tokens` deserialize into `value`.
/// ///
/// ```edition2021 /// ```edition2021
/// # use serde::{Serialize, Deserialize}; /// # use serde_derive::{Serialize, Deserialize};
/// # use serde_test::{assert_de_tokens, Token}; /// # use serde_test::{assert_de_tokens, Token};
/// # /// #
/// #[derive(Serialize, Deserialize, PartialEq, Debug)] /// #[derive(Serialize, Deserialize, PartialEq, Debug)]
@ -185,7 +185,7 @@ where
/// Asserts that the given `tokens` yield `error` when deserializing. /// Asserts that the given `tokens` yield `error` when deserializing.
/// ///
/// ```edition2021 /// ```edition2021
/// # use serde::{Serialize, Deserialize}; /// # use serde_derive::{Serialize, Deserialize};
/// # use serde_test::{assert_de_tokens_error, Token}; /// # use serde_test::{assert_de_tokens_error, Token};
/// # /// #
/// #[derive(Serialize, Deserialize, PartialEq, Debug)] /// #[derive(Serialize, Deserialize, PartialEq, Debug)]

View File

@ -186,7 +186,7 @@ pub enum Token {
/// A serialized unit struct of the given name. /// A serialized unit struct of the given name.
/// ///
/// ```edition2021 /// ```edition2021
/// # use serde::{Serialize, Deserialize}; /// # use serde_derive::{Serialize, Deserialize};
/// # use serde_test::{assert_tokens, Token}; /// # use serde_test::{assert_tokens, Token};
/// # /// #
/// # fn main() { /// # fn main() {
@ -201,7 +201,7 @@ pub enum Token {
/// A unit variant of an enum. /// A unit variant of an enum.
/// ///
/// ```edition2021 /// ```edition2021
/// # use serde::{Serialize, Deserialize}; /// # use serde_derive::{Serialize, Deserialize};
/// # use serde_test::{assert_tokens, Token}; /// # use serde_test::{assert_tokens, Token};
/// # /// #
/// # fn main() { /// # fn main() {
@ -224,7 +224,7 @@ pub enum Token {
/// After this header is the value contained in the newtype struct. /// After this header is the value contained in the newtype struct.
/// ///
/// ```edition2021 /// ```edition2021
/// # use serde::{Serialize, Deserialize}; /// # use serde_derive::{Serialize, Deserialize};
/// # use serde_test::{assert_tokens, Token}; /// # use serde_test::{assert_tokens, Token};
/// # /// #
/// # fn main() { /// # fn main() {
@ -245,7 +245,7 @@ pub enum Token {
/// After this header is the value contained in the newtype variant. /// After this header is the value contained in the newtype variant.
/// ///
/// ```edition2021 /// ```edition2021
/// # use serde::{Serialize, Deserialize}; /// # use serde_derive::{Serialize, Deserialize};
/// # use serde_test::{assert_tokens, Token}; /// # use serde_test::{assert_tokens, Token};
/// # /// #
/// # fn main() { /// # fn main() {
@ -314,7 +314,7 @@ pub enum Token {
/// `TupleStructEnd`. /// `TupleStructEnd`.
/// ///
/// ```edition2021 /// ```edition2021
/// # use serde::{Serialize, Deserialize}; /// # use serde_derive::{Serialize, Deserialize};
/// # use serde_test::{assert_tokens, Token}; /// # use serde_test::{assert_tokens, Token};
/// # /// #
/// # fn main() { /// # fn main() {
@ -341,7 +341,7 @@ pub enum Token {
/// `TupleVariantEnd`. /// `TupleVariantEnd`.
/// ///
/// ```edition2021 /// ```edition2021
/// # use serde::{Serialize, Deserialize}; /// # use serde_derive::{Serialize, Deserialize};
/// # use serde_test::{assert_tokens, Token}; /// # use serde_test::{assert_tokens, Token};
/// # /// #
/// # fn main() { /// # fn main() {
@ -400,7 +400,7 @@ pub enum Token {
/// After this header are the fields of the struct, followed by `StructEnd`. /// After this header are the fields of the struct, followed by `StructEnd`.
/// ///
/// ```edition2021 /// ```edition2021
/// # use serde::{Serialize, Deserialize}; /// # use serde_derive::{Serialize, Deserialize};
/// # use serde_test::{assert_tokens, Token}; /// # use serde_test::{assert_tokens, Token};
/// # /// #
/// # fn main() { /// # fn main() {
@ -432,7 +432,7 @@ pub enum Token {
/// `StructVariantEnd`. /// `StructVariantEnd`.
/// ///
/// ```edition2021 /// ```edition2021
/// # use serde::{Serialize, Deserialize}; /// # use serde_derive::{Serialize, Deserialize};
/// # use serde_test::{assert_tokens, Token}; /// # use serde_test::{assert_tokens, Token};
/// # /// #
/// # fn main() { /// # fn main() {
@ -462,7 +462,7 @@ pub enum Token {
/// The header to an enum of the given name. /// The header to an enum of the given name.
/// ///
/// ```edition2021 /// ```edition2021
/// # use serde::{Serialize, Deserialize}; /// # use serde_derive::{Serialize, Deserialize};
/// # use serde_test::{assert_tokens, Token}; /// # use serde_test::{assert_tokens, Token};
/// # /// #
/// # fn main() { /// # fn main() {