Move doctest-only helpers to a doc module

This commit is contained in:
David Tolnay
2021-01-23 22:24:20 -08:00
parent 9fd56cd41c
commit e61261e002
6 changed files with 36 additions and 33 deletions
+1 -1
View File
@@ -10,7 +10,7 @@
/// bother with this macro and may assume support for 128-bit integers. /// bother with this macro and may assume support for 128-bit integers.
/// ///
/// ```edition2018 /// ```edition2018
/// # use serde::__private::ser::Error; /// # use serde::__private::doc::Error;
/// # /// #
/// # struct MySerializer; /// # struct MySerializer;
/// # /// #
@@ -1,3 +1,35 @@
// Used only by Serde doc tests. Not public API.
use lib::*;
use ser;
#[doc(hidden)]
#[derive(Debug)]
pub struct Error;
impl ser::Error for Error {
fn custom<T>(_: T) -> Self
where
T: Display,
{
unimplemented!()
}
}
#[cfg(feature = "std")]
impl error::Error for Error {
fn description(&self) -> &str {
unimplemented!()
}
}
impl Display for Error {
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
unimplemented!()
}
}
#[doc(hidden)] #[doc(hidden)]
#[macro_export] #[macro_export]
macro_rules! __private_serialize { macro_rules! __private_serialize {
@@ -10,7 +42,6 @@ macro_rules! __private_serialize {
}; };
} }
/// Used only by Serde doc tests. Not public API.
#[doc(hidden)] #[doc(hidden)]
#[macro_export(local_inner_macros)] #[macro_export(local_inner_macros)]
macro_rules! __serialize_unimplemented { macro_rules! __serialize_unimplemented {
+1 -2
View File
@@ -1,6 +1,5 @@
mod macros;
pub mod de; pub mod de;
pub mod doc;
pub mod ser; pub mod ser;
pub use lib::clone::Clone; pub use lib::clone::Clone;
-27
View File
@@ -335,33 +335,6 @@ where
} }
} }
/// Used only by Serde doc tests. Not public API.
#[doc(hidden)]
#[derive(Debug)]
pub struct Error;
impl ser::Error for Error {
fn custom<T>(_: T) -> Self
where
T: Display,
{
unimplemented!()
}
}
#[cfg(feature = "std")]
impl error::Error for Error {
fn description(&self) -> &str {
unimplemented!()
}
}
impl Display for Error {
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
unimplemented!()
}
}
#[cfg(any(feature = "std", feature = "alloc"))] #[cfg(any(feature = "std", feature = "alloc"))]
mod content { mod content {
use lib::*; use lib::*;
+1 -1
View File
@@ -17,7 +17,7 @@ use ser::{
/// ///
/// ```edition2018 /// ```edition2018
/// # use serde::ser::{Serializer, Impossible}; /// # use serde::ser::{Serializer, Impossible};
/// # use serde::__private::ser::Error; /// # use serde::__private::doc::Error;
/// # /// #
/// # struct MySerializer; /// # struct MySerializer;
/// # /// #
+1 -1
View File
@@ -711,7 +711,7 @@ pub trait Serializer: Sized {
/// ///
/// ```edition2018 /// ```edition2018
/// # use serde::ser::{Serializer, SerializeSeq}; /// # use serde::ser::{Serializer, SerializeSeq};
/// # use serde::__private::ser::Error; /// # use serde::__private::doc::Error;
/// # /// #
/// # struct MySerializer; /// # struct MySerializer;
/// # /// #