From: Valentin Obst <kernel@valentinobst.de>
To: Miguel Ojeda <ojeda@kernel.org>,
Alex Gaynor <alex.gaynor@gmail.com>,
Wedson Almeida Filho <wedsonaf@gmail.com>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 06/12] rust: str: move SAFETY comment in front of unsafe block
Date: Tue, 23 Jan 2024 17:06:41 +0100 [thread overview]
Message-ID: <20240123160642.125285-1-kernel@valentinobst.de> (raw)
In-Reply-To: <20240123150112.124084-1-kernel@valentinobst.de>
SAFETY comments should immediately precede the unsafe block they
justify. Move assignment to `bar` past comment as it is safe.
Signed-off-by: Valentin Obst <kernel@valentinobst.de>
Reviewed-by: Trevor Gross <tmgross@umich.edu>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
---
rust/kernel/str.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs
index 843ffeec9b3e..fec5c4314758 100644
--- a/rust/kernel/str.rs
+++ b/rust/kernel/str.rs
@@ -191,9 +191,9 @@ pub fn to_str(&self) -> Result<&str, core::str::Utf8Error> {
/// ```
/// # use kernel::c_str;
/// # use kernel::str::CStr;
+ /// let bar = c_str!("ツ");
/// // SAFETY: String literals are guaranteed to be valid UTF-8
/// // by the Rust compiler.
- /// let bar = c_str!("ツ");
/// assert_eq!(unsafe { bar.as_str_unchecked() }, "ツ");
/// ```
#[inline]
--
2.43.0
next prev parent reply other threads:[~2024-01-23 16:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 15:00 [PATCH v2 00/12] rust: kernel: documentation improvements Valentin Obst
2024-01-23 15:00 ` [PATCH v2 01/12] rust: kernel: fix multiple typos in documentation Valentin Obst
2024-01-23 15:00 ` [PATCH v2 02/12] rust: error: improve unsafe code in example Valentin Obst
2024-01-27 15:10 ` Martin Rodriguez Reboredo
2024-01-23 15:00 ` [PATCH v2 03/12] rust: ioctl: end top-level module docs with full stop Valentin Obst
2024-01-23 15:00 ` [PATCH v2 04/12] rust: kernel: add srctree-relative doclinks Valentin Obst
2024-01-23 15:00 ` [PATCH v2 05/12] rust: str: use `NUL` instead of 0 in doc comments Valentin Obst
2024-01-23 16:06 ` Valentin Obst [this message]
2024-01-23 16:07 ` [PATCH v2 07/12] rust: kernel: unify spelling of refcount in docs Valentin Obst
2024-01-23 16:09 ` [PATCH v2 08/12] rust: kernel: mark code fragments in docs with backticks Valentin Obst
2024-01-23 16:09 ` [PATCH v2 09/12] rust: kernel: add blank lines in front of code blocks Valentin Obst
2024-01-23 16:10 ` [PATCH v2 10/12] rust: kernel: add doclinks Valentin Obst
2024-01-23 16:10 ` [PATCH v2 11/12] rust: kernel: remove unneeded doclink targets Valentin Obst
2024-01-23 16:10 ` [PATCH v2 12/12] rust: locked_by: shorten doclink preview Valentin Obst
2024-01-30 9:22 ` [PATCH v2 00/12] rust: kernel: documentation improvements Alice Ryhl
2024-01-30 10:44 ` Valentin Obst
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240123160642.125285-1-kernel@valentinobst.de \
--to=kernel@valentinobst.de \
--cc=alex.gaynor@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).