[PATCH 2/6] rust: str: make doctests compilable/testable

Miguel Ojeda posted 6 patches 2 years, 7 months ago
There is a newer version of this series
[PATCH 2/6] rust: str: make doctests compilable/testable
Posted by Miguel Ojeda 2 years, 7 months ago
Rust documentation tests are going to be build/run-tested
with the KUnit integration added in a future patch, thus
update them to make them compilable/testable so that we
may start enforcing it.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
 rust/kernel/str.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs
index c9dd3bf59e34..c41607b2e4fe 100644
--- a/rust/kernel/str.rs
+++ b/rust/kernel/str.rs
@@ -213,6 +213,7 @@ impl fmt::Display for CStr {
     ///
     /// ```
     /// # use kernel::c_str;
+    /// # use kernel::fmt;
     /// # use kernel::str::CStr;
     /// # use kernel::str::CString;
     /// let penguin = c_str!("🐧");
@@ -241,6 +242,7 @@ impl fmt::Debug for CStr {
     ///
     /// ```
     /// # use kernel::c_str;
+    /// # use kernel::fmt;
     /// # use kernel::str::CStr;
     /// # use kernel::str::CString;
     /// let penguin = c_str!("🐧");
@@ -529,7 +531,7 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
 /// # Examples
 ///
 /// ```
-/// use kernel::str::CString;
+/// use kernel::{str::CString, fmt};
 ///
 /// let s = CString::try_from_fmt(fmt!("{}{}{}", "abc", 10, 20)).unwrap();
 /// assert_eq!(s.as_bytes_with_nul(), "abc1020\0".as_bytes());
-- 
2.41.0

Re: [PATCH 2/6] rust: str: make doctests compilable/testable
Posted by Björn Roy Baron 2 years, 7 months ago
------- Original Message -------
On Wednesday, June 14th, 2023 at 20:08, Miguel Ojeda <ojeda@kernel.org> wrote:

> Rust documentation tests are going to be build/run-tested
> with the KUnit integration added in a future patch, thus
> update them to make them compilable/testable so that we
> may start enforcing it.
> 
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
>  rust/kernel/str.rs | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs
> index c9dd3bf59e34..c41607b2e4fe 100644
> --- a/rust/kernel/str.rs
> +++ b/rust/kernel/str.rs
> @@ -213,6 +213,7 @@ impl fmt::Display for CStr {
>      ///
>      /// ```
>      /// # use kernel::c_str;
> +    /// # use kernel::fmt;
>      /// # use kernel::str::CStr;
>      /// # use kernel::str::CString;
>      /// let penguin = c_str!("🐧");
> @@ -241,6 +242,7 @@ impl fmt::Debug for CStr {
>      ///
>      /// ```
>      /// # use kernel::c_str;
> +    /// # use kernel::fmt;
>      /// # use kernel::str::CStr;
>      /// # use kernel::str::CString;
>      /// let penguin = c_str!("🐧");
> @@ -529,7 +531,7 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
>  /// # Examples
>  ///
>  /// ```
> -/// use kernel::str::CString;
> +/// use kernel::{str::CString, fmt};
>  ///
>  /// let s = CString::try_from_fmt(fmt!("{}{}{}", "abc", 10, 20)).unwrap();
>  /// assert_eq!(s.as_bytes_with_nul(), "abc1020\0".as_bytes());
> -- 
> 2.41.0

Reviewed-by: Björn Roy Baron <bjorn3_gh@protonmail.com>
Re: [PATCH 2/6] rust: str: make doctests compilable/testable
Posted by David Gow 2 years, 7 months ago
On Thu, 15 Jun 2023 at 02:09, Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Rust documentation tests are going to be build/run-tested
> with the KUnit integration added in a future patch, thus
> update them to make them compilable/testable so that we
> may start enforcing it.
>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---

Reviewed-by: David Gow <davidgow@google.com>

Cheers,
-- David
Re: [PATCH 2/6] rust: str: make doctests compilable/testable
Posted by Vincenzo Palazzo 2 years, 7 months ago
> Rust documentation tests are going to be build/run-tested
> with the KUnit integration added in a future patch, thus
> update them to make them compilable/testable so that we
> may start enforcing it.
>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---

Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Re: [PATCH 2/6] rust: str: make doctests compilable/testable
Posted by Martin Rodriguez Reboredo 2 years, 7 months ago
On 6/14/23 15:08, Miguel Ojeda wrote:
> Rust documentation tests are going to be build/run-tested
> with the KUnit integration added in a future patch, thus
> update them to make them compilable/testable so that we
> may start enforcing it.
> 
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> [...]

Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Re: [PATCH 2/6] rust: str: make doctests compilable/testable
Posted by Alice Ryhl 2 years, 7 months ago
Miguel Ojeda <ojeda@kernel.org> writes:
> Rust documentation tests are going to be build/run-tested
> with the KUnit integration added in a future patch, thus
> update them to make them compilable/testable so that we
> may start enforcing it.
> 
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Reviewed-by: Alice Ryhl <aliceryhl@google.com>