Re: [PATCH v4 1/2] rust: Introduce file_from_location()
From: Boqun Feng
Date: Thu Jun 19 2025 - 16:51:16 EST
On Thu, Jun 19, 2025 at 10:42:44PM +0200, Miguel Ojeda wrote:
> On Thu, Jun 19, 2025 at 5:10 PM Boqun Feng <boqun.feng@xxxxxxxxx> wrote:
> >
> > +/// // - A path like "rust/kernel/example.rs" if file_with_nul() available.
>
> "is available."
>
Fixed.
> > +pub fn file_from_location<'a>(_loc: &'a core::panic::Location<'a>) -> &'a core::ffi::CStr {
> > + #[cfg(CONFIG_RUSTC_HAS_FILE_WITH_NUL)]
> > + { _loc.file_with_nul() }
> > +
> > + #[cfg(not(CONFIG_RUSTC_HAS_FILE_WITH_NUL))]
> > + { c"<Location::file_with_nul() not supported>" }
> > +}
>
> If a `let _` works, then it may be better -- please see a similar case at:
>
> https://lore.kernel.org/rust-for-linux/CANiq72=ph_XG0TtkdsNJCUZMiAMYBo11eJaCTLCTpTAFXtcNMA@xxxxxxxxxxxxxx/
>
Make sense, applied.
> The new version looks great, thanks!
>
Thanks! I pushed the updated version at:
https://git.kernel.org/pub/scm/linux/kernel/git/boqun/linux.git/log/?h=rust-sched-v2
"-v2" because it's going to be a v2 of the pull request.
Regards,
Boqun
> Cheers,
> Miguel