rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Timur Tabi <ttabi@nvidia.com>
Cc: Miguel Ojeda <ojeda@kernel.org>,
	lossin@kernel.org, Alice Ryhl <aliceryhl@google.com>,
	 Danilo Krummrich <dakr@kernel.org>,
	rust-for-linux@vger.kernel.org
Subject: Re: [PATCH] [v2] rust: introduce sfile macro for succinct code tracing
Date: Wed, 4 Jun 2025 00:53:48 +0200	[thread overview]
Message-ID: <CANiq72nGZusApAFztsZOoLhRWJYEMmRY6XfAC89e4-dW6snC8Q@mail.gmail.com> (raw)
In-Reply-To: <20250603195426.2360773-1-ttabi@nvidia.com>

On Tue, Jun 3, 2025 at 9:55 PM Timur Tabi <ttabi@nvidia.com> wrote:
>
> +/// built-in file!() macro, which returns the full path of the current file.

This is missing a code span and it is still using a single sentence
for the "short title".

> +/// ```
> +/// pr_err!("{}:{}\n", sfile!(), line!());
> +/// ```

Examples are built and tested, so please make sure they work -- this
will likely fail to build, since `sfile!` is not imported nor in the
prelude.

> +        assert!(FILE.is_ascii()); // .as_bytes() does not support non-ascii filenames

We generally avoid comments after a statement, instead we typically
put them in the previous line.

Also: code span is missing, "ASCII", and we end them with periods.

> +        // Return the index of the last occurrence of `needle` in `haystack`,
> +        // or zero if not found.  We can't use rfind() because it's not const (yet).
> +        // Avoiding rfind() allows this macro to be evaluated at compile time.

The first sentence should be `///`, and the rest a comment. It also
lacks code spans.

> +        // We use these unsafe functions because apparently indexing into
> +        // a string using normal Rust methods is not completely const operation.

Hmm... I am confused about what this is trying to say. `rfind` is not
const, but that does not imply "indexing into a string" is not const
(what "indexing into a string" means here?)

Also, we should try to avoid "apparently". And what does "not
completely const" mean here?

By the way, please use the standard "[...]" for patch titles -- you
can pass e.g. `-v2` to Git for that. (And ideally please provide `--base` too).

Thanks!

Cheers,
Miguel

  reply	other threads:[~2025-06-03 22:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-03 19:54 [PATCH] [v2] rust: introduce sfile macro for succinct code tracing Timur Tabi
2025-06-03 22:53 ` Miguel Ojeda [this message]
2025-06-06 22:11   ` Timur Tabi
2025-06-07  0:13     ` John Hubbard
2025-06-07 10:17     ` Miguel Ojeda
2025-06-04  9:00 ` Alice Ryhl
2025-06-04 20:43   ` Timur Tabi

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=CANiq72nGZusApAFztsZOoLhRWJYEMmRY6XfAC89e4-dW6snC8Q@mail.gmail.com \
    --to=miguel.ojeda.sandonis@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=dakr@kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=ttabi@nvidia.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).