Re: [PATCH v11 2/7] rust: debugfs: Add support for read-only files

From: Danilo Krummrich

Date: Tue Sep 09 2025 - 04:29:33 EST


On Tue Sep 9, 2025 at 9:29 AM CEST, Dirk Behme wrote:
> On 04/09/2025 23:13, Matthew Maurer wrote:
>> +#[cfg(not(CONFIG_DEBUG_FS))]
>> +impl<'b, T: 'b> Scope<T> {
>> + fn new<E: 'b, F>(data: impl PinInit<T, E> + 'b, init: F) -> impl PinInit<Self, E> + 'b
>> + where
>> + F: for<'a> FnOnce(&'a T) -> Entry + 'b,
>
> Inspired by Greg's & Danilo's discussion I tried building with
> CONFIG_DEBUG_FS disabled. And get
>
> error[E0412]: cannot find type `Entry` in this scope
> --> rust/kernel/debugfs.rs:351:37
> |
> 351 | F: for<'a> FnOnce(&'a T) -> Entry + 'b,
> | ^^^^^ not found in this scope
>
> And giving it some Entry (for my 1.81.0)
>
> error: hidden lifetime parameters in types are deprecated
> --> rust/kernel/debugfs.rs:352:37
> |
> 352 | F: for<'a> FnOnce(&'a T) -> Entry + 'b,
> | ^^^^^ expected lifetime parameter

Yeah, I caught this as well and fixed it up on my end with the following diff:

diff --git a/rust/kernel/debugfs.rs b/rust/kernel/debugfs.rs
index ecfcce845d3f..1f25777743db 100644
--- a/rust/kernel/debugfs.rs
+++ b/rust/kernel/debugfs.rs
@@ -348,7 +348,7 @@ pub struct File<T> {
impl<'b, T: 'b> Scope<T> {
fn new<E: 'b, F>(data: impl PinInit<T, E> + 'b, init: F) -> impl PinInit<Self, E> + 'b
where
- F: for<'a> FnOnce(&'a T) -> Entry + 'b,
+ F: for<'a> FnOnce(&'a T) + 'b,
{
try_pin_init! {
Self {